now adhering to standard js added getStringArray method
This commit is contained in:
parent
c0a5cb6e30
commit
e917c8b9f7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
docs/
|
pages/
|
||||||
|
public/
|
||||||
coverage/
|
coverage/
|
||||||
.nogit/
|
.nogit/
|
4
dist/index.d.ts
vendored
4
dist/index.d.ts
vendored
@ -1,2 +1,2 @@
|
|||||||
export * from "./lik.stringmap";
|
export * from './lik.stringmap';
|
||||||
export * from "./lik.objectmap";
|
export * from './lik.objectmap';
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -5,4 +5,4 @@ function __export(m) {
|
|||||||
// import modules
|
// import modules
|
||||||
__export(require("./lik.stringmap"));
|
__export(require("./lik.stringmap"));
|
||||||
__export(require("./lik.objectmap"));
|
__export(require("./lik.objectmap"));
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWlCO0FBRWpCLGlCQUFjLGlCQUFpQixDQUFDLEVBQUE7QUFDaEMsaUJBQWMsaUJBQWlCLENBQUMsRUFBQSJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWlCO0FBRWpCLHFDQUErQjtBQUMvQixxQ0FBK0IifQ==
|
11
dist/lik.objectmap.js
vendored
11
dist/lik.objectmap.js
vendored
@ -1,6 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
;
|
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* allows keeping track of objects
|
* allows keeping track of objects
|
||||||
*/
|
*/
|
||||||
@ -11,14 +9,12 @@ class Objectmap {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.objectArray = [];
|
this.objectArray = [];
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* add object to Objectmap
|
* add object to Objectmap
|
||||||
*/
|
*/
|
||||||
add(objectArg) {
|
add(objectArg) {
|
||||||
this.objectArray.push(objectArg);
|
this.objectArray.push(objectArg);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* remove object from Objectmap
|
* remove object from Objectmap
|
||||||
*/
|
*/
|
||||||
@ -29,17 +25,14 @@ class Objectmap {
|
|||||||
replacmentArray.push(item);
|
replacmentArray.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
|
||||||
this.objectArray = replacmentArray;
|
this.objectArray = replacmentArray;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* 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;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* find object
|
* find object
|
||||||
*/
|
*/
|
||||||
@ -51,7 +44,6 @@ class Objectmap {
|
|||||||
else {
|
else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* run function for each item in Objectmap
|
* run function for each item in Objectmap
|
||||||
@ -59,7 +51,6 @@ class Objectmap {
|
|||||||
forEach(functionArg) {
|
forEach(functionArg) {
|
||||||
return this.objectArray.forEach(functionArg);
|
return this.objectArray.forEach(functionArg);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* wipe Objectmap
|
* wipe Objectmap
|
||||||
*/
|
*/
|
||||||
@ -68,4 +59,4 @@ class Objectmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Objectmap = Objectmap;
|
exports.Objectmap = Objectmap;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUtDLENBQUM7QUFJRCxDQUFDO0FBR0Y7O0dBRUc7QUFDSDtJQUdJOztPQUVHO0lBQ0g7UUFMUSxnQkFBVyxHQUFPLEVBQUUsQ0FBQztJQU83QixDQUFDOztJQUdEOztPQUVHO0lBQ0gsR0FBRyxDQUFDLFNBQVc7UUFDWCxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNyQyxDQUFDOztJQUVEOztPQUVHO0lBQ0gsTUFBTSxDQUFDLFNBQVc7UUFDZCxJQUFJLGVBQWUsR0FBRyxFQUFFLENBQUM7UUFDekIsR0FBRyxDQUFDLENBQUMsSUFBSSxJQUFJLElBQUksSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUM7WUFDaEMsRUFBRSxDQUFDLENBQUMsSUFBSSxLQUFLLFNBQVMsQ0FBQyxDQUFDLENBQUM7Z0JBQ3JCLGVBQWUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDL0IsQ0FBQztRQUNMLENBQUM7UUFBQSxDQUFDO1FBQ0YsSUFBSSxDQUFDLFdBQVcsR0FBRyxlQUFlLENBQUM7SUFDdkMsQ0FBQzs7SUFFRDs7T0FFRztJQUNILGNBQWMsQ0FBQyxTQUFXO1FBQ3RCLE1BQU0sQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0F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FDLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQTtJQUNoRCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0EsSUFBSSxDQUFDLFdBQVcsR0FBRyxFQUFFLENBQUE7SUFDekIsQ0FBQztDQUNKO0FBOURELDhCQThEQyJ9
|
7
dist/lik.plugins.d.ts
vendored
7
dist/lik.plugins.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
export import q = require("q");
|
export import q = require('q');
|
||||||
export import minimatch = require("minimatch");
|
export import lodash = require('lodash');
|
||||||
|
export import minimatch = require('minimatch');
|
||||||
|
3
dist/lik.plugins.js
vendored
3
dist/lik.plugins.js
vendored
@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.q = require("q");
|
exports.q = require("q");
|
||||||
|
exports.lodash = require("lodash");
|
||||||
exports.minimatch = require("minimatch");
|
exports.minimatch = require("minimatch");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsU0FBQyxXQUFXLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMifQ==
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLHlCQUE4QjtBQUM5QixtQ0FBd0M7QUFDeEMseUNBQThDIn0=
|
14
dist/lik.stringmap.d.ts
vendored
14
dist/lik.stringmap.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* allows you to easily keep track of a bunch of strings;
|
* allows you to easily keep track of a bunch of strings
|
||||||
*/
|
*/
|
||||||
export interface triggerFunction {
|
export interface ITriggerFunction {
|
||||||
(): boolean;
|
(): boolean;
|
||||||
}
|
}
|
||||||
export declare class Stringmap {
|
export declare class Stringmap {
|
||||||
@ -33,11 +33,15 @@ export declare class Stringmap {
|
|||||||
*/
|
*/
|
||||||
checkIsEmpty(): boolean;
|
checkIsEmpty(): boolean;
|
||||||
/**
|
/**
|
||||||
* notifies triggers
|
* gets a cloned copy of the current string Array
|
||||||
*/
|
*/
|
||||||
private notifyTrigger();
|
getStringArray(): string[];
|
||||||
/**
|
/**
|
||||||
* register a new trigger
|
* register a new trigger
|
||||||
*/
|
*/
|
||||||
registerUntilTrue(functionArg: triggerFunction, doFunctionArg: any): void;
|
registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg: any): void;
|
||||||
|
/**
|
||||||
|
* notifies triggers
|
||||||
|
*/
|
||||||
|
private notifyTrigger();
|
||||||
}
|
}
|
||||||
|
32
dist/lik.stringmap.js
vendored
32
dist/lik.stringmap.js
vendored
@ -5,7 +5,6 @@ class Stringmap {
|
|||||||
this._stringArray = [];
|
this._stringArray = [];
|
||||||
this._triggerUntilTrueFunctionArray = [];
|
this._triggerUntilTrueFunctionArray = [];
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* add a string to the Stringmap
|
* add a string to the Stringmap
|
||||||
*/
|
*/
|
||||||
@ -13,7 +12,6 @@ class Stringmap {
|
|||||||
this._stringArray.push(stringArg);
|
this._stringArray.push(stringArg);
|
||||||
this.notifyTrigger();
|
this.notifyTrigger();
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* removes a string from Stringmap
|
* removes a string from Stringmap
|
||||||
*/
|
*/
|
||||||
@ -22,9 +20,7 @@ class Stringmap {
|
|||||||
if (this._stringArray[keyArg] === stringArg) {
|
if (this._stringArray[keyArg] === stringArg) {
|
||||||
this._stringArray.splice(parseInt(keyArg), 1);
|
this._stringArray.splice(parseInt(keyArg), 1);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
;
|
|
||||||
this.notifyTrigger();
|
this.notifyTrigger();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -38,7 +34,7 @@ class Stringmap {
|
|||||||
* check if string is in Stringmap
|
* check if string is in Stringmap
|
||||||
*/
|
*/
|
||||||
checkString(stringArg) {
|
checkString(stringArg) {
|
||||||
return this._stringArray.indexOf(stringArg) != -1;
|
return this._stringArray.indexOf(stringArg) !== -1;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* checks stringPresence with minimatch
|
* checks stringPresence with minimatch
|
||||||
@ -49,29 +45,22 @@ class Stringmap {
|
|||||||
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
||||||
foundMatch = true;
|
foundMatch = true;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
;
|
|
||||||
return foundMatch;
|
return foundMatch;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
/**
|
/**
|
||||||
* checks if the Stringmap is empty
|
* checks if the Stringmap is empty
|
||||||
*/
|
*/
|
||||||
checkIsEmpty() {
|
checkIsEmpty() {
|
||||||
return (this._stringArray.length === 0);
|
return (this._stringArray.length === 0);
|
||||||
}
|
}
|
||||||
// trigger registering
|
|
||||||
/**
|
/**
|
||||||
* notifies triggers
|
* gets a cloned copy of the current string Array
|
||||||
*/
|
*/
|
||||||
notifyTrigger() {
|
getStringArray() {
|
||||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
return plugins.lodash.cloneDeep(this._stringArray);
|
||||||
return !functionArg();
|
|
||||||
});
|
|
||||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
|
||||||
}
|
}
|
||||||
;
|
// trigger registering
|
||||||
/**
|
/**
|
||||||
* register a new trigger
|
* register a new trigger
|
||||||
*/
|
*/
|
||||||
@ -85,6 +74,15 @@ class Stringmap {
|
|||||||
});
|
});
|
||||||
this.notifyTrigger();
|
this.notifyTrigger();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* notifies triggers
|
||||||
|
*/
|
||||||
|
notifyTrigger() {
|
||||||
|
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||||
|
return !functionArg();
|
||||||
|
});
|
||||||
|
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.Stringmap = Stringmap;
|
exports.Stringmap = Stringmap;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLGVBQWUsQ0FBQyxDQUFBO0FBVXpDO0lBR0k7UUFGUSxpQkFBWSxHQUFZLEVBQUUsQ0FBQztRQUMzQixtQ0FBOEIsR0FBcUIsRUFBRSxDQUFDO0lBRzlELENBQUM7O0lBQ0Q7O09BRUc7SUFDSCxTQUFTLENBQUMsU0FBZ0I7UUFDdEIsSUFBSSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDbEMsSUFBSSxDQUFDLGFBQWEsRUFBRSxDQUFDO0lBQ3pCLENBQUM7O0lBRUQ7O09BRUc7SUFDSCxZQUFZLENBQUMsU0FBZ0I7UUFDekIsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksSUFBSSxDQUFDLFlBQVksQ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UFNLENBQUMsQ0FBQyxXQUFXO1lBQ3ZFLE1BQU0sQ0FBQyxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQ3pCLENBQUMsQ0FBQyxDQUFBO1FBQ0YsSUFBSSxDQUFDLDhCQUE4QixHQUFHLGFBQWEsQ0FBQTtJQUN2RCxDQUFDO0NBRUo7QUE5RkQsOEJBOEZDIn0=
|
11
package.json
11
package.json
@ -18,14 +18,17 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6",
|
"@types/should": "^8.1.30",
|
||||||
"should": "^10.0.0",
|
"npmts-g": "^5.2.8",
|
||||||
"typings-test": "^1.0.1"
|
"should": "^11.1.0",
|
||||||
|
"typings-test": "^1.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/lodash": "^4.14.35",
|
||||||
"@types/minimatch": "2.x.x",
|
"@types/minimatch": "2.x.x",
|
||||||
"@types/q": "0.x.x",
|
"@types/q": "0.x.x",
|
||||||
"minimatch": "^3.0.2",
|
"lodash": "^4.16.1",
|
||||||
|
"minimatch": "^3.0.3",
|
||||||
"q": "^1.4.1"
|
"q": "^1.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
test/test.d.ts
vendored
3
test/test.d.ts
vendored
@ -1,2 +1 @@
|
|||||||
import "typings-test";
|
import 'typings-test';
|
||||||
import "should";
|
|
||||||
|
89
test/test.js
89
test/test.js
@ -1,78 +1,83 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-test");
|
require("typings-test");
|
||||||
const lik = require("../dist/index");
|
const lik = require("../dist/index");
|
||||||
require("should");
|
const should = require("should");
|
||||||
describe("lik", function () {
|
describe('lik', function () {
|
||||||
describe("Stringmap", function () {
|
describe('Stringmap', function () {
|
||||||
let testStringmap;
|
let testStringmap;
|
||||||
let testString1 = "testString1";
|
let testString1 = 'testString1';
|
||||||
let testString2 = "testString2";
|
let testString2 = 'testString2';
|
||||||
let testString3 = "testString3";
|
let testString3 = 'testString3';
|
||||||
it("should create an instance of Stringmap", function () {
|
it('should create an instance of Stringmap', function () {
|
||||||
testStringmap = new lik.Stringmap();
|
testStringmap = new lik.Stringmap();
|
||||||
testStringmap.should.be.instanceof(lik.Stringmap);
|
should(testStringmap).be.instanceof(lik.Stringmap);
|
||||||
});
|
});
|
||||||
it("should return false for an string not in Stringmap", function () {
|
it('should return false for an string not in Stringmap', function () {
|
||||||
testStringmap.checkString(testString1).should.be.false();
|
should(testStringmap.checkString(testString1)).be.false();
|
||||||
});
|
});
|
||||||
it("should add an string to Stringmap", function () {
|
it('should add an string to Stringmap', function () {
|
||||||
testStringmap.addString(testString1);
|
testStringmap.addString(testString1);
|
||||||
testStringmap.addString(testString2);
|
testStringmap.addString(testString2);
|
||||||
testStringmap.addString(testString3);
|
testStringmap.addString(testString3);
|
||||||
testStringmap.checkString(testString1).should.be.true();
|
should(testStringmap.checkString(testString1)).be.true();
|
||||||
testStringmap.checkString(testString2).should.be.true();
|
should(testStringmap.checkString(testString2)).be.true();
|
||||||
testStringmap.checkString(testString3).should.be.true();
|
should(testStringmap.checkString(testString3)).be.true();
|
||||||
testStringmap.checkMinimatch("*String1").should.be.true();
|
should(testStringmap.checkMinimatch('*String1')).be.true();
|
||||||
testStringmap.checkMinimatch("*String2").should.be.true();
|
should(testStringmap.checkMinimatch('*String2')).be.true();
|
||||||
testStringmap.checkMinimatch("*String4").should.be.false();
|
should(testStringmap.checkMinimatch('*String4')).be.false();
|
||||||
});
|
});
|
||||||
it("should remove a string from Stringmap", function () {
|
it('should remove a string from Stringmap', function () {
|
||||||
testStringmap.removeString(testString2);
|
testStringmap.removeString(testString2);
|
||||||
testStringmap.checkString(testString2).should.be.false();
|
should(testStringmap.checkString(testString2)).be.false();
|
||||||
});
|
});
|
||||||
it("should register a function to trigger when empty", function () {
|
it('should return a copy of stringArray', function () {
|
||||||
testStringmap.registerUntilTrue(() => { return testStringmap.checkIsEmpty(); }, () => { console.log("Stringmap now is empty"); });
|
let clonedArray = testStringmap.getStringArray();
|
||||||
|
should(clonedArray[0] === 'testString1').be.true();
|
||||||
|
should(clonedArray[0] === testString1).be.true();
|
||||||
});
|
});
|
||||||
it("should remove wipe and then notify", function () {
|
it('should register a function to trigger when empty', function () {
|
||||||
|
testStringmap.registerUntilTrue(() => { return testStringmap.checkIsEmpty(); }, () => { console.log('Stringmap now is empty'); });
|
||||||
|
});
|
||||||
|
it('should remove wipe and then notify', function () {
|
||||||
testStringmap.wipe();
|
testStringmap.wipe();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("Objectmap", function () {
|
describe('Objectmap', function () {
|
||||||
let testObjectmap;
|
let testObjectmap;
|
||||||
let testObject1 = {
|
let testObject1 = {
|
||||||
propOne: "hello",
|
propOne: 'hello',
|
||||||
propTwo: "hello2"
|
propTwo: 'hello2'
|
||||||
};
|
};
|
||||||
let testObject2 = {
|
let testObject2 = {
|
||||||
propOne: "hello",
|
propOne: 'hello',
|
||||||
propTwo: "hello2"
|
propTwo: 'hello2'
|
||||||
};
|
};
|
||||||
it("should correctly instantiate an Objectmap", function () {
|
it('should correctly instantiate an Objectmap', function () {
|
||||||
testObjectmap = new lik.Objectmap();
|
testObjectmap = new lik.Objectmap();
|
||||||
testObjectmap.should.be.instanceof(lik.Objectmap);
|
should(testObjectmap).be.instanceof(lik.Objectmap);
|
||||||
});
|
});
|
||||||
it("should correctly add an object to Objectmap", function () {
|
it('should correctly add an object to Objectmap', function () {
|
||||||
testObjectmap.add(testObject1);
|
testObjectmap.add(testObject1);
|
||||||
testObjectmap.checkForObject(testObject1).should.be.true;
|
should(testObjectmap.checkForObject(testObject1)).be.true;
|
||||||
testObjectmap.checkForObject(testObject2).should.be.false;
|
should(testObjectmap.checkForObject(testObject2)).be.false;
|
||||||
});
|
});
|
||||||
it("should correctly remove an object to Objectmap", function () {
|
it('should correctly remove an object to Objectmap', function () {
|
||||||
testObjectmap.add(testObject2);
|
testObjectmap.add(testObject2);
|
||||||
testObjectmap.remove(testObject1);
|
testObjectmap.remove(testObject1);
|
||||||
testObjectmap.checkForObject(testObject1).should.be.false;
|
should(testObjectmap.checkForObject(testObject1)).be.false;
|
||||||
testObjectmap.checkForObject(testObject2).should.be.true;
|
should(testObjectmap.checkForObject(testObject2)).be.true;
|
||||||
});
|
});
|
||||||
it("should correctly run a function forEach map object", function () {
|
it('should correctly run a function forEach map object', function () {
|
||||||
testObjectmap.forEach(itemArg => {
|
testObjectmap.forEach(itemArg => {
|
||||||
itemArg.should.have.ownProperty("propOne");
|
should(itemArg).have.ownProperty('propOne');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should correctly find an object", function () {
|
it('should correctly find an object', function () {
|
||||||
let myObject = { item1: "hello", item2: "hello2" };
|
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||||
testObjectmap.add(myObject);
|
testObjectmap.add(myObject);
|
||||||
let referenceObject = testObjectmap.find((itemArg) => { return (itemArg.item1 === "hello"); });
|
let referenceObject = testObjectmap.find((itemArg) => { return (itemArg.propOne === 'helloThere'); });
|
||||||
(myObject === referenceObject).should.be.true();
|
should(myObject === referenceObject).be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsTUFBTyxHQUFHLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDdEMsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixRQUFRLENBQUMsS0FBSyxFQUFDO0lBQ1gsUUFBUSxD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Q0FBQyxPQUFPLEtBQUssWUFBWSxDQUFDLENBQUEsQ0FBQyxDQUFDLENBQUMsQ0FBQTtZQUNwRyxNQUFNLENBQUMsUUFBUSxLQUFLLGVBQWUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUNsRCxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
167
test/test.ts
167
test/test.ts
@ -1,84 +1,89 @@
|
|||||||
import "typings-test";
|
import 'typings-test'
|
||||||
import lik = require("../dist/index");
|
import lik = require('../dist/index')
|
||||||
import "should";
|
import * as should from 'should'
|
||||||
|
|
||||||
describe("lik",function(){
|
describe('lik',function(){
|
||||||
describe("Stringmap",function(){
|
describe('Stringmap',function(){
|
||||||
let testStringmap:lik.Stringmap;
|
let testStringmap: lik.Stringmap
|
||||||
let testString1 = "testString1";
|
let testString1 = 'testString1'
|
||||||
let testString2 = "testString2";
|
let testString2 = 'testString2'
|
||||||
let testString3 = "testString3";
|
let testString3 = 'testString3'
|
||||||
it("should create an instance of Stringmap",function(){
|
it('should create an instance of Stringmap',function(){
|
||||||
testStringmap = new lik.Stringmap();
|
testStringmap = new lik.Stringmap()
|
||||||
testStringmap.should.be.instanceof(lik.Stringmap);
|
should(testStringmap).be.instanceof(lik.Stringmap)
|
||||||
});
|
})
|
||||||
it("should return false for an string not in Stringmap",function(){
|
it('should return false for an string not in Stringmap',function(){
|
||||||
testStringmap.checkString(testString1).should.be.false();
|
should(testStringmap.checkString(testString1)).be.false()
|
||||||
});
|
})
|
||||||
it("should add an string to Stringmap",function(){
|
it('should add an string to Stringmap',function(){
|
||||||
testStringmap.addString(testString1);
|
testStringmap.addString(testString1)
|
||||||
testStringmap.addString(testString2);
|
testStringmap.addString(testString2)
|
||||||
testStringmap.addString(testString3);
|
testStringmap.addString(testString3)
|
||||||
testStringmap.checkString(testString1).should.be.true();
|
should(testStringmap.checkString(testString1)).be.true()
|
||||||
testStringmap.checkString(testString2).should.be.true();
|
should(testStringmap.checkString(testString2)).be.true()
|
||||||
testStringmap.checkString(testString3).should.be.true();
|
should(testStringmap.checkString(testString3)).be.true()
|
||||||
testStringmap.checkMinimatch("*String1").should.be.true();
|
should(testStringmap.checkMinimatch('*String1')).be.true()
|
||||||
testStringmap.checkMinimatch("*String2").should.be.true();
|
should(testStringmap.checkMinimatch('*String2')).be.true()
|
||||||
testStringmap.checkMinimatch("*String4").should.be.false();
|
should(testStringmap.checkMinimatch('*String4')).be.false()
|
||||||
});
|
})
|
||||||
it("should remove a string from Stringmap",function(){
|
it('should remove a string from Stringmap',function(){
|
||||||
testStringmap.removeString(testString2);
|
testStringmap.removeString(testString2)
|
||||||
testStringmap.checkString(testString2).should.be.false();
|
should(testStringmap.checkString(testString2)).be.false()
|
||||||
});
|
})
|
||||||
it("should register a function to trigger when empty",function(){
|
it('should return a copy of stringArray',function(){
|
||||||
testStringmap.registerUntilTrue(
|
let clonedArray = testStringmap.getStringArray()
|
||||||
() => {return testStringmap.checkIsEmpty()},
|
should(clonedArray[0] === 'testString1').be.true()
|
||||||
() => {console.log("Stringmap now is empty")}
|
should(clonedArray[0] === testString1).be.true()
|
||||||
);
|
})
|
||||||
});
|
it('should register a function to trigger when empty',function(){
|
||||||
it("should remove wipe and then notify",function(){
|
testStringmap.registerUntilTrue(
|
||||||
testStringmap.wipe();
|
() => { return testStringmap.checkIsEmpty() },
|
||||||
|
() => { console.log('Stringmap now is empty') }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
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;
|
|
||||||
});
|
|
||||||
it("should correctly run a function forEach map object",function(){
|
|
||||||
testObjectmap.forEach(itemArg => {
|
|
||||||
itemArg.should.have.ownProperty("propOne");
|
|
||||||
})
|
|
||||||
});
|
|
||||||
it("should correctly find an object",function(){
|
|
||||||
let myObject = {item1: "hello",item2: "hello2"};
|
|
||||||
testObjectmap.add(myObject);
|
|
||||||
let referenceObject = testObjectmap.find((itemArg) => {return (itemArg.item1 === "hello")});
|
|
||||||
(myObject === referenceObject).should.be.true();
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
});
|
describe('Objectmap',function(){
|
||||||
|
interface ITestObject {
|
||||||
|
propOne: string
|
||||||
|
propTwo: string
|
||||||
|
}
|
||||||
|
let testObjectmap: lik.Objectmap<ITestObject>
|
||||||
|
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<ITestObject>()
|
||||||
|
should(testObjectmap).be.instanceof(lik.Objectmap)
|
||||||
|
})
|
||||||
|
it('should correctly add an object to Objectmap',function(){
|
||||||
|
testObjectmap.add(testObject1)
|
||||||
|
should(testObjectmap.checkForObject(testObject1)).be.true
|
||||||
|
should(testObjectmap.checkForObject(testObject2)).be.false
|
||||||
|
})
|
||||||
|
it('should correctly remove an object to Objectmap',function(){
|
||||||
|
testObjectmap.add(testObject2)
|
||||||
|
testObjectmap.remove(testObject1)
|
||||||
|
should(testObjectmap.checkForObject(testObject1)).be.false
|
||||||
|
should(testObjectmap.checkForObject(testObject2)).be.true
|
||||||
|
})
|
||||||
|
it('should correctly run a function forEach map object',function(){
|
||||||
|
testObjectmap.forEach(itemArg => {
|
||||||
|
should(itemArg).have.ownProperty('propOne')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('should correctly find an object',function(){
|
||||||
|
let myObject = {propOne: 'helloThere', propTwo: 'helloAnyway'}
|
||||||
|
testObjectmap.add(myObject)
|
||||||
|
let referenceObject = testObjectmap.find((itemArg) => { return (itemArg.propOne === 'helloThere') })
|
||||||
|
should(myObject === referenceObject).be.true()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins'
|
||||||
|
|
||||||
// import modules
|
// import modules
|
||||||
|
|
||||||
export * from "./lik.stringmap";
|
export * from './lik.stringmap'
|
||||||
export * from "./lik.objectmap";
|
export * from './lik.objectmap'
|
||||||
|
@ -1,81 +1,76 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins'
|
||||||
|
|
||||||
|
|
||||||
export interface IObjectmapForEachFunction<T> {
|
export interface IObjectmapForEachFunction<T> {
|
||||||
(itemArg: T): void
|
(itemArg: T): void
|
||||||
};
|
}
|
||||||
|
|
||||||
export interface IObjectmapFindFunction<T> {
|
export interface IObjectmapFindFunction<T> {
|
||||||
(itemArg: T): boolean
|
(itemArg: T): boolean
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allows keeping track of objects
|
* allows keeping track of objects
|
||||||
*/
|
*/
|
||||||
export class Objectmap<T> {
|
export class Objectmap<T> {
|
||||||
private objectArray:T[] = [];
|
private objectArray: T[] = []
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a new instance
|
* returns a new instance
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add object to Objectmap
|
* add object to Objectmap
|
||||||
*/
|
*/
|
||||||
add(objectArg:T) {
|
add(objectArg: T) {
|
||||||
this.objectArray.push(objectArg);
|
this.objectArray.push(objectArg)
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove object from Objectmap
|
* remove object from Objectmap
|
||||||
*/
|
*/
|
||||||
remove(objectArg:T) {
|
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) {
|
||||||
replacmentArray.push(item);
|
replacmentArray.push(item)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
this.objectArray = replacmentArray;
|
this.objectArray = replacmentArray
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if object is in Objectmap
|
* check if object is in Objectmap
|
||||||
*/
|
*/
|
||||||
checkForObject(objectArg:T) {
|
checkForObject(objectArg: T) {
|
||||||
return this.objectArray.indexOf(objectArg) !== -1
|
return this.objectArray.indexOf(objectArg) !== -1
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find object
|
* find object
|
||||||
*/
|
*/
|
||||||
find(findFunction: IObjectmapFindFunction<T>) {
|
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]
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* run function for each item in Objectmap
|
* run function for each item in Objectmap
|
||||||
*/
|
*/
|
||||||
forEach(functionArg: IObjectmapForEachFunction<T>) {
|
forEach(functionArg: IObjectmapForEachFunction<T>) {
|
||||||
return this.objectArray.forEach(functionArg);
|
return this.objectArray.forEach(functionArg)
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wipe Objectmap
|
* wipe Objectmap
|
||||||
*/
|
*/
|
||||||
wipe() {
|
wipe() {
|
||||||
this.objectArray = [];
|
this.objectArray = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
import "typings-global";
|
import 'typings-global'
|
||||||
export import q = require("q");
|
export import q = require('q')
|
||||||
export import minimatch = require("minimatch");
|
export import lodash = require('lodash')
|
||||||
|
export import minimatch = require('minimatch')
|
||||||
|
@ -1,99 +1,105 @@
|
|||||||
import * as plugins from "./lik.plugins";
|
import * as plugins from './lik.plugins'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allows you to easily keep track of a bunch of strings;
|
* allows you to easily keep track of a bunch of strings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface triggerFunction {
|
export interface ITriggerFunction {
|
||||||
():boolean;
|
(): boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Stringmap {
|
export class Stringmap {
|
||||||
private _stringArray:string[] = [];
|
private _stringArray: string[] = []
|
||||||
private _triggerUntilTrueFunctionArray:triggerFunction[] = [];
|
private _triggerUntilTrueFunctionArray: ITriggerFunction[] = []
|
||||||
constructor(){
|
constructor() {}
|
||||||
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* add a string to the Stringmap
|
* add a string to the Stringmap
|
||||||
*/
|
*/
|
||||||
addString(stringArg:string){
|
addString(stringArg: string) {
|
||||||
this._stringArray.push(stringArg);
|
this._stringArray.push(stringArg)
|
||||||
this.notifyTrigger();
|
this.notifyTrigger()
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removes a string from Stringmap
|
* removes a string from Stringmap
|
||||||
*/
|
*/
|
||||||
removeString(stringArg:string){
|
removeString(stringArg: string) {
|
||||||
for (let keyArg in this._stringArray){
|
for (let keyArg in this._stringArray) {
|
||||||
if(this._stringArray[keyArg] === stringArg){
|
if (this._stringArray[keyArg] === stringArg) {
|
||||||
this._stringArray.splice(parseInt(keyArg),1);
|
this._stringArray.splice(parseInt(keyArg),1)
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
this.notifyTrigger();
|
this.notifyTrigger()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wipes the Stringmap
|
* wipes the Stringmap
|
||||||
*/
|
*/
|
||||||
wipe(){
|
wipe() {
|
||||||
this._stringArray = [];
|
this._stringArray = []
|
||||||
this.notifyTrigger();
|
this.notifyTrigger()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if string is in Stringmap
|
* check if string is in Stringmap
|
||||||
*/
|
*/
|
||||||
checkString(stringArg:string):boolean {
|
checkString(stringArg: string): boolean {
|
||||||
return this._stringArray.indexOf(stringArg) != -1;
|
return this._stringArray.indexOf(stringArg) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks stringPresence with minimatch
|
* checks stringPresence with minimatch
|
||||||
*/
|
*/
|
||||||
checkMinimatch(miniMatchStringArg:string):boolean {
|
checkMinimatch(miniMatchStringArg: string): boolean {
|
||||||
let foundMatch:boolean = false;
|
let foundMatch: boolean = false
|
||||||
for(let stringItem of this._stringArray){
|
for (let stringItem of this._stringArray){
|
||||||
if(plugins.minimatch(stringItem,miniMatchStringArg)){
|
if (plugins.minimatch(stringItem,miniMatchStringArg)) {
|
||||||
foundMatch = true;
|
foundMatch = true
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
return foundMatch;
|
return foundMatch
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the Stringmap is empty
|
* checks if the Stringmap is empty
|
||||||
*/
|
*/
|
||||||
checkIsEmpty(){
|
checkIsEmpty() {
|
||||||
return (this._stringArray.length === 0);
|
return (this._stringArray.length === 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets a cloned copy of the current string Array
|
||||||
|
*/
|
||||||
|
getStringArray() {
|
||||||
|
return plugins.lodash.cloneDeep(this._stringArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger registering
|
// trigger registering
|
||||||
|
|
||||||
/**
|
|
||||||
* notifies triggers
|
|
||||||
*/
|
|
||||||
private notifyTrigger(){
|
|
||||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
|
||||||
return !functionArg();
|
|
||||||
});
|
|
||||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a new trigger
|
* register a new trigger
|
||||||
*/
|
*/
|
||||||
registerUntilTrue(functionArg:triggerFunction,doFunctionArg){
|
registerUntilTrue(functionArg: ITriggerFunction,doFunctionArg) {
|
||||||
this._triggerUntilTrueFunctionArray.push(
|
this._triggerUntilTrueFunctionArray.push(
|
||||||
() => {
|
() => {
|
||||||
let result = functionArg();
|
let result = functionArg()
|
||||||
if(result === true){
|
if (result === true) {
|
||||||
doFunctionArg();
|
doFunctionArg()
|
||||||
}
|
}
|
||||||
return result;
|
return result
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
this.notifyTrigger();
|
this.notifyTrigger()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* notifies triggers
|
||||||
|
*/
|
||||||
|
private notifyTrigger() {
|
||||||
|
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||||
|
return !functionArg()
|
||||||
|
})
|
||||||
|
this._triggerUntilTrueFunctionArray = filteredArray
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "tslint-config-standard"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user