Compare commits

..

6 Commits

Author SHA1 Message Date
5159d7e4bf 3.0.19 2020-02-16 23:15:51 +00:00
7b78aaea72 fix(FastMap): added .clean() method 2020-02-16 23:15:50 +00:00
54a63d1f41 3.0.18 2020-02-15 21:25:50 +00:00
dd5a009d0f fix(core): update 2020-02-15 21:25:49 +00:00
e7933cd7f4 3.0.17 2020-02-07 16:32:58 +00:00
56a8d9182b fix(core): update 2020-02-07 16:32:58 +00:00
6 changed files with 18 additions and 14 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/lik", "name": "@pushrocks/lik",
"version": "3.0.16", "version": "3.0.19",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/lik", "name": "@pushrocks/lik",
"version": "3.0.16", "version": "3.0.19",
"private": false, "private": false,
"description": "light little helpers for node", "description": "light little helpers for node",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -1,7 +1,4 @@
import * as plugins from './lik.plugins'; export * from './lik.fastmap';
// import modules
export * from './lik.interestmap'; export * from './lik.interestmap';
export * from './lik.limitedarray'; export * from './lik.limitedarray';
export * from './lik.looptracker'; export * from './lik.looptracker';

View File

@ -38,4 +38,8 @@ export class FastMap<T> {
} }
return keys; return keys;
} }
public clean() {
this.mapObject = {};
}
} }

View File

@ -106,8 +106,8 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
*/ */
public findInterest(objectArg: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> { public findInterest(objectArg: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> {
const comparableString = this.comparisonFunc(objectArg); const comparableString = this.comparisonFunc(objectArg);
const interest = this.interestObjectMap.find(interest => { const interest = this.interestObjectMap.find(interestArg => {
return interest.comparisonString === comparableString; return interestArg.comparisonString === comparableString;
}); });
return interest; // if an interest is found, the interest is returned, otherwise interest is null return interest; // if an interest is found, the interest is returned, otherwise interest is null
} }

View File

@ -87,7 +87,7 @@ export class Objectmap<T> {
/** /**
* get key for object * get key for object
* @param findFunction * @param findFunction
*/ */
public getKeyForObject(objectArg: T) { public getKeyForObject(objectArg: T) {
let foundKey: string = null; let foundKey: string = null;
@ -137,10 +137,14 @@ export class Objectmap<T> {
*/ */
public getOneAndRemove(): T { public getOneAndRemove(): T {
const keys = this.fastMap.getKeys(); const keys = this.fastMap.getKeys();
const keyToUse = keys[keys.length - 1]; if (keys.length === 0) {
const removedItem = this.fastMap.removeFromMap(keyToUse); return null;
this.eventSubject.next('remove'); } else {
return removedItem; const keyToUse = keys[0];
const removedItem = this.fastMap.removeFromMap(keyToUse);
this.eventSubject.next('remove');
return removedItem;
}
} }
/** /**
@ -181,6 +185,5 @@ export class Objectmap<T> {
for (const keyArg of this.fastMap.getKeys()) { for (const keyArg of this.fastMap.getKeys()) {
this.fastMap.removeFromMap(keyArg); this.fastMap.removeFromMap(keyArg);
} }
} }
} }