UNPKG

debian-control

Version:

Parse package control files from Debian

54 lines (43 loc) 1.7 kB
// Generated by CoffeeScript 2.4.1 (function() { // lineStream.coffee // Copyright 2019 Patrick Meade. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. //---------------------------------------------------------------------- var Transform; ({Transform} = require("stream")); exports.LineStream = class LineStream extends Transform { constructor(options) { super(options || {}); this.buffer = Buffer.alloc(0); } _transform(chunk, encoding, callback) { var nextLineEnding; this.buffer = Buffer.concat([this.buffer, chunk]); while (true) { nextLineEnding = this.buffer.indexOf("\n"); if (nextLineEnding >= 0) { this.push(this.buffer.slice(0, nextLineEnding + 1)); this.buffer = this.buffer.slice(nextLineEnding + 1); } else { break; } } return callback(); } _flush(callback) { return callback(null, this.buffer); } }; //---------------------------------------------------------------------- // end of lineStream.coffee }).call(this);