Comparing version 0.0.32 to 0.0.33
export interface EventBuffer<T> { | ||
push(value: T): void; | ||
error(error: Error): void; | ||
finish(): void; | ||
@@ -4,0 +5,0 @@ drain(): AsyncGenerator<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createEventBuffer = void 0; | ||
const observer_1 = require("./observer"); | ||
function createEventBuffer(config) { | ||
const queue = []; | ||
let resolve = undefined; | ||
let deferred; | ||
let finished = false; | ||
@@ -12,5 +13,5 @@ return { | ||
throw new Error("can't push after finish"); | ||
if (resolve) { | ||
resolve({ value, done: false }); | ||
resolve = undefined; | ||
if (deferred) { | ||
deferred.resolve({ value, done: false }); | ||
deferred = undefined; | ||
} | ||
@@ -21,4 +22,8 @@ else { | ||
}, | ||
error(error) { | ||
deferred === null || deferred === void 0 ? void 0 : deferred.reject(error); | ||
finished = true; | ||
}, | ||
finish() { | ||
resolve && resolve({ value: undefined, done: true }); | ||
deferred === null || deferred === void 0 ? void 0 : deferred.resolve({ value: undefined, done: true }); | ||
finished = true; | ||
@@ -43,3 +48,3 @@ }, | ||
else { | ||
return new Promise((r) => (resolve = r)); | ||
return deferred = (0, observer_1.defer)(); | ||
} | ||
@@ -46,0 +51,0 @@ } |
{ | ||
"name": "pbkit", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"author": "JongChan Choi <jong@chan.moe>", | ||
@@ -5,0 +5,0 @@ "license": "(MIT OR Apache-2.0)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8498424
83
11746