"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const stream_1 = require("stream"); const xmlfeedparser_1 = __importDefault(require("./xmlfeedparser")); const jsonfeedparser_1 = __importDefault(require("./jsonfeedparser")); class FeedMe extends stream_1.Writable { /** * Creates an instance of a parser. Parser can be JSON/XML. * * @param {boolean} buffer If true, feed will be buffered into memory * and can be retrieved using `parser.done()` on the `end` event. * @constructor */ constructor(buffer = false) { super(); this._buffer = buffer; } _proxyEvents() { const parserEmit = this._parser.parser.emit; this._parser.parser.emit = (event, ...args) => { parserEmit.apply(this._parser.parser, [event, ...args]); if (event !== 'error') { return this.emit(event, ...args); } return true; }; this._parser.parser.on('error', this.emit.bind(this, 'error')); } /** * @param {Buffer} data */ _write(data, encoding, callback) { const str = data.toString(); // First find out what type of feed this is. if (!this._parser) { if (/^\s*