fix(core): update
This commit is contained in:
parent
24559d1582
commit
da5bd43a42
9115
package-lock.json
generated
9115
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -7,7 +7,7 @@
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild && tsbundle npm)"
|
||||
"build": "(tsbuild --web && tsbundle npm)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -21,20 +21,20 @@
|
||||
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.24",
|
||||
"@gitzone/tsbundle": "^1.0.69",
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.2.1",
|
||||
"@types/node": "^14.0.5",
|
||||
"@gitzone/tsbundle": "^1.0.72",
|
||||
"@gitzone/tsrun": "^1.2.12",
|
||||
"@gitzone/tstest": "^1.0.41",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.0.22",
|
||||
"tslint": "^6.1.2",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.9",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartmatch": "^1.0.7",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartrx": "^2.0.15",
|
||||
"@pushrocks/smarttime": "^3.0.18",
|
||||
"@pushrocks/smartrx": "^2.0.17",
|
||||
"@pushrocks/smarttime": "^3.0.24",
|
||||
"@types/minimatch": "^3.0.3",
|
||||
"symbol-tree": "^3.2.4"
|
||||
},
|
||||
@ -49,5 +49,8 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
21
readme.md
21
readme.md
@ -8,13 +8,20 @@ light little helpers for node
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/lik/)
|
||||
|
||||
## Status for master
|
||||
[![pipeline status](https://gitlab.com/pushrocks/lik/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/lik/commits/master)
|
||||
[![coverage report](https://gitlab.com/pushrocks/lik/badges/master/coverage.svg)](https://gitlab.com/pushrocks/lik/commits/master)
|
||||
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/lik.svg)](https://www.npmjs.com/package/@pushrocks/lik)
|
||||
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/lik/badge.svg)](https://snyk.io/test/npm/@pushrocks/lik)
|
||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/lik/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/lik/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/lik)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/lik)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/lik)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/lik)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/lik)](https://lossless.cloud)
|
||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -4,7 +4,7 @@ import * as lik from '../ts/index';
|
||||
let testInterestmap: lik.InterestMap<number, number>;
|
||||
|
||||
tap.test('should create an interestmap', async () => {
|
||||
testInterestmap = new lik.InterestMap(numberArg => {
|
||||
testInterestmap = new lik.InterestMap((numberArg) => {
|
||||
return numberArg.toString();
|
||||
});
|
||||
});
|
||||
|
78
test/test.objectmap.browser.ts
Normal file
78
test/test.objectmap.browser.ts
Normal file
@ -0,0 +1,78 @@
|
||||
// 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';
|
||||
|
||||
// Objectmap
|
||||
interface ITestObject {
|
||||
propOne: string;
|
||||
propTwo: string;
|
||||
}
|
||||
let testObjectmap: lik.ObjectMap<ITestObject>;
|
||||
let testObject1: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
let testObject2: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
|
||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||
testObjectmap = new lik.ObjectMap<ITestObject>();
|
||||
expect(testObjectmap).be.instanceof(lik.ObjectMap);
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.add() -> should correctly add an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject1);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).be.true;
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).be.false;
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject2);
|
||||
testObjectmap.remove(testObject1);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).be.false;
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).be.true;
|
||||
});
|
||||
|
||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||
testObjectmap.forEach((itemArg) => {
|
||||
expect(itemArg).to.have.property('propOne');
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||
testObjectmap.add(myObject);
|
||||
let referenceObject = testObjectmap.find((itemArg) => {
|
||||
return itemArg.propOne === 'helloThere';
|
||||
});
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(myObject === referenceObject).be.true;
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () => {
|
||||
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' };
|
||||
testObjectmap.add(myObject);
|
||||
let clonedArray = testObjectmap.getArray();
|
||||
expect(clonedArray[clonedArray.length - 1]).to.eql(myObject);
|
||||
});
|
||||
|
||||
tap.test('should get one object and then remove it', async () => {
|
||||
let originalLength = testObjectmap.getArray().length;
|
||||
let oneObject = testObjectmap.getOneAndRemove();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(oneObject).not.be.null;
|
||||
expect(testObjectmap.getArray().length).equal(originalLength - 1);
|
||||
expect(testObjectmap.getArray()).to.not.contain(oneObject);
|
||||
});
|
||||
|
||||
tap.start();
|
@ -14,11 +14,11 @@ interface ITestObject {
|
||||
let testObjectmap: lik.ObjectMap<ITestObject>;
|
||||
let testObject1: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2'
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
let testObject2: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2'
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
|
||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||
@ -44,7 +44,7 @@ tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectm
|
||||
});
|
||||
|
||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||
testObjectmap.forEach(itemArg => {
|
||||
testObjectmap.forEach((itemArg) => {
|
||||
expect(itemArg).to.have.property('propOne');
|
||||
});
|
||||
});
|
||||
@ -52,7 +52,7 @@ tap.test('Objectmap.forEach -> should correctly run a function forEach map objec
|
||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||
testObjectmap.add(myObject);
|
||||
let referenceObject = testObjectmap.find(itemArg => {
|
||||
let referenceObject = testObjectmap.find((itemArg) => {
|
||||
return itemArg.propOne === 'helloThere';
|
||||
});
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
|
@ -8,12 +8,12 @@ import * as lik from '../ts/index';
|
||||
|
||||
let testTimedAggregator: lik.TimedAggregtor<string>;
|
||||
|
||||
tap.test('should create a timed aggregaotor', async tools => {
|
||||
tap.test('should create a timed aggregaotor', async (tools) => {
|
||||
testTimedAggregator = new lik.TimedAggregtor<string>({
|
||||
aggregationIntervalInMillis: 1000,
|
||||
functionForAggregation: aggregation => {
|
||||
functionForAggregation: (aggregation) => {
|
||||
console.log(aggregation);
|
||||
}
|
||||
},
|
||||
});
|
||||
testTimedAggregator.add('This');
|
||||
testTimedAggregator.add('is a whole sentence.');
|
||||
|
@ -1 +0,0 @@
|
||||
import './test.objectmap';
|
@ -60,7 +60,7 @@ export class FastMap<T> {
|
||||
|
||||
for (const key of fastMapArg.getKeys()) {
|
||||
concatedFastmap.addToMap(key, fastMapArg.getByKey(key), {
|
||||
force: true
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ export class FastMap<T> {
|
||||
public addAllFromOther(fastMapArg: FastMap<T>) {
|
||||
for (const key of fastMapArg.getKeys()) {
|
||||
this.addToMap(key, fastMapArg.getByKey(key), {
|
||||
force: true
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||
this.comparisonFunc
|
||||
);
|
||||
let interestExists = false;
|
||||
await this.interestObjectMap.forEach(interestArg => {
|
||||
await this.interestObjectMap.forEach((interestArg) => {
|
||||
if (!interestExists && interestArg.comparisonString === newInterest.comparisonString) {
|
||||
console.log('info', `interest already exists for ${newInterest.comparisonString}`);
|
||||
interestExists = true;
|
||||
@ -61,7 +61,7 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||
* @param objectArg removes an interest from the InterestMap
|
||||
*/
|
||||
public removeInterest(interestArg: Interest<DTInterestId, DTInterestFullfillment>) {
|
||||
const interestToRemove = this.interestObjectMap.findOneAndRemove(interestArg2 => {
|
||||
const interestToRemove = this.interestObjectMap.findOneAndRemove((interestArg2) => {
|
||||
return interestArg.comparisonString === interestArg2.comparisonString;
|
||||
});
|
||||
}
|
||||
@ -79,7 +79,7 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||
* @param comparisonStringArg
|
||||
*/
|
||||
public checkInterestByString(comparisonStringArg: string): boolean {
|
||||
const foundInterest = this.interestObjectMap.find(interest => {
|
||||
const foundInterest = this.interestObjectMap.find((interest) => {
|
||||
return interest.comparisonString === comparisonStringArg;
|
||||
});
|
||||
if (foundInterest) {
|
||||
@ -106,7 +106,7 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||
*/
|
||||
public findInterest(objectArg: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> {
|
||||
const comparableString = this.comparisonFunc(objectArg);
|
||||
const interest = this.interestObjectMap.find(interestArg => {
|
||||
const interest = this.interestObjectMap.find((interestArg) => {
|
||||
return interestArg.comparisonString === comparableString;
|
||||
});
|
||||
return interest; // if an interest is found, the interest is returned, otherwise interest is null
|
||||
|
@ -2,7 +2,7 @@ import * as plugins from './lik.plugins';
|
||||
import { FastMap } from './lik.fastmap';
|
||||
|
||||
export const uni = (prefix: string = 'uni') => {
|
||||
return `${prefix}xxxxxxxxxxx`.replace(/[xy]/g, c => {
|
||||
return `${prefix}xxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
|
@ -111,7 +111,7 @@ export class Stringmap {
|
||||
* notifies triggers
|
||||
*/
|
||||
private notifyTrigger() {
|
||||
const filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
||||
const filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||
return !functionArg();
|
||||
});
|
||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||
|
Loading…
Reference in New Issue
Block a user