MCPcopy Index your code
hub / github.com/JavaCS3/xterm-player / parse

Method parse

src/CastParser.ts:69–94  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

67 */
68export class AsciinemaCastV2Parser implements ICastParser {
69 public parse(text: string): ICastObject {
70 const lines = text.trim().split('\n').filter(txt => txt)
71
72 if (lines.length) {
73 const header = JSON.parse(lines[0])
74 const events = lines.slice(1)
75
76 const cast: ICastObject = {
77 header,
78 events: events.map(e => {
79 const j = JSON.parse(e)
80 return {
81 time: j[0] * MILLISECOND,
82 type: j[1],
83 data: j[2]
84 }
85 })
86 }
87
88 cast.header.duration = cast.events[cast.events.length - 1].time
89
90 return cast
91 } else {
92 throw new Error('Invalid cast format')
93 }
94 }
95}
96
97export class TerminalizerParser implements ICastParser {

Callers

nothing calls this directly

Calls 1

parseMethod · 0.65

Tested by

no test coverage detected