Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
052322fb98 | |||
9e1eb0b3a0 | |||
af9b045d31 | |||
d7718d4340 | |||
92592d9e9a | |||
a786c43970 | |||
66658dc877 | |||
be78d74124 | |||
bde0404777 | |||
dfe973f5d8 | |||
326030456f | |||
184dc98127 | |||
702ce00288 | |||
ff0d745170 | |||
8fc0438c75 | |||
355c2d132e |
@ -119,6 +119,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npmci node install stable
|
npmci node install stable
|
||||||
npmci npm install
|
npmci npm install
|
||||||
pnpm install -g @gitzone/tsdoc
|
pnpm install -g @git.zone/tsdoc
|
||||||
npmci command tsdoc
|
npmci command tsdoc
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/lik",
|
"name": "@push.rocks/lik",
|
||||||
"version": "6.0.5",
|
"version": "6.0.13",
|
||||||
"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",
|
||||||
@ -22,21 +22,21 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.63",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^2.0.4",
|
"@git.zone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tsrun": "^1.2.39",
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
"@gitzone/tstest": "^1.0.71",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@pushrocks/tapbundle": "^5.0.3",
|
"@pushrocks/tapbundle": "^5.0.8",
|
||||||
"@types/node": "^18.11.18"
|
"@types/node": "^20.9.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartdelay": "^3.0.2",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartmatch": "^2.0.0",
|
"@push.rocks/smartmatch": "^2.0.0",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@push.rocks/smartrx": "^3.0.0",
|
"@push.rocks/smartrx": "^3.0.7",
|
||||||
"@push.rocks/smarttime": "^4.0.1",
|
"@push.rocks/smarttime": "^4.0.6",
|
||||||
"@types/minimatch": "^5.1.2",
|
"@types/minimatch": "^5.1.2",
|
||||||
"@types/symbol-tree": "^3.2.2",
|
"@types/symbol-tree": "^3.2.5",
|
||||||
"symbol-tree": "^3.2.4"
|
"symbol-tree": "^3.2.4"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
4297
pnpm-lock.yaml
generated
4297
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -26,4 +26,4 @@ tap.test('should run in parallel', async (toolsArg) => {
|
|||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -27,4 +27,4 @@ tap.test('should find an entry', async () => {
|
|||||||
expect(result.value1).toEqual('heyho3');
|
expect(result.value1).toEqual('heyho3');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -22,4 +22,4 @@ tap.test('should be able to inform about a lost interest', async () => {
|
|||||||
testInterestmap.informLostInterest(3);
|
testInterestmap.informLostInterest(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -14,4 +14,4 @@ tap.test('should never be longer than the set length', async () => {
|
|||||||
expect(testLimitedArray.array.length < 7).toBeTrue();
|
expect(testLimitedArray.array.length < 7).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -21,4 +21,4 @@ tap.test('should add objects once and return true', async () => {
|
|||||||
expect(myLoopTracker.checkAndTrack(object2)).toBeFalse();
|
expect(myLoopTracker.checkAndTrack(object2)).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -73,4 +73,4 @@ tap.test('should get one object and then remove it', async () => {
|
|||||||
expect(testObjectmap.getArray()).not.toContain(oneObject);
|
expect(testObjectmap.getArray()).not.toContain(oneObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -83,4 +83,4 @@ tap.test('lik.Stringmap.empty() -> should remove wipe and then notify', async ()
|
|||||||
testStringmap.wipe();
|
testStringmap.wipe();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -20,4 +20,4 @@ tap.test('should create a timed aggregaotor', async (tools) => {
|
|||||||
await tools.delayFor(2000);
|
await tools.delayFor(2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -37,4 +37,4 @@ tap.test("should create a JSON object that reflects a tree's hierachy", async ()
|
|||||||
const jsonTreet = testTree.toJsonWithHierachy(testInstance);
|
const jsonTreet = testTree.toJsonWithHierachy(testInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
await tap.start();
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/lik',
|
name: '@push.rocks/lik',
|
||||||
version: '6.0.5',
|
version: '6.0.13',
|
||||||
description: 'light little helpers for node'
|
description: 'light little helpers for node'
|
||||||
}
|
}
|
||||||
|
62
ts/backpressuredarray.ts
Normal file
62
ts/backpressuredarray.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import * as plugins from './lik.plugins.js';
|
||||||
|
|
||||||
|
export class BackpressuredArray<T> {
|
||||||
|
public data: T[];
|
||||||
|
private highWaterMark: number;
|
||||||
|
public hasSpace = new plugins.smartrx.rxjs.Subject<'hasSpace'>();
|
||||||
|
private itemsAvailable = new plugins.smartrx.rxjs.Subject<'itemsAvailable'>();
|
||||||
|
|
||||||
|
constructor(highWaterMark: number = 16) {
|
||||||
|
this.data = [];
|
||||||
|
this.highWaterMark = highWaterMark;
|
||||||
|
}
|
||||||
|
|
||||||
|
push(item: T): boolean {
|
||||||
|
this.data.push(item);
|
||||||
|
this.itemsAvailable.next('itemsAvailable');
|
||||||
|
|
||||||
|
const spaceAvailable = this.checkSpaceAvailable();
|
||||||
|
if (spaceAvailable) {
|
||||||
|
this.hasSpace.next('hasSpace');
|
||||||
|
}
|
||||||
|
return spaceAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
shift(): T | undefined {
|
||||||
|
const item = this.data.shift();
|
||||||
|
if (this.checkSpaceAvailable()) {
|
||||||
|
this.hasSpace.next('hasSpace');
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkSpaceAvailable(): boolean {
|
||||||
|
return this.data.length < this.highWaterMark;
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForSpace(): Promise<void> {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
if (this.checkSpaceAvailable()) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
const subscription = this.hasSpace.subscribe(() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForItems(): Promise<void> {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
if (this.data.length > 0) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
const subscription = this.itemsAvailable.subscribe(() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
export * from './lik.asyncexecutionstack.js';
|
export * from './lik.asyncexecutionstack.js';
|
||||||
|
export * from './backpressuredarray.js';
|
||||||
export * from './lik.fastmap.js';
|
export * from './lik.fastmap.js';
|
||||||
export * from './lik.interestmap.js';
|
export * from './lik.interestmap.js';
|
||||||
export * from './lik.interestmap.interest.js';
|
export * from './lik.interestmap.interest.js';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './lik.plugins.js';
|
||||||
|
|
||||||
import { InterestMap, IInterestComparisonFunc } from './lik.interestmap.js';
|
import { InterestMap, type IInterestComparisonFunc } from './lik.interestmap.js';
|
||||||
|
|
||||||
export interface IInterestOptions<DTInterestFullfillment> {
|
export interface IInterestOptions<DTInterestFullfillment> {
|
||||||
markLostAfterDefault: number;
|
markLostAfterDefault: number;
|
||||||
|
Reference in New Issue
Block a user