UNPKG

pngjs

Version:

PNG encoder/decoder in pure JS, supporting any bit size & interlace, async & sync with full test suite.

25 lines (20 loc) 558 B
"use strict"; let util = require("util"); let ChunkStream = require("./chunkstream"); let Filter = require("./filter-parse"); let FilterAsync = (module.exports = function (bitmapInfo) { ChunkStream.call(this); let buffers = []; let that = this; this._filter = new Filter(bitmapInfo, { read: this.read.bind(this), write: function (buffer) { buffers.push(buffer); }, complete: function () { that.emit("complete", Buffer.concat(buffers)); }, }); this._filter.start(); }); util.inherits(FilterAsync, ChunkStream);