Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
5e31dbb504 | |||
b2ca6e13e7 | |||
052322fb98 | |||
9e1eb0b3a0 | |||
af9b045d31 | |||
d7718d4340 | |||
92592d9e9a | |||
a786c43970 | |||
66658dc877 | |||
be78d74124 | |||
bde0404777 | |||
dfe973f5d8 | |||
326030456f | |||
184dc98127 | |||
702ce00288 | |||
ff0d745170 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/lik",
|
"name": "@push.rocks/lik",
|
||||||
"version": "6.0.6",
|
"version": "6.0.14",
|
||||||
"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",
|
||||||
|
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@ -1846,7 +1846,7 @@ packages:
|
|||||||
'@web/parse5-utils': 2.1.0
|
'@web/parse5-utils': 2.1.0
|
||||||
chokidar: 3.5.3
|
chokidar: 3.5.3
|
||||||
clone: 2.1.2
|
clone: 2.1.2
|
||||||
es-module-lexer: 1.3.1
|
es-module-lexer: 1.4.1
|
||||||
get-stream: 6.0.1
|
get-stream: 6.0.1
|
||||||
is-stream: 2.0.1
|
is-stream: 2.0.1
|
||||||
isbinaryfile: 5.0.0
|
isbinaryfile: 5.0.0
|
||||||
@ -2891,6 +2891,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-JUFAyicQV9mXc3YRxPnDlrfBKpqt6hUYzz9/boprUJHs4e4KVr3XwOF70doO6gwXUor6EWZJAyWAfKki84t20Q==}
|
resolution: {integrity: sha512-JUFAyicQV9mXc3YRxPnDlrfBKpqt6hUYzz9/boprUJHs4e4KVr3XwOF70doO6gwXUor6EWZJAyWAfKki84t20Q==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/es-module-lexer@1.4.1:
|
||||||
|
resolution: {integrity: sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/es-set-tostringtag@2.0.2:
|
/es-set-tostringtag@2.0.2:
|
||||||
resolution: {integrity: sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==}
|
resolution: {integrity: sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/lik',
|
name: '@push.rocks/lik',
|
||||||
version: '6.0.6',
|
version: '6.0.14',
|
||||||
description: 'light little helpers for node'
|
description: 'light little helpers for node'
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
interface IExecutionSlot<T> {
|
interface IExecutionSlot<T> {
|
||||||
executionDeferred: plugins.smartpromise.Deferred<T>;
|
executionDeferred: plugins.smartpromise.Deferred<T>;
|
62
ts/classes.backpressuredarray.ts
Normal file
62
ts/classes.backpressuredarray.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import * as plugins from './classes.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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ The FastMap has the goal of creating the fastes to use map possible in JS
|
|||||||
|
|
||||||
============ */
|
============ */
|
||||||
|
|
||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fast map allows for very quick lookups of objects with a unique key
|
* fast map allows for very quick lookups of objects with a unique key
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
import { InterestMap, type IInterestComparisonFunc } from './lik.interestmap.js';
|
import { InterestMap, type IInterestComparisonFunc } from './classes.interestmap.js';
|
||||||
|
|
||||||
export interface IInterestOptions<DTInterestFullfillment> {
|
export interface IInterestOptions<DTInterestFullfillment> {
|
||||||
markLostAfterDefault: number;
|
markLostAfterDefault: number;
|
@ -8,9 +8,9 @@ Subssequent interests will be mapped to the same interest
|
|||||||
which is then is only fullfilled once.
|
which is then is only fullfilled once.
|
||||||
=========== */
|
=========== */
|
||||||
|
|
||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
import { ObjectMap } from './lik.objectmap.js';
|
import { ObjectMap } from './classes.objectmap.js';
|
||||||
import { Interest } from './lik.interestmap.interest.js';
|
import { Interest } from './classes.interestmap.interest.js';
|
||||||
|
|
||||||
export type IInterestComparisonFunc<T> = (objectArg: T) => string;
|
export type IInterestComparisonFunc<T> = (objectArg: T) => string;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
export class LimitedArray<T> {
|
export class LimitedArray<T> {
|
||||||
array: T[] = [];
|
array: T[] = [];
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
import { ObjectMap } from './lik.objectmap.js';
|
import { ObjectMap } from './classes.objectmap.js';
|
||||||
|
|
||||||
export class LoopTracker<T> {
|
export class LoopTracker<T> {
|
||||||
referenceObjectMap = new ObjectMap<any>();
|
referenceObjectMap = new ObjectMap<any>();
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
import { FastMap } from './lik.fastmap.js';
|
import { FastMap } from './classes.fastmap.js';
|
||||||
|
|
||||||
export const uni = (prefix: string = 'uni') => {
|
export const uni = (prefix: string = 'uni') => {
|
||||||
return `${prefix}xxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
return `${prefix}xxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allows you to easily keep track of a bunch of strings
|
* allows you to easily keep track of a bunch of strings
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
export interface ITimedAggregatorOptions<T> {
|
export interface ITimedAggregatorOptions<T> {
|
||||||
aggregationIntervalInMillis: number;
|
aggregationIntervalInMillis: number;
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './lik.plugins.js';
|
import * as plugins from './classes.plugins.js';
|
||||||
|
|
||||||
export class Tree<T> {
|
export class Tree<T> {
|
||||||
symbolTree: any;
|
symbolTree: any;
|
21
ts/index.ts
21
ts/index.ts
@ -1,10 +1,11 @@
|
|||||||
export * from './lik.asyncexecutionstack.js';
|
export * from './classes.asyncexecutionstack.js';
|
||||||
export * from './lik.fastmap.js';
|
export * from './classes.backpressuredarray.js';
|
||||||
export * from './lik.interestmap.js';
|
export * from './classes.fastmap.js';
|
||||||
export * from './lik.interestmap.interest.js';
|
export * from './classes.interestmap.js';
|
||||||
export * from './lik.limitedarray.js';
|
export * from './classes.interestmap.interest.js';
|
||||||
export * from './lik.looptracker.js';
|
export * from './classes.limitedarray.js';
|
||||||
export * from './lik.objectmap.js';
|
export * from './classes.looptracker.js';
|
||||||
export * from './lik.stringmap.js';
|
export * from './classes.objectmap.js';
|
||||||
export * from './lik.timedaggregator.js';
|
export * from './classes.stringmap.js';
|
||||||
export * from './lik.tree.js';
|
export * from './classes.timedaggregator.js';
|
||||||
|
export * from './classes.tree.js';
|
||||||
|
Reference in New Issue
Block a user