buffer
1 year ago
core.js
1 year ago
core.js.map
1 year ago
stack.js
1 year ago
stack.js.map
1 year ago
stream.js
1 year ago
stream.js.map
1 year ago
stream.js
31 lines
| 1 | import { Transform } from 'node:stream'; |
| 2 | import { jsonrepairCore } from './core.js'; |
| 3 | export function jsonrepairTransform(options) { |
| 4 | const repair = jsonrepairCore({ |
| 5 | onData: chunk => transform.push(chunk), |
| 6 | bufferSize: options === null || options === void 0 ? void 0 : options.bufferSize, |
| 7 | chunkSize: options === null || options === void 0 ? void 0 : options.chunkSize |
| 8 | }); |
| 9 | const transform = new Transform({ |
| 10 | transform(chunk, encoding, callback) { |
| 11 | try { |
| 12 | repair.transform(chunk.toString()); |
| 13 | } catch (err) { |
| 14 | this.emit('error', err); |
| 15 | } finally { |
| 16 | callback(); |
| 17 | } |
| 18 | }, |
| 19 | flush(callback) { |
| 20 | try { |
| 21 | repair.flush(); |
| 22 | } catch (err) { |
| 23 | this.emit('error', err); |
| 24 | } finally { |
| 25 | callback(); |
| 26 | } |
| 27 | } |
| 28 | }); |
| 29 | return transform; |
| 30 | } |
| 31 | //# sourceMappingURL=stream.js.map |