From 184dc9812734fb45719e1eb949a93e7fcf749fa9 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 13 Nov 2023 14:59:03 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/backpressuredarray.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b12a18e..84f4e65 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/lik', - version: '6.0.7', + version: '6.0.8', description: 'light little helpers for node' } diff --git a/ts/backpressuredarray.ts b/ts/backpressuredarray.ts index 8e16233..66baff9 100644 --- a/ts/backpressuredarray.ts +++ b/ts/backpressuredarray.ts @@ -31,4 +31,17 @@ export class BackpressuredArray { checkSpaceAvailable(): boolean { return this.data.length < this.highWaterMark; } + + waitForSpace(): Promise { + return new Promise((resolve) => { + if (this.checkSpaceAvailable()) { + resolve(); + } else { + const subscription = this.hasSpace.subscribe(() => { + subscription.unsubscribe(); + resolve(); + }); + } + }); + } }