Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
92592d9e9a | |||
a786c43970 | |||
66658dc877 | |||
be78d74124 | |||
bde0404777 | |||
dfe973f5d8 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/lik",
|
"name": "@push.rocks/lik",
|
||||||
"version": "6.0.8",
|
"version": "6.0.11",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "light little helpers for node",
|
"description": "light little helpers for node",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/lik',
|
name: '@push.rocks/lik',
|
||||||
version: '6.0.8',
|
version: '6.0.11',
|
||||||
description: 'light little helpers for node'
|
description: 'light little helpers for node'
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './lik.plugins.js';
|
||||||
|
|
||||||
export class BackpressuredArray<T> {
|
export class BackpressuredArray<T> {
|
||||||
private data: T[];
|
public data: T[];
|
||||||
private highWaterMark: number;
|
private highWaterMark: number;
|
||||||
public hasSpace: plugins.smartrx.rxjs.Subject<void>;
|
public hasSpace = new plugins.smartrx.rxjs.Subject<'hasSpace'>();
|
||||||
|
|
||||||
constructor(highWaterMark: number = 16) {
|
constructor(highWaterMark: number = 16) {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
this.highWaterMark = highWaterMark;
|
this.highWaterMark = highWaterMark;
|
||||||
this.hasSpace = new plugins.smartrx.rxjs.Subject<void>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
push(item: T): boolean {
|
push(item: T): boolean {
|
||||||
this.data.push(item);
|
this.data.push(item);
|
||||||
const spaceAvailable = this.checkSpaceAvailable();
|
const spaceAvailable = this.checkSpaceAvailable();
|
||||||
if (spaceAvailable) {
|
if (spaceAvailable) {
|
||||||
this.hasSpace.next();
|
this.hasSpace.next('hasSpace');
|
||||||
}
|
}
|
||||||
return spaceAvailable
|
return spaceAvailable
|
||||||
}
|
}
|
||||||
@ -23,7 +22,7 @@ export class BackpressuredArray<T> {
|
|||||||
shift(): T | undefined {
|
shift(): T | undefined {
|
||||||
const item = this.data.shift();
|
const item = this.data.shift();
|
||||||
if (this.checkSpaceAvailable()) {
|
if (this.checkSpaceAvailable()) {
|
||||||
this.hasSpace.next();
|
this.hasSpace.next('hasSpace');
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user