Compare commits
172 Commits
Author | SHA1 | Date | |
---|---|---|---|
5d9624bd56 | |||
32397a97cd | |||
753b829d18 | |||
4be2784bf4 | |||
cd08cf370c | |||
b64fe567a8 | |||
2a68c9ad90 | |||
aa978413d1 | |||
f24636ba80 | |||
5e31dbb504 | |||
b2ca6e13e7 | |||
052322fb98 | |||
9e1eb0b3a0 | |||
af9b045d31 | |||
d7718d4340 | |||
92592d9e9a | |||
a786c43970 | |||
66658dc877 | |||
be78d74124 | |||
bde0404777 | |||
dfe973f5d8 | |||
326030456f | |||
184dc98127 | |||
702ce00288 | |||
ff0d745170 | |||
8fc0438c75 | |||
355c2d132e | |||
c083a47f07 | |||
9eb9403bea | |||
029f2a6872 | |||
66676d89a5 | |||
775a307056 | |||
4aa7621401 | |||
b7ac5cb864 | |||
f580281ccd | |||
cc66f81c7e | |||
6f1e32284d | |||
47b511f1f0 | |||
24f82fe570 | |||
60a0fab9db | |||
61e287fbe4 | |||
984297c9c3 | |||
55e4edc785 | |||
0fdc891326 | |||
69ab47ed41 | |||
b1bd8132de | |||
4e672b13f4 | |||
75c2f23d02 | |||
da0c459d74 | |||
079b093e2c | |||
55a3caec44 | |||
28b3666aad | |||
b17dd2ed64 | |||
e551a68237 | |||
f402e55ff3 | |||
15b8fe406a | |||
c7557163cd | |||
f84822dd5d | |||
21d6e19a22 | |||
8947738dc1 | |||
14bc5dcd25 | |||
c2f366de7f | |||
ae47276569 | |||
42b59c109d | |||
8f18faaf1c | |||
ccd5b80d67 | |||
298904e17e | |||
fa91e67aef | |||
5e99066bee | |||
a838f7eb80 | |||
979e93be27 | |||
60587f052c | |||
da5bd43a42 | |||
24559d1582 | |||
d92657b130 | |||
f8f34bf8a3 | |||
861d2c04b3 | |||
5845d74160 | |||
9dd952e6b7 | |||
742a711359 | |||
8878a0ef8b | |||
6a52e81cdd | |||
757e709f3f | |||
e0d9c3a3e0 | |||
150953adaf | |||
e0eba5d206 | |||
d9eb836f98 | |||
6d29798660 | |||
f80a84086c | |||
929a6eff07 | |||
87243881bb | |||
5d51c14bd6 | |||
453c6d6ae8 | |||
2e9fe308df | |||
96a71638a0 | |||
1c7582d328 | |||
ccff9b39be | |||
749be9ac60 | |||
7c9ad26519 | |||
6fdf08c8a9 | |||
de04d75e18 | |||
5159d7e4bf | |||
7b78aaea72 | |||
54a63d1f41 | |||
dd5a009d0f | |||
e7933cd7f4 | |||
56a8d9182b | |||
3a971301a4 | |||
b880036b64 | |||
9d756dbff7 | |||
b8111c66ff | |||
8d660a8573 | |||
596a897afc | |||
e1442b1bc8 | |||
2ca9e14f76 | |||
e65f36dfa2 | |||
adb95cd683 | |||
d2106690b4 | |||
2ea5111eb8 | |||
aae10344fe | |||
52b65d7dc3 | |||
1135b418cb | |||
2eb1dbd0b3 | |||
8ec54c17a1 | |||
500a291b2a | |||
256a14fcb0 | |||
7aa0f05bae | |||
6208cab36a | |||
50a9697baf | |||
7956cf6ace | |||
d8956d4e32 | |||
c93a67c351 | |||
fafd9867ad | |||
2dfa96bbc5 | |||
a7484e791a | |||
|
2dba68df8c | ||
6aff4c9031 | |||
e81e0ebd41 | |||
18866b9a05 | |||
71b12b2d9c | |||
0669fc3779 | |||
7021f8f1ae | |||
2392915959 | |||
b8100f8dfc | |||
04e9d8be77 | |||
a9715381c1 | |||
c2f081d69a | |||
b98f075cbd | |||
5ff74aea88 | |||
a6eaf78c80 | |||
adda1c932a | |||
7c8643b090 | |||
9e81960095 | |||
a76832bedb | |||
3c229e8e26 | |||
29d6f2d7e0 | |||
2b5ff6a4ab | |||
c75437e73f | |||
61e4a62689 | |||
d53f5410cd | |||
53516b1c8f | |||
e59205490b | |||
38884ff59c | |||
861833e930 | |||
1274840d17 | |||
d2ce1094de | |||
6b3fcff971 | |||
011a865271 | |||
78914e54b3 | |||
281cfdc38a | |||
217252de1e | |||
ab7f7230ef |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,5 +1,20 @@
|
||||
node_modules/
|
||||
pages/
|
||||
public/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
.nogit/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -1,72 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage
|
||||
tags:
|
||||
- docker
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
55
changelog.md
Normal file
55
changelog.md
Normal file
@ -0,0 +1,55 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-10-13 - 6.1.0 - feat(BackpressuredArray)
|
||||
Add method to check if items are present in BackpressuredArray
|
||||
|
||||
- Implemented a new method `checkHasItems` in the BackpressuredArray class to determine if the array contains any items.
|
||||
|
||||
## 2024-05-29 to 2024-04-18 - 6.0.15
|
||||
Minor updates were made to documentation and descriptions.
|
||||
|
||||
- Update project description
|
||||
|
||||
## 2024-04-18 to 2024-02-25 - 6.0.14
|
||||
Several updates were made to configurations and json files.
|
||||
|
||||
- Updated core components in the codebase
|
||||
- Modified tsconfig settings
|
||||
- Revised npmextra.json with githost configurations
|
||||
|
||||
## 2024-02-25 to 2024-02-23 - 6.0.13
|
||||
No relevant changes.
|
||||
|
||||
## 2024-02-23 to 2023-11-13 - 6.0.12 to 6.0.8
|
||||
Multiple core updates were performed to ensure stability and performance.
|
||||
|
||||
- Fixed various issues in core components
|
||||
|
||||
## 2023-11-13 to 2023-08-14 - 6.0.7 to 6.0.3
|
||||
Minor internal core updates.
|
||||
|
||||
## 2023-08-14 to 2023-07-12 - 6.0.2
|
||||
Implemented a switch to a new organizational scheme.
|
||||
|
||||
## 2023-01-18 to 2022-05-27 - 6.0.0
|
||||
Updated core functionalities; introduced breaking changes for compatibility with ECMAScript modules.
|
||||
|
||||
- Core updates
|
||||
- Switching from CommonJS to ECMAScript modules
|
||||
|
||||
## 2022-05-27 to 2022-05-27 - 5.0.6 to 5.0.0
|
||||
Minor updates and a significant change in `objectmap` behavior to support async operations.
|
||||
|
||||
- Included async behaviors in objectmap as a breaking change
|
||||
|
||||
## 2020-05-04 to 2020-02-17 - 4.0.0
|
||||
Refactored ObjectMap; introduced new features.
|
||||
|
||||
- Refactored ObjectMap with concat functionality as a breaking change
|
||||
- Added .clean() to FastMap
|
||||
|
||||
## 2020-02-17 to 2020-02-06 - 3.0.19 to 3.0.15
|
||||
Enhancements and new functionality in ObjectMap.
|
||||
|
||||
- Added object mapping enhancements
|
||||
- Introduced object map with unique keys
|
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export * from './lik.stringmap';
|
||||
export * from './lik.objectmap';
|
||||
export * from './lik.observablemap';
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// import modules
|
||||
__export(require("./lik.stringmap"));
|
||||
__export(require("./lik.objectmap"));
|
||||
__export(require("./lik.observablemap"));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLGlCQUFpQjtBQUVqQixxQ0FBK0I7QUFDL0IscUNBQStCO0FBQy9CLHlDQUFtQyJ9
|
60
dist/lik.objectmap.d.ts
vendored
60
dist/lik.objectmap.d.ts
vendored
@ -1,60 +0,0 @@
|
||||
export interface IObjectmapForEachFunction<T> {
|
||||
(itemArg: T): void;
|
||||
}
|
||||
export interface IObjectmapFindFunction<T> {
|
||||
(itemArg: T): boolean;
|
||||
}
|
||||
/**
|
||||
* allows keeping track of objects
|
||||
*/
|
||||
export declare class Objectmap<T> {
|
||||
private objectArray;
|
||||
/**
|
||||
* returns a new instance
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* add object to Objectmap
|
||||
*/
|
||||
add(objectArg: T): void;
|
||||
/**
|
||||
* like .add but adds an whole array of objects
|
||||
*/
|
||||
addArray(objectArrayArg: T[]): void;
|
||||
/**
|
||||
* check if object is in Objectmap
|
||||
*/
|
||||
checkForObject(objectArg: T): boolean;
|
||||
/**
|
||||
* find object
|
||||
*/
|
||||
find(findFunction: IObjectmapFindFunction<T>): T;
|
||||
/**
|
||||
* finds a specific element and then removes it
|
||||
*/
|
||||
findOneAndRemove(findFunction: IObjectmapFindFunction<T>): T;
|
||||
/**
|
||||
* run function for each item in Objectmap
|
||||
*/
|
||||
forEach(functionArg: IObjectmapForEachFunction<T>): void;
|
||||
/**
|
||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||
*/
|
||||
getOneAndRemove(): T;
|
||||
/**
|
||||
* returns a cloned array of all the objects currently in the Objectmap
|
||||
*/
|
||||
getArray(): T[];
|
||||
/**
|
||||
* check if Objectmap ist empty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
/**
|
||||
* remove object from Objectmap
|
||||
*/
|
||||
remove(objectArg: T): void;
|
||||
/**
|
||||
* wipe Objectmap
|
||||
*/
|
||||
wipe(): void;
|
||||
}
|
106
dist/lik.objectmap.js
vendored
106
dist/lik.objectmap.js
vendored
@ -1,106 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./lik.plugins");
|
||||
/**
|
||||
* allows keeping track of objects
|
||||
*/
|
||||
class Objectmap {
|
||||
/**
|
||||
* returns a new instance
|
||||
*/
|
||||
constructor() {
|
||||
this.objectArray = [];
|
||||
// nothing here
|
||||
}
|
||||
/**
|
||||
* add object to Objectmap
|
||||
*/
|
||||
add(objectArg) {
|
||||
this.objectArray.push(objectArg);
|
||||
}
|
||||
/**
|
||||
* like .add but adds an whole array of objects
|
||||
*/
|
||||
addArray(objectArrayArg) {
|
||||
for (let item of objectArrayArg) {
|
||||
this.add(item);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if object is in Objectmap
|
||||
*/
|
||||
checkForObject(objectArg) {
|
||||
return this.objectArray.indexOf(objectArg) !== -1;
|
||||
}
|
||||
/**
|
||||
* find object
|
||||
*/
|
||||
find(findFunction) {
|
||||
let resultArray = this.objectArray.filter(findFunction);
|
||||
if (resultArray.length > 0) {
|
||||
return resultArray[0];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finds a specific element and then removes it
|
||||
*/
|
||||
findOneAndRemove(findFunction) {
|
||||
let foundElement = this.find(findFunction);
|
||||
if (foundElement) {
|
||||
this.remove(foundElement);
|
||||
}
|
||||
return foundElement;
|
||||
}
|
||||
/**
|
||||
* run function for each item in Objectmap
|
||||
*/
|
||||
forEach(functionArg) {
|
||||
return this.objectArray.forEach(functionArg);
|
||||
}
|
||||
/**
|
||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||
*/
|
||||
getOneAndRemove() {
|
||||
return this.objectArray.shift();
|
||||
}
|
||||
/**
|
||||
* returns a cloned array of all the objects currently in the Objectmap
|
||||
*/
|
||||
getArray() {
|
||||
return plugins.lodash.cloneDeep(this.objectArray);
|
||||
}
|
||||
/**
|
||||
* check if Objectmap ist empty
|
||||
*/
|
||||
isEmpty() {
|
||||
if (this.objectArray.length === 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* remove object from Objectmap
|
||||
*/
|
||||
remove(objectArg) {
|
||||
let replacementArray = [];
|
||||
for (let item of this.objectArray) {
|
||||
if (item !== objectArg) {
|
||||
replacementArray.push(item);
|
||||
}
|
||||
}
|
||||
this.objectArray = replacementArray;
|
||||
}
|
||||
/**
|
||||
* wipe Objectmap
|
||||
*/
|
||||
wipe() {
|
||||
this.objectArray = [];
|
||||
}
|
||||
}
|
||||
exports.Objectmap = Objectmap;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBd0M7QUFVeEM7O0dBRUc7QUFDSDtJQUdFOztPQUVHO0lBQ0g7UUFMUSxnQkFBVyxHQUFRLEVBQUUsQ0FBQTtRQU0zQixlQUFlO0lBQ2pCLENBQUM7SUFFRDs7T0FFRztJQUNILEdBQUcsQ0FBRSxTQUFZO1FBQ2YsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDbEMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsUUFBUSxDQUFFLGNBQW1CO1FBQzNCLEdBQUcsQ0FBQyxDQUFDLElBQUksSUFBSSxJQUFJLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDaEMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUNoQixDQUFDO0lBQ0gsQ0FBQztJQUVEOztPQUVHO0lBQ0gsY0FBYyxDQUFFLFNBQVk7UUFDMUIsTUFBTSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFBO0lBQ25ELENBQUM7SUFFRDs7T0FFRztJQUNILElBQUksQ0FBRSxZQUF1QztRQUMzQyxJQUFJLFdBQVcsR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxZQUFZLENBQUMsQ0FBQTtRQUN2RCxFQUFFLENBQUMsQ0FBQyxXQUFXLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDM0IsTUFBTSxDQUFDLFdBQVcsQ0FBRSxDQUFDLENBQUUsQ0FBQTtRQUN6QixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixNQUFNLENBQUMsSUFBSSxDQUFBO1FBQ2IsQ0FBQztJQUNILENBQUM7SUFFRDs7T0FFRztJQUNILGdCQUFnQixDQUFFLFlBQXVDO1FBQ3ZELElBQUksWUFBWSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDMUMsRUFBRSxDQUFDLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUNqQixJQUFJLENBQUMsTUFBTSxDQUFDLFlBQVksQ0FBQyxDQUFBO1FBQzNCLENBQUM7UUFDRCxNQUFNLENBQUMsWUFBWSxDQUFBO0lBQ3JCLENBQUM7SUFFRDs7T0FFRztJQUNILE9BQU8sQ0FBRSxXQUF5QztRQUNoRCxNQUFNLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUE7SUFDOUMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsZUFBZTtRQUNiLE1BQU0sQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQ2pDLENBQUM7SUFFRDs7T0FFRztJQUNILFFBQVE7UUFDTixNQUFNLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFBO0lBQ25ELENBQUM7SUFFRDs7T0FFRztJQUNILE9BQU87UUFDTCxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2xDLE1BQU0sQ0FBQyxJQUFJLENBQUE7UUFDYixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixNQUFNLENBQUMsS0FBSyxDQUFBO1FBQ2QsQ0FBQztJQUNILENBQUM7SUFFRDs7T0FFRztJQUNILE1BQU0sQ0FBRSxTQUFZO1FBQ2xCLElBQUksZ0JBQWdCLEdBQUcsRUFBRSxDQUFBO1FBQ3pCLEdBQUcsQ0FBQyxDQUFDLElBQUksSUFBSSxJQUFJLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQ2xDLEVBQUUsQ0FBQyxDQUFDLElBQUksS0FBSyxTQUFTLENBQUMsQ0FBQyxDQUFDO2dCQUN2QixnQkFBZ0IsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7WUFDN0IsQ0FBQztRQUNILENBQUM7UUFDRCxJQUFJLENBQUMsV0FBVyxHQUFHLGdCQUFnQixDQUFBO0lBQ3JDLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUk7UUFDRixJQUFJLENBQUMsV0FBVyxHQUFHLEVBQUUsQ0FBQTtJQUN2QixDQUFDO0NBQ0Y7QUEzR0QsOEJBMkdDIn0=
|
23
dist/lik.observablemap.d.ts
vendored
23
dist/lik.observablemap.d.ts
vendored
@ -1,23 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import * as plugins from './lik.plugins';
|
||||
import { Objectmap } from './lik.objectmap';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
/**
|
||||
* bundles an observable with an emitter
|
||||
*/
|
||||
export interface ObservableEmitterBundle {
|
||||
observable: plugins.rx.Observable<any>;
|
||||
emitter: plugins.events.EventEmitter;
|
||||
event: string;
|
||||
}
|
||||
/**
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
export declare class Observablemap {
|
||||
ObservableEmitterBundleObjectmap: Objectmap<ObservableEmitterBundle>;
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
getObservableForEmitterEvent(emitterArg: plugins.events.EventEmitter, eventArg: string): Observable<any>;
|
||||
}
|
35
dist/lik.observablemap.js
vendored
35
dist/lik.observablemap.js
vendored
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./lik.plugins");
|
||||
const lik_objectmap_1 = require("./lik.objectmap");
|
||||
/**
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
class Observablemap {
|
||||
constructor() {
|
||||
this.ObservableEmitterBundleObjectmap = new lik_objectmap_1.Objectmap();
|
||||
}
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
getObservableForEmitterEvent(emitterArg, eventArg) {
|
||||
let existingBundle = this.ObservableEmitterBundleObjectmap.find((bundleArg) => {
|
||||
return (bundleArg.emitter === emitterArg && bundleArg.event === eventArg);
|
||||
});
|
||||
if (existingBundle) {
|
||||
return existingBundle.observable;
|
||||
}
|
||||
else {
|
||||
let emitterObservable = plugins.rx.Observable.fromEvent(emitterArg, eventArg);
|
||||
this.ObservableEmitterBundleObjectmap.add({
|
||||
observable: emitterObservable,
|
||||
emitter: emitterArg,
|
||||
event: eventArg
|
||||
});
|
||||
return emitterObservable;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Observablemap = Observablemap;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9ic2VydmFibGVtYXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsub2JzZXJ2YWJsZW1hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlDQUF3QztBQUN4QyxtREFBMkM7QUFhM0M7O0dBRUc7QUFDSDtJQUFBO1FBQ0UscUNBQWdDLEdBQUcsSUFBSSx5QkFBUyxFQUEyQixDQUFBO0lBc0I3RSxDQUFDO0lBcEJDOzs7T0FHRztJQUNILDRCQUE0QixDQUFFLFVBQXVDLEVBQUUsUUFBZ0I7UUFDckYsSUFBSSxjQUFjLEdBQUcsSUFBSSxDQUFDLGdDQUFnQyxDQUFDLElBQUksQ0FBQyxDQUFDLFNBQVM7WUFDeEUsTUFBTSxDQUFDLENBQUMsU0FBUyxDQUFDLE9BQU8sS0FBSyxVQUFVLElBQUksU0FBUyxDQUFDLEtBQUssS0FBSyxRQUFRLENBQUMsQ0FBQTtRQUMzRSxDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDbkIsTUFBTSxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUE7UUFDbEMsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ04sSUFBSSxpQkFBaUIsR0FBRyxPQUFPLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxTQUFTLENBQUMsVUFBVSxFQUFFLFFBQVEsQ0FBQyxDQUFBO1lBQzdFLElBQUksQ0FBQyxnQ0FBZ0MsQ0FBQyxHQUFHLENBQUM7Z0JBQ3hDLFVBQVUsRUFBRSxpQkFBaUI7Z0JBQzdCLE9BQU8sRUFBRSxVQUFVO2dCQUNuQixLQUFLLEVBQUUsUUFBUTthQUNoQixDQUFDLENBQUE7WUFDRixNQUFNLENBQUMsaUJBQWlCLENBQUE7UUFDMUIsQ0FBQztJQUNILENBQUM7Q0FDRjtBQXZCRCxzQ0F1QkMifQ==
|
6
dist/lik.plugins.d.ts
vendored
6
dist/lik.plugins.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
import 'typings-global';
|
||||
export import q = require('q');
|
||||
export import events = require('events');
|
||||
export import lodash = require('lodash');
|
||||
export import minimatch = require('minimatch');
|
||||
export import rx = require('rxjs/Rx');
|
9
dist/lik.plugins.js
vendored
9
dist/lik.plugins.js
vendored
@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
exports.q = require("q");
|
||||
exports.events = require("events");
|
||||
exports.lodash = require("lodash");
|
||||
exports.minimatch = require("minimatch");
|
||||
exports.rx = require("rxjs/Rx");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qix5QkFBOEI7QUFDOUIsbUNBQXdDO0FBQ3hDLG1DQUF3QztBQUN4Qyx5Q0FBOEM7QUFDOUMsZ0NBQXFDIn0=
|
51
dist/lik.stringmap.d.ts
vendored
51
dist/lik.stringmap.d.ts
vendored
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* allows you to easily keep track of a bunch of strings
|
||||
*/
|
||||
export interface ITriggerFunction {
|
||||
(): boolean;
|
||||
}
|
||||
export declare class Stringmap {
|
||||
private _stringArray;
|
||||
private _triggerUntilTrueFunctionArray;
|
||||
constructor();
|
||||
/**
|
||||
* add a string to the Stringmap
|
||||
*/
|
||||
addString(stringArg: string): void;
|
||||
/**
|
||||
* like addString, but accepts an array of strings
|
||||
*/
|
||||
addStringArray(stringArrayArg: string[]): void;
|
||||
/**
|
||||
* removes a string from Stringmap
|
||||
*/
|
||||
removeString(stringArg: string): void;
|
||||
/**
|
||||
* wipes the Stringmap
|
||||
*/
|
||||
wipe(): void;
|
||||
/**
|
||||
* check if string is in Stringmap
|
||||
*/
|
||||
checkString(stringArg: string): boolean;
|
||||
/**
|
||||
* checks stringPresence with minimatch
|
||||
*/
|
||||
checkMinimatch(miniMatchStringArg: string): boolean;
|
||||
/**
|
||||
* checks if the Stringmap is empty
|
||||
*/
|
||||
checkIsEmpty(): boolean;
|
||||
/**
|
||||
* gets a cloned copy of the current string Array
|
||||
*/
|
||||
getStringArray(): string[];
|
||||
/**
|
||||
* register a new trigger
|
||||
*/
|
||||
registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg: any): void;
|
||||
/**
|
||||
* notifies triggers
|
||||
*/
|
||||
private notifyTrigger();
|
||||
}
|
97
dist/lik.stringmap.js
vendored
97
dist/lik.stringmap.js
vendored
@ -1,97 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./lik.plugins");
|
||||
class Stringmap {
|
||||
constructor() {
|
||||
this._stringArray = [];
|
||||
this._triggerUntilTrueFunctionArray = [];
|
||||
}
|
||||
/**
|
||||
* add a string to the Stringmap
|
||||
*/
|
||||
addString(stringArg) {
|
||||
this._stringArray.push(stringArg);
|
||||
this.notifyTrigger();
|
||||
}
|
||||
/**
|
||||
* like addString, but accepts an array of strings
|
||||
*/
|
||||
addStringArray(stringArrayArg) {
|
||||
for (let stringItem of stringArrayArg) {
|
||||
this.addString(stringItem);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* removes a string from Stringmap
|
||||
*/
|
||||
removeString(stringArg) {
|
||||
for (let keyArg in this._stringArray) {
|
||||
if (this._stringArray[keyArg] === stringArg) {
|
||||
this._stringArray.splice(parseInt(keyArg), 1);
|
||||
}
|
||||
}
|
||||
this.notifyTrigger();
|
||||
}
|
||||
/**
|
||||
* wipes the Stringmap
|
||||
*/
|
||||
wipe() {
|
||||
this._stringArray = [];
|
||||
this.notifyTrigger();
|
||||
}
|
||||
/**
|
||||
* check if string is in Stringmap
|
||||
*/
|
||||
checkString(stringArg) {
|
||||
return this._stringArray.indexOf(stringArg) !== -1;
|
||||
}
|
||||
/**
|
||||
* checks stringPresence with minimatch
|
||||
*/
|
||||
checkMinimatch(miniMatchStringArg) {
|
||||
let foundMatch = false;
|
||||
for (let stringItem of this._stringArray) {
|
||||
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
||||
foundMatch = true;
|
||||
}
|
||||
}
|
||||
return foundMatch;
|
||||
}
|
||||
/**
|
||||
* checks if the Stringmap is empty
|
||||
*/
|
||||
checkIsEmpty() {
|
||||
return (this._stringArray.length === 0);
|
||||
}
|
||||
/**
|
||||
* gets a cloned copy of the current string Array
|
||||
*/
|
||||
getStringArray() {
|
||||
return plugins.lodash.cloneDeep(this._stringArray);
|
||||
}
|
||||
// trigger registering
|
||||
/**
|
||||
* register a new trigger
|
||||
*/
|
||||
registerUntilTrue(functionArg, doFunctionArg) {
|
||||
this._triggerUntilTrueFunctionArray.push(() => {
|
||||
let result = functionArg();
|
||||
if (result === true) {
|
||||
doFunctionArg();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
this.notifyTrigger();
|
||||
}
|
||||
/**
|
||||
* notifies triggers
|
||||
*/
|
||||
notifyTrigger() {
|
||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||
return !functionArg();
|
||||
});
|
||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||
}
|
||||
}
|
||||
exports.Stringmap = Stringmap;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBd0M7QUFVeEM7SUFHSTtRQUZRLGlCQUFZLEdBQWEsRUFBRSxDQUFBO1FBQzNCLG1DQUE4QixHQUF1QixFQUFFLENBQUE7SUFDaEQsQ0FBQztJQUNoQjs7T0FFRztJQUNILFNBQVMsQ0FBQyxTQUFpQjtRQUN2QixJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtRQUNqQyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUE7SUFDeEIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsY0FBYyxDQUFDLGNBQXdCO1FBQ25DLEdBQUcsQ0FBQyxDQUFDLElBQUksVUFBVSxJQUFJLGNBQWMsQ0FBQyxDQUFBLENBQUM7WUFDbkMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUM5QixDQUFDO0lBQ0wsQ0FBQztJQUVEOztPQUVHO0lBQ0gsWUFBWSxDQUFDLFNBQWlCO1FBQzFCLEdBQUcsQ0FBQyxDQUFDLElBQUksTUFBTSxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDO1lBQ25DLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsTUFBTSxDQUFDLEtBQUssU0FBUyxDQUFDLENBQUMsQ0FBQztnQkFDMUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxFQUFDLENBQUMsQ0FBQyxDQUFBO1lBQ2hELENBQUM7UUFDTCxDQUFDO1FBQ0QsSUFBSSxDQUFDLGFBQWEsRUFBRSxDQUFBO0lBQ3hCLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUk7UUFDQSxJQUFJLENBQUMsWUFBWSxHQUFHLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsYUFBYSxFQUFFLENBQUE7SUFDeEIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsV0FBVyxDQUFDLFNBQWlCO1FBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQTtJQUN0RCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxjQUFjLENBQUMsa0JBQTBCO1FBQ3JDLElBQUksVUFBVSxHQUFZLEtBQUssQ0FBQTtRQUMvQixHQUFHLENBQUMsQ0FBQyxJQUFJLFVBQVUsSUFBSSxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUEsQ0FBQztZQUN0QyxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLFVBQVUsRUFBQyxrQkFBa0IsQ0FBQyxDQUFDLENBQUMsQ0FBQztnQkFDbkQsVUFBVSxHQUFHLElBQUksQ0FBQTtZQUNyQixDQUFDO1FBQ0wsQ0FBQztRQUNELE1BQU0sQ0FBQyxVQUFVLENBQUE7SUFDckIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsWUFBWTtRQUNSLE1BQU0sQ0FBQyxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsTUFBTSxLQUFLLENBQUMsQ0FBQyxDQUFBO0lBQzNDLENBQUM7SUFFRDs7T0FFRztJQUNILGNBQWM7UUFDVixNQUFNLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxDQUFBO0lBQ3RELENBQUM7SUFFRCxzQkFBc0I7SUFFdEI7O09BRUc7SUFDSCxpQkFBaUIsQ0FBQyxXQUE2QixFQUFDLGFBQWE7UUFDekQsSUFBSSxDQUFDLDhCQUE4QixDQUFDLElBQUksQ0FDcEM7WUFDSSxJQUFJLE1BQU0sR0FBRyxXQUFXLEVBQUUsQ0FBQTtZQUMxQixFQUFFLENBQUMsQ0FBQyxNQUFNLEtBQUssSUFBSSxDQUFDLENBQUMsQ0FBQztnQkFDbEIsYUFBYSxFQUFFLENBQUE7WUFDbkIsQ0FBQztZQUNELE1BQU0sQ0FBQyxNQUFNLENBQUE7UUFDakIsQ0FBQyxDQUNKLENBQUE7UUFDRCxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUE7SUFDeEIsQ0FBQztJQUVEOztPQUVHO0lBQ0ssYUFBYTtRQUNqQixJQUFJLGFBQWEsR0FBRyxJQUFJLENBQUMsOEJBQThCLENBQUMsTUFBTSxDQUFDLENBQUMsV0FBVztZQUN2RSxNQUFNLENBQUMsQ0FBQyxXQUFXLEVBQUUsQ0FBQTtRQUN6QixDQUFDLENBQUMsQ0FBQTtRQUNGLElBQUksQ0FBQyw4QkFBOEIsR0FBRyxhQUFhLENBQUE7SUFDdkQsQ0FBQztDQUVKO0FBdkdELDhCQXVHQyJ9
|
@ -1,13 +1,16 @@
|
||||
# lik
|
||||
|
||||
light little helpers for node
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/lik)
|
||||
[](https://GitLab.com/pushrocks/lik)
|
||||
[](https://github.com/pushrocks/lik)
|
||||
[](https://pushrocks.gitlab.io/lik/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/lik/commits/master)
|
||||
[](https://GitLab.com/pushrocks/lik/commits/master)
|
||||
[](https://www.npmjs.com/package/lik)
|
||||
@ -19,30 +22,25 @@ light little helpers for node
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```javascript
|
||||
// import any tool that you need from lik
|
||||
import { Stringmap, Objectmap, Observablemap } from "lik";
|
||||
import { Stringmap, Objectmap, Observablemap } from 'lik';
|
||||
```
|
||||
|
||||
### class Stringmap
|
||||
|
||||
Stringmap allows you to keep track of strings. It allows you to register triggers for certain events
|
||||
like when a certain string is removed or added to the map
|
||||
|
||||
### class Objectmap
|
||||
|
||||
Sometimes you need to keep track of objects, but implementing logic for removing, finding or updating is tedious.
|
||||
Objectmap takes care of keeping track of objects for you.
|
||||
|
||||
### class Observablemap
|
||||
Event Emitters are nice. However often times you end up with registering multiple listeners for the exact same thing.
|
||||
Observables have a smaller footprint and a more manageable subscribe logic.
|
||||
Observablemap registers only one rxjs observable per event and then continues to reference
|
||||
the same observable that you can subscribe to.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
@ -1,10 +1,33 @@
|
||||
{
|
||||
"npmci": {
|
||||
"globalNpmTools": [
|
||||
"npmts"
|
||||
]
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"npmts": {
|
||||
"coverageTreshold": 40
|
||||
}
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "lik",
|
||||
"description": "Provides a collection of lightweight helpers and utilities for Node.js projects.",
|
||||
"npmPackagename": "@push.rocks/lik",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"Utilities",
|
||||
"Helpers",
|
||||
"Typescript",
|
||||
"Node.js",
|
||||
"String manipulation",
|
||||
"Object management",
|
||||
"Execution control",
|
||||
"Data structures",
|
||||
"Asynchronous programming",
|
||||
"Event handling",
|
||||
"Data aggregation"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
74
package.json
74
package.json
@ -1,34 +1,70 @@
|
||||
{
|
||||
"name": "lik",
|
||||
"version": "1.0.35",
|
||||
"description": "light little helpers for node",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/lik",
|
||||
"version": "6.1.0",
|
||||
"private": false,
|
||||
"description": "Provides a collection of lightweight helpers and utilities for Node.js projects.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/lik.git"
|
||||
"url": "https://code.foss.global/push.rocks/lik.git"
|
||||
},
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/lik/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/lik",
|
||||
"devDependencies": {
|
||||
"tapbundle": "^1.0.14"
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsbundle": "^2.0.15",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.12.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.67",
|
||||
"@types/minimatch": "2.x.x",
|
||||
"@types/q": "1.x.x",
|
||||
"lodash": "^4.17.4",
|
||||
"minimatch": "^3.0.4",
|
||||
"q": "^1.5.0",
|
||||
"rxjs": "^5.4.1",
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.19"
|
||||
}
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartmatch": "^2.0.0",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartrx": "^3.0.7",
|
||||
"@push.rocks/smarttime": "^4.0.6",
|
||||
"@types/minimatch": "^5.1.2",
|
||||
"@types/symbol-tree": "^3.2.5",
|
||||
"symbol-tree": "^3.2.4"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"keywords": [
|
||||
"Utilities",
|
||||
"Helpers",
|
||||
"Typescript",
|
||||
"Node.js",
|
||||
"String manipulation",
|
||||
"Object management",
|
||||
"Execution control",
|
||||
"Data structures",
|
||||
"Asynchronous programming",
|
||||
"Event handling",
|
||||
"Data aggregation"
|
||||
]
|
||||
}
|
||||
|
4919
pnpm-lock.yaml
generated
Normal file
4919
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
204
readme.md
Normal file
204
readme.md
Normal file
@ -0,0 +1,204 @@
|
||||
# @push.rocks/lik
|
||||
light little helpers for node
|
||||
|
||||
## Install
|
||||
|
||||
To install `@push.rocks/lik`, you can use npm (Node Package Manager). Simply run the following command in your terminal:
|
||||
|
||||
```bash
|
||||
npm install @push.rocks/lik --save
|
||||
```
|
||||
|
||||
This will download `@push.rocks/lik` and add it to your project's `package.json` dependencies.
|
||||
|
||||
## Usage
|
||||
|
||||
`@push.rocks/lik` is a versatile package offering a variety of helper classes designed to simplify common tasks in Node.js development. From managing asynchronous operations to handling collections efficiently, this library provides lightweight solutions to enhance your coding workflow. Below, we explore several key features of `@push.rocks/lik`, presenting TypeScript examples to demonstrate their practical application in real-world scenarios.
|
||||
|
||||
### AsyncExecutionStack
|
||||
|
||||
`AsyncExecutionStack` allows for managing asynchronous task execution with exclusive and non-exclusive slots, ensuring effective handling of resource-intensive operations.
|
||||
|
||||
```typescript
|
||||
import { AsyncExecutionStack } from '@push.rocks/lik';
|
||||
|
||||
const myAsyncStack = new AsyncExecutionStack();
|
||||
|
||||
// Exclusive execution ensures this task doesn't run in parallel with others
|
||||
await myAsyncStack.getExclusiveExecutionSlot(async () => {
|
||||
// some asynchronous operation
|
||||
}, 2500);
|
||||
|
||||
// Non-exclusive slots can run in parallel
|
||||
myAsyncStack.getNonExclusiveExecutionSlot(async () => {
|
||||
// another asynchronous operation
|
||||
}, 1500);
|
||||
```
|
||||
|
||||
### FastMap
|
||||
|
||||
`FastMap` offers a high-performance, key-value map optimized for rapid access and modifications, ideal for scenarios requiring frequent read/write operations.
|
||||
|
||||
```typescript
|
||||
import { FastMap } from '@push.rocks/lik';
|
||||
|
||||
const myFastMap = new FastMap<string>();
|
||||
|
||||
// Add items
|
||||
myFastMap.addToMap('key1', 'value1');
|
||||
myFastMap.addToMap('key2', 'value2');
|
||||
|
||||
// Retrieve item
|
||||
const value = myFastMap.getByKey('key1'); // 'value1'
|
||||
```
|
||||
|
||||
### LimitedArray
|
||||
|
||||
`LimitedArray` enforces a maximum size on an array, automatically managing its length to prevent it from exceeding a defined limit.
|
||||
|
||||
```typescript
|
||||
import { LimitedArray } from '@push.rocks/lik';
|
||||
|
||||
const myLimitedArray = new LimitedArray<number>(5); // limit size to 5
|
||||
|
||||
myLimitedArray.addMany([1, 2, 3, 4, 5, 6]);
|
||||
console.log(myLimitedArray.array); // [2, 3, 4, 5, 6]
|
||||
```
|
||||
|
||||
### LoopTracker
|
||||
|
||||
`LoopTracker` helps detect and prevent infinite loops by tracking object references during iterations.
|
||||
|
||||
```typescript
|
||||
import { LoopTracker } from '@push.rocks/lik';
|
||||
|
||||
const myLoopTracker = new LoopTracker<object>();
|
||||
const obj1 = {};
|
||||
|
||||
if (myLoopTracker.checkAndTrack(obj1)) {
|
||||
// proceed with operation
|
||||
} else {
|
||||
// potential loop detected
|
||||
}
|
||||
```
|
||||
|
||||
### ObjectMap
|
||||
|
||||
`ObjectMap` facilitates object management, providing functionalities for adding, finding, and removing objects with ease.
|
||||
|
||||
```typescript
|
||||
import { ObjectMap } from '@push.rocks/lik';
|
||||
|
||||
interface MyObject {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const myObjectMap = new ObjectMap<MyObject>();
|
||||
const obj: MyObject = { id: 1, name: 'Test Object' };
|
||||
|
||||
// Add object
|
||||
myObjectMap.add(obj);
|
||||
|
||||
// Find object
|
||||
const found = myObjectMap.findSync(item => item.id === 1);
|
||||
```
|
||||
|
||||
### StringMap
|
||||
|
||||
`StringMap` simplifies string collection management, allowing you to add, remove, and query strings effectively.
|
||||
|
||||
```typescript
|
||||
import { Stringmap } from '@push.rocks/lik';
|
||||
|
||||
const myStringMap = new Stringmap();
|
||||
|
||||
// Add strings
|
||||
myStringMap.addString('hello');
|
||||
myStringMap.addStringArray(['world', 'example']);
|
||||
|
||||
// Check string presence
|
||||
const exists = myStringMap.checkString('hello'); // true
|
||||
```
|
||||
|
||||
### TimedAggregator
|
||||
|
||||
`TimedAggregator` batches operations over a specified time interval, useful for aggregating logs, metrics, or any data points over time.
|
||||
|
||||
```typescript
|
||||
import { TimedAggregtor } from '@push.rocks/lik';
|
||||
|
||||
const myAggregator = new TimedAggregtor<string>({
|
||||
aggregationIntervalInMillis: 5000, // 5 seconds
|
||||
functionForAggregation: (items) => {
|
||||
console.log('Aggregated items:', items);
|
||||
}
|
||||
});
|
||||
|
||||
// Add items
|
||||
myAggregator.add('item1');
|
||||
myAggregator.add('item2');
|
||||
|
||||
// After 5 seconds, the functionForAggregation will log the aggregated items
|
||||
```
|
||||
|
||||
### InterestMap and Tree
|
||||
|
||||
`InterestMap` provides a structure for managing subscriptions or interests in certain events or entities, optimizing notification mechanisms.
|
||||
|
||||
```typescript
|
||||
import { InterestMap } from '@push.rocks/lik';
|
||||
|
||||
const myInterestMap = new InterestMap<string, number>((str) => str);
|
||||
|
||||
myInterestMap.addInterest('event1').then((interest) => {
|
||||
interest.fullfillInterest(42);
|
||||
});
|
||||
```
|
||||
|
||||
`Tree` offers a way to handle hierarchical data structures, allowing for the composition and traversal of tree-like data sets.
|
||||
|
||||
```typescript
|
||||
import { Tree } from '@push.rocks/lik';
|
||||
|
||||
class TreeNode {
|
||||
constructor(public value: string) {}
|
||||
}
|
||||
|
||||
const myTree = new Tree<TreeNode>();
|
||||
const rootNode = new TreeNode('root');
|
||||
myTree.initialize(rootNode);
|
||||
|
||||
// Add child nodes
|
||||
const childNode = new TreeNode('child');
|
||||
myTree.appendChild(rootNode, childNode);
|
||||
```
|
||||
|
||||
### Utilizing @push.rocks/lik in Your Project
|
||||
|
||||
With `@push.rocks/lik`, you gain access to a comprehensive set of lightweight utilities that can significantly simplify and expedite the development process in Node.js environments. By leveraging the library's classes and functions, you can implement efficient data structures, manage asynchronous operations gracefully, and streamline complex logic with ease.
|
||||
|
||||
By integrating `@push.rocks/lik` into your project, you'll benefit from improved code clarity, reduced boilerplate, and enhanced performance, allowing you to focus on developing the core functionalities of your application. Whether you're managing various collections, executing asynchronous tasks in controlled manners, or dealing with hierarchical data, `@push.rocks/lik` provides the tools you need to achieve your objectives with minimal overhead.
|
||||
|
||||
Remember, continuous exploration of `@push.rocks/lik`'s capabilities and experimenting with its various components in different scenarios will help you unlock its full potential. As your familiarity with the library grows, you'll discover even more ways to optimize your codebase and streamline your development workflow.
|
||||
|
||||
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
29
test/test.asyncexecutionstack.both.ts
Normal file
29
test/test.asyncexecutionstack.both.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
let testAsyncExecutionStack: lik.AsyncExecutionStack;
|
||||
|
||||
tap.test('should create a valid instance of AsyncExectionStack', async () => {
|
||||
testAsyncExecutionStack = new lik.AsyncExecutionStack();
|
||||
expect(testAsyncExecutionStack).toBeInstanceOf(lik.AsyncExecutionStack);
|
||||
});
|
||||
|
||||
tap.test('should run in parallel', async (toolsArg) => {
|
||||
await testAsyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
||||
await toolsArg.delayFor(2000);
|
||||
console.log('should run first');
|
||||
}, 2500);
|
||||
testAsyncExecutionStack.getNonExclusiveExecutionSlot(async () => {
|
||||
await toolsArg.delayFor(2000);
|
||||
console.log('should run third');
|
||||
}, 2500);
|
||||
testAsyncExecutionStack.getNonExclusiveExecutionSlot(async () => {
|
||||
await toolsArg.delayFor(1000);
|
||||
console.log('should run second');
|
||||
}, 2500);
|
||||
await testAsyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
||||
console.log('should run fourth');
|
||||
}, 0);
|
||||
});
|
||||
|
||||
export default tap.start();
|
30
test/test.fastmap.both.ts
Normal file
30
test/test.fastmap.both.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
tap.test('should create a valid fastmap', async () => {
|
||||
const fastmap = new lik.FastMap();
|
||||
expect(fastmap).toBeInstanceOf(lik.FastMap);
|
||||
});
|
||||
|
||||
tap.test('should find an entry', async () => {
|
||||
const fastmap = new lik.FastMap<{
|
||||
value1: string;
|
||||
value2: string;
|
||||
}>();
|
||||
fastmap.addToMap('heythere', {
|
||||
value1: 'heyho',
|
||||
value2: 'heyho2',
|
||||
});
|
||||
fastmap.addToMap('heythere2', {
|
||||
value1: 'heyho3',
|
||||
value2: 'heyho4',
|
||||
});
|
||||
|
||||
const result = await fastmap.find(async (itemArg) => {
|
||||
return itemArg.value2 === 'heyho4';
|
||||
});
|
||||
expect(result.value1).toEqual('heyho3');
|
||||
});
|
||||
|
||||
export default tap.start();
|
25
test/test.interestmap.both.ts
Normal file
25
test/test.interestmap.both.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
let testInterestmap: lik.InterestMap<number, number>;
|
||||
|
||||
tap.test('should create an interestmap', async () => {
|
||||
testInterestmap = new lik.InterestMap((numberArg) => {
|
||||
return numberArg.toString();
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should create an interest', async () => {
|
||||
testInterestmap.addInterest(3);
|
||||
testInterestmap.addInterest(4);
|
||||
});
|
||||
|
||||
tap.test('should return an already existing interest', async () => {
|
||||
await testInterestmap.addInterest(3);
|
||||
});
|
||||
|
||||
tap.test('should be able to inform about a lost interest', async () => {
|
||||
testInterestmap.informLostInterest(3);
|
||||
});
|
||||
|
||||
export default tap.start();
|
17
test/test.limitedarray.both.ts
Normal file
17
test/test.limitedarray.both.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
import { LimitedArray } from '../ts/index.js';
|
||||
|
||||
let testLimitedArray: LimitedArray<string>;
|
||||
|
||||
tap.test('should create a LimitedArray', async () => {
|
||||
testLimitedArray = new LimitedArray(6);
|
||||
expect(testLimitedArray).toBeInstanceOf(LimitedArray);
|
||||
});
|
||||
|
||||
tap.test('should never be longer than the set length', async () => {
|
||||
testLimitedArray.addMany(['hi', 'this', 'is', 'quite', 'a', 'long', 'string', ':)']);
|
||||
expect(testLimitedArray.array.length < 7).toBeTrue();
|
||||
});
|
||||
|
||||
export default tap.start();
|
24
test/test.looptracker.both.ts
Normal file
24
test/test.looptracker.both.ts
Normal file
@ -0,0 +1,24 @@
|
||||
// import test framework
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
// import the module
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
let object1 = {};
|
||||
let object2 = {};
|
||||
let myLoopTracker: lik.LoopTracker<any>;
|
||||
|
||||
// tests
|
||||
tap.test('should create a valid looptracker instance', async () => {
|
||||
myLoopTracker = new lik.LoopTracker();
|
||||
expect(myLoopTracker).toBeInstanceOf(lik.LoopTracker);
|
||||
});
|
||||
|
||||
tap.test('should add objects once and return true', async () => {
|
||||
expect(myLoopTracker.checkAndTrack(object1)).toBeTrue();
|
||||
expect(myLoopTracker.checkAndTrack(object1)).toBeFalse();
|
||||
expect(myLoopTracker.checkAndTrack(object2)).toBeTrue();
|
||||
expect(myLoopTracker.checkAndTrack(object2)).toBeFalse();
|
||||
});
|
||||
|
||||
export default tap.start();
|
76
test/test.objectmap.both.ts
Normal file
76
test/test.objectmap.both.ts
Normal file
@ -0,0 +1,76 @@
|
||||
// import test framework
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
// import the module
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
// Objectmap
|
||||
interface ITestObject {
|
||||
propOne: string;
|
||||
propTwo: string;
|
||||
}
|
||||
let testObjectmap: lik.ObjectMap<ITestObject>;
|
||||
let testObject1: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
let testObject2: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
|
||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||
testObjectmap = new lik.ObjectMap<ITestObject>();
|
||||
expect(testObjectmap).toBeInstanceOf(lik.ObjectMap);
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.add() -> should correctly add an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject1);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject2);
|
||||
testObjectmap.remove(testObject1);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).toBeFalse();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||
testObjectmap.forEach((itemArg) => {
|
||||
expect(itemArg).toHaveProperty('propOne');
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||
testObjectmap.add(myObject);
|
||||
let referenceObject = await testObjectmap.find(async (itemArg) => {
|
||||
return itemArg.propOne === 'helloThere';
|
||||
});
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(myObject === referenceObject).toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () => {
|
||||
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' };
|
||||
testObjectmap.add(myObject);
|
||||
let clonedArray = testObjectmap.getArray();
|
||||
expect(clonedArray[clonedArray.length - 1]).toEqual(myObject);
|
||||
});
|
||||
|
||||
tap.test('should get one object and then remove it', async () => {
|
||||
let originalLength = testObjectmap.getArray().length;
|
||||
let oneObject = testObjectmap.getOneAndRemove();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(oneObject).not.toBeNull();
|
||||
expect(testObjectmap.getArray().length).toEqual(originalLength - 1);
|
||||
expect(testObjectmap.getArray()).not.toContain(oneObject);
|
||||
});
|
||||
|
||||
export default tap.start();
|
86
test/test.stringmap.both.ts
Normal file
86
test/test.stringmap.both.ts
Normal file
@ -0,0 +1,86 @@
|
||||
// import test framework
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
// import the module
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
// testData
|
||||
let testStringmap: lik.Stringmap;
|
||||
let testString1 = 'testString1';
|
||||
let testString2 = 'testString2';
|
||||
let testString3 = 'testString3';
|
||||
let testString4 = 'testString4';
|
||||
let testString5 = 'testString5';
|
||||
let testString6 = 'testString6';
|
||||
|
||||
// tests
|
||||
tap.test('new lik.Objectmap() -> should create an instance of Stringmap', async () => {
|
||||
testStringmap = new lik.Stringmap();
|
||||
expect(testStringmap).toBeInstanceOf(lik.Stringmap);
|
||||
});
|
||||
|
||||
tap.test(
|
||||
'lik.Stringmap.checkString -> should return false for an string not in Stringmap',
|
||||
async () => {
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString1)).toBeFalse();
|
||||
}
|
||||
);
|
||||
|
||||
tap.test('lik.Stringmap.addString -> should add an string to Stringmap', async () => {
|
||||
testStringmap.addString(testString1);
|
||||
testStringmap.addString(testString2);
|
||||
testStringmap.addString(testString3);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString1)).toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString2)).toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString3)).toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String1')).toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String2')).toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String4')).toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('lik.Stringmap.addStringArray -> should add an array of strings', async () => {
|
||||
testStringmap.addStringArray([testString4, testString5, testString6]);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String4')).toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('lik.Stringmap.removeString -> should remove a string from Stringmap', async () => {
|
||||
testStringmap.removeString(testString2);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString2)).toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('lik.Stringmap.getStringArray() -> should return a copy of stringArray', async () => {
|
||||
let clonedArray = testStringmap.getStringArray();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(clonedArray[0] === 'testString1').toBeTrue();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(clonedArray[0] === testString1).toBeTrue();
|
||||
});
|
||||
|
||||
tap.test(
|
||||
'lik.Stringmap.checkIsEmpty() -> should register a function to trigger when empty',
|
||||
async () => {
|
||||
testStringmap.registerUntilTrue(
|
||||
() => {
|
||||
return testStringmap.checkIsEmpty();
|
||||
},
|
||||
() => {
|
||||
console.log('Stringmap now is empty');
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
tap.test('lik.Stringmap.empty() -> should remove wipe and then notify', async () => {
|
||||
testStringmap.wipe();
|
||||
});
|
||||
|
||||
export default tap.start();
|
23
test/test.timedaggregator.both.ts
Normal file
23
test/test.timedaggregator.both.ts
Normal file
@ -0,0 +1,23 @@
|
||||
// import test framework
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
// import the module
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
let testTimedAggregator: lik.TimedAggregtor<string>;
|
||||
|
||||
tap.test('should create a timed aggregaotor', async (tools) => {
|
||||
testTimedAggregator = new lik.TimedAggregtor<string>({
|
||||
aggregationIntervalInMillis: 1000,
|
||||
functionForAggregation: (aggregation) => {
|
||||
console.log(aggregation);
|
||||
},
|
||||
});
|
||||
testTimedAggregator.add('This');
|
||||
testTimedAggregator.add('is a whole sentence.');
|
||||
await tools.delayFor(1001);
|
||||
testTimedAggregator.add('This one is another.');
|
||||
await tools.delayFor(2000);
|
||||
});
|
||||
|
||||
export default tap.start();
|
40
test/test.tree.both.ts
Normal file
40
test/test.tree.both.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
class TestClass {
|
||||
constructor(public hey: string) {
|
||||
// nothing here
|
||||
}
|
||||
}
|
||||
|
||||
let testTree = new lik.Tree<TestClass>();
|
||||
|
||||
let testInstance = new TestClass('first');
|
||||
let testInstance2 = new TestClass('second');
|
||||
let testInstance3 = new TestClass('third');
|
||||
let testInstance4 = new TestClass('fourth');
|
||||
let testInstance5 = new TestClass('fifth');
|
||||
let testInstance6 = new TestClass('sixth');
|
||||
|
||||
tap.test('create a valid tree instance', async () => {
|
||||
testTree = new lik.Tree();
|
||||
expect(testTree).toBeInstanceOf(lik.Tree);
|
||||
});
|
||||
|
||||
tap.test('should insert an object', async () => {
|
||||
testTree.initialize(testInstance);
|
||||
let resultArray = testTree.treeToArray(testInstance, {});
|
||||
expect(resultArray).toContain(testInstance);
|
||||
});
|
||||
|
||||
tap.test('should add other objects in a hierachy', async () => {
|
||||
testTree.appendChild(testInstance, testInstance2);
|
||||
testTree.appendChild(testInstance, testInstance3);
|
||||
testTree.appendChild(testInstance, testInstance4);
|
||||
});
|
||||
|
||||
tap.test("should create a JSON object that reflects a tree's hierachy", async () => {
|
||||
const jsonTreet = testTree.toJsonWithHierachy(testInstance);
|
||||
});
|
||||
|
||||
export default tap.start();
|
151
test/test.ts
151
test/test.ts
@ -1,151 +0,0 @@
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as events from 'events'
|
||||
import * as rx from 'rxjs/Rx'
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
import lik = require('../dist/index')
|
||||
let testStringmap: lik.Stringmap
|
||||
let testString1 = 'testString1'
|
||||
let testString2 = 'testString2'
|
||||
let testString3 = 'testString3'
|
||||
let testString4 = 'testString4'
|
||||
let testString5 = 'testString5'
|
||||
let testString6 = 'testString6'
|
||||
tap.test('new lik.Objectmap() -> should create an instance of Stringmap', async () => {
|
||||
testStringmap = new lik.Stringmap()
|
||||
expect(testStringmap).be.instanceof(lik.Stringmap)
|
||||
})
|
||||
tap.test('lik.Stringmap.checkString -> should return false for an string not in Stringmap', async () => {
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString1)).be.false
|
||||
})
|
||||
tap.test('lik.Stringmap.addString -> should add an string to Stringmap', async () => {
|
||||
testStringmap.addString(testString1)
|
||||
testStringmap.addString(testString2)
|
||||
testStringmap.addString(testString3)
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString1)).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString2)).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString3)).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String1')).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String2')).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String4')).be.false
|
||||
})
|
||||
tap.test('lik.Stringmap.addStringArray -> should add an array of strings', async () => {
|
||||
testStringmap.addStringArray([ testString4, testString5, testString6 ])
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkMinimatch('*String4')).be.true
|
||||
})
|
||||
tap.test('lik.Stringmap.removeString -> should remove a string from Stringmap', async () => {
|
||||
testStringmap.removeString(testString2)
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testStringmap.checkString(testString2)).be.false
|
||||
})
|
||||
tap.test('lik.Stringmap.getStringArray() -> should return a copy of stringArray', async () => {
|
||||
let clonedArray = testStringmap.getStringArray()
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(clonedArray[ 0 ] === 'testString1').be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(clonedArray[ 0 ] === testString1).be.true
|
||||
})
|
||||
tap.test('lik.Stringmap.checkIsEmpty() -> should register a function to trigger when empty', async () => {
|
||||
testStringmap.registerUntilTrue(
|
||||
() => { return testStringmap.checkIsEmpty() },
|
||||
() => { console.log('Stringmap now is empty') }
|
||||
)
|
||||
})
|
||||
tap.test('lik.Stringmap.empty() -> should remove wipe and then notify', async () => {
|
||||
testStringmap.wipe()
|
||||
})
|
||||
|
||||
// Objectmap
|
||||
interface ITestObject {
|
||||
propOne: string
|
||||
propTwo: string
|
||||
}
|
||||
let testObjectmap: lik.Objectmap<ITestObject>
|
||||
let testObject1: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2'
|
||||
}
|
||||
let testObject2: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2'
|
||||
}
|
||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||
testObjectmap = new lik.Objectmap<ITestObject>()
|
||||
expect(testObjectmap).be.instanceof(lik.Objectmap)
|
||||
})
|
||||
tap.test('lik.Objectmap.add() -> should correctly add an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject1)
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).be.false
|
||||
})
|
||||
tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject2)
|
||||
testObjectmap.remove(testObject1)
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).be.false
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).be.true
|
||||
})
|
||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||
testObjectmap.forEach(itemArg => {
|
||||
expect(itemArg).have.ownProperty('propOne')
|
||||
})
|
||||
})
|
||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' }
|
||||
testObjectmap.add(myObject)
|
||||
let referenceObject = testObjectmap.find((itemArg) => { return (itemArg.propOne === 'helloThere') })
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(myObject === referenceObject).be.true
|
||||
})
|
||||
tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () => {
|
||||
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' }
|
||||
testObjectmap.add(myObject)
|
||||
let clonedArray = testObjectmap.getArray()
|
||||
expect(clonedArray[ clonedArray.length - 1 ]).eql(myObject)
|
||||
})
|
||||
tap.test('should get one object and then remove it', async () => {
|
||||
let originalLength = testObjectmap.getArray().length
|
||||
let oneObject = testObjectmap.getOneAndRemove()
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(oneObject).not.be.null
|
||||
expect(testObjectmap.getArray().length).equal(originalLength - 1)
|
||||
expect(testObjectmap.getArray()).to.not.contain(oneObject)
|
||||
})
|
||||
let testObservablemap: lik.Observablemap
|
||||
let testObservable1: rx.Observable<any>
|
||||
let testObservable2: rx.Observable<any>
|
||||
let testObservable3: rx.Observable<any>
|
||||
let testEmitter: events.EventEmitter
|
||||
tap.test('should create an instance', async () => {
|
||||
testObservablemap = new lik.Observablemap()
|
||||
expect(testObservablemap).be.instanceof(lik.Observablemap)
|
||||
})
|
||||
tap.test('should accept a new emitter', async () => {
|
||||
let done = smartq.defer()
|
||||
testEmitter = new events.EventEmitter()
|
||||
testObservable1 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1')
|
||||
testObservable1.subscribe(x => {
|
||||
done.resolve()
|
||||
})
|
||||
testObservable2 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1')
|
||||
testObservable3 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event2')
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObservable1 === testObservable2).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObservable1 === testObservable3).be.false
|
||||
testEmitter.emit('event1')
|
||||
await done.promise
|
||||
})
|
||||
|
||||
tap.start()
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/lik',
|
||||
version: '6.1.0',
|
||||
description: 'Provides a collection of lightweight helpers and utilities for Node.js projects.'
|
||||
}
|
110
ts/classes.asyncexecutionstack.ts
Normal file
110
ts/classes.asyncexecutionstack.ts
Normal file
@ -0,0 +1,110 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
interface IExecutionSlot<T> {
|
||||
executionDeferred: plugins.smartpromise.Deferred<T>;
|
||||
funcToExecute: () => Promise<T>;
|
||||
timeout?: number;
|
||||
mode: 'exclusive' | 'nonexclusive';
|
||||
}
|
||||
|
||||
export class AsyncExecutionStack {
|
||||
private executionSlots: IExecutionSlot<any>[] = [];
|
||||
private isProcessing = false;
|
||||
|
||||
public async getExclusiveExecutionSlot<T = any>(
|
||||
funcArg: () => Promise<T>,
|
||||
timeoutArg?: number
|
||||
): Promise<T> {
|
||||
const executionDeferred = plugins.smartpromise.defer<T>();
|
||||
const executionSlot: IExecutionSlot<T> = {
|
||||
funcToExecute: funcArg,
|
||||
executionDeferred,
|
||||
timeout: timeoutArg,
|
||||
mode: 'exclusive',
|
||||
};
|
||||
this.executionSlots.push(executionSlot);
|
||||
this.processExecutionSlots();
|
||||
return executionDeferred.promise;
|
||||
}
|
||||
|
||||
public async getNonExclusiveExecutionSlot<T = any>(
|
||||
funcArg: () => Promise<T>,
|
||||
timeoutArg?: number
|
||||
): Promise<T> {
|
||||
const executionDeferred = plugins.smartpromise.defer<T>();
|
||||
const executionSlot: IExecutionSlot<T> = {
|
||||
funcToExecute: funcArg,
|
||||
executionDeferred,
|
||||
timeout: timeoutArg,
|
||||
mode: 'nonexclusive',
|
||||
};
|
||||
this.executionSlots.push(executionSlot);
|
||||
this.processExecutionSlots();
|
||||
return executionDeferred.promise;
|
||||
}
|
||||
|
||||
private async processExecutionSlots() {
|
||||
if (this.isProcessing) {
|
||||
return;
|
||||
}
|
||||
this.isProcessing = true;
|
||||
|
||||
while (this.executionSlots.length > 0) {
|
||||
const currentSlot = this.executionSlots[0];
|
||||
if (currentSlot.mode === 'exclusive') {
|
||||
await this.executeExclusiveSlot(currentSlot);
|
||||
this.executionSlots.shift();
|
||||
} else {
|
||||
// Gather all non-exclusive slots at the front of the queue
|
||||
const nonExclusiveSlots: IExecutionSlot<any>[] = [];
|
||||
while (this.executionSlots.length > 0 && this.executionSlots[0].mode === 'nonexclusive') {
|
||||
nonExclusiveSlots.push(this.executionSlots.shift()!);
|
||||
}
|
||||
await this.executeNonExclusiveSlots(nonExclusiveSlots);
|
||||
}
|
||||
}
|
||||
this.isProcessing = false;
|
||||
}
|
||||
|
||||
private async executeExclusiveSlot(slot: IExecutionSlot<any>) {
|
||||
try {
|
||||
if (slot.timeout) {
|
||||
const result = await Promise.race([
|
||||
slot.funcToExecute(),
|
||||
plugins.smartdelay.delayFor(slot.timeout).then(() => {
|
||||
throw new Error('Timeout reached');
|
||||
}),
|
||||
]);
|
||||
slot.executionDeferred.resolve(result);
|
||||
} else {
|
||||
const result = await slot.funcToExecute();
|
||||
slot.executionDeferred.resolve(result);
|
||||
}
|
||||
} catch (error) {
|
||||
slot.executionDeferred.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
private async executeNonExclusiveSlots(slots: IExecutionSlot<any>[]) {
|
||||
const promises = slots.map(async (slot) => {
|
||||
try {
|
||||
if (slot.timeout) {
|
||||
const result = await Promise.race([
|
||||
slot.funcToExecute(),
|
||||
plugins.smartdelay.delayFor(slot.timeout).then(() => {
|
||||
throw new Error('Timeout reached');
|
||||
}),
|
||||
]);
|
||||
slot.executionDeferred.resolve(result);
|
||||
} else {
|
||||
const result = await slot.funcToExecute();
|
||||
slot.executionDeferred.resolve(result);
|
||||
}
|
||||
} catch (error) {
|
||||
slot.executionDeferred.reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
}
|
66
ts/classes.backpressuredarray.ts
Normal file
66
ts/classes.backpressuredarray.ts
Normal file
@ -0,0 +1,66 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public checkHasItems(): boolean {
|
||||
return this.data.length > 0;
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
97
ts/classes.fastmap.ts
Normal file
97
ts/classes.fastmap.ts
Normal file
@ -0,0 +1,97 @@
|
||||
/* ============
|
||||
The FastMap has the goal of creating the fastes to use map possible in JS
|
||||
|
||||
============ */
|
||||
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
/**
|
||||
* fast map allows for very quick lookups of objects with a unique key
|
||||
*/
|
||||
export class FastMap<T> {
|
||||
private mapObject: { [key: string]: T } = {};
|
||||
|
||||
public isUniqueKey(keyArg: string): boolean {
|
||||
return this.mapObject[keyArg] ? false : true;
|
||||
}
|
||||
|
||||
public addToMap(
|
||||
keyArg: string,
|
||||
objectArg: T,
|
||||
optionsArg?: {
|
||||
force: boolean;
|
||||
}
|
||||
): boolean {
|
||||
if (this.isUniqueKey(keyArg) || (optionsArg && optionsArg.force)) {
|
||||
this.mapObject[keyArg] = objectArg;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public getByKey(keyArg: string) {
|
||||
return this.mapObject[keyArg];
|
||||
}
|
||||
|
||||
public removeFromMap(keyArg: string): T {
|
||||
const removedItem = this.getByKey(keyArg);
|
||||
delete this.mapObject[keyArg];
|
||||
return removedItem;
|
||||
}
|
||||
|
||||
public getKeys() {
|
||||
const keys: string[] = [];
|
||||
for (const keyArg in this.mapObject) {
|
||||
if (this.mapObject[keyArg]) {
|
||||
keys.push(keyArg);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
public clean() {
|
||||
this.mapObject = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a new Fastmap that includes all values from this and all from the fastmap in the argument
|
||||
*/
|
||||
public concat(fastMapArg: FastMap<T>) {
|
||||
const concatedFastmap = new FastMap<T>();
|
||||
for (const key of this.getKeys()) {
|
||||
concatedFastmap.addToMap(key, this.getByKey(key));
|
||||
}
|
||||
|
||||
for (const key of fastMapArg.getKeys()) {
|
||||
concatedFastmap.addToMap(key, fastMapArg.getByKey(key), {
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
|
||||
return concatedFastmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to merge another Fastmap
|
||||
* Note: uniqueKeyCollisions will cause overwrite
|
||||
* @param fastMapArg
|
||||
*/
|
||||
public addAllFromOther(fastMapArg: FastMap<T>) {
|
||||
for (const key of fastMapArg.getKeys()) {
|
||||
this.addToMap(key, fastMapArg.getByKey(key), {
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async find(findFunctionArg: (mapItemArg: T) => Promise<boolean>) {
|
||||
for (const key of this.getKeys()) {
|
||||
const item = this.getByKey(key);
|
||||
const findFunctionResult = await findFunctionArg(item);
|
||||
if (findFunctionResult) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
93
ts/classes.interestmap.interest.ts
Normal file
93
ts/classes.interestmap.interest.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
import { InterestMap, type IInterestComparisonFunc } from './classes.interestmap.js';
|
||||
|
||||
export interface IInterestOptions<DTInterestFullfillment> {
|
||||
markLostAfterDefault: number;
|
||||
defaultFullfillment?: DTInterestFullfillment;
|
||||
}
|
||||
|
||||
export class Interest<DTInterestId, DTInterestFullfillment> {
|
||||
public options: IInterestOptions<DTInterestFullfillment>;
|
||||
|
||||
private interestMapRef: InterestMap<DTInterestId, DTInterestFullfillment>;
|
||||
public originalInterest: DTInterestId;
|
||||
public comparisonFunc: IInterestComparisonFunc<DTInterestId>;
|
||||
public destructionTimer = new plugins.smarttime.Timer(10000);
|
||||
public isFullfilled = false;
|
||||
|
||||
/**
|
||||
* a generic store to store objects in that are needed for fullfillment;
|
||||
*/
|
||||
public fullfillmentStore: any[] = [];
|
||||
|
||||
/**
|
||||
* quick access to a string that makes the interest comparable for checking for similar interests
|
||||
*/
|
||||
public get comparisonString() {
|
||||
return this.comparisonFunc(this.originalInterest);
|
||||
}
|
||||
|
||||
private interestDeferred: plugins.smartpromise.Deferred<DTInterestFullfillment> =
|
||||
new plugins.smartpromise.Deferred();
|
||||
public interestFullfilled = this.interestDeferred.promise;
|
||||
|
||||
/**
|
||||
* fullfill the interest
|
||||
*/
|
||||
public fullfillInterest(objectArg: DTInterestFullfillment) {
|
||||
this.isFullfilled = true;
|
||||
this.fullfillmentStore = [];
|
||||
this.interestDeferred.resolve(objectArg);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
constructor(
|
||||
interestMapArg: InterestMap<DTInterestId, DTInterestFullfillment>,
|
||||
interestArg: DTInterestId,
|
||||
comparisonFuncArg: IInterestComparisonFunc<DTInterestId>,
|
||||
optionsArg?: IInterestOptions<DTInterestFullfillment>
|
||||
) {
|
||||
this.interestMapRef = interestMapArg;
|
||||
this.originalInterest = interestArg;
|
||||
this.comparisonFunc = comparisonFuncArg;
|
||||
this.options = optionsArg;
|
||||
|
||||
this.destructionTimer.completed.then(() => {
|
||||
this.destroy();
|
||||
});
|
||||
if (this.options?.markLostAfterDefault) {
|
||||
plugins.smartdelay.delayFor(this.options.markLostAfterDefault).then(this.markLost);
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================
|
||||
// LIFECYCLE MANAGEMENT
|
||||
// ===============================
|
||||
|
||||
/**
|
||||
* self destructs the interest
|
||||
*/
|
||||
public destroy() {
|
||||
this.interestMapRef.removeInterest(this);
|
||||
if (!this.isFullfilled && this.options.defaultFullfillment) {
|
||||
this.fullfillInterest(this.options.defaultFullfillment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* notifies the interest that the interest in it has been lost
|
||||
*/
|
||||
public markLost() {
|
||||
this.destructionTimer.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* notifies the interest that the interest in it has been restored
|
||||
*/
|
||||
public renew() {
|
||||
this.destructionTimer.reset();
|
||||
}
|
||||
}
|
134
ts/classes.interestmap.ts
Normal file
134
ts/classes.interestmap.ts
Normal file
@ -0,0 +1,134 @@
|
||||
/* ===========
|
||||
The InterestMap is an mechanism that collects interests into something
|
||||
An interest is expressed by an object, string or number.
|
||||
A comparison func can be specified to make interests comparable
|
||||
|
||||
For every unique interestId an interest is created.
|
||||
Subssequent interests will be mapped to the same interest
|
||||
which is then is only fullfilled once.
|
||||
=========== */
|
||||
|
||||
import * as plugins from './classes.plugins.js';
|
||||
import { ObjectMap } from './classes.objectmap.js';
|
||||
import { Interest } from './classes.interestmap.interest.js';
|
||||
|
||||
export type IInterestComparisonFunc<T> = (objectArg: T) => string;
|
||||
|
||||
export interface IInterestMapOptions {
|
||||
markLostAfterDefault?: number;
|
||||
}
|
||||
|
||||
export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||
public options: IInterestMapOptions;
|
||||
|
||||
/**
|
||||
* stores interests that are currently fullfilled by the cache
|
||||
*/
|
||||
private interestObjectMap = new ObjectMap<Interest<DTInterestId, DTInterestFullfillment>>();
|
||||
|
||||
/**
|
||||
* a function to compare interests
|
||||
*/
|
||||
private comparisonFunc: IInterestComparisonFunc<DTInterestId>;
|
||||
|
||||
constructor(
|
||||
comparisonFuncArg: IInterestComparisonFunc<DTInterestId>,
|
||||
optionsArg: IInterestMapOptions = {}
|
||||
) {
|
||||
this.comparisonFunc = comparisonFuncArg;
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds an interest to the InterestMap
|
||||
* @param interestId
|
||||
*/
|
||||
public async addInterest(
|
||||
interestId: DTInterestId,
|
||||
defaultFullfillmentArg?: DTInterestFullfillment
|
||||
): Promise<Interest<DTInterestId, DTInterestFullfillment>> {
|
||||
const comparisonString = this.comparisonFunc(interestId);
|
||||
let returnInterest: Interest<DTInterestId, DTInterestFullfillment>;
|
||||
const newInterest = new Interest<DTInterestId, DTInterestFullfillment>(
|
||||
this,
|
||||
interestId,
|
||||
this.comparisonFunc,
|
||||
{
|
||||
markLostAfterDefault: this.options.markLostAfterDefault,
|
||||
defaultFullfillment: defaultFullfillmentArg,
|
||||
}
|
||||
);
|
||||
let interestExists = false;
|
||||
await this.interestObjectMap.forEach((interestArg) => {
|
||||
if (!interestExists && interestArg.comparisonString === newInterest.comparisonString) {
|
||||
console.log('info', `interest already exists for ${newInterest.comparisonString}`);
|
||||
interestExists = true;
|
||||
returnInterest = interestArg;
|
||||
returnInterest.renew();
|
||||
}
|
||||
});
|
||||
if (!returnInterest) {
|
||||
returnInterest = newInterest;
|
||||
this.interestObjectMap.add(returnInterest);
|
||||
}
|
||||
this.interestObservable.push(returnInterest);
|
||||
return returnInterest;
|
||||
}
|
||||
|
||||
public interestObservable = new plugins.smartrx.ObservableIntake<Interest<DTInterestId, any>>();
|
||||
|
||||
/**
|
||||
* removes an interest from the interest map
|
||||
*/
|
||||
public removeInterest(interestArg: Interest<DTInterestId, DTInterestFullfillment>) {
|
||||
const interestToRemove = this.interestObjectMap.findOneAndRemoveSync((interestArg2) => {
|
||||
return interestArg.comparisonString === interestArg2.comparisonString;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* check interest
|
||||
*/
|
||||
public checkInterest(objectArg: DTInterestId): boolean {
|
||||
const comparisonString = this.comparisonFunc(objectArg);
|
||||
return this.checkInterestByString(comparisonString);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks an interest
|
||||
* @param comparisonStringArg
|
||||
*/
|
||||
public checkInterestByString(comparisonStringArg: string): boolean {
|
||||
const foundInterest = this.interestObjectMap.findSync((interest) => {
|
||||
return interest.comparisonString === comparisonStringArg;
|
||||
});
|
||||
if (foundInterest) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* inform lost interest
|
||||
* @param interestId
|
||||
*/
|
||||
public informLostInterest(interestId: DTInterestId) {
|
||||
const wantedInterest = this.findInterest(interestId);
|
||||
if (wantedInterest) {
|
||||
wantedInterest.markLost();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* finds an interest
|
||||
* @param interestId
|
||||
*/
|
||||
public findInterest(interestId: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> {
|
||||
const comparableString = this.comparisonFunc(interestId);
|
||||
const interest = this.interestObjectMap.findSync((interestArg) => {
|
||||
return interestArg.comparisonString === comparableString;
|
||||
});
|
||||
return interest; // if an interest is found, the interest is returned, otherwise interest is null
|
||||
}
|
||||
}
|
42
ts/classes.limitedarray.ts
Normal file
42
ts/classes.limitedarray.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
export class LimitedArray<T> {
|
||||
array: T[] = [];
|
||||
arrayLimit: number;
|
||||
constructor(limitArg: number) {
|
||||
this.arrayLimit = limitArg;
|
||||
}
|
||||
|
||||
addOne(objectArg: T) {
|
||||
this.array.unshift(objectArg);
|
||||
if (this.array.length > this.arrayLimit) {
|
||||
this.array.length = this.arrayLimit;
|
||||
}
|
||||
}
|
||||
|
||||
addMany(objectArrayArg: T[]) {
|
||||
for (let objectArg of objectArrayArg) {
|
||||
this.addOne(objectArg);
|
||||
}
|
||||
}
|
||||
|
||||
setLimit(limitArg: number) {
|
||||
this.arrayLimit = limitArg;
|
||||
if (this.array.length > this.arrayLimit) {
|
||||
this.array.length = this.arrayLimit;
|
||||
}
|
||||
}
|
||||
|
||||
getAverage(): number {
|
||||
if (typeof this.array[0] === 'number') {
|
||||
let sum = 0;
|
||||
for (let localNumber of this.array) {
|
||||
let localNumberAny: any = localNumber;
|
||||
sum = sum + localNumberAny;
|
||||
}
|
||||
return sum / this.array.length;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
23
ts/classes.looptracker.ts
Normal file
23
ts/classes.looptracker.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
import { ObjectMap } from './classes.objectmap.js';
|
||||
|
||||
export class LoopTracker<T> {
|
||||
referenceObjectMap = new ObjectMap<any>();
|
||||
constructor() {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
/**
|
||||
* checks and tracks an object
|
||||
* @param objectArg
|
||||
*/
|
||||
checkAndTrack(objectArg: T): boolean {
|
||||
if (!this.referenceObjectMap.checkForObject(objectArg)) {
|
||||
this.referenceObjectMap.add(objectArg);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
246
ts/classes.objectmap.ts
Normal file
246
ts/classes.objectmap.ts
Normal file
@ -0,0 +1,246 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
import { FastMap } from './classes.fastmap.js';
|
||||
|
||||
export const uni = (prefix: string = 'uni') => {
|
||||
return `${prefix}xxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
|
||||
export interface IObjectmapForEachFunction<T> {
|
||||
(itemArg: T): void;
|
||||
}
|
||||
|
||||
export interface IObjectmapFindFunctionSync<T> {
|
||||
(itemArg: T): boolean;
|
||||
}
|
||||
|
||||
export interface IObjectmapFindFunction<T> {
|
||||
(itemArg: T): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface IObjectMapEventData<T> {
|
||||
operation: 'add' | 'remove';
|
||||
payload: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows keeping track of objects
|
||||
*/
|
||||
export class ObjectMap<T> {
|
||||
private fastMap = new FastMap<T>();
|
||||
|
||||
// events
|
||||
public eventSubject = new plugins.smartrx.rxjs.Subject<IObjectMapEventData<T>>();
|
||||
|
||||
/**
|
||||
* returns a new instance
|
||||
*/
|
||||
constructor() {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
/**
|
||||
* adds an object mapped to a string
|
||||
* the string must be unique
|
||||
*/
|
||||
addMappedUnique(uniqueKeyArg: string, objectArg: T) {
|
||||
this.fastMap.addToMap(uniqueKeyArg, objectArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* fastest way to get an object from the map
|
||||
* @param uniqueKey
|
||||
*/
|
||||
public getMappedUnique(uniqueKeyArg: string) {
|
||||
return this.fastMap.getByKey(uniqueKeyArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove key
|
||||
* @param functionArg
|
||||
*/
|
||||
public removeMappedUnique(uniqueKey: string) {
|
||||
const object = this.getMappedUnique(uniqueKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* add object to Objectmap
|
||||
* returns false if the object is already in the map
|
||||
* returns true if the object was added successfully
|
||||
*/
|
||||
public add(objectArg: T): string {
|
||||
// lets search for an existing unique key
|
||||
for (const keyArg of this.fastMap.getKeys()) {
|
||||
const object = this.fastMap.getByKey(keyArg);
|
||||
if (object === objectArg) {
|
||||
return keyArg;
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise lets create it
|
||||
const uniqueKey = uni('key');
|
||||
this.addMappedUnique(uniqueKey, objectArg);
|
||||
this.eventSubject.next({
|
||||
operation: 'add',
|
||||
payload: objectArg,
|
||||
});
|
||||
return uniqueKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* like .add but adds an whole array of objects
|
||||
*/
|
||||
public addArray(objectArrayArg: T[]) {
|
||||
for (const item of objectArrayArg) {
|
||||
this.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if object is in Objectmap
|
||||
*/
|
||||
public checkForObject(objectArg: T): boolean {
|
||||
return !!this.getKeyForObject(objectArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* get key for object
|
||||
* @param findFunction
|
||||
*/
|
||||
public getKeyForObject(objectArg: T) {
|
||||
let foundKey: string = null;
|
||||
for (const keyArg of this.fastMap.getKeys()) {
|
||||
if (!foundKey && this.fastMap.getByKey(keyArg) === objectArg) {
|
||||
foundKey = keyArg;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return foundKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* find object
|
||||
*/
|
||||
public async find(findFunction: IObjectmapFindFunction<T>): Promise<T> {
|
||||
return this.fastMap.find(findFunction);
|
||||
}
|
||||
|
||||
public findSync(findFunction: IObjectmapFindFunctionSync<T>): T {
|
||||
for (const keyArg of this.fastMap.getKeys()) {
|
||||
if (findFunction(this.fastMap.getByKey(keyArg))) {
|
||||
return this.getMappedUnique(keyArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* finds a specific element and then removes it
|
||||
*/
|
||||
public async findOneAndRemove(findFunction: IObjectmapFindFunction<T>): Promise<T> {
|
||||
const foundElement = await this.find(findFunction);
|
||||
if (foundElement) {
|
||||
this.remove(foundElement);
|
||||
}
|
||||
return foundElement;
|
||||
}
|
||||
public findOneAndRemoveSync(findFunction: IObjectmapFindFunctionSync<T>): T {
|
||||
const foundElement = this.findSync(findFunction);
|
||||
if (foundElement) {
|
||||
this.remove(foundElement);
|
||||
}
|
||||
return foundElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* run function for each item in Objectmap
|
||||
*/
|
||||
public async forEach(functionArg: IObjectmapForEachFunction<T>) {
|
||||
for (const keyArg of this.fastMap.getKeys()) {
|
||||
await functionArg(this.fastMap.getByKey(keyArg));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||
*/
|
||||
public getOneAndRemove(): T {
|
||||
const keys = this.fastMap.getKeys();
|
||||
if (keys.length === 0) {
|
||||
return null;
|
||||
} else {
|
||||
const keyToUse = keys[0];
|
||||
const removedItem = this.fastMap.removeFromMap(keyToUse);
|
||||
this.eventSubject.next({
|
||||
operation: 'remove',
|
||||
payload: removedItem,
|
||||
});
|
||||
return removedItem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a cloned array of all the objects currently in the Objectmap
|
||||
*/
|
||||
public getArray(): T[] {
|
||||
const returnArray: any[] = [];
|
||||
for (const keyArg of this.fastMap.getKeys()) {
|
||||
returnArray.push(this.fastMap.getByKey(keyArg));
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if Objectmap ist empty
|
||||
*/
|
||||
public isEmpty(): boolean {
|
||||
return this.fastMap.getKeys().length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove object from Objectmap
|
||||
*/
|
||||
public remove(objectArg: T): T {
|
||||
if (this.checkForObject(objectArg)) {
|
||||
const keyArg = this.getKeyForObject(objectArg);
|
||||
const removedObject = this.fastMap.removeFromMap(keyArg);
|
||||
this.eventSubject.next({
|
||||
operation: 'remove',
|
||||
payload: removedObject,
|
||||
});
|
||||
return removedObject;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* wipe Objectmap
|
||||
*/
|
||||
public wipe() {
|
||||
for (const keyArg of this.fastMap.getKeys()) {
|
||||
this.fastMap.removeFromMap(keyArg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a new Objectmap that includes
|
||||
*/
|
||||
public concat(objectMapArg: ObjectMap<T>) {
|
||||
const concattedObjectMap = new ObjectMap<T>();
|
||||
concattedObjectMap.fastMap.addAllFromOther(this.fastMap);
|
||||
concattedObjectMap.fastMap.addAllFromOther(objectMapArg.fastMap);
|
||||
return concattedObjectMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to merge another Objectmap
|
||||
* Note: uniqueKeyCollisions will cause overwrite
|
||||
* @param objectMapArg
|
||||
*/
|
||||
public addAllFromOther(objectMapArg: ObjectMap<T>) {
|
||||
this.fastMap.addAllFromOther(objectMapArg.fastMap);
|
||||
}
|
||||
}
|
17
ts/classes.plugins.ts
Normal file
17
ts/classes.plugins.ts
Normal file
@ -0,0 +1,17 @@
|
||||
// ==============
|
||||
// @pushrocks
|
||||
// ==============
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartmatch from '@push.rocks/smartmatch';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartrx from '@push.rocks/smartrx';
|
||||
import * as smarttime from '@push.rocks/smarttime';
|
||||
|
||||
export { smartdelay, smartmatch, smartpromise, smartrx, smarttime };
|
||||
|
||||
// ==============
|
||||
// third party
|
||||
// ==============
|
||||
import symbolTree from 'symbol-tree';
|
||||
|
||||
export { symbolTree };
|
119
ts/classes.stringmap.ts
Normal file
119
ts/classes.stringmap.ts
Normal file
@ -0,0 +1,119 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
/**
|
||||
* allows you to easily keep track of a bunch of strings
|
||||
*/
|
||||
|
||||
export type TTriggerFunction = (stringArray?: string[]) => boolean;
|
||||
|
||||
export class Stringmap {
|
||||
private _stringArray: string[] = [];
|
||||
private _triggerUntilTrueFunctionArray: TTriggerFunction[] = [];
|
||||
constructor() {}
|
||||
/**
|
||||
* add a string to the Stringmap
|
||||
*/
|
||||
addString(stringArg: string) {
|
||||
this._stringArray.push(stringArg);
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* like addString, but accepts an array of strings
|
||||
*/
|
||||
addStringArray(stringArrayArg: string[]) {
|
||||
for (const stringItem of stringArrayArg) {
|
||||
this.addString(stringItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a string from Stringmap
|
||||
*/
|
||||
removeString(stringArg: string) {
|
||||
for (const keyArg in this._stringArray) {
|
||||
if (this._stringArray[keyArg] === stringArg) {
|
||||
this._stringArray.splice(parseInt(keyArg), 1);
|
||||
}
|
||||
}
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* wipes the Stringmap
|
||||
*/
|
||||
wipe() {
|
||||
this._stringArray = [];
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* check if string is in Stringmap
|
||||
*/
|
||||
public checkString(stringArg: string): boolean {
|
||||
return this._stringArray.indexOf(stringArg) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks stringPresence with minimatch
|
||||
*/
|
||||
public checkMinimatch(miniMatchStringArg: string): boolean {
|
||||
const smartMatchInstance = new plugins.smartmatch.SmartMatch(miniMatchStringArg);
|
||||
let foundMatch: boolean = false;
|
||||
for (const stringItem of this._stringArray) {
|
||||
if (smartMatchInstance.match(stringItem)) {
|
||||
foundMatch = true;
|
||||
}
|
||||
}
|
||||
return foundMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Stringmap is empty
|
||||
*/
|
||||
public checkIsEmpty() {
|
||||
return this._stringArray.length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a cloned copy of the current string Array
|
||||
*/
|
||||
public getStringArray() {
|
||||
const returnArray: string[] = [];
|
||||
for (const stringItem of this._stringArray) {
|
||||
returnArray.push(stringItem);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
// trigger registering
|
||||
|
||||
/**
|
||||
* register a new trigger
|
||||
*/
|
||||
public registerUntilTrue(functionArg: TTriggerFunction, callbackArg?: () => any) {
|
||||
const trueDeferred = plugins.smartpromise.defer();
|
||||
this._triggerUntilTrueFunctionArray.push(() => {
|
||||
const result = functionArg(this.getStringArray());
|
||||
if (result === true) {
|
||||
if (callbackArg) {
|
||||
callbackArg();
|
||||
}
|
||||
trueDeferred.resolve();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
this.notifyTrigger();
|
||||
return trueDeferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* notifies triggers
|
||||
*/
|
||||
private notifyTrigger() {
|
||||
const filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||
return !functionArg();
|
||||
});
|
||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||
}
|
||||
}
|
41
ts/classes.timedaggregator.ts
Normal file
41
ts/classes.timedaggregator.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
export interface ITimedAggregatorOptions<T> {
|
||||
aggregationIntervalInMillis: number;
|
||||
functionForAggregation: (input: T[]) => void;
|
||||
}
|
||||
|
||||
export class TimedAggregtor<T> {
|
||||
public options: ITimedAggregatorOptions<T>;
|
||||
private storageArray: T[] = [];
|
||||
|
||||
constructor(optionsArg: ITimedAggregatorOptions<T>) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
private aggregationTimer: plugins.smarttime.Timer;
|
||||
private checkAggregationStatus() {
|
||||
const addAggregationTimer = () => {
|
||||
this.aggregationTimer = new plugins.smarttime.Timer(this.options.aggregationIntervalInMillis);
|
||||
this.aggregationTimer.completed.then(() => {
|
||||
const aggregateForProcessing = this.storageArray;
|
||||
if (aggregateForProcessing.length === 0) {
|
||||
this.aggregationTimer = null;
|
||||
return;
|
||||
}
|
||||
this.storageArray = [];
|
||||
addAggregationTimer();
|
||||
this.options.functionForAggregation(aggregateForProcessing);
|
||||
});
|
||||
this.aggregationTimer.start();
|
||||
};
|
||||
if (!this.aggregationTimer) {
|
||||
addAggregationTimer();
|
||||
}
|
||||
}
|
||||
|
||||
public add(aggregationArg: T) {
|
||||
this.storageArray.push(aggregationArg);
|
||||
this.checkAggregationStatus();
|
||||
}
|
||||
}
|
141
ts/classes.tree.ts
Normal file
141
ts/classes.tree.ts
Normal file
@ -0,0 +1,141 @@
|
||||
import * as plugins from './classes.plugins.js';
|
||||
|
||||
export class Tree<T> {
|
||||
symbolTree: any;
|
||||
constructor() {
|
||||
this.symbolTree = new plugins.symbolTree();
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// Functions that map to the functionality of symbol-tree
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
*
|
||||
* @param objectArg
|
||||
*/
|
||||
initialize(objectArg: T): T {
|
||||
return this.symbolTree.initialize(objectArg);
|
||||
}
|
||||
|
||||
hasChildren(objectArg: T): boolean {
|
||||
return this.symbolTree.hasChildren(objectArg);
|
||||
}
|
||||
|
||||
firstChild(objectArg: T): T {
|
||||
return this.symbolTree.firstChild(objectArg);
|
||||
}
|
||||
|
||||
lastChild(objectArg: T): T {
|
||||
return this.symbolTree.lastChild(objectArg);
|
||||
}
|
||||
|
||||
previousSibling(objectArg: T): T {
|
||||
return this.symbolTree.previousSibling(objectArg);
|
||||
}
|
||||
|
||||
nextSibling(objectArg: T): T {
|
||||
return this.symbolTree.nextSibling(objectArg);
|
||||
}
|
||||
|
||||
parent(objectArg: T): T {
|
||||
return this.symbolTree.parent(objectArg);
|
||||
}
|
||||
|
||||
lastInclusiveDescendant(objectArg: T): T {
|
||||
return this.symbolTree.lastInclusiveDescendant(objectArg);
|
||||
}
|
||||
|
||||
preceding(objectArg: T, optionsArg?: any): T {
|
||||
return this.symbolTree.preceding(objectArg, optionsArg);
|
||||
}
|
||||
|
||||
following(object: T, optionsArg: any) {
|
||||
return this.symbolTree.following(object, optionsArg);
|
||||
}
|
||||
|
||||
childrenToArray(parentArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.childrenToArray(parentArg, optionsArg);
|
||||
}
|
||||
|
||||
ancestorsToArray(objectArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.ancestorsToArray(objectArg, optionsArg);
|
||||
}
|
||||
|
||||
treeToArray(rootArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.treeToArray(rootArg, optionsArg);
|
||||
}
|
||||
|
||||
childrenIterator(parentArg: T, optionsArg: any): T {
|
||||
return this.symbolTree.childrenIterator(parentArg, optionsArg);
|
||||
}
|
||||
|
||||
previousSiblingsIterator(objectArg: T): T {
|
||||
return this.symbolTree.previousSiblingsIterator(objectArg);
|
||||
}
|
||||
|
||||
nextSiblingsIterator(objectArg: T) {
|
||||
return this.symbolTree.nextSiblingsIterator();
|
||||
}
|
||||
|
||||
ancestorsIterator(objectArg: T) {
|
||||
this.symbolTree.ancestorsIterator();
|
||||
}
|
||||
|
||||
treeIterator(rootArg: T, optionsArg: any): Iterable<T> {
|
||||
return this.symbolTree.treeIterator(rootArg);
|
||||
}
|
||||
|
||||
index(childArg: T): number {
|
||||
return this.symbolTree.index(childArg);
|
||||
}
|
||||
|
||||
childrenCount(parentArg: T): number {
|
||||
return this.symbolTree.childrenCount(parentArg);
|
||||
}
|
||||
|
||||
compareTreePosition(leftArg: T, rightArg: T): number {
|
||||
return this.compareTreePosition(leftArg, rightArg);
|
||||
}
|
||||
|
||||
remove(removeObjectArg: T): T {
|
||||
return this.symbolTree.remove(removeObjectArg);
|
||||
}
|
||||
|
||||
insertBefore(referenceObjectArg: T, newObjectArg: T): T {
|
||||
return this.symbolTree.insertBefore(referenceObjectArg, newObjectArg);
|
||||
}
|
||||
|
||||
insertAfter(referenceObject: T, newObjectArg: T) {
|
||||
return this.symbolTree.insertAfter(referenceObject, newObjectArg);
|
||||
}
|
||||
|
||||
prependChild(referenceObjectArg: T, newObjectArg: T): T {
|
||||
return this.symbolTree.prependChild(referenceObjectArg, newObjectArg);
|
||||
}
|
||||
|
||||
appendChild(referenceObjectArg: T, newObjectArg: T) {
|
||||
return this.symbolTree.appendChild(referenceObjectArg, newObjectArg);
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// Functionionality that extends symbol-tree
|
||||
// ===========================================
|
||||
|
||||
/**
|
||||
* returns a branch of the tree as JSON
|
||||
* can be user
|
||||
*/
|
||||
toJsonWithHierachy(rootElement: T) {
|
||||
const treeIterable = this.treeIterator(rootElement, {});
|
||||
for (const treeItem of treeIterable) {
|
||||
console.log(treeItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a tree from a JSON with hierachy
|
||||
* @param rootElement
|
||||
*/
|
||||
fromJsonWithHierachy(rootElement: T) {}
|
||||
}
|
18
ts/index.ts
18
ts/index.ts
@ -1,7 +1,11 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
|
||||
// import modules
|
||||
|
||||
export * from './lik.stringmap'
|
||||
export * from './lik.objectmap'
|
||||
export * from './lik.observablemap'
|
||||
export * from './classes.asyncexecutionstack.js';
|
||||
export * from './classes.backpressuredarray.js';
|
||||
export * from './classes.fastmap.js';
|
||||
export * from './classes.interestmap.js';
|
||||
export * from './classes.interestmap.interest.js';
|
||||
export * from './classes.limitedarray.js';
|
||||
export * from './classes.looptracker.js';
|
||||
export * from './classes.objectmap.js';
|
||||
export * from './classes.stringmap.js';
|
||||
export * from './classes.timedaggregator.js';
|
||||
export * from './classes.tree.js';
|
||||
|
@ -1,121 +0,0 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
|
||||
export interface IObjectmapForEachFunction<T> {
|
||||
(itemArg: T): void
|
||||
}
|
||||
|
||||
export interface IObjectmapFindFunction<T> {
|
||||
(itemArg: T): boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* allows keeping track of objects
|
||||
*/
|
||||
export class Objectmap<T> {
|
||||
private objectArray: T[] = []
|
||||
|
||||
/**
|
||||
* returns a new instance
|
||||
*/
|
||||
constructor () {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
/**
|
||||
* add object to Objectmap
|
||||
*/
|
||||
add (objectArg: T) {
|
||||
this.objectArray.push(objectArg)
|
||||
}
|
||||
|
||||
/**
|
||||
* like .add but adds an whole array of objects
|
||||
*/
|
||||
addArray (objectArrayArg: T[]) {
|
||||
for (let item of objectArrayArg) {
|
||||
this.add(item)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if object is in Objectmap
|
||||
*/
|
||||
checkForObject (objectArg: T) {
|
||||
return this.objectArray.indexOf(objectArg) !== -1
|
||||
}
|
||||
|
||||
/**
|
||||
* find object
|
||||
*/
|
||||
find (findFunction: IObjectmapFindFunction<T>) {
|
||||
let resultArray = this.objectArray.filter(findFunction)
|
||||
if (resultArray.length > 0) {
|
||||
return resultArray[ 0 ]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* finds a specific element and then removes it
|
||||
*/
|
||||
findOneAndRemove (findFunction: IObjectmapFindFunction<T>): T {
|
||||
let foundElement = this.find(findFunction)
|
||||
if (foundElement) {
|
||||
this.remove(foundElement)
|
||||
}
|
||||
return foundElement
|
||||
}
|
||||
|
||||
/**
|
||||
* run function for each item in Objectmap
|
||||
*/
|
||||
forEach (functionArg: IObjectmapForEachFunction<T>) {
|
||||
return this.objectArray.forEach(functionArg)
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||
*/
|
||||
getOneAndRemove (): T {
|
||||
return this.objectArray.shift()
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a cloned array of all the objects currently in the Objectmap
|
||||
*/
|
||||
getArray () {
|
||||
return plugins.lodash.cloneDeep(this.objectArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* check if Objectmap ist empty
|
||||
*/
|
||||
isEmpty (): boolean {
|
||||
if (this.objectArray.length === 0) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove object from Objectmap
|
||||
*/
|
||||
remove (objectArg: T) {
|
||||
let replacementArray = []
|
||||
for (let item of this.objectArray) {
|
||||
if (item !== objectArg) {
|
||||
replacementArray.push(item)
|
||||
}
|
||||
}
|
||||
this.objectArray = replacementArray
|
||||
}
|
||||
|
||||
/**
|
||||
* wipe Objectmap
|
||||
*/
|
||||
wipe () {
|
||||
this.objectArray = []
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import { Objectmap } from './lik.objectmap'
|
||||
import { Stringmap } from './lik.stringmap'
|
||||
import { Observable } from 'rxjs/Rx'
|
||||
|
||||
/**
|
||||
* bundles an observable with an emitter
|
||||
*/
|
||||
export interface ObservableEmitterBundle {
|
||||
observable: plugins.rx.Observable<any>
|
||||
emitter: plugins.events.EventEmitter
|
||||
event: string
|
||||
}
|
||||
|
||||
/**
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
export class Observablemap {
|
||||
ObservableEmitterBundleObjectmap = new Objectmap<ObservableEmitterBundle>()
|
||||
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
getObservableForEmitterEvent (emitterArg: plugins.events.EventEmitter, eventArg: string) {
|
||||
let existingBundle = this.ObservableEmitterBundleObjectmap.find((bundleArg) => {
|
||||
return (bundleArg.emitter === emitterArg && bundleArg.event === eventArg)
|
||||
})
|
||||
if (existingBundle) {
|
||||
return existingBundle.observable
|
||||
} else {
|
||||
let emitterObservable = plugins.rx.Observable.fromEvent(emitterArg, eventArg)
|
||||
this.ObservableEmitterBundleObjectmap.add({
|
||||
observable: emitterObservable,
|
||||
emitter: emitterArg,
|
||||
event: eventArg
|
||||
})
|
||||
return emitterObservable
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
import 'typings-global'
|
||||
export import q = require('q')
|
||||
export import events = require('events')
|
||||
export import lodash = require('lodash')
|
||||
export import minimatch = require('minimatch')
|
||||
export import rx = require('rxjs/Rx')
|
@ -1,114 +0,0 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
|
||||
/**
|
||||
* allows you to easily keep track of a bunch of strings
|
||||
*/
|
||||
|
||||
export interface ITriggerFunction {
|
||||
(): boolean
|
||||
}
|
||||
|
||||
export class Stringmap {
|
||||
private _stringArray: string[] = []
|
||||
private _triggerUntilTrueFunctionArray: ITriggerFunction[] = []
|
||||
constructor() {}
|
||||
/**
|
||||
* add a string to the Stringmap
|
||||
*/
|
||||
addString(stringArg: string) {
|
||||
this._stringArray.push(stringArg)
|
||||
this.notifyTrigger()
|
||||
}
|
||||
|
||||
/**
|
||||
* like addString, but accepts an array of strings
|
||||
*/
|
||||
addStringArray(stringArrayArg: string[]) {
|
||||
for (let stringItem of stringArrayArg){
|
||||
this.addString(stringItem)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a string from Stringmap
|
||||
*/
|
||||
removeString(stringArg: string) {
|
||||
for (let keyArg in this._stringArray) {
|
||||
if (this._stringArray[keyArg] === stringArg) {
|
||||
this._stringArray.splice(parseInt(keyArg),1)
|
||||
}
|
||||
}
|
||||
this.notifyTrigger()
|
||||
}
|
||||
|
||||
/**
|
||||
* wipes the Stringmap
|
||||
*/
|
||||
wipe() {
|
||||
this._stringArray = []
|
||||
this.notifyTrigger()
|
||||
}
|
||||
|
||||
/**
|
||||
* check if string is in Stringmap
|
||||
*/
|
||||
checkString(stringArg: string): boolean {
|
||||
return this._stringArray.indexOf(stringArg) !== -1
|
||||
}
|
||||
|
||||
/**
|
||||
* checks stringPresence with minimatch
|
||||
*/
|
||||
checkMinimatch(miniMatchStringArg: string): boolean {
|
||||
let foundMatch: boolean = false
|
||||
for (let stringItem of this._stringArray){
|
||||
if (plugins.minimatch(stringItem,miniMatchStringArg)) {
|
||||
foundMatch = true
|
||||
}
|
||||
}
|
||||
return foundMatch
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Stringmap is empty
|
||||
*/
|
||||
checkIsEmpty() {
|
||||
return (this._stringArray.length === 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a cloned copy of the current string Array
|
||||
*/
|
||||
getStringArray() {
|
||||
return plugins.lodash.cloneDeep(this._stringArray)
|
||||
}
|
||||
|
||||
// trigger registering
|
||||
|
||||
/**
|
||||
* register a new trigger
|
||||
*/
|
||||
registerUntilTrue(functionArg: ITriggerFunction,doFunctionArg) {
|
||||
this._triggerUntilTrueFunctionArray.push(
|
||||
() => {
|
||||
let result = functionArg()
|
||||
if (result === true) {
|
||||
doFunctionArg()
|
||||
}
|
||||
return result
|
||||
}
|
||||
)
|
||||
this.notifyTrigger()
|
||||
}
|
||||
|
||||
/**
|
||||
* notifies triggers
|
||||
*/
|
||||
private notifyTrigger() {
|
||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||
return !functionArg()
|
||||
})
|
||||
this._triggerUntilTrueFunctionArray = filteredArray
|
||||
}
|
||||
|
||||
}
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
333
yarn.lock
333
yarn.lock
@ -1,333 +0,0 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/chai-as-promised@0.0.29":
|
||||
version "0.0.29"
|
||||
resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-0.0.29.tgz#43d52892aa998e185a3de3e2477edb8573be1d77"
|
||||
dependencies:
|
||||
"@types/chai" "*"
|
||||
"@types/promises-a-plus" "*"
|
||||
|
||||
"@types/chai-string@^1.1.30":
|
||||
version "1.1.30"
|
||||
resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.1.30.tgz#4d8744b31a5a2295fc01c981ed1e2d4c8a070f0a"
|
||||
dependencies:
|
||||
"@types/chai" "*"
|
||||
|
||||
"@types/chai@*":
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.1.tgz#37fea779617cfec3fd2b19a0247e8bbdd5133bf6"
|
||||
|
||||
"@types/chai@^3.4.35":
|
||||
version "3.5.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.5.2.tgz#c11cd2817d3a401b7ba0f5a420f35c56139b1c1e"
|
||||
|
||||
"@types/lodash@^4.14.67":
|
||||
version "4.14.67"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.67.tgz#4714714434da110306b9862fbd36b30b55eb850a"
|
||||
|
||||
"@types/minimatch@2.x.x":
|
||||
version "2.0.29"
|
||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a"
|
||||
|
||||
"@types/node@*":
|
||||
version "8.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.6.tgz#ed2c3e011cb51ccd3cf874989130f1b9ffe06069"
|
||||
|
||||
"@types/promises-a-plus@*":
|
||||
version "0.0.27"
|
||||
resolved "https://registry.yarnpkg.com/@types/promises-a-plus/-/promises-a-plus-0.0.27.tgz#c64651134614c84b8f5d7114ce8901d36a609780"
|
||||
|
||||
"@types/q@1.x.x":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.0.1.tgz#dbccb01bd8f0f801a12a4604c7d7af59bb02ae2f"
|
||||
|
||||
"@types/shelljs@^0.7.2":
|
||||
version "0.7.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.7.2.tgz#c2bdb3fe80cd7a3da08750ca898ae44c589671f3"
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/which@^1.0.28":
|
||||
version "1.0.28"
|
||||
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.0.28.tgz#016e387629b8817bed653fe32eab5d11279c8df6"
|
||||
|
||||
ansi-256-colors@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
|
||||
|
||||
assertion-error@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
|
||||
beautycolor@^1.0.7:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.7.tgz#a4715738ac4c8221371e9cbeb5a6cc6d11ecbf7c"
|
||||
dependencies:
|
||||
ansi-256-colors "^1.1.0"
|
||||
typings-global "^1.0.14"
|
||||
|
||||
bindings@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11"
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.8"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
chai-as-promised@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-6.0.0.tgz#1a02a433a6f24dafac63b9c96fa1684db1aa8da6"
|
||||
dependencies:
|
||||
check-error "^1.0.2"
|
||||
|
||||
chai-string@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.4.0.tgz#359140c051d36a4e4b1a5fc6b910152f438a8d49"
|
||||
|
||||
chai@^3.5.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"
|
||||
dependencies:
|
||||
assertion-error "^1.0.1"
|
||||
deep-eql "^0.1.3"
|
||||
type-detect "^1.0.0"
|
||||
|
||||
check-error@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
|
||||
deep-eql@^0.1.3:
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2"
|
||||
dependencies:
|
||||
type-detect "0.1.1"
|
||||
|
||||
early@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
|
||||
dependencies:
|
||||
beautycolor "^1.0.7"
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.16"
|
||||
|
||||
es6-error@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98"
|
||||
|
||||
fs.realpath@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
|
||||
glob@^7.0.0:
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.4"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
inflight@^1.0.4:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||
dependencies:
|
||||
once "^1.3.0"
|
||||
wrappy "1"
|
||||
|
||||
inherits@2:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||
|
||||
interpret@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90"
|
||||
|
||||
isexe@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
|
||||
leakage@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/leakage/-/leakage-0.3.0.tgz#15d698abdc76bbc6439601f4f3020e77e2d50c39"
|
||||
dependencies:
|
||||
es6-error "^4.0.2"
|
||||
left-pad "^1.1.3"
|
||||
memwatch-next "^0.3.0"
|
||||
minimist "^1.2.0"
|
||||
pretty-bytes "^4.0.2"
|
||||
|
||||
left-pad@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a"
|
||||
|
||||
lodash@^4.17.4:
|
||||
version "4.17.4"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
||||
|
||||
memwatch-next@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/memwatch-next/-/memwatch-next-0.3.0.tgz#2111050f9a906e0aa2d72a4ec0f0089c78726f8f"
|
||||
dependencies:
|
||||
bindings "^1.2.1"
|
||||
nan "^2.3.2"
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimist@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
||||
|
||||
nan@^2.3.2:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45"
|
||||
|
||||
once@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
path-is-absolute@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||
|
||||
path-parse@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
|
||||
|
||||
pretty-bytes@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
|
||||
|
||||
q@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"
|
||||
|
||||
rechoir@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
|
||||
dependencies:
|
||||
resolve "^1.1.6"
|
||||
|
||||
resolve@^1.1.6:
|
||||
version "1.3.3"
|
||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5"
|
||||
dependencies:
|
||||
path-parse "^1.0.5"
|
||||
|
||||
rxjs@^5.4.1:
|
||||
version "5.4.1"
|
||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.1.tgz#b62f757f279445d265a18a58fb0a70dc90e91626"
|
||||
dependencies:
|
||||
symbol-observable "^1.0.1"
|
||||
|
||||
semver@^5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
|
||||
|
||||
shelljs@^0.7.8:
|
||||
version "0.7.8"
|
||||
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3"
|
||||
dependencies:
|
||||
glob "^7.0.0"
|
||||
interpret "^1.0.0"
|
||||
rechoir "^0.6.2"
|
||||
|
||||
smartchai@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.3.tgz#de6d010bb8b5aef24cb70b31a5f5334e8c41b72f"
|
||||
dependencies:
|
||||
"@types/chai" "^3.4.35"
|
||||
"@types/chai-as-promised" "0.0.29"
|
||||
"@types/chai-string" "^1.1.30"
|
||||
chai "^3.5.0"
|
||||
chai-as-promised "^6.0.0"
|
||||
chai-string "^1.3.0"
|
||||
|
||||
smartdelay@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/smartdelay/-/smartdelay-1.0.3.tgz#5fd44dad77262d110702f0293efa80c072cfb579"
|
||||
dependencies:
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.16"
|
||||
|
||||
smartq@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.1.tgz#efb358705260d41ae18aef7ffd815f7b6fe17dd3"
|
||||
dependencies:
|
||||
typed-promisify "^0.3.0"
|
||||
typings-global "^1.0.14"
|
||||
|
||||
smartshell@^1.0.6:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/smartshell/-/smartshell-1.0.8.tgz#1535756c0fe8069f7e6da1e3f9cb6c8f77094e42"
|
||||
dependencies:
|
||||
"@types/shelljs" "^0.7.2"
|
||||
"@types/which" "^1.0.28"
|
||||
shelljs "^0.7.8"
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.19"
|
||||
which "^1.2.14"
|
||||
|
||||
symbol-observable@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
|
||||
|
||||
tapbundle@^1.0.14:
|
||||
version "1.0.14"
|
||||
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.0.14.tgz#75827e335fcb02216f0267a26a26d702ddc02e3c"
|
||||
dependencies:
|
||||
early "^2.1.1"
|
||||
leakage "^0.3.0"
|
||||
smartchai "^1.0.3"
|
||||
smartdelay "^1.0.3"
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.16"
|
||||
|
||||
type-detect@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
|
||||
|
||||
type-detect@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
|
||||
|
||||
typed-promisify@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/typed-promisify/-/typed-promisify-0.3.0.tgz#1ba0af5e444c87d8047406f18ce49092a1191853"
|
||||
|
||||
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19:
|
||||
version "1.0.19"
|
||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.19.tgz#3376a72d4de1e5541bf5702248ff64c3e6ea316c"
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
smartshell "^1.0.6"
|
||||
|
||||
which@^1.2.14:
|
||||
version "1.2.14"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
|
||||
dependencies:
|
||||
isexe "^2.0.0"
|
||||
|
||||
wrappy@1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
Loading…
x
Reference in New Issue
Block a user