From e3a811bffd954cb26792a5e15620220f70f1e24f Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Sun, 31 Jul 2016 00:54:46 +0200 Subject: [PATCH] added Objectmap --- dist/index.d.ts | 1 + dist/index.js | 3 ++- dist/lik.objectmap.d.ts | 10 ++++++++++ dist/lik.objectmap.js | 33 +++++++++++++++++++++++++++++++++ dist/lik.stringmap.js | 8 ++++---- test/test.js | 28 +++++++++++++++++++++++++++- test/test.ts | 30 ++++++++++++++++++++++++++++++ ts/index.ts | 3 ++- ts/lik.objectmap.ts | 26 ++++++++++++++++++++++++++ ts/lik.stringmap.ts | 6 +++--- 10 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 dist/lik.objectmap.d.ts create mode 100644 dist/lik.objectmap.js create mode 100644 ts/lik.objectmap.ts diff --git a/dist/index.d.ts b/dist/index.d.ts index 878e20c..f743eb0 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1 +1,2 @@ export * from "./lik.stringmap"; +export * from "./lik.objectmap"; diff --git a/dist/index.js b/dist/index.js index fdfcf48..06bec46 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4,4 +4,5 @@ function __export(m) { } // import modules __export(require("./lik.stringmap")); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWlCO0FBRWpCLGlCQUFjLGlCQUFpQixDQUFDLEVBQUEifQ== \ No newline at end of file +__export(require("./lik.objectmap")); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWlCO0FBRWpCLGlCQUFjLGlCQUFpQixDQUFDLEVBQUE7QUFDaEMsaUJBQWMsaUJBQWlCLENBQUMsRUFBQSJ9 \ No newline at end of file diff --git a/dist/lik.objectmap.d.ts b/dist/lik.objectmap.d.ts new file mode 100644 index 0000000..55ed66f --- /dev/null +++ b/dist/lik.objectmap.d.ts @@ -0,0 +1,10 @@ +/** + * allows keeping track of objects + */ +export declare class Objectmap { + private objectArray; + add(objectArg: any): void; + remove(objectArg: any): void; + checkForObject(objectArg: any): number; + wipe(): void; +} diff --git a/dist/lik.objectmap.js b/dist/lik.objectmap.js new file mode 100644 index 0000000..f8106e1 --- /dev/null +++ b/dist/lik.objectmap.js @@ -0,0 +1,33 @@ +"use strict"; +/** + * allows keeping track of objects + */ +class Objectmap { + constructor() { + this.objectArray = []; + } + add(objectArg) { + this.objectArray.push(objectArg); + } + ; + remove(objectArg) { + let replacmentArray = []; + for (let item of this.objectArray) { + if (item !== objectArg) { + replacmentArray.push(item); + } + } + ; + this.objectArray = replacmentArray; + } + ; + checkForObject(objectArg) { + return this.objectArray.indexOf(objectArg !== -1); + } + ; + wipe() { + this.objectArray = []; + } +} +exports.Objectmap = Objectmap; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVBOztHQUVHO0FBQ0g7SUFBQTtRQUNZLGdCQUFXLEdBQUcsRUFBRSxDQUFDO0lBbUI3QixDQUFDO0lBbEJHLEdBQUcsQ0FBQyxTQUFTO1FBQ1QsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDckMsQ0FBQzs7SUFDRCxNQUFNLENBQUMsU0FBUztRQUNaLElBQUksZUFBZSxHQUFHLEVBQUUsQ0FBQztRQUN6QixHQUFHLENBQUEsQ0FBQyxJQUFJLElBQUksSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUEsQ0FBQztZQUM5QixFQUFFLENBQUEsQ0FBQyxJQUFJLEtBQUssU0FBUyxDQUFDLENBQUEsQ0FBQztnQkFDbkIsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztZQUMvQixDQUFDO1FBQ0wsQ0FBQztRQUFBLENBQUM7UUFDRixJQUFJLENBQUMsV0FBVyxHQUFHLGVBQWUsQ0FBQztJQUN2QyxDQUFDOztJQUNELGNBQWMsQ0FBQyxTQUFTO1FBQ3BCLE1BQU0sQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQyxTQUFTLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUNyRCxDQUFDOztJQUNELElBQUk7UUFDQSxJQUFJLENBQUMsV0FBVyxHQUFHLEVBQUUsQ0FBQztJQUMxQixDQUFDO0FBQ0wsQ0FBQztBQXBCWSxpQkFBUyxZQW9CckIsQ0FBQSJ9 \ No newline at end of file diff --git a/dist/lik.stringmap.js b/dist/lik.stringmap.js index 10f4816..a5f096f 100644 --- a/dist/lik.stringmap.js +++ b/dist/lik.stringmap.js @@ -19,7 +19,7 @@ class Stringmap { */ removeString(stringArg) { for (let keyArg in this._stringArray) { - if (this._stringArray[keyArg] == stringArg) { + if (this._stringArray[keyArg] === stringArg) { this._stringArray.splice(parseInt(keyArg), 1); } ; @@ -59,7 +59,7 @@ class Stringmap { * checks if the Stringmap is empty */ checkIsEmpty() { - return (this._stringArray.length == 0); + return (this._stringArray.length === 0); } // trigger registering /** @@ -78,7 +78,7 @@ class Stringmap { registerUntilTrue(functionArg, doFunctionArg) { this._triggerUntilTrueFunctionArray.push(() => { let result = functionArg(); - if (result == true) { + if (result === true) { doFunctionArg(); } return result; @@ -87,4 +87,4 @@ class Stringmap { } } exports.Stringmap = Stringmap; -//# sourceMappingURL=data:application/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1BQU0sS0FBSyxDQUFDLENBQUMsQ0FBQztJQUM1QyxDQUFDO0lBRUQsc0JBQXNCO0lBRXRCOztPQUVHO0lBQ0ssYUFBYTtRQUNqQixJQUFJLGFBQWEsR0FBRyxJQUFJLENBQUMsOEJBQThCLENBQUMsTUFBTSxDQUFDLENBQUMsV0FBVztZQUN2RSxNQUFNLENBQUMsQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUMxQixDQUFDLENBQUMsQ0FBQztRQUNILElBQUksQ0FBQyw4QkFBOEIsR0FBRyxhQUFhLENBQUM7SUFDeEQsQ0FBQzs7SUFFRDs7T0FFRztJQUNILGlCQUFpQixDQUFDLFdBQTJCLEVBQUMsYUFBYTtRQUN2RCxJQUFJLENBQUMsOEJBQThCLENBQUMsSUFBSSxDQUNwQztZQUNJLElBQUksTUFBTSxHQUFHLFdBQVcsRUFBRSxDQUFDO1lBQzNCLEVBQUUsQ0FBQSxDQUFDLE1BQU0sS0FBSyxJQUFJLENBQUMsQ0FBQSxDQUFDO2dCQUNoQixhQUFhLEVBQUUsQ0FBQztZQUNwQixDQUFDO1lBQ0QsTUFBTSxDQUFDLE1BQU0sQ0FBQztRQUNsQixDQUFDLENBQ0osQ0FBQztRQUNGLElBQUksQ0FBQyxhQUFhLEVBQUUsQ0FBQztJQUN6QixDQUFDO0FBQ0wsQ0FBQztBQXhGWSxpQkFBUyxZQXdGckIsQ0FBQSJ9 \ No newline at end of file diff --git a/test/test.js b/test/test.js index 1ef7f3f..6318291 100644 --- a/test/test.js +++ b/test/test.js @@ -37,5 +37,31 @@ describe("lik", function () { testStringmap.wipe(); }); }); + describe("Objectmap", function () { + let testObjectmap; + let testObject1 = { + propOne: "hello", + propTwo: "hello2" + }; + let testObject2 = { + propOne: "hello", + propTwo: "hello2" + }; + it("should correctly instantiate an Objectmap", function () { + testObjectmap = new lik.Objectmap(); + testObjectmap.should.be.instanceof(lik.Objectmap); + }); + it("should correctly add an object to Objectmap", function () { + testObjectmap.add(testObject1); + testObjectmap.checkForObject(testObject1).should.be.true; + testObjectmap.checkForObject(testObject2).should.be.false; + }); + it("should correctly remove an object to Objectmap", function () { + testObjectmap.add(testObject2); + testObjectmap.remove(testObject1); + testObjectmap.checkForObject(testObject1).should.be.false; + testObjectmap.checkForObject(testObject2).should.be.true; + }); + }); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsTUFBTyxHQUFHLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDdEMsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixRQUFRLENBQUMsS0FBSyxFQUFDO0lBQ1gsUUFBUSxDQUFDLFdBQVcsRUFBQztRQUNqQixJQUFJLGFBQTJCLENBQUM7UUFDaEMsSUFBSSxXQUFXLEdBQUcsYUFBYSxDQUFDO1FBQ2hDLElBQUksV0FBVyxHQUFHLGFBQWEsQ0FBQztRQUNoQyxJQUFJLFdBQVcsR0FBRyxhQUFhLENBQUM7UUFDaEMsRUFBRSxDQUFDLHdDQUF3QyxFQUFDO1lBQ3hDLGFBQWEsR0FBRyxJQUFJLEdBQUcsQ0FBQyxTQUFTLEVBQUUsQ0FBQztZQUNwQyxhQUFhLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3RELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLG9EQUFvRCxFQUFDO1lBQ3BELGFBQWEsQ0FBQyxXQUFXLENBQUMsV0FBVyxDQUFDLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3RCxDQUFDLENBQUMsQ0FBQztRQUNILE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QyxhQUFhLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3RELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLDZDQUE2QyxFQUFDO1lBQzdDLGFBQWEsQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUM7WUFDL0IsYUFBYSxDQUFDLGNBQWMsQ0FBQyxXQUFXLENBQUMsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQztZQUN6RCxhQUFhLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDO1FBQzlELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLGdEQUFnRCxFQUFDO1lBQ2hELGFBQWEsQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUM7WUFDL0IsYUFBYSxDQUFDLE1BQU0sQ0FBQyxXQUFXLENBQUMsQ0FBQztZQUNsQyxhQUFhLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDO1lBQzFELGFBQWEsQ0FBQyxjQUFjLENBQUMsV0FBVyxDQUFDLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7UUFDN0QsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 17e861b..9dda828 100644 --- a/test/test.ts +++ b/test/test.ts @@ -39,5 +39,35 @@ describe("lik",function(){ it("should remove wipe and then notify",function(){ testStringmap.wipe(); }) + }); + describe("Objectmap",function(){ + interface ITestObject { + propOne:string; + propTwo:string; + } + let testObjectmap:lik.Objectmap; + let testObject1:ITestObject = { + propOne: "hello", + propTwo: "hello2" + }; + let testObject2:ITestObject = { + propOne: "hello", + propTwo: "hello2" + }; + it("should correctly instantiate an Objectmap",function(){ + testObjectmap = new lik.Objectmap(); + testObjectmap.should.be.instanceof(lik.Objectmap); + }); + it("should correctly add an object to Objectmap",function(){ + testObjectmap.add(testObject1); + testObjectmap.checkForObject(testObject1).should.be.true; + testObjectmap.checkForObject(testObject2).should.be.false; + }); + it("should correctly remove an object to Objectmap",function(){ + testObjectmap.add(testObject2); + testObjectmap.remove(testObject1); + testObjectmap.checkForObject(testObject1).should.be.false; + testObjectmap.checkForObject(testObject2).should.be.true; + }); }) }); \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index d2cee77..1816b45 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -2,4 +2,5 @@ import * as plugins from "./lik.plugins"; // import modules -export * from "./lik.stringmap"; \ No newline at end of file +export * from "./lik.stringmap"; +export * from "./lik.objectmap"; \ No newline at end of file diff --git a/ts/lik.objectmap.ts b/ts/lik.objectmap.ts new file mode 100644 index 0000000..dcf0fb4 --- /dev/null +++ b/ts/lik.objectmap.ts @@ -0,0 +1,26 @@ +import * as plugins from "./lik.plugins"; + +/** + * allows keeping track of objects + */ +export class Objectmap { + private objectArray = []; + add(objectArg){ + this.objectArray.push(objectArg); + }; + remove(objectArg){ + let replacmentArray = []; + for(let item of this.objectArray){ + if(item !== objectArg){ + replacmentArray.push(item); + } + }; + this.objectArray = replacmentArray; + }; + checkForObject(objectArg){ + return this.objectArray.indexOf(objectArg !== -1) + }; + wipe(){ + this.objectArray = []; + } +} \ No newline at end of file diff --git a/ts/lik.stringmap.ts b/ts/lik.stringmap.ts index e221165..6e61771 100644 --- a/ts/lik.stringmap.ts +++ b/ts/lik.stringmap.ts @@ -27,7 +27,7 @@ export class Stringmap { */ removeString(stringArg:string){ for (let keyArg in this._stringArray){ - if(this._stringArray[keyArg] == stringArg){ + if(this._stringArray[keyArg] === stringArg){ this._stringArray.splice(parseInt(keyArg),1); }; }; @@ -66,7 +66,7 @@ export class Stringmap { * checks if the Stringmap is empty */ checkIsEmpty(){ - return (this._stringArray.length == 0); + return (this._stringArray.length === 0); } // trigger registering @@ -88,7 +88,7 @@ export class Stringmap { this._triggerUntilTrueFunctionArray.push( () => { let result = functionArg(); - if(result == true){ + if(result === true){ doFunctionArg(); } return result;