MCPcopy Create free account
hub / github.com/JavaCS3/xterm-player / AsciinemaCastV1Parser

Class AsciinemaCastV1Parser

src/CastParser.ts:37–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 * https://github.com/asciinema/asciinema/blob/master/doc/asciicast-v1.md
36 */
37export class AsciinemaCastV1Parser implements ICastParser {
38 public parse(text: string): ICastObject {
39 const j = JSON.parse(text)
40 const stdouts: Array<[number, string]> = j.stdout
41
42 let timestamp = 0.0
43 const events = stdouts.map(e => {
44 timestamp += e[0] * MILLISECOND
45 return {
46 time: timestamp,
47 type: 'o',
48 data: e[1]
49 }
50 })
51
52 return {
53 header: {
54 version: 1,
55 width: j.width,
56 height: j.height,
57 duration: j.duration * MILLISECOND
58 },
59 events
60 }
61 }
62}
63
64/**
65 * Asciinema cast v2 parser

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected