{“ast”:null,“code”:“"use strict";nnvar utils = require('../utils');nnvar GenericWorker = require('../stream/GenericWorker');n/**n * A worker that use a nodejs stream as source.n * @constructorn * @param {String} filename the name of the file entry for this stream.n * @param {Readable} stream the nodejs stream.n */nnnfunction NodejsStreamInputAdapter(filename, stream) {n GenericWorker.call(this, "Nodejs stream input adapter for " + filename);n this._upstreamEnded = false;nn this._bindStream(stream);n}nnutils.inherits(NodejsStreamInputAdapter, GenericWorker);n/**n * Prepare the stream and bind the callbacks on it.n * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.n * @param {Stream} stream the nodejs stream to use.n */nnNodejsStreamInputAdapter.prototype._bindStream = function (stream) {n var self = this;n this._stream = stream;n stream.pause();n stream.on("data", function (chunk) {n self.push({n data: chunk,n meta: {n percent: 0n }n });n }).on("error", function (e) {n if (self.isPaused) {n this.generatedError = e;n } else {n self.error(e);n }n }).on("end", function () {n if (self.isPaused) {n self._upstreamEnded = true;n } else {n self.end();n }n });n};nnNodejsStreamInputAdapter.prototype.pause = function () {n if (!GenericWorker.prototype.pause.call(this)) {n return false;n }nn this._stream.pause();nn return true;n};nnNodejsStreamInputAdapter.prototype.resume = function () {n if (!GenericWorker.prototype.resume.call(this)) {n return false;n }nn if (this._upstreamEnded) {n this.end();n } else {n this._stream.resume();n }nn return true;n};nnmodule.exports = NodejsStreamInputAdapter;”,“map”:null,“metadata”:{},“sourceType”:“module”}