(input, output)
| 27 | |
| 28 | class 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; |
nothing calls this directly
no test coverage detected