fix(core): update
This commit is contained in:
11
ts/lik.fastmap.ts
Normal file
11
ts/lik.fastmap.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import * as plugins from './lik.plugins';
|
||||
|
||||
export class FastMap<T> {
|
||||
private mapObject: { [key: string]: T } = {};
|
||||
|
||||
public isUniqueKey() {}
|
||||
|
||||
public addToMap(identifier: string, objectArg: T) {
|
||||
this.mapObject[identifier] = objectArg;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import * as plugins from './lik.plugins';
|
||||
import { FastMap } from './lik.fastmap';
|
||||
|
||||
export interface IObjectmapForEachFunction<T> {
|
||||
(itemArg: T): void;
|
||||
@ -12,6 +13,7 @@ export interface IObjectmapFindFunction<T> {
|
||||
* allows keeping track of objects
|
||||
*/
|
||||
export class Objectmap<T> {
|
||||
private fastMap = new FastMap<T>();
|
||||
private objectArray: T[] = [];
|
||||
|
||||
// events
|
||||
@ -24,6 +26,27 @@ export class Objectmap<T> {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
/**
|
||||
* adds an object mapped to a string
|
||||
* the string must be unique
|
||||
*/
|
||||
addMappedUnique(uniqueKey: string, objectArg: T) {
|
||||
this.add(objectArg);
|
||||
this.fastMap.addToMap(uniqueKey, objectArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* fastest way to get an object from the map
|
||||
* @param uniqueKey
|
||||
*/
|
||||
public getMappedUnique(uniqueKey: string) {}
|
||||
|
||||
/**
|
||||
* remove key
|
||||
* @param functionArg
|
||||
*/
|
||||
public removeMappedUnique() {}
|
||||
|
||||
/**
|
||||
* add object to Objectmap
|
||||
* returns false if the object is already in the map
|
||||
|
@ -24,7 +24,7 @@ export class Stringmap {
|
||||
* like addString, but accepts an array of strings
|
||||
*/
|
||||
addStringArray(stringArrayArg: string[]) {
|
||||
for (let stringItem of stringArrayArg) {
|
||||
for (const stringItem of stringArrayArg) {
|
||||
this.addString(stringItem);
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@ export class Stringmap {
|
||||
* removes a string from Stringmap
|
||||
*/
|
||||
removeString(stringArg: string) {
|
||||
for (let keyArg in this._stringArray) {
|
||||
for (const keyArg in this._stringArray) {
|
||||
if (this._stringArray[keyArg] === stringArg) {
|
||||
this._stringArray.splice(parseInt(keyArg), 1);
|
||||
}
|
||||
@ -61,7 +61,7 @@ export class Stringmap {
|
||||
*/
|
||||
public checkMinimatch(miniMatchStringArg: string): boolean {
|
||||
let foundMatch: boolean = false;
|
||||
for (let stringItem of this._stringArray) {
|
||||
for (const stringItem of this._stringArray) {
|
||||
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
||||
foundMatch = true;
|
||||
}
|
||||
@ -94,7 +94,7 @@ export class Stringmap {
|
||||
*/
|
||||
public registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) {
|
||||
this._triggerUntilTrueFunctionArray.push(() => {
|
||||
let result = functionArg();
|
||||
const result = functionArg();
|
||||
if (result === true) {
|
||||
doFunctionArg();
|
||||
}
|
||||
@ -107,7 +107,7 @@ export class Stringmap {
|
||||
* notifies triggers
|
||||
*/
|
||||
private notifyTrigger() {
|
||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
||||
const filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
||||
return !functionArg();
|
||||
});
|
||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||
|
Reference in New Issue
Block a user