asciicast

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package asciicast provides methods for working with asciinema's file format asciicast v2.

Refer to the official documentation about asciicast v2 format here: https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md

Index

Constants

View Source
const (
	Input  eventType = "i" // Data read from stdin.
	Output eventType = "o" // Data writed to stdout.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cast

type Cast struct {
	Header header
	Events []Event
}

Cast contains asciicast file data

func New added in v0.3.0

func New() *Cast

New will instantiate new Cast with basic medatada (version, timestamp and environment).

func Unmarshal added in v0.3.0

func Unmarshal(data []byte) (*Cast, error)

Unmarshal parses the JSON-encoded data into a Cast struct.

func (*Cast) AdjustSpeed

func (c *Cast) AdjustSpeed(speed float64)

AdjustSpeed changes the time of each event. Slower < 1.0 > Faster.

func (*Cast) CapRelativeTime

func (c *Cast) CapRelativeTime(limit float64)

CapRelativeTime limits the amount of time between each event

func (*Cast) Compress added in v0.2.0

func (c *Cast) Compress()

Compress chains together events with the same time.

func (*Cast) Marshal added in v0.3.0

func (c *Cast) Marshal() ([]byte, error)

Marshal returns the JSON-like encoding of v.

func (*Cast) ToAbsoluteTime

func (c *Cast) ToAbsoluteTime()

ToAbsoluteTime converts event time to the absolute difference from the start. This is the default time format.

func (*Cast) ToRelativeTime

func (c *Cast) ToRelativeTime()

ToRelativeTime converts event time to the difference between each event.

type Event

type Event struct {
	Time      float64   `json:"time"`
	EventType eventType `json:"event-type"`
	EventData string    `json:"event-data"`
}

Event is a 3-tuple encoded as JSON array.

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

MarshalJSON reads json list as Event fields.

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON reads json list as Event fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL