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(); + }); + } + }); + } }