MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / constructor

Method constructor

tools/xsbug-log/xsbug-machine.js:29–62  ·  view source on GitHub ↗
(input, output)

Source from the content-addressed store, hash-verified

27
28class Machine {
29 constructor(input, output) {
30 const parser = new Saxophone()
31 parser.on('tagopen', ({ name, attrs, isSelfClosing }) => {
32 this.onStartElement(name, Saxophone.parseAttrs(attrs));
33 if (isSelfClosing)
34 this.onEndElement(name);
35 });
36 parser.on('tagclose', ({ name }) => {
37 this.onEndElement(name);
38 });
39 parser.on('text', ({ contents }) => {
40 this.onCharacterData(Saxophone.parseEntities(contents));
41 });
42 parser.on('cdata', ({ contents }) => {
43 this.onCharacterData(contents);
44 });
45 parser.on('error', err => {
46 this.onError(err);
47 });
48 input.pipe(parser);
49 this.encoder = new TextEncoder();
50 this.instruments = [];
51 this.output = output;
52 this.profile = new Profile();
53 this.profiling = false;
54
55 input.on('error', (err) => {
56 input.unpipe(parser);
57 });
58
59 input.on('close', () => {
60 input.unpipe(parser);
61 });
62 }
63
64 onStartElement(name, attributes) {
65 const parent = this.current;

Callers

nothing calls this directly

Calls 5

onStartElementMethod · 0.95
onEndElementMethod · 0.95
onCharacterDataMethod · 0.95
onErrorMethod · 0.95
onMethod · 0.45

Tested by

no test coverage detected