fix(core): update

This commit is contained in:
2020-02-06 11:11:16 +00:00
parent e1442b1bc8
commit 596a897afc
10 changed files with 174 additions and 117 deletions

11
ts/lik.fastmap.ts Normal file
View 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;
}
}

View File

@ -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

View File

@ -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;