Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,5 +1,22 @@
|
|||||||
node_modules/
|
|
||||||
pages/
|
|
||||||
public/
|
|
||||||
coverage/
|
|
||||||
.nogit/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
101
.gitlab-ci.yml
101
.gitlab-ci.yml
@ -1,96 +1,121 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: clone
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .yarn/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- mirror
|
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
mirror:
|
mirror:
|
||||||
stage: mirror
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
security:
|
snyk:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add snyk
|
- npmci npm prepare
|
||||||
- npmci command yarn install --ignore-scripts
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# test stage
|
||||||
script:
|
# ====================
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
testStable:
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci node install lts
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
stage: pages
|
services:
|
||||||
|
- docker:18-dind
|
||||||
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add npmpage
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci command npmpage
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"workbench.colorCustomizations": {}
|
||||||
|
}
|
41
README.md
41
README.md
@ -1,25 +1,20 @@
|
|||||||
# lik
|
# @pushrocks/lik
|
||||||
|
|
||||||
light little helpers for node
|
light little helpers for node
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/lik)
|
||||||
[](https://www.npmjs.com/package/lik)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/lik)
|
||||||
[](https://GitLab.com/pushrocks/lik)
|
* [github.com (source mirror)](https://github.com/pushrocks/lik)
|
||||||
[](https://github.com/pushrocks/lik)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/lik/)
|
||||||
[](https://pushrocks.gitlab.io/lik/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/lik/commits/master)
|
||||||
[](https://GitLab.com/pushrocks/lik/commits/master)
|
[](https://gitlab.com/pushrocks/lik/commits/master)
|
||||||
[](https://GitLab.com/pushrocks/lik/commits/master)
|
[](https://www.npmjs.com/package/@pushrocks/lik)
|
||||||
[](https://www.npmjs.com/package/lik)
|
[](https://snyk.io/test/npm/@pushrocks/lik)
|
||||||
[](https://david-dm.org/pushrocks/lik)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/pushrocks/lik/master/dependencies/npm)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/pushrocks/lik)
|
[](https://prettier.io/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -27,7 +22,7 @@ Use TypeScript for best in class instellisense.
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// import any tool that you need from lik
|
// import any tool that you need from lik
|
||||||
import { Stringmap, Objectmap, Observablemap } from "lik";
|
import { Stringmap, Objectmap, Observablemap } from 'lik';
|
||||||
```
|
```
|
||||||
|
|
||||||
### class Stringmap
|
### class Stringmap
|
||||||
@ -40,7 +35,9 @@ like when a certain string is removed or added to the map
|
|||||||
Sometimes you need to keep track of objects, but implementing logic for removing, finding or updating is tedious.
|
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.
|
Objectmap takes care of keeping track of objects for you.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
For further information read the linked docs at the top of this readme.
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
5
dist/index.d.ts
vendored
5
dist/index.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
export * from "./lik.looptracker";
|
|
||||||
export * from "./lik.objectmap";
|
|
||||||
export * from "./lik.stringmap";
|
|
||||||
export * from "./lik.limitedarray";
|
|
||||||
export * from "./lik.tree";
|
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -1,12 +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.looptracker"));
|
|
||||||
__export(require("./lik.objectmap"));
|
|
||||||
__export(require("./lik.stringmap"));
|
|
||||||
__export(require("./lik.limitedarray"));
|
|
||||||
__export(require("./lik.tree"));
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLGlCQUFpQjtBQUVqQix1Q0FBa0M7QUFDbEMscUNBQWdDO0FBQ2hDLHFDQUFnQztBQUNoQyx3Q0FBbUM7QUFDbkMsZ0NBQTJCIn0=
|
|
9
dist/lik.limitedarray.d.ts
vendored
9
dist/lik.limitedarray.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
export declare class LimitedArray<T> {
|
|
||||||
array: T[];
|
|
||||||
arrayLimit: number;
|
|
||||||
constructor(limitArg: number);
|
|
||||||
addOne(objectArg: T): void;
|
|
||||||
addMany(objectArrayArg: T[]): void;
|
|
||||||
setLimit(limitArg: number): void;
|
|
||||||
getAverage(): number;
|
|
||||||
}
|
|
40
dist/lik.limitedarray.js
vendored
40
dist/lik.limitedarray.js
vendored
@ -1,40 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
class LimitedArray {
|
|
||||||
constructor(limitArg) {
|
|
||||||
this.array = [];
|
|
||||||
this.arrayLimit = limitArg;
|
|
||||||
}
|
|
||||||
addOne(objectArg) {
|
|
||||||
this.array.unshift(objectArg);
|
|
||||||
if (this.array.length > this.arrayLimit) {
|
|
||||||
this.array.length = this.arrayLimit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addMany(objectArrayArg) {
|
|
||||||
for (let objectArg of objectArrayArg) {
|
|
||||||
this.addOne(objectArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setLimit(limitArg) {
|
|
||||||
this.arrayLimit = limitArg;
|
|
||||||
if (this.array.length > this.arrayLimit) {
|
|
||||||
this.array.length = this.arrayLimit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getAverage() {
|
|
||||||
if (typeof this.array[0] === "number") {
|
|
||||||
let sum = 0;
|
|
||||||
for (let localNumber of this.array) {
|
|
||||||
let localNumberAny = localNumber;
|
|
||||||
sum = sum + localNumberAny;
|
|
||||||
}
|
|
||||||
return sum / this.array.length;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.LimitedArray = LimitedArray;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLmxpbWl0ZWRhcnJheS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5saW1pdGVkYXJyYXkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFFQTtJQUdFLFlBQVksUUFBZ0I7UUFGNUIsVUFBSyxHQUFRLEVBQUUsQ0FBQztRQUdkLElBQUksQ0FBQyxVQUFVLEdBQUcsUUFBUSxDQUFDO0lBQzdCLENBQUM7SUFFRCxNQUFNLENBQUMsU0FBWTtRQUNqQixJQUFJLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUM5QixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQztZQUN4QyxJQUFJLENBQUMsS0FBSyxDQUFDLE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UUFDZCxDQUFDO0lBQ0gsQ0FBQztDQUNGO0FBdkNELG9DQXVDQyJ9
|
|
10
dist/lik.looptracker.d.ts
vendored
10
dist/lik.looptracker.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import { Objectmap } from "./lik.objectmap";
|
|
||||||
export declare class LoopTracker<T> {
|
|
||||||
referenceObjectMap: Objectmap<any>;
|
|
||||||
constructor();
|
|
||||||
/**
|
|
||||||
* checks and tracks an object
|
|
||||||
* @param objectArg
|
|
||||||
*/
|
|
||||||
checkAndTrack(objectArg: T): boolean;
|
|
||||||
}
|
|
18
dist/lik.looptracker.js
vendored
18
dist/lik.looptracker.js
vendored
@ -1,18 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const lik_objectmap_1 = require("./lik.objectmap");
|
|
||||||
class LoopTracker {
|
|
||||||
constructor() {
|
|
||||||
this.referenceObjectMap = new lik_objectmap_1.Objectmap();
|
|
||||||
// nothing here
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* checks and tracks an object
|
|
||||||
* @param objectArg
|
|
||||||
*/
|
|
||||||
checkAndTrack(objectArg) {
|
|
||||||
return this.referenceObjectMap.add(objectArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.LoopTracker = LoopTracker;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLmxvb3B0cmFja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbGlrLmxvb3B0cmFja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUEsbURBQTRDO0FBRTVDO0lBRUU7UUFEQSx1QkFBa0IsR0FBRyxJQUFJLHlCQUFTLEVBQU8sQ0FBQztRQUV4QyxlQUFlO0lBQ2pCLENBQUM7SUFFRDs7O09BR0c7SUFDSCxhQUFhLENBQUMsU0FBWTtRQUN4QixNQUFNLENBQUMsSUFBSSxDQUFDLGtCQUFrQixDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNoRCxDQUFDO0NBQ0Y7QUFiRCxrQ0FhQyJ9
|
|
62
dist/lik.objectmap.d.ts
vendored
62
dist/lik.objectmap.d.ts
vendored
@ -1,62 +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
|
|
||||||
* returns false if the object is already in the map
|
|
||||||
* returns true if the object was added successfully
|
|
||||||
*/
|
|
||||||
add(objectArg: T): boolean;
|
|
||||||
/**
|
|
||||||
* 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>): Promise<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;
|
|
||||||
}
|
|
128
dist/lik.objectmap.js
vendored
128
dist/lik.objectmap.js
vendored
@ -1,128 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
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
|
|
||||||
* returns false if the object is already in the map
|
|
||||||
* returns true if the object was added successfully
|
|
||||||
*/
|
|
||||||
add(objectArg) {
|
|
||||||
if (this.checkForObject(objectArg)) {
|
|
||||||
// the object is already in the objectmap
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// the object is not yet in the objectmap
|
|
||||||
this.objectArray.push(objectArg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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 __awaiter(this, void 0, void 0, function* () {
|
|
||||||
for (let object of this.objectArray) {
|
|
||||||
yield functionArg(object);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLHlDQUF5QztBQVV6Qzs7R0FFRztBQUNIO0lBR0U7O09BRUc7SUFDSDtRQUxRLGdCQUFXLEdBQVEsRUFBRSxDQUFDO1FBTTVCLGVBQWU7SUFDakIsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxHQUFHLENBQUMsU0FBWTtRQUNkLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ25DLHlDQUF5QztZQUN6QyxNQUFNLENBQUMsS0FBSyxDQUFDO1FBQ2YsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ04seUNBQXlDO1lBQ3pDLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1lBQ2pDLE1BQU0sQ0FBQyxJQUFJLENBQUM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SUFBSSxDQUFDLFdBQVcsR0FBRyxnQkFBZ0IsQ0FBQztJQUN0QyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0YsSUFBSSxDQUFDLFdBQVcsR0FBRyxFQUFFLENBQUM7SUFDeEIsQ0FBQztDQUNGO0FBdEhELDhCQXNIQyJ9
|
|
6
dist/lik.plugins.d.ts
vendored
6
dist/lik.plugins.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import * as events from "events";
|
|
||||||
import * as lodash from "lodash";
|
|
||||||
import * as minimatch from "minimatch";
|
|
||||||
import * as smartq from "smartq";
|
|
||||||
declare const symbolTree: any;
|
|
||||||
export { events, lodash, minimatch, smartq, symbolTree };
|
|
13
dist/lik.plugins.js
vendored
13
dist/lik.plugins.js
vendored
@ -1,13 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const events = require("events");
|
|
||||||
exports.events = events;
|
|
||||||
const lodash = require("lodash");
|
|
||||||
exports.lodash = lodash;
|
|
||||||
const minimatch = require("minimatch");
|
|
||||||
exports.minimatch = minimatch;
|
|
||||||
const smartq = require("smartq");
|
|
||||||
exports.smartq = smartq;
|
|
||||||
const symbolTree = require("symbol-tree");
|
|
||||||
exports.symbolTree = symbolTree;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGlDQUFpQztBQU14Qix3QkFBTTtBQUxmLGlDQUFpQztBQUtoQix3QkFBTTtBQUp2Qix1Q0FBdUM7QUFJZCw4QkFBUztBQUhsQyxpQ0FBaUM7QUFHRyx3QkFBTTtBQUYxQyxNQUFNLFVBQVUsR0FBRyxPQUFPLENBQUMsYUFBYSxDQUFDLENBQUM7QUFFRSxnQ0FBVSJ9
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBeUM7QUFVekM7SUFHRTtRQUZRLGlCQUFZLEdBQWEsRUFBRSxDQUFDO1FBQzVCLG1DQUE4QixHQUF1QixFQUFFLENBQUM7SUFDakQsQ0FBQztJQUNoQjs7T0FFRztJQUNILFNBQVMsQ0FBQyxTQUFpQjtRQUN6QixJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsQyxJQUFJLENBQUMsYUFBYSxFQUFFLEN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LENBQUMsRUFBRTtZQUNaLE1BQU0sQ0FBQyxDQUFDLFdBQVcsRUFBRSxDQUFDO1FBQ3hCLENBQUMsQ0FDRixDQUFDO1FBQ0YsSUFBSSxDQUFDLDhCQUE4QixHQUFHLGFBQWEsQ0FBQztJQUN0RCxDQUFDO0NBQ0Y7QUF0R0QsOEJBc0dDIn0=
|
|
34
dist/lik.tree.d.ts
vendored
34
dist/lik.tree.d.ts
vendored
@ -1,34 +0,0 @@
|
|||||||
export declare class Tree<T> {
|
|
||||||
symbolTree: any;
|
|
||||||
constructor();
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param objectArg
|
|
||||||
*/
|
|
||||||
initialize(objectArg: T): T;
|
|
||||||
hasChildren(objectArg: T): boolean;
|
|
||||||
firstChild(objectArg: T): T;
|
|
||||||
lastChild(objectArg: T): T;
|
|
||||||
previousSibling(objectArg: T): T;
|
|
||||||
nextSibling(objectArg: T): T;
|
|
||||||
parent(objectArg: T): T;
|
|
||||||
lastInclusiveDescendant(objectArg: T): T;
|
|
||||||
preceding(objectArg: T, optionsArg?: any): T;
|
|
||||||
following(object: T, optionsArg: any): any;
|
|
||||||
childrenToArray(parentArg: T, optionsArg: any): T[];
|
|
||||||
ancestorsToArray(objectArg: T, optionsArg: any): T[];
|
|
||||||
treeToArray(rootArg: any, optionsArg: any): T[];
|
|
||||||
childrenIterator(parentArg: T, optionsArg: any): T;
|
|
||||||
previousSiblingsIterator(objectArg: any): T;
|
|
||||||
nextSiblingsIterator(objectArg: T): any;
|
|
||||||
ancestorsIterator(objectArg: any): void;
|
|
||||||
treeIterator(rootArg: T, optionsArg: any): T;
|
|
||||||
index(childArg: T): number;
|
|
||||||
childrenCount(parentArg: T): number;
|
|
||||||
compareTreePosition(leftArg: T, rightArg: T): number;
|
|
||||||
remove(removeObjectArg: T): T;
|
|
||||||
insertBefore(referenceObjectArg: T, newObjectArg: T): T;
|
|
||||||
insertAfter(referenceObject: T, newObjectArg: T): any;
|
|
||||||
prependChild(referenceObjectArg: T, newObjectArg: T): T;
|
|
||||||
appendChild(referenceObjectArg: any, newObjectArg: any): any;
|
|
||||||
}
|
|
92
dist/lik.tree.js
vendored
92
dist/lik.tree.js
vendored
@ -1,92 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const plugins = require("./lik.plugins");
|
|
||||||
class Tree {
|
|
||||||
constructor() {
|
|
||||||
this.symbolTree = new plugins.symbolTree();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param objectArg
|
|
||||||
*/
|
|
||||||
initialize(objectArg) {
|
|
||||||
return this.symbolTree.initialize(objectArg);
|
|
||||||
}
|
|
||||||
hasChildren(objectArg) {
|
|
||||||
return this.symbolTree.hasChildren(objectArg);
|
|
||||||
}
|
|
||||||
firstChild(objectArg) {
|
|
||||||
return this.symbolTree.firstChild(objectArg);
|
|
||||||
}
|
|
||||||
lastChild(objectArg) {
|
|
||||||
return this.symbolTree.lastChild(objectArg);
|
|
||||||
}
|
|
||||||
previousSibling(objectArg) {
|
|
||||||
return this.symbolTree.previousSibling(objectArg);
|
|
||||||
}
|
|
||||||
nextSibling(objectArg) {
|
|
||||||
return this.symbolTree.nextSibling(objectArg);
|
|
||||||
}
|
|
||||||
parent(objectArg) {
|
|
||||||
return this.symbolTree.parent(objectArg);
|
|
||||||
}
|
|
||||||
lastInclusiveDescendant(objectArg) {
|
|
||||||
return this.symbolTree.lastInclusiveDescendant(objectArg);
|
|
||||||
}
|
|
||||||
preceding(objectArg, optionsArg) {
|
|
||||||
return this.symbolTree.preceding(objectArg, optionsArg);
|
|
||||||
}
|
|
||||||
following(object, optionsArg) {
|
|
||||||
return this.symbolTree.following(object, optionsArg);
|
|
||||||
}
|
|
||||||
childrenToArray(parentArg, optionsArg) {
|
|
||||||
return this.symbolTree.childrenToArray(parent, optionsArg);
|
|
||||||
}
|
|
||||||
ancestorsToArray(objectArg, optionsArg) {
|
|
||||||
return this.symbolTree.ancestorsToArray(objectArg, optionsArg);
|
|
||||||
}
|
|
||||||
treeToArray(rootArg, optionsArg) {
|
|
||||||
return this.symbolTree.treeToArray(rootArg, optionsArg);
|
|
||||||
}
|
|
||||||
childrenIterator(parentArg, optionsArg) {
|
|
||||||
return this.symbolTree.childrenIterator(parentArg, optionsArg);
|
|
||||||
}
|
|
||||||
previousSiblingsIterator(objectArg) {
|
|
||||||
return this.symbolTree.previousSiblingsIterator(objectArg);
|
|
||||||
}
|
|
||||||
nextSiblingsIterator(objectArg) {
|
|
||||||
return this.symbolTree.nextSiblingsIterator();
|
|
||||||
}
|
|
||||||
ancestorsIterator(objectArg) {
|
|
||||||
this.symbolTree.ancestorsIterator();
|
|
||||||
}
|
|
||||||
treeIterator(rootArg, optionsArg) {
|
|
||||||
return this.symbolTree.treeIterator(rootArg);
|
|
||||||
}
|
|
||||||
index(childArg) {
|
|
||||||
return this.symbolTree.index(childArg);
|
|
||||||
}
|
|
||||||
childrenCount(parentArg) {
|
|
||||||
return this.symbolTree.childrenCount(parentArg);
|
|
||||||
}
|
|
||||||
compareTreePosition(leftArg, rightArg) {
|
|
||||||
return this.compareTreePosition(leftArg, rightArg);
|
|
||||||
}
|
|
||||||
remove(removeObjectArg) {
|
|
||||||
return this.symbolTree.remove(removeObjectArg);
|
|
||||||
}
|
|
||||||
insertBefore(referenceObjectArg, newObjectArg) {
|
|
||||||
return this.symbolTree.insertBefore(referenceObjectArg, newObjectArg);
|
|
||||||
}
|
|
||||||
insertAfter(referenceObject, newObjectArg) {
|
|
||||||
return this.symbolTree.insertAfter(referenceObject, newObjectArg);
|
|
||||||
}
|
|
||||||
prependChild(referenceObjectArg, newObjectArg) {
|
|
||||||
return this.symbolTree.prependChild(referenceObjectArg, newObjectArg);
|
|
||||||
}
|
|
||||||
appendChild(referenceObjectArg, newObjectArg) {
|
|
||||||
return this.symbolTree.appendChild(referenceObjectArg, newObjectArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Tree =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xJQUFJLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxlQUFlLENBQUMsQ0FBQztJQUNqRCxDQUFDO0lBRUQsWUFBWSxDQUFDLGtCQUFxQixFQUFFLFlBQWU7UUFDakQsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsWUFBWSxDQUFDLGtCQUFrQixFQUFFLFlBQVksQ0FBQyxDQUFDO0lBQ3hFLENBQUM7SUFFRCxXQUFXLENBQUMsZUFBa0IsRUFBRSxZQUFlO1FBQzdDLE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7SUFDcEUsQ0FBQztJQUVELFlBQVksQ0FBQyxrQkFBcUIsRUFBRSxZQUFlO1FBQ2pELE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLFlBQVksQ0FBQyxrQkFBa0IsRUFBRSxZQUFZLENBQUMsQ0FBQztJQUN4RSxDQUFDO0lBRUQsV0FBVyxDQUFDLGtCQUFrQixFQUFFLFlBQVk7UUFDMUMsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsV0FBVyxDQUFDLGtCQUFrQixFQUFFLFlBQVksQ0FBQyxDQUFDO0lBQ3ZFLENBQUM7Q0FDRjtBQWpIRCxvQkFpSEMifQ==
|
|
@ -1,13 +1,16 @@
|
|||||||
# lik
|
# lik
|
||||||
|
|
||||||
light little helpers for node
|
light little helpers for node
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/lik)
|
[](https://www.npmjs.com/package/lik)
|
||||||
[](https://GitLab.com/pushrocks/lik)
|
[](https://GitLab.com/pushrocks/lik)
|
||||||
[](https://github.com/pushrocks/lik)
|
[](https://github.com/pushrocks/lik)
|
||||||
[](https://pushrocks.gitlab.io/lik/)
|
[](https://pushrocks.gitlab.io/lik/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
[](https://GitLab.com/pushrocks/lik/commits/master)
|
[](https://GitLab.com/pushrocks/lik/commits/master)
|
||||||
[](https://GitLab.com/pushrocks/lik/commits/master)
|
[](https://GitLab.com/pushrocks/lik/commits/master)
|
||||||
[](https://www.npmjs.com/package/lik)
|
[](https://www.npmjs.com/package/lik)
|
||||||
@ -19,22 +22,25 @@ light little helpers for node
|
|||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// import any tool that you need from lik
|
// import any tool that you need from lik
|
||||||
import { Stringmap, Objectmap, Observablemap } from "lik";
|
import { Stringmap, Objectmap, Observablemap } from 'lik';
|
||||||
```
|
```
|
||||||
|
|
||||||
### class Stringmap
|
### class Stringmap
|
||||||
|
|
||||||
Stringmap allows you to keep track of strings. It allows you to register triggers for certain events
|
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
|
like when a certain string is removed or added to the map
|
||||||
|
|
||||||
### class Objectmap
|
### class Objectmap
|
||||||
|
|
||||||
Sometimes you need to keep track of objects, but implementing logic for removing, finding or updating is tedious.
|
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.
|
Objectmap takes care of keeping track of objects for you.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> 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)
|
[](https://push.rocks)
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"npmts": {
|
"gitzone": {
|
||||||
"coverageTreshold": 40,
|
"module": {
|
||||||
"testConfig": {
|
"githost": "gitlab.com",
|
||||||
"parallel": false
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "lik",
|
||||||
|
"shortDescription": "light little helpers for node",
|
||||||
|
"npmPackagename": "@pushrocks/lik",
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1897
package-lock.json
generated
Normal file
1897
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "lik",
|
"name": "@pushrocks/lik",
|
||||||
"version": "2.0.4",
|
"version": "3.0.13",
|
||||||
|
"private": false,
|
||||||
"description": "light little helpers for node",
|
"description": "light little helpers for node",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -18,21 +20,32 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^9.4.0",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"cz-conventional-changelog": "^2.1.0",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"tapbundle": "^1.1.1"
|
"@gitzone/tstest": "^1.0.28",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
|
"@types/node": "^12.12.14",
|
||||||
|
"tslint": "^5.20.1",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "^4.14.97",
|
"@pushrocks/smartdelay": "^2.0.6",
|
||||||
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
|
"@pushrocks/smartrx": "^2.0.5",
|
||||||
|
"@pushrocks/smarttime": "^3.0.12",
|
||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
"lodash": "^4.17.4",
|
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"smartq": "^1.1.6",
|
"symbol-tree": "^3.2.4"
|
||||||
"symbol-tree": "^3.2.2"
|
|
||||||
},
|
},
|
||||||
"config": {
|
"files": [
|
||||||
"commitizen": {
|
"ts/*",
|
||||||
"path": "./node_modules/cz-conventional-changelog"
|
"ts_web/*",
|
||||||
}
|
"dist/*",
|
||||||
}
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
25
test/test.interestmap.ts
Normal file
25
test/test.interestmap.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
import * as lik from '../ts/index';
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,17 +1,17 @@
|
|||||||
import { tap, expect } from 'tapbundle'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
import { LimitedArray } from '../ts/index'
|
import { LimitedArray } from '../ts/index';
|
||||||
|
|
||||||
let testLimitedArray: LimitedArray<string>
|
let testLimitedArray: LimitedArray<string>;
|
||||||
|
|
||||||
tap.test('should create a LimitedArray', async () => {
|
tap.test('should create a LimitedArray', async () => {
|
||||||
testLimitedArray = new LimitedArray(6)
|
testLimitedArray = new LimitedArray(6);
|
||||||
expect(testLimitedArray).to.be.instanceof(LimitedArray)
|
expect(testLimitedArray).to.be.instanceof(LimitedArray);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should never be longer than the set length', async () => {
|
tap.test('should never be longer than the set length', async () => {
|
||||||
testLimitedArray.addMany(['hi','this','is','quite','a','long','string',':)'])
|
testLimitedArray.addMany(['hi', 'this', 'is', 'quite', 'a', 'long', 'string', ':)']);
|
||||||
expect(testLimitedArray.array.length).to.be.lessThan(7)
|
expect(testLimitedArray.array.length).to.be.lessThan(7);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
// import test framework
|
// import test framework
|
||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as events from 'events'
|
import * as events from 'events';
|
||||||
import * as smartq from 'smartq'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
// import the module
|
// import the module
|
||||||
import * as lik from '../ts/index'
|
import * as lik from '../ts/index';
|
||||||
|
|
||||||
let object1 = {}
|
let object1 = {};
|
||||||
let object2 = {}
|
let object2 = {};
|
||||||
let myLoopTracker: lik.LoopTracker<any>
|
let myLoopTracker: lik.LoopTracker<any>;
|
||||||
|
|
||||||
// tests
|
// tests
|
||||||
tap.test('should create a valid looptracker instance', async () => {
|
tap.test('should create a valid looptracker instance', async () => {
|
||||||
myLoopTracker = new lik.LoopTracker()
|
myLoopTracker = new lik.LoopTracker();
|
||||||
expect(myLoopTracker).to.be.instanceof(lik.LoopTracker)
|
expect(myLoopTracker).to.be.instanceof(lik.LoopTracker);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should add objects once and return true', async () => {
|
tap.test('should add objects once and return true', async () => {
|
||||||
expect(myLoopTracker.checkAndTrack(object1)).to.be.true
|
expect(myLoopTracker.checkAndTrack(object1)).to.be.true;
|
||||||
expect(myLoopTracker.checkAndTrack(object1)).to.be.false
|
expect(myLoopTracker.checkAndTrack(object1)).to.be.false;
|
||||||
expect(myLoopTracker.checkAndTrack(object2)).to.be.true
|
expect(myLoopTracker.checkAndTrack(object2)).to.be.true;
|
||||||
expect(myLoopTracker.checkAndTrack(object2)).to.be.false
|
expect(myLoopTracker.checkAndTrack(object2)).to.be.false;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@ -1,76 +1,78 @@
|
|||||||
// import test framework
|
// import test framework
|
||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as events from 'events'
|
import * as events from 'events';
|
||||||
import * as smartq from 'smartq'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
// import the module
|
// import the module
|
||||||
import * as lik from '../ts/index'
|
import * as lik from '../ts/index';
|
||||||
|
|
||||||
// Objectmap
|
// Objectmap
|
||||||
interface ITestObject {
|
interface ITestObject {
|
||||||
propOne: string
|
propOne: string;
|
||||||
propTwo: string
|
propTwo: string;
|
||||||
}
|
}
|
||||||
let testObjectmap: lik.Objectmap<ITestObject>
|
let testObjectmap: lik.Objectmap<ITestObject>;
|
||||||
let testObject1: ITestObject = {
|
let testObject1: ITestObject = {
|
||||||
propOne: 'hello',
|
propOne: 'hello',
|
||||||
propTwo: 'hello2'
|
propTwo: 'hello2'
|
||||||
}
|
};
|
||||||
let testObject2: ITestObject = {
|
let testObject2: ITestObject = {
|
||||||
propOne: 'hello',
|
propOne: 'hello',
|
||||||
propTwo: 'hello2'
|
propTwo: 'hello2'
|
||||||
}
|
};
|
||||||
|
|
||||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||||
testObjectmap = new lik.Objectmap<ITestObject>()
|
testObjectmap = new lik.Objectmap<ITestObject>();
|
||||||
expect(testObjectmap).be.instanceof(lik.Objectmap)
|
expect(testObjectmap).be.instanceof(lik.Objectmap);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Objectmap.add() -> should correctly add an object to Objectmap', async () => {
|
tap.test('lik.Objectmap.add() -> should correctly add an object to Objectmap', async () => {
|
||||||
testObjectmap.add(testObject1)
|
testObjectmap.add(testObject1);
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testObjectmap.checkForObject(testObject1)).be.true
|
expect(testObjectmap.checkForObject(testObject1)).be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testObjectmap.checkForObject(testObject2)).be.false
|
expect(testObjectmap.checkForObject(testObject2)).be.false;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectmap', async () => {
|
tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectmap', async () => {
|
||||||
testObjectmap.add(testObject2)
|
testObjectmap.add(testObject2);
|
||||||
testObjectmap.remove(testObject1)
|
testObjectmap.remove(testObject1);
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testObjectmap.checkForObject(testObject1)).be.false
|
expect(testObjectmap.checkForObject(testObject1)).be.false;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testObjectmap.checkForObject(testObject2)).be.true
|
expect(testObjectmap.checkForObject(testObject2)).be.true;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||||
testObjectmap.forEach(itemArg => {
|
testObjectmap.forEach(itemArg => {
|
||||||
expect(itemArg).to.contain('propOne')
|
expect(itemArg).to.have.property('propOne');
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' }
|
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||||
testObjectmap.add(myObject)
|
testObjectmap.add(myObject);
|
||||||
let referenceObject = testObjectmap.find((itemArg) => { return (itemArg.propOne === 'helloThere') })
|
let referenceObject = testObjectmap.find(itemArg => {
|
||||||
|
return itemArg.propOne === 'helloThere';
|
||||||
|
});
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(myObject === referenceObject).be.true
|
expect(myObject === referenceObject).be.true;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () => {
|
tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () => {
|
||||||
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' }
|
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' };
|
||||||
testObjectmap.add(myObject)
|
testObjectmap.add(myObject);
|
||||||
let clonedArray = testObjectmap.getArray()
|
let clonedArray = testObjectmap.getArray();
|
||||||
expect(clonedArray[ clonedArray.length - 1 ]).to.equal(myObject)
|
expect(clonedArray[clonedArray.length - 1]).to.eql(myObject);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should get one object and then remove it', async () => {
|
tap.test('should get one object and then remove it', async () => {
|
||||||
let originalLength = testObjectmap.getArray().length
|
let originalLength = testObjectmap.getArray().length;
|
||||||
let oneObject = testObjectmap.getOneAndRemove()
|
let oneObject = testObjectmap.getOneAndRemove();
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(oneObject).not.be.null
|
expect(oneObject).not.be.null;
|
||||||
expect(testObjectmap.getArray().length).equal(originalLength - 1)
|
expect(testObjectmap.getArray().length).equal(originalLength - 1);
|
||||||
expect(testObjectmap.getArray()).to.not.contain(oneObject)
|
expect(testObjectmap.getArray()).to.not.contain(oneObject);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@ -1,78 +1,88 @@
|
|||||||
// import test framework
|
// import test framework
|
||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as events from 'events'
|
import * as events from 'events';
|
||||||
import * as smartq from 'smartq'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
// import the module
|
// import the module
|
||||||
import * as lik from '../ts/index'
|
import * as lik from '../ts/index';
|
||||||
|
|
||||||
// testData
|
// testData
|
||||||
let testStringmap: lik.Stringmap
|
let testStringmap: lik.Stringmap;
|
||||||
let testString1 = 'testString1'
|
let testString1 = 'testString1';
|
||||||
let testString2 = 'testString2'
|
let testString2 = 'testString2';
|
||||||
let testString3 = 'testString3'
|
let testString3 = 'testString3';
|
||||||
let testString4 = 'testString4'
|
let testString4 = 'testString4';
|
||||||
let testString5 = 'testString5'
|
let testString5 = 'testString5';
|
||||||
let testString6 = 'testString6'
|
let testString6 = 'testString6';
|
||||||
|
|
||||||
// tests
|
// tests
|
||||||
tap.test('new lik.Objectmap() -> should create an instance of Stringmap', async () => {
|
tap.test('new lik.Objectmap() -> should create an instance of Stringmap', async () => {
|
||||||
testStringmap = new lik.Stringmap()
|
testStringmap = new lik.Stringmap();
|
||||||
expect(testStringmap).be.instanceof(lik.Stringmap)
|
expect(testStringmap).be.instanceof(lik.Stringmap);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Stringmap.checkString -> should return false for an string not in Stringmap', async () => {
|
tap.test(
|
||||||
|
'lik.Stringmap.checkString -> should return false for an string not in Stringmap',
|
||||||
|
async () => {
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkString(testString1)).be.false
|
expect(testStringmap.checkString(testString1)).be.false;
|
||||||
})
|
}
|
||||||
|
);
|
||||||
|
|
||||||
tap.test('lik.Stringmap.addString -> should add an string to Stringmap', async () => {
|
tap.test('lik.Stringmap.addString -> should add an string to Stringmap', async () => {
|
||||||
testStringmap.addString(testString1)
|
testStringmap.addString(testString1);
|
||||||
testStringmap.addString(testString2)
|
testStringmap.addString(testString2);
|
||||||
testStringmap.addString(testString3)
|
testStringmap.addString(testString3);
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkString(testString1)).be.true
|
expect(testStringmap.checkString(testString1)).be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkString(testString2)).be.true
|
expect(testStringmap.checkString(testString2)).be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkString(testString3)).be.true
|
expect(testStringmap.checkString(testString3)).be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkMinimatch('*String1')).be.true
|
expect(testStringmap.checkMinimatch('*String1')).be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkMinimatch('*String2')).be.true
|
expect(testStringmap.checkMinimatch('*String2')).be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkMinimatch('*String4')).be.false
|
expect(testStringmap.checkMinimatch('*String4')).be.false;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Stringmap.addStringArray -> should add an array of strings', async () => {
|
tap.test('lik.Stringmap.addStringArray -> should add an array of strings', async () => {
|
||||||
testStringmap.addStringArray([ testString4, testString5, testString6 ])
|
testStringmap.addStringArray([testString4, testString5, testString6]);
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkMinimatch('*String4')).be.true
|
expect(testStringmap.checkMinimatch('*String4')).be.true;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Stringmap.removeString -> should remove a string from Stringmap', async () => {
|
tap.test('lik.Stringmap.removeString -> should remove a string from Stringmap', async () => {
|
||||||
testStringmap.removeString(testString2)
|
testStringmap.removeString(testString2);
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(testStringmap.checkString(testString2)).be.false
|
expect(testStringmap.checkString(testString2)).be.false;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Stringmap.getStringArray() -> should return a copy of stringArray', async () => {
|
tap.test('lik.Stringmap.getStringArray() -> should return a copy of stringArray', async () => {
|
||||||
let clonedArray = testStringmap.getStringArray()
|
let clonedArray = testStringmap.getStringArray();
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(clonedArray[ 0 ] === 'testString1').be.true
|
expect(clonedArray[0] === 'testString1').be.true;
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(clonedArray[ 0 ] === testString1).be.true
|
expect(clonedArray[0] === testString1).be.true;
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('lik.Stringmap.checkIsEmpty() -> should register a function to trigger when empty', async () => {
|
tap.test(
|
||||||
|
'lik.Stringmap.checkIsEmpty() -> should register a function to trigger when empty',
|
||||||
|
async () => {
|
||||||
testStringmap.registerUntilTrue(
|
testStringmap.registerUntilTrue(
|
||||||
() => { return testStringmap.checkIsEmpty() },
|
() => {
|
||||||
() => { console.log('Stringmap now is empty') }
|
return testStringmap.checkIsEmpty();
|
||||||
)
|
},
|
||||||
})
|
() => {
|
||||||
|
console.log('Stringmap now is empty');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
tap.test('lik.Stringmap.empty() -> should remove wipe and then notify', async () => {
|
tap.test('lik.Stringmap.empty() -> should remove wipe and then notify', async () => {
|
||||||
testStringmap.wipe()
|
testStringmap.wipe();
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
25
test/test.timedaggregator.ts
Normal file
25
test/test.timedaggregator.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// import test framework
|
||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as events from 'events';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
|
// import the module
|
||||||
|
import * as lik from '../ts/index';
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,24 +1,40 @@
|
|||||||
import { tap, expect } from 'tapbundle'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as lik from '../ts/index'
|
import * as lik from '../ts/index';
|
||||||
|
|
||||||
let testTree = new lik.Tree<TestClass>()
|
|
||||||
|
|
||||||
class TestClass {
|
class TestClass {
|
||||||
constructor (public hey: string) {
|
constructor(public hey: string) {
|
||||||
// nothing here
|
// nothing here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let testInstance = new TestClass('first')
|
|
||||||
|
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 () => {
|
tap.test('create a valid tree instance', async () => {
|
||||||
testTree = new lik.Tree()
|
testTree = new lik.Tree();
|
||||||
expect(testTree).to.be.instanceOf(lik.Tree)
|
expect(testTree).to.be.instanceOf(lik.Tree);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should insert an object', async () => {
|
tap.test('should insert an object', async () => {
|
||||||
testTree.initialize(testInstance)
|
testTree.initialize(testInstance);
|
||||||
let resultArray = testTree.treeToArray(testInstance, {})
|
let resultArray = testTree.treeToArray(testInstance, {});
|
||||||
expect(resultArray).to.contain(testInstance)
|
expect(resultArray).to.contain(testInstance);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
1
test/test.ts
Normal file
1
test/test.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import './test.objectmap';
|
14
ts/index.ts
14
ts/index.ts
@ -1,9 +1,11 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
// import modules
|
// import modules
|
||||||
|
|
||||||
export * from "./lik.looptracker";
|
export * from './lik.interestmap';
|
||||||
export * from "./lik.objectmap";
|
export * from './lik.limitedarray';
|
||||||
export * from "./lik.stringmap";
|
export * from './lik.looptracker';
|
||||||
export * from "./lik.limitedarray";
|
export * from './lik.objectmap';
|
||||||
export * from "./lik.tree";
|
export * from './lik.stringmap';
|
||||||
|
export * from './lik.timedaggregator';
|
||||||
|
export * from './lik.tree';
|
||||||
|
78
ts/lik.interestmap.interest.ts
Normal file
78
ts/lik.interestmap.interest.ts
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
|
import { InterestMap, IInterestComparisonFunc } from './lik.interestmap';
|
||||||
|
|
||||||
|
export class Interest<DTInterestId, 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>
|
||||||
|
) {
|
||||||
|
this.originalInterest = interestArg;
|
||||||
|
this.comparisonFunc = comparisonFuncArg;
|
||||||
|
this.interestMapRef = interestMapArg;
|
||||||
|
this.destructionTimer.completed.then(() => {
|
||||||
|
this.destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===============================
|
||||||
|
// LIFECYCLE MANAGEMENT
|
||||||
|
// ===============================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* self destructs the interest
|
||||||
|
*/
|
||||||
|
public destroy() {
|
||||||
|
this.interestMapRef.removeInterest(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
114
ts/lik.interestmap.ts
Normal file
114
ts/lik.interestmap.ts
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
import * as plugins from './lik.plugins';
|
||||||
|
import { Objectmap } from './lik.objectmap';
|
||||||
|
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
import { Interest } from './lik.interestmap.interest';
|
||||||
|
|
||||||
|
export type IInterestComparisonFunc<T> = (objectArg: T) => string;
|
||||||
|
|
||||||
|
export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||||
|
/**
|
||||||
|
* 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>) {
|
||||||
|
this.comparisonFunc = comparisonFuncArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds an interest to the InterestMap
|
||||||
|
* @param objectArg
|
||||||
|
*/
|
||||||
|
public async addInterest(
|
||||||
|
objectArg: DTInterestId
|
||||||
|
): Promise<Interest<DTInterestId, DTInterestFullfillment>> {
|
||||||
|
const comparisonString = this.comparisonFunc(objectArg);
|
||||||
|
let returnInterest: Interest<DTInterestId, DTInterestFullfillment>;
|
||||||
|
const newInterest = new Interest<DTInterestId, DTInterestFullfillment>(
|
||||||
|
this,
|
||||||
|
objectArg,
|
||||||
|
this.comparisonFunc
|
||||||
|
);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line:member-ordering
|
||||||
|
public interestObservable = new plugins.smartrx.ObservableIntake<Interest<DTInterestId, any>>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes an interest from the interest map
|
||||||
|
* @param objectArg removes an interest from the InterestMap
|
||||||
|
*/
|
||||||
|
public removeInterest(interestArg: Interest<DTInterestId, DTInterestFullfillment>) {
|
||||||
|
const interestToRemove = this.interestObjectMap.findOneAndRemove(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.find(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 objectArg
|
||||||
|
*/
|
||||||
|
public findInterest(objectArg: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> {
|
||||||
|
const comparableString = this.comparisonFunc(objectArg);
|
||||||
|
const interest = this.interestObjectMap.find(interest => {
|
||||||
|
return interest.comparisonString === comparableString;
|
||||||
|
});
|
||||||
|
return interest; // if an interest is found, the interest is returned, otherwise interest is null
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
export class LimitedArray<T> {
|
export class LimitedArray<T> {
|
||||||
array: T[] = [];
|
array: T[] = [];
|
||||||
@ -28,7 +28,7 @@ export class LimitedArray<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAverage(): number {
|
getAverage(): number {
|
||||||
if (typeof this.array[0] === "number") {
|
if (typeof this.array[0] === 'number') {
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (let localNumber of this.array) {
|
for (let localNumber of this.array) {
|
||||||
let localNumberAny: any = localNumber;
|
let localNumberAny: any = localNumber;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
import { Objectmap } from "./lik.objectmap";
|
import { Objectmap } from './lik.objectmap';
|
||||||
|
|
||||||
export class LoopTracker<T> {
|
export class LoopTracker<T> {
|
||||||
referenceObjectMap = new Objectmap<any>();
|
referenceObjectMap = new Objectmap<any>();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
export interface IObjectmapForEachFunction<T> {
|
export interface IObjectmapForEachFunction<T> {
|
||||||
(itemArg: T): void;
|
(itemArg: T): void;
|
||||||
@ -14,6 +14,9 @@ export interface IObjectmapFindFunction<T> {
|
|||||||
export class Objectmap<T> {
|
export class Objectmap<T> {
|
||||||
private objectArray: T[] = [];
|
private objectArray: T[] = [];
|
||||||
|
|
||||||
|
// events
|
||||||
|
public eventSubject = new plugins.smartrx.rxjs.Subject<any>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a new instance
|
* returns a new instance
|
||||||
*/
|
*/
|
||||||
@ -26,13 +29,14 @@ export class Objectmap<T> {
|
|||||||
* returns false if the object is already in the map
|
* returns false if the object is already in the map
|
||||||
* returns true if the object was added successfully
|
* returns true if the object was added successfully
|
||||||
*/
|
*/
|
||||||
add(objectArg: T): boolean {
|
public add(objectArg: T): boolean {
|
||||||
if (this.checkForObject(objectArg)) {
|
if (this.checkForObject(objectArg)) {
|
||||||
// the object is already in the objectmap
|
// the object is already in the objectmap
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// the object is not yet in the objectmap
|
// the object is not yet in the objectmap
|
||||||
this.objectArray.push(objectArg);
|
this.objectArray.push(objectArg);
|
||||||
|
this.eventSubject.next('add');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,7 +44,7 @@ export class Objectmap<T> {
|
|||||||
/**
|
/**
|
||||||
* like .add but adds an whole array of objects
|
* like .add but adds an whole array of objects
|
||||||
*/
|
*/
|
||||||
addArray(objectArrayArg: T[]) {
|
public addArray(objectArrayArg: T[]) {
|
||||||
for (let item of objectArrayArg) {
|
for (let item of objectArrayArg) {
|
||||||
this.add(item);
|
this.add(item);
|
||||||
}
|
}
|
||||||
@ -49,15 +53,15 @@ export class Objectmap<T> {
|
|||||||
/**
|
/**
|
||||||
* check if object is in Objectmap
|
* check if object is in Objectmap
|
||||||
*/
|
*/
|
||||||
checkForObject(objectArg: T) {
|
public checkForObject(objectArg: T) {
|
||||||
return this.objectArray.indexOf(objectArg) !== -1;
|
return this.objectArray.indexOf(objectArg) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find object
|
* find object
|
||||||
*/
|
*/
|
||||||
find(findFunction: IObjectmapFindFunction<T>) {
|
public find(findFunction: IObjectmapFindFunction<T>) {
|
||||||
let resultArray = this.objectArray.filter(findFunction);
|
const resultArray = this.objectArray.filter(findFunction);
|
||||||
if (resultArray.length > 0) {
|
if (resultArray.length > 0) {
|
||||||
return resultArray[0];
|
return resultArray[0];
|
||||||
} else {
|
} else {
|
||||||
@ -68,8 +72,8 @@ export class Objectmap<T> {
|
|||||||
/**
|
/**
|
||||||
* finds a specific element and then removes it
|
* finds a specific element and then removes it
|
||||||
*/
|
*/
|
||||||
findOneAndRemove(findFunction: IObjectmapFindFunction<T>): T {
|
public findOneAndRemove(findFunction: IObjectmapFindFunction<T>): T {
|
||||||
let foundElement = this.find(findFunction);
|
const foundElement = this.find(findFunction);
|
||||||
if (foundElement) {
|
if (foundElement) {
|
||||||
this.remove(foundElement);
|
this.remove(foundElement);
|
||||||
}
|
}
|
||||||
@ -79,7 +83,7 @@ export class Objectmap<T> {
|
|||||||
/**
|
/**
|
||||||
* run function for each item in Objectmap
|
* run function for each item in Objectmap
|
||||||
*/
|
*/
|
||||||
async forEach(functionArg: IObjectmapForEachFunction<T>) {
|
public async forEach(functionArg: IObjectmapForEachFunction<T>) {
|
||||||
for (let object of this.objectArray) {
|
for (let object of this.objectArray) {
|
||||||
await functionArg(object);
|
await functionArg(object);
|
||||||
}
|
}
|
||||||
@ -88,21 +92,27 @@ export class Objectmap<T> {
|
|||||||
/**
|
/**
|
||||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||||
*/
|
*/
|
||||||
getOneAndRemove(): T {
|
public getOneAndRemove(): T {
|
||||||
return this.objectArray.shift();
|
const removedItem = this.objectArray.shift();
|
||||||
|
this.eventSubject.next('remove');
|
||||||
|
return removedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a cloned array of all the objects currently in the Objectmap
|
* returns a cloned array of all the objects currently in the Objectmap
|
||||||
*/
|
*/
|
||||||
getArray() {
|
public getArray(): T[] {
|
||||||
return plugins.lodash.cloneDeep(this.objectArray);
|
const returnArray: any[] = [];
|
||||||
|
for (const objectItem of this.objectArray) {
|
||||||
|
returnArray.push(objectItem);
|
||||||
|
}
|
||||||
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if Objectmap ist empty
|
* check if Objectmap ist empty
|
||||||
*/
|
*/
|
||||||
isEmpty(): boolean {
|
public isEmpty(): boolean {
|
||||||
if (this.objectArray.length === 0) {
|
if (this.objectArray.length === 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -113,7 +123,7 @@ export class Objectmap<T> {
|
|||||||
/**
|
/**
|
||||||
* remove object from Objectmap
|
* remove object from Objectmap
|
||||||
*/
|
*/
|
||||||
remove(objectArg: T) {
|
public remove(objectArg: T) {
|
||||||
let replacementArray = [];
|
let replacementArray = [];
|
||||||
for (let item of this.objectArray) {
|
for (let item of this.objectArray) {
|
||||||
if (item !== objectArg) {
|
if (item !== objectArg) {
|
||||||
@ -121,12 +131,14 @@ export class Objectmap<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.objectArray = replacementArray;
|
this.objectArray = replacementArray;
|
||||||
|
this.eventSubject.next('remove');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wipe Objectmap
|
* wipe Objectmap
|
||||||
*/
|
*/
|
||||||
wipe() {
|
public wipe() {
|
||||||
this.objectArray = [];
|
this.objectArray = [];
|
||||||
|
this.eventSubject.next('wiped');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,25 @@
|
|||||||
import * as events from "events";
|
// ==============
|
||||||
import * as lodash from "lodash";
|
// native
|
||||||
import * as minimatch from "minimatch";
|
// ==============
|
||||||
import * as smartq from "smartq";
|
|
||||||
const symbolTree = require("symbol-tree");
|
|
||||||
|
|
||||||
export { events, lodash, minimatch, smartq, symbolTree };
|
import * as events from 'events';
|
||||||
|
|
||||||
|
export { events };
|
||||||
|
|
||||||
|
// ==============
|
||||||
|
// @pushrocks
|
||||||
|
// ==============
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
|
import * as smarttime from '@pushrocks/smarttime';
|
||||||
|
|
||||||
|
export { smartdelay, smartpromise, smartrx, smarttime };
|
||||||
|
|
||||||
|
// ==============
|
||||||
|
// third party
|
||||||
|
// ==============
|
||||||
|
import minimatch from 'minimatch';
|
||||||
|
const symbolTree = require('symbol-tree');
|
||||||
|
|
||||||
|
export { minimatch, symbolTree };
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allows you to easily keep track of a bunch of strings
|
* allows you to easily keep track of a bunch of strings
|
||||||
@ -52,14 +52,14 @@ export class Stringmap {
|
|||||||
/**
|
/**
|
||||||
* check if string is in Stringmap
|
* check if string is in Stringmap
|
||||||
*/
|
*/
|
||||||
checkString(stringArg: string): boolean {
|
public checkString(stringArg: string): boolean {
|
||||||
return this._stringArray.indexOf(stringArg) !== -1;
|
return this._stringArray.indexOf(stringArg) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks stringPresence with minimatch
|
* checks stringPresence with minimatch
|
||||||
*/
|
*/
|
||||||
checkMinimatch(miniMatchStringArg: string): boolean {
|
public checkMinimatch(miniMatchStringArg: string): boolean {
|
||||||
let foundMatch: boolean = false;
|
let foundMatch: boolean = false;
|
||||||
for (let stringItem of this._stringArray) {
|
for (let stringItem of this._stringArray) {
|
||||||
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
||||||
@ -72,15 +72,19 @@ export class Stringmap {
|
|||||||
/**
|
/**
|
||||||
* checks if the Stringmap is empty
|
* checks if the Stringmap is empty
|
||||||
*/
|
*/
|
||||||
checkIsEmpty() {
|
public checkIsEmpty() {
|
||||||
return this._stringArray.length === 0;
|
return this._stringArray.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a cloned copy of the current string Array
|
* gets a cloned copy of the current string Array
|
||||||
*/
|
*/
|
||||||
getStringArray() {
|
public getStringArray() {
|
||||||
return plugins.lodash.cloneDeep(this._stringArray);
|
const returnArray: string[] = [];
|
||||||
|
for (const stringItem of this._stringArray) {
|
||||||
|
returnArray.push(stringItem);
|
||||||
|
}
|
||||||
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger registering
|
// trigger registering
|
||||||
@ -88,7 +92,7 @@ export class Stringmap {
|
|||||||
/**
|
/**
|
||||||
* register a new trigger
|
* register a new trigger
|
||||||
*/
|
*/
|
||||||
registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) {
|
public registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) {
|
||||||
this._triggerUntilTrueFunctionArray.push(() => {
|
this._triggerUntilTrueFunctionArray.push(() => {
|
||||||
let result = functionArg();
|
let result = functionArg();
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
@ -103,11 +107,9 @@ export class Stringmap {
|
|||||||
* notifies triggers
|
* notifies triggers
|
||||||
*/
|
*/
|
||||||
private notifyTrigger() {
|
private notifyTrigger() {
|
||||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter(
|
let filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
||||||
functionArg => {
|
|
||||||
return !functionArg();
|
return !functionArg();
|
||||||
}
|
});
|
||||||
);
|
|
||||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
ts/lik.timedaggregator.ts
Normal file
41
ts/lik.timedaggregator.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
export class Tree<T> {
|
export class Tree<T> {
|
||||||
symbolTree: any;
|
symbolTree: any;
|
||||||
@ -6,6 +6,10 @@ export class Tree<T> {
|
|||||||
this.symbolTree = new plugins.symbolTree();
|
this.symbolTree = new plugins.symbolTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================
|
||||||
|
// Functions that map to the functionality of symbol-tree
|
||||||
|
// =======================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param objectArg
|
* @param objectArg
|
||||||
@ -51,7 +55,7 @@ export class Tree<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
childrenToArray(parentArg: T, optionsArg: any): T[] {
|
childrenToArray(parentArg: T, optionsArg: any): T[] {
|
||||||
return this.symbolTree.childrenToArray(parent, optionsArg);
|
return this.symbolTree.childrenToArray(parentArg, optionsArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
ancestorsToArray(objectArg: T, optionsArg: any): T[] {
|
ancestorsToArray(objectArg: T, optionsArg: any): T[] {
|
||||||
@ -78,7 +82,7 @@ export class Tree<T> {
|
|||||||
this.symbolTree.ancestorsIterator();
|
this.symbolTree.ancestorsIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
treeIterator(rootArg: T, optionsArg): T {
|
treeIterator(rootArg: T, optionsArg): Iterable<T> {
|
||||||
return this.symbolTree.treeIterator(rootArg);
|
return this.symbolTree.treeIterator(rootArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,4 +117,25 @@ export class Tree<T> {
|
|||||||
appendChild(referenceObjectArg, newObjectArg) {
|
appendChild(referenceObjectArg, newObjectArg) {
|
||||||
return this.symbolTree.appendChild(referenceObjectArg, newObjectArg);
|
return this.symbolTree.appendChild(referenceObjectArg, newObjectArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================
|
||||||
|
// Functionionality that extends symbol-tree
|
||||||
|
// ===========================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a branch of the tree as JSON
|
||||||
|
* can be user
|
||||||
|
*/
|
||||||
|
toJsonWithHierachy(rootElement) {
|
||||||
|
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) {}
|
||||||
}
|
}
|
||||||
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
265
yarn.lock
265
yarn.lock
@ -1,265 +0,0 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
"@types/code@^4.0.3":
|
|
||||||
version "4.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/code/-/code-4.0.3.tgz#9c4de39f86eb3eba070146d2dab7dbc3f8eac35f"
|
|
||||||
|
|
||||||
"@types/lodash@^4.14.97":
|
|
||||||
version "4.14.97"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.97.tgz#7262d6d5fc5e87cdb3f68eb33accd4024f2b211e"
|
|
||||||
|
|
||||||
"@types/minimatch@^3.0.3":
|
|
||||||
version "3.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
|
|
||||||
|
|
||||||
"@types/node@^8.0.33":
|
|
||||||
version "8.5.9"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.9.tgz#7155cfb4ae405bca4dd8df1a214c339e939109bf"
|
|
||||||
|
|
||||||
"@types/node@^9.4.0":
|
|
||||||
version "9.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.0.tgz#b85a0bcf1e1cc84eb4901b7e96966aedc6f078d1"
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
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.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.11.tgz#71c5568d5a7ed5c144d3a54f753ad1b08862aea5"
|
|
||||||
dependencies:
|
|
||||||
ansi-256-colors "^1.1.0"
|
|
||||||
typings-global "^1.0.14"
|
|
||||||
|
|
||||||
bindings@^1.2.1:
|
|
||||||
version "1.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
code@^5.1.0:
|
|
||||||
version "5.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/code/-/code-5.1.2.tgz#e3310c2078ca7dc0b49b9c39a8b0a7b06bd75efe"
|
|
||||||
dependencies:
|
|
||||||
hoek "5.x.x"
|
|
||||||
|
|
||||||
concat-map@0.0.1:
|
|
||||||
version "0.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
|
||||||
|
|
||||||
conventional-commit-types@^2.0.0:
|
|
||||||
version "2.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/conventional-commit-types/-/conventional-commit-types-2.2.0.tgz#5db95739d6c212acbe7b6f656a11b940baa68946"
|
|
||||||
|
|
||||||
cz-conventional-changelog@^2.1.0:
|
|
||||||
version "2.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/cz-conventional-changelog/-/cz-conventional-changelog-2.1.0.tgz#2f4bc7390e3244e4df293e6ba351e4c740a7c764"
|
|
||||||
dependencies:
|
|
||||||
conventional-commit-types "^2.0.0"
|
|
||||||
lodash.map "^4.5.1"
|
|
||||||
longest "^1.0.1"
|
|
||||||
right-pad "^1.0.1"
|
|
||||||
word-wrap "^1.0.3"
|
|
||||||
|
|
||||||
define-properties@^1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
|
|
||||||
dependencies:
|
|
||||||
foreach "^2.0.5"
|
|
||||||
object-keys "^1.0.8"
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
es-abstract@^1.5.1:
|
|
||||||
version "1.10.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
|
|
||||||
dependencies:
|
|
||||||
es-to-primitive "^1.1.1"
|
|
||||||
function-bind "^1.1.1"
|
|
||||||
has "^1.0.1"
|
|
||||||
is-callable "^1.1.3"
|
|
||||||
is-regex "^1.0.4"
|
|
||||||
|
|
||||||
es-to-primitive@^1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
|
|
||||||
dependencies:
|
|
||||||
is-callable "^1.1.1"
|
|
||||||
is-date-object "^1.0.1"
|
|
||||||
is-symbol "^1.0.1"
|
|
||||||
|
|
||||||
es6-error@^4.0.2:
|
|
||||||
version "4.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
|
|
||||||
|
|
||||||
foreach@^2.0.5:
|
|
||||||
version "2.0.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
|
|
||||||
|
|
||||||
function-bind@^1.0.2, function-bind@^1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
|
|
||||||
|
|
||||||
has@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
|
|
||||||
dependencies:
|
|
||||||
function-bind "^1.0.2"
|
|
||||||
|
|
||||||
hoek@5.x.x:
|
|
||||||
version "5.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.2.tgz#d2f2c95d36fe7189cf8aa8c237abc1950eca1378"
|
|
||||||
|
|
||||||
is-callable@^1.1.1, is-callable@^1.1.3:
|
|
||||||
version "1.1.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
|
|
||||||
|
|
||||||
is-date-object@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
|
|
||||||
|
|
||||||
is-regex@^1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
|
|
||||||
dependencies:
|
|
||||||
has "^1.0.1"
|
|
||||||
|
|
||||||
is-symbol@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
|
|
||||||
|
|
||||||
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.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
|
|
||||||
|
|
||||||
lodash.map@^4.5.1:
|
|
||||||
version "4.6.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
|
|
||||||
|
|
||||||
lodash@^4.17.4:
|
|
||||||
version "4.17.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
|
||||||
|
|
||||||
longest@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
|
|
||||||
|
|
||||||
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.8.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"
|
|
||||||
|
|
||||||
object-keys@^1.0.8:
|
|
||||||
version "1.0.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
|
|
||||||
|
|
||||||
object.getownpropertydescriptors@^2.0.3:
|
|
||||||
version "2.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
|
|
||||||
dependencies:
|
|
||||||
define-properties "^1.1.2"
|
|
||||||
es-abstract "^1.5.1"
|
|
||||||
|
|
||||||
pretty-bytes@^4.0.2:
|
|
||||||
version "4.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
|
|
||||||
|
|
||||||
right-pad@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/right-pad/-/right-pad-1.0.1.tgz#8ca08c2cbb5b55e74dafa96bf7fd1a27d568c8d0"
|
|
||||||
|
|
||||||
smartchai@^1.0.3:
|
|
||||||
version "1.0.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.8.tgz#a074836f4ddd4b98c50f1e7ae9e8e8ad9f6f1902"
|
|
||||||
dependencies:
|
|
||||||
"@types/code" "^4.0.3"
|
|
||||||
code "^5.1.0"
|
|
||||||
typings-global "^1.0.20"
|
|
||||||
|
|
||||||
smartdelay@^1.0.3:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartdelay/-/smartdelay-1.0.4.tgz#791c1a4ee6770494064c10b1d2d2b8e6f3105b82"
|
|
||||||
dependencies:
|
|
||||||
smartq "^1.1.1"
|
|
||||||
typings-global "^1.0.16"
|
|
||||||
|
|
||||||
smartq@^1.1.1, smartq@^1.1.6:
|
|
||||||
version "1.1.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
|
|
||||||
dependencies:
|
|
||||||
typings-global "^1.0.19"
|
|
||||||
util.promisify "^1.0.0"
|
|
||||||
|
|
||||||
symbol-tree@^3.2.2:
|
|
||||||
version "3.2.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
|
|
||||||
|
|
||||||
tapbundle@^1.1.1:
|
|
||||||
version "1.1.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.1.8.tgz#e08aee0e100a830d8a26a583a85d37ce53312e02"
|
|
||||||
dependencies:
|
|
||||||
"@types/node" "^8.0.33"
|
|
||||||
early "^2.1.1"
|
|
||||||
leakage "^0.3.0"
|
|
||||||
smartchai "^1.0.3"
|
|
||||||
smartdelay "^1.0.3"
|
|
||||||
smartq "^1.1.1"
|
|
||||||
typings-global "^1.0.19"
|
|
||||||
|
|
||||||
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19, typings-global@^1.0.20:
|
|
||||||
version "1.0.28"
|
|
||||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.28.tgz#e28cc965476564cbc00e438739e0aa0735d323d4"
|
|
||||||
|
|
||||||
util.promisify@^1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
|
|
||||||
dependencies:
|
|
||||||
define-properties "^1.1.2"
|
|
||||||
object.getownpropertydescriptors "^2.0.3"
|
|
||||||
|
|
||||||
word-wrap@^1.0.3:
|
|
||||||
version "1.2.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
|
|
Reference in New Issue
Block a user