asynciterator-promiseproxy
Advanced tools
Comparing version 1.1.0 to 1.2.0
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./lib/PromiseProxyIterator"), exports); | ||
__export(require("./lib/PromiseProxyIterator")); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var asynciterator_1 = require("asynciterator"); | ||
const asynciterator_1 = require("asynciterator"); | ||
/** | ||
@@ -11,24 +10,20 @@ * A {@link TransformIterator} that allows the source to be set through a lazy Promise. | ||
*/ | ||
var PromiseProxyIterator = /** @class */ (function (_super) { | ||
tslib_1.__extends(PromiseProxyIterator, _super); | ||
function PromiseProxyIterator(sourceGetter, options) { | ||
var _this = _super.call(this, options || { autoStart: false }) || this; | ||
_this.sourceGetter = sourceGetter; | ||
return _this; | ||
class PromiseProxyIterator extends asynciterator_1.TransformIterator { | ||
constructor(sourceGetter, options) { | ||
super(options || { autoStart: false }); | ||
this.sourceGetter = sourceGetter; | ||
} | ||
PromiseProxyIterator.prototype._read = function (count, done) { | ||
var _this = this; | ||
_read(count, done) { | ||
if (!this.source) { | ||
this.sourceGetter().then(function (source) { | ||
_this.source = source; | ||
_super.prototype._read.call(_this, count, done); | ||
}).catch(function (error) { return _this.emit('error', error); }); | ||
this.sourceGetter().then((source) => { | ||
this.source = source; | ||
super._read(count, done); | ||
}).catch((error) => this.emit('error', error)); | ||
} | ||
else { | ||
_super.prototype._read.call(this, count, done); | ||
super._read(count, done); | ||
} | ||
}; | ||
return PromiseProxyIterator; | ||
}(asynciterator_1.TransformIterator)); | ||
} | ||
} | ||
exports.PromiseProxyIterator = PromiseProxyIterator; | ||
//# sourceMappingURL=PromiseProxyIterator.js.map |
{ | ||
"name": "asynciterator-promiseproxy", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "An AsyncIterator proxy that allows its source to be set via a promise.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6066
46