Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
5159d7e4bf | |||
7b78aaea72 | |||
54a63d1f41 | |||
dd5a009d0f | |||
e7933cd7f4 | |||
56a8d9182b |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/lik",
|
||||
"version": "3.0.16",
|
||||
"version": "3.0.19",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/lik",
|
||||
"version": "3.0.16",
|
||||
"version": "3.0.19",
|
||||
"private": false,
|
||||
"description": "light little helpers for node",
|
||||
"main": "dist/index.js",
|
||||
|
@ -1,7 +1,4 @@
|
||||
import * as plugins from './lik.plugins';
|
||||
|
||||
// import modules
|
||||
|
||||
export * from './lik.fastmap';
|
||||
export * from './lik.interestmap';
|
||||
export * from './lik.limitedarray';
|
||||
export * from './lik.looptracker';
|
||||
|
@ -38,4 +38,8 @@ export class FastMap<T> {
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
public clean() {
|
||||
this.mapObject = {};
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
|
||||
*/
|
||||
public findInterest(objectArg: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> {
|
||||
const comparableString = this.comparisonFunc(objectArg);
|
||||
const interest = this.interestObjectMap.find(interest => {
|
||||
return interest.comparisonString === comparableString;
|
||||
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
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ export class Objectmap<T> {
|
||||
|
||||
/**
|
||||
* get key for object
|
||||
* @param findFunction
|
||||
* @param findFunction
|
||||
*/
|
||||
public getKeyForObject(objectArg: T) {
|
||||
let foundKey: string = null;
|
||||
@ -137,10 +137,14 @@ export class Objectmap<T> {
|
||||
*/
|
||||
public getOneAndRemove(): T {
|
||||
const keys = this.fastMap.getKeys();
|
||||
const keyToUse = keys[keys.length - 1];
|
||||
const removedItem = this.fastMap.removeFromMap(keyToUse);
|
||||
this.eventSubject.next('remove');
|
||||
return removedItem;
|
||||
if (keys.length === 0) {
|
||||
return null;
|
||||
} else {
|
||||
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()) {
|
||||
this.fastMap.removeFromMap(keyArg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user