1 var streamify = require('./streamify.js')
2 , defer = require('./defer.js')
6 module.exports = ReadableAsyncKit;
9 * Base constructor for all streams
10 * used to hold properties/methods
12 function ReadableAsyncKit()
14 ReadableAsyncKit.super_.apply(this, arguments);
16 // list of active jobs
20 this.destroy = destroy;
26 * Destroys readable stream,
27 * by aborting outstanding jobs
38 this.destroyed = true;
40 if (typeof this.terminator == 'function')
47 * Starts provided jobs in async manner
53 // first argument – runner function
54 var runner = arguments[0]
55 // take away first argument
56 , args = Array.prototype.slice.call(arguments, 1)
57 // second argument - input data
59 // last argument - result callback
60 , endCb = streamify.callback.call(this, args[args.length - 1])
63 args[args.length - 1] = endCb;
64 // third argument - iterator
65 args[1] = streamify.iterator.call(this, args[1]);
67 // allow time for proper setup
72 this.terminator = runner.apply(null, args);
76 endCb(null, Array.isArray(input) ? [] : {});
83 * Implement _read to comply with Readable streams
84 * Doesn't really make sense for flowing object mode