now works with TypeScript Generic Types to track type usage of Objectmap
This commit is contained in:
parent
ba714fe637
commit
b85e79b07d
20
dist/lik.objectmap.d.ts
vendored
20
dist/lik.objectmap.d.ts
vendored
@ -1,13 +1,13 @@
|
|||||||
export interface IObjectmapForEachFunction {
|
export interface IObjectmapForEachFunction<T> {
|
||||||
(itemArg: any): void;
|
(itemArg: T): void;
|
||||||
}
|
}
|
||||||
export interface IObjectmapFindFunction {
|
export interface IObjectmapFindFunction<T> {
|
||||||
(itemArg: any): boolean;
|
(itemArg: T): boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* allows keeping track of objects
|
* allows keeping track of objects
|
||||||
*/
|
*/
|
||||||
export declare class Objectmap {
|
export declare class Objectmap<T> {
|
||||||
private objectArray;
|
private objectArray;
|
||||||
/**
|
/**
|
||||||
* returns a new instance
|
* returns a new instance
|
||||||
@ -16,23 +16,23 @@ export declare class Objectmap {
|
|||||||
/**
|
/**
|
||||||
* add object to Objectmap
|
* add object to Objectmap
|
||||||
*/
|
*/
|
||||||
add(objectArg: any): void;
|
add(objectArg: T): void;
|
||||||
/**
|
/**
|
||||||
* remove object from Objectmap
|
* remove object from Objectmap
|
||||||
*/
|
*/
|
||||||
remove(objectArg: any): void;
|
remove(objectArg: T): void;
|
||||||
/**
|
/**
|
||||||
* check if object is in Objectmap
|
* check if object is in Objectmap
|
||||||
*/
|
*/
|
||||||
checkForObject(objectArg: any): number;
|
checkForObject(objectArg: T): boolean;
|
||||||
/**
|
/**
|
||||||
* find object
|
* find object
|
||||||
*/
|
*/
|
||||||
find(findFunction: IObjectmapFindFunction): any;
|
find(findFunction: IObjectmapFindFunction<T>): T;
|
||||||
/**
|
/**
|
||||||
* run function for each item in Objectmap
|
* run function for each item in Objectmap
|
||||||
*/
|
*/
|
||||||
forEach(functionArg: IObjectmapForEachFunction): void;
|
forEach(functionArg: IObjectmapForEachFunction<T>): void;
|
||||||
/**
|
/**
|
||||||
* wipe Objectmap
|
* wipe Objectmap
|
||||||
*/
|
*/
|
||||||
|
5
dist/lik.objectmap.js
vendored
5
dist/lik.objectmap.js
vendored
@ -37,7 +37,7 @@ class Objectmap {
|
|||||||
* check if object is in Objectmap
|
* check if object is in Objectmap
|
||||||
*/
|
*/
|
||||||
checkForObject(objectArg) {
|
checkForObject(objectArg) {
|
||||||
return this.objectArray.indexOf(objectArg !== -1);
|
return this.objectArray.indexOf(objectArg) !== -1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
/**
|
/**
|
||||||
@ -59,6 +59,7 @@ class Objectmap {
|
|||||||
forEach(functionArg) {
|
forEach(functionArg) {
|
||||||
return this.objectArray.forEach(functionArg);
|
return this.objectArray.forEach(functionArg);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
/**
|
/**
|
||||||
* wipe Objectmap
|
* wipe Objectmap
|
||||||
*/
|
*/
|
||||||
@ -67,4 +68,4 @@ class Objectmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Objectmap = Objectmap;
|
exports.Objectmap = Objectmap;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUtDLENBQUM7QUFJRCxDQUFDO0FBR0Y7O0dBRUc7QUFDSDtJQUdJOztPQUVHO0lBQ0g7UUFMUSxnQkFBVyxHQUFHLEVBQUUsQ0FBQztJQU96QixDQUFDOztJQUdEOztPQUVHO0lBQ0gsR0FBRyxDQUFDLFNBQVM7UUFDVCxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNyQyxDQUFDOztJQUVEOztPQUVHO0lBQ0gsTUFBTSxDQUFDLFNBQVM7UUFDWixJQUFJLGVBQWUsR0FBRyxFQUFFLENBQUM7UUFD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QTtJQUNyRCxDQUFDOztJQUdEOztPQUVHO0lBQ0gsSUFBSSxDQUFDLFlBQXVDO1FBQ3hDLElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLFlBQVksQ0FBQyxDQUFDO1FBQ3hELEVBQUUsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUN6QixNQUFNLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzFCLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE1BQU0sQ0FBQyxTQUFTLENBQUM7UUFDckIsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBR0Q7O09BRUc7SUFDSCxPQUFPLENBQUMsV0FBeUM7UUFDN0MsTUFBTSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ2pELENBQUM7O0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0EsSUFBSSxDQUFDLFdBQVcsR0FBRyxFQUFFLENBQUM7SUFDMUIsQ0FBQztBQUNMLENBQUM7QUFqRVksaUJBQVMsWUFpRXJCLENBQUEifQ==
|
@ -1,20 +1,20 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from "./lik.plugins";
|
||||||
|
|
||||||
|
|
||||||
export interface IObjectmapForEachFunction {
|
export interface IObjectmapForEachFunction<T> {
|
||||||
(itemArg:any):void
|
(itemArg: T): void
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IObjectmapFindFunction {
|
export interface IObjectmapFindFunction<T> {
|
||||||
(itemArg:any):boolean
|
(itemArg: T): boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allows keeping track of objects
|
* allows keeping track of objects
|
||||||
*/
|
*/
|
||||||
export class Objectmap {
|
export class Objectmap<T> {
|
||||||
private objectArray = [];
|
private objectArray:T[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a new instance
|
* returns a new instance
|
||||||
@ -27,14 +27,14 @@ export class Objectmap {
|
|||||||
/**
|
/**
|
||||||
* add object to Objectmap
|
* add object to Objectmap
|
||||||
*/
|
*/
|
||||||
add(objectArg){
|
add(objectArg:T) {
|
||||||
this.objectArray.push(objectArg);
|
this.objectArray.push(objectArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove object from Objectmap
|
* remove object from Objectmap
|
||||||
*/
|
*/
|
||||||
remove(objectArg){
|
remove(objectArg:T) {
|
||||||
let replacmentArray = [];
|
let replacmentArray = [];
|
||||||
for (let item of this.objectArray) {
|
for (let item of this.objectArray) {
|
||||||
if (item !== objectArg) {
|
if (item !== objectArg) {
|
||||||
@ -47,15 +47,15 @@ export class Objectmap {
|
|||||||
/**
|
/**
|
||||||
* check if object is in Objectmap
|
* check if object is in Objectmap
|
||||||
*/
|
*/
|
||||||
checkForObject(objectArg){
|
checkForObject(objectArg:T) {
|
||||||
return this.objectArray.indexOf(objectArg !== -1)
|
return this.objectArray.indexOf(objectArg) !== -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find object
|
* find object
|
||||||
*/
|
*/
|
||||||
find(findFunction:IObjectmapFindFunction){
|
find(findFunction: IObjectmapFindFunction<T>) {
|
||||||
let resultArray = this.objectArray.filter(findFunction);
|
let resultArray = this.objectArray.filter(findFunction);
|
||||||
if (resultArray.length > 0) {
|
if (resultArray.length > 0) {
|
||||||
return resultArray[0];
|
return resultArray[0];
|
||||||
@ -68,9 +68,9 @@ export class Objectmap {
|
|||||||
/**
|
/**
|
||||||
* run function for each item in Objectmap
|
* run function for each item in Objectmap
|
||||||
*/
|
*/
|
||||||
forEach(functionArg:IObjectmapForEachFunction){
|
forEach(functionArg: IObjectmapForEachFunction<T>) {
|
||||||
return this.objectArray.forEach(functionArg);
|
return this.objectArray.forEach(functionArg);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wipe Objectmap
|
* wipe Objectmap
|
||||||
|
Loading…
Reference in New Issue
Block a user