feat(core): update to newest gitzone package format
This commit is contained in:
12
ts/index.ts
12
ts/index.ts
@ -1,9 +1,9 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import * as plugins from "./lik.plugins";
|
||||
|
||||
// import modules
|
||||
|
||||
export * from './lik.looptracker'
|
||||
export * from './lik.objectmap'
|
||||
export * from './lik.stringmap'
|
||||
export * from './lik.limitedarray'
|
||||
export * from './lik.tree'
|
||||
export * from "./lik.looptracker";
|
||||
export * from "./lik.objectmap";
|
||||
export * from "./lik.stringmap";
|
||||
export * from "./lik.limitedarray";
|
||||
export * from "./lik.tree";
|
||||
|
@ -1,43 +1,42 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import * as plugins from "./lik.plugins";
|
||||
|
||||
export class LimitedArray<T> {
|
||||
array: T[] = []
|
||||
arrayLimit: number
|
||||
array: T[] = [];
|
||||
arrayLimit: number;
|
||||
constructor(limitArg: number) {
|
||||
this.arrayLimit = limitArg
|
||||
this.arrayLimit = limitArg;
|
||||
}
|
||||
|
||||
addOne (objectArg: T) {
|
||||
this.array.unshift(objectArg)
|
||||
addOne(objectArg: T) {
|
||||
this.array.unshift(objectArg);
|
||||
if (this.array.length > this.arrayLimit) {
|
||||
this.array.length = this.arrayLimit
|
||||
this.array.length = this.arrayLimit;
|
||||
}
|
||||
}
|
||||
|
||||
addMany (objectArrayArg: T[]) {
|
||||
addMany(objectArrayArg: T[]) {
|
||||
for (let objectArg of objectArrayArg) {
|
||||
this.addOne(objectArg)
|
||||
this.addOne(objectArg);
|
||||
}
|
||||
}
|
||||
|
||||
setLimit (limitArg: number) {
|
||||
this.arrayLimit = limitArg
|
||||
setLimit(limitArg: number) {
|
||||
this.arrayLimit = limitArg;
|
||||
if (this.array.length > this.arrayLimit) {
|
||||
this.array.length = this.arrayLimit
|
||||
this.array.length = this.arrayLimit;
|
||||
}
|
||||
}
|
||||
|
||||
getAverage ():number {
|
||||
if (typeof this.array[0] === 'number') {
|
||||
let sum = 0
|
||||
getAverage(): number {
|
||||
if (typeof this.array[0] === "number") {
|
||||
let sum = 0;
|
||||
for (let localNumber of this.array) {
|
||||
let localNumberAny: any = localNumber
|
||||
sum = sum + localNumberAny
|
||||
let localNumberAny: any = localNumber;
|
||||
sum = sum + localNumberAny;
|
||||
}
|
||||
return sum / this.array.length
|
||||
return sum / this.array.length;
|
||||
} else {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import * as plugins from "./lik.plugins";
|
||||
|
||||
import { Objectmap } from './lik.objectmap'
|
||||
import { Objectmap } from "./lik.objectmap";
|
||||
|
||||
export class LoopTracker<T> {
|
||||
referenceObjectMap = new Objectmap<any>()
|
||||
constructor () {
|
||||
referenceObjectMap = new Objectmap<any>();
|
||||
constructor() {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ export class LoopTracker<T> {
|
||||
* checks and tracks an object
|
||||
* @param objectArg
|
||||
*/
|
||||
checkAndTrack (objectArg: T) {
|
||||
return this.referenceObjectMap.add(objectArg)
|
||||
checkAndTrack(objectArg: T) {
|
||||
return this.referenceObjectMap.add(objectArg);
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import * as plugins from "./lik.plugins";
|
||||
|
||||
export interface IObjectmapForEachFunction<T> {
|
||||
(itemArg: T): void
|
||||
(itemArg: T): void;
|
||||
}
|
||||
|
||||
export interface IObjectmapFindFunction<T> {
|
||||
(itemArg: T): boolean
|
||||
(itemArg: T): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows keeping track of objects
|
||||
*/
|
||||
export class Objectmap<T> {
|
||||
private objectArray: T[] = []
|
||||
private objectArray: T[] = [];
|
||||
|
||||
/**
|
||||
* returns a new instance
|
||||
*/
|
||||
constructor () {
|
||||
constructor() {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
@ -26,107 +26,107 @@ export class Objectmap<T> {
|
||||
* returns false if the object is already in the map
|
||||
* returns true if the object was added successfully
|
||||
*/
|
||||
add (objectArg: T): boolean {
|
||||
add(objectArg: T): boolean {
|
||||
if (this.checkForObject(objectArg)) {
|
||||
// the object is already in the objectmap
|
||||
return false
|
||||
return false;
|
||||
} else {
|
||||
// the object is not yet in the objectmap
|
||||
this.objectArray.push(objectArg)
|
||||
return true
|
||||
this.objectArray.push(objectArg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* like .add but adds an whole array of objects
|
||||
*/
|
||||
addArray (objectArrayArg: T[]) {
|
||||
addArray(objectArrayArg: T[]) {
|
||||
for (let item of objectArrayArg) {
|
||||
this.add(item)
|
||||
this.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if object is in Objectmap
|
||||
*/
|
||||
checkForObject (objectArg: T) {
|
||||
return this.objectArray.indexOf(objectArg) !== -1
|
||||
checkForObject(objectArg: T) {
|
||||
return this.objectArray.indexOf(objectArg) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* find object
|
||||
*/
|
||||
find (findFunction: IObjectmapFindFunction<T>) {
|
||||
let resultArray = this.objectArray.filter(findFunction)
|
||||
find(findFunction: IObjectmapFindFunction<T>) {
|
||||
let resultArray = this.objectArray.filter(findFunction);
|
||||
if (resultArray.length > 0) {
|
||||
return resultArray[ 0 ]
|
||||
return resultArray[0];
|
||||
} else {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* finds a specific element and then removes it
|
||||
*/
|
||||
findOneAndRemove (findFunction: IObjectmapFindFunction<T>): T {
|
||||
let foundElement = this.find(findFunction)
|
||||
findOneAndRemove(findFunction: IObjectmapFindFunction<T>): T {
|
||||
let foundElement = this.find(findFunction);
|
||||
if (foundElement) {
|
||||
this.remove(foundElement)
|
||||
this.remove(foundElement);
|
||||
}
|
||||
return foundElement
|
||||
return foundElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* run function for each item in Objectmap
|
||||
*/
|
||||
async forEach (functionArg: IObjectmapForEachFunction<T>) {
|
||||
async forEach(functionArg: IObjectmapForEachFunction<T>) {
|
||||
for (let object of this.objectArray) {
|
||||
await functionArg(object)
|
||||
await functionArg(object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||
*/
|
||||
getOneAndRemove (): T {
|
||||
return this.objectArray.shift()
|
||||
getOneAndRemove(): T {
|
||||
return this.objectArray.shift();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a cloned array of all the objects currently in the Objectmap
|
||||
*/
|
||||
getArray () {
|
||||
return plugins.lodash.cloneDeep(this.objectArray)
|
||||
getArray() {
|
||||
return plugins.lodash.cloneDeep(this.objectArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if Objectmap ist empty
|
||||
*/
|
||||
isEmpty (): boolean {
|
||||
isEmpty(): boolean {
|
||||
if (this.objectArray.length === 0) {
|
||||
return true
|
||||
return true;
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove object from Objectmap
|
||||
*/
|
||||
remove (objectArg: T) {
|
||||
let replacementArray = []
|
||||
remove(objectArg: T) {
|
||||
let replacementArray = [];
|
||||
for (let item of this.objectArray) {
|
||||
if (item !== objectArg) {
|
||||
replacementArray.push(item)
|
||||
replacementArray.push(item);
|
||||
}
|
||||
}
|
||||
this.objectArray = replacementArray
|
||||
this.objectArray = replacementArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* wipe Objectmap
|
||||
*/
|
||||
wipe () {
|
||||
this.objectArray = []
|
||||
wipe() {
|
||||
this.objectArray = [];
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,7 @@
|
||||
import 'typings-global'
|
||||
import * as events from 'events'
|
||||
import * as lodash from 'lodash'
|
||||
import * as minimatch from 'minimatch'
|
||||
import * as smartq from 'smartq'
|
||||
const symbolTree = require('symbol-tree')
|
||||
import * as events from "events";
|
||||
import * as lodash from "lodash";
|
||||
import * as minimatch from "minimatch";
|
||||
import * as smartq from "smartq";
|
||||
const symbolTree = require("symbol-tree");
|
||||
|
||||
export {
|
||||
events,
|
||||
lodash,
|
||||
minimatch,
|
||||
smartq,
|
||||
symbolTree
|
||||
}
|
||||
export { events, lodash, minimatch, smartq, symbolTree };
|
||||
|
@ -1,86 +1,86 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import * as plugins from "./lik.plugins";
|
||||
|
||||
/**
|
||||
* allows you to easily keep track of a bunch of strings
|
||||
*/
|
||||
|
||||
export interface ITriggerFunction {
|
||||
(): boolean
|
||||
(): boolean;
|
||||
}
|
||||
|
||||
export class Stringmap {
|
||||
private _stringArray: string[] = []
|
||||
private _triggerUntilTrueFunctionArray: ITriggerFunction[] = []
|
||||
constructor() { }
|
||||
private _stringArray: string[] = [];
|
||||
private _triggerUntilTrueFunctionArray: ITriggerFunction[] = [];
|
||||
constructor() {}
|
||||
/**
|
||||
* add a string to the Stringmap
|
||||
*/
|
||||
addString (stringArg: string) {
|
||||
this._stringArray.push(stringArg)
|
||||
this.notifyTrigger()
|
||||
addString(stringArg: string) {
|
||||
this._stringArray.push(stringArg);
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* like addString, but accepts an array of strings
|
||||
*/
|
||||
addStringArray (stringArrayArg: string[]) {
|
||||
addStringArray(stringArrayArg: string[]) {
|
||||
for (let stringItem of stringArrayArg) {
|
||||
this.addString(stringItem)
|
||||
this.addString(stringItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a string from Stringmap
|
||||
*/
|
||||
removeString (stringArg: string) {
|
||||
removeString(stringArg: string) {
|
||||
for (let keyArg in this._stringArray) {
|
||||
if (this._stringArray[ keyArg ] === stringArg) {
|
||||
this._stringArray.splice(parseInt(keyArg), 1)
|
||||
if (this._stringArray[keyArg] === stringArg) {
|
||||
this._stringArray.splice(parseInt(keyArg), 1);
|
||||
}
|
||||
}
|
||||
this.notifyTrigger()
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* wipes the Stringmap
|
||||
*/
|
||||
wipe () {
|
||||
this._stringArray = []
|
||||
this.notifyTrigger()
|
||||
wipe() {
|
||||
this._stringArray = [];
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* check if string is in Stringmap
|
||||
*/
|
||||
checkString (stringArg: string): boolean {
|
||||
return this._stringArray.indexOf(stringArg) !== -1
|
||||
checkString(stringArg: string): boolean {
|
||||
return this._stringArray.indexOf(stringArg) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks stringPresence with minimatch
|
||||
*/
|
||||
checkMinimatch (miniMatchStringArg: string): boolean {
|
||||
let foundMatch: boolean = false
|
||||
checkMinimatch(miniMatchStringArg: string): boolean {
|
||||
let foundMatch: boolean = false;
|
||||
for (let stringItem of this._stringArray) {
|
||||
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
||||
foundMatch = true
|
||||
foundMatch = true;
|
||||
}
|
||||
}
|
||||
return foundMatch
|
||||
return foundMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Stringmap is empty
|
||||
*/
|
||||
checkIsEmpty () {
|
||||
return (this._stringArray.length === 0)
|
||||
checkIsEmpty() {
|
||||
return this._stringArray.length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a cloned copy of the current string Array
|
||||
*/
|
||||
getStringArray () {
|
||||
return plugins.lodash.cloneDeep(this._stringArray)
|
||||
getStringArray() {
|
||||
return plugins.lodash.cloneDeep(this._stringArray);
|
||||
}
|
||||
|
||||
// trigger registering
|
||||
@ -88,27 +88,26 @@ export class Stringmap {
|
||||
/**
|
||||
* register a new trigger
|
||||
*/
|
||||
registerUntilTrue (functionArg: ITriggerFunction, doFunctionArg) {
|
||||
this._triggerUntilTrueFunctionArray.push(
|
||||
() => {
|
||||
let result = functionArg()
|
||||
if (result === true) {
|
||||
doFunctionArg()
|
||||
}
|
||||
return result
|
||||
registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) {
|
||||
this._triggerUntilTrueFunctionArray.push(() => {
|
||||
let result = functionArg();
|
||||
if (result === true) {
|
||||
doFunctionArg();
|
||||
}
|
||||
)
|
||||
this.notifyTrigger()
|
||||
return result;
|
||||
});
|
||||
this.notifyTrigger();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* notifies triggers
|
||||
*/
|
||||
private notifyTrigger () {
|
||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
||||
return !functionArg()
|
||||
})
|
||||
this._triggerUntilTrueFunctionArray = filteredArray
|
||||
private notifyTrigger() {
|
||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter(
|
||||
functionArg => {
|
||||
return !functionArg();
|
||||
}
|
||||
);
|
||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
118
ts/lik.tree.ts
118
ts/lik.tree.ts
@ -1,116 +1,116 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import * as plugins from "./lik.plugins";
|
||||
|
||||
export class Tree<T> {
|
||||
symbolTree: any
|
||||
constructor () {
|
||||
this.symbolTree = new plugins.symbolTree()
|
||||
symbolTree: any;
|
||||
constructor() {
|
||||
this.symbolTree = new plugins.symbolTree();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param objectArg
|
||||
*
|
||||
* @param objectArg
|
||||
*/
|
||||
initialize (objectArg: T): T {
|
||||
return this.symbolTree.initialize(objectArg)
|
||||
initialize(objectArg: T): T {
|
||||
return this.symbolTree.initialize(objectArg);
|
||||
}
|
||||
|
||||
hasChildren (objectArg: T): boolean {
|
||||
return this.symbolTree.hasChildren(objectArg)
|
||||
hasChildren(objectArg: T): boolean {
|
||||
return this.symbolTree.hasChildren(objectArg);
|
||||
}
|
||||
|
||||
firstChild (objectArg: T): T {
|
||||
return this.symbolTree.firstChild(objectArg)
|
||||
firstChild(objectArg: T): T {
|
||||
return this.symbolTree.firstChild(objectArg);
|
||||
}
|
||||
|
||||
lastChild (objectArg: T): T {
|
||||
return this.symbolTree.lastChild(objectArg)
|
||||
lastChild(objectArg: T): T {
|
||||
return this.symbolTree.lastChild(objectArg);
|
||||
}
|
||||
|
||||
previousSibling (objectArg: T): T {
|
||||
return this.symbolTree.previousSibling(objectArg)
|
||||
previousSibling(objectArg: T): T {
|
||||
return this.symbolTree.previousSibling(objectArg);
|
||||
}
|
||||
|
||||
nextSibling (objectArg: T): T {
|
||||
return this.symbolTree.nextSibling(objectArg)
|
||||
nextSibling(objectArg: T): T {
|
||||
return this.symbolTree.nextSibling(objectArg);
|
||||
}
|
||||
|
||||
parent (objectArg: T): T {
|
||||
return this.symbolTree.parent(objectArg)
|
||||
parent(objectArg: T): T {
|
||||
return this.symbolTree.parent(objectArg);
|
||||
}
|
||||
|
||||
lastInclusiveDescendant(objectArg: T): T {
|
||||
return this.symbolTree.lastInclusiveDescendant(objectArg)
|
||||
return this.symbolTree.lastInclusiveDescendant(objectArg);
|
||||
}
|
||||
|
||||
preceding(objectArg: T, optionsArg?: any): T {
|
||||
return this.symbolTree.preceding(objectArg, optionsArg)
|
||||
return this.symbolTree.preceding(objectArg, optionsArg);
|
||||
}
|
||||
|
||||
following (object: T, optionsArg: any) {
|
||||
return this.symbolTree.following(object, optionsArg)
|
||||
following(object: T, optionsArg: any) {
|
||||
return this.symbolTree.following(object, optionsArg);
|
||||
}
|
||||
|
||||
childrenToArray (parentArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.childrenToArray(parent, optionsArg)
|
||||
childrenToArray(parentArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.childrenToArray(parent, optionsArg);
|
||||
}
|
||||
|
||||
ancestorsToArray (objectArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.ancestorsToArray(objectArg, optionsArg)
|
||||
ancestorsToArray(objectArg: T, optionsArg: any): T[] {
|
||||
return this.symbolTree.ancestorsToArray(objectArg, optionsArg);
|
||||
}
|
||||
|
||||
treeToArray (rootArg, optionsArg: any): T[] {
|
||||
return this.symbolTree.treeToArray(rootArg, optionsArg)
|
||||
treeToArray(rootArg, optionsArg: any): T[] {
|
||||
return this.symbolTree.treeToArray(rootArg, optionsArg);
|
||||
}
|
||||
|
||||
childrenIterator (parentArg: T, optionsArg): T {
|
||||
return this.symbolTree.childrenIterator(parentArg, optionsArg)
|
||||
}
|
||||
|
||||
previousSiblingsIterator (objectArg): T {
|
||||
return this.symbolTree.previousSiblingsIterator(objectArg)
|
||||
childrenIterator(parentArg: T, optionsArg): T {
|
||||
return this.symbolTree.childrenIterator(parentArg, optionsArg);
|
||||
}
|
||||
|
||||
nextSiblingsIterator (objectArg: T) {
|
||||
return this.symbolTree.nextSiblingsIterator()
|
||||
previousSiblingsIterator(objectArg): T {
|
||||
return this.symbolTree.previousSiblingsIterator(objectArg);
|
||||
}
|
||||
|
||||
ancestorsIterator (objectArg) {
|
||||
this.symbolTree.ancestorsIterator()
|
||||
nextSiblingsIterator(objectArg: T) {
|
||||
return this.symbolTree.nextSiblingsIterator();
|
||||
}
|
||||
|
||||
treeIterator (rootArg: T, optionsArg): T {
|
||||
return this.symbolTree.treeIterator(rootArg)
|
||||
ancestorsIterator(objectArg) {
|
||||
this.symbolTree.ancestorsIterator();
|
||||
}
|
||||
|
||||
index (childArg: T): number {
|
||||
return this.symbolTree.index(childArg)
|
||||
treeIterator(rootArg: T, optionsArg): T {
|
||||
return this.symbolTree.treeIterator(rootArg);
|
||||
}
|
||||
|
||||
childrenCount (parentArg: T): number {
|
||||
return this.symbolTree.childrenCount(parentArg)
|
||||
index(childArg: T): number {
|
||||
return this.symbolTree.index(childArg);
|
||||
}
|
||||
|
||||
compareTreePosition (leftArg: T, rightArg: T): number {
|
||||
return this.compareTreePosition(leftArg, rightArg)
|
||||
childrenCount(parentArg: T): number {
|
||||
return this.symbolTree.childrenCount(parentArg);
|
||||
}
|
||||
|
||||
remove (removeObjectArg: T): T {
|
||||
return this.symbolTree.remove(removeObjectArg)
|
||||
compareTreePosition(leftArg: T, rightArg: T): number {
|
||||
return this.compareTreePosition(leftArg, rightArg);
|
||||
}
|
||||
|
||||
insertBefore (referenceObjectArg: T, newObjectArg: T): T {
|
||||
return this.symbolTree.insertBefore(referenceObjectArg, newObjectArg)
|
||||
remove(removeObjectArg: T): T {
|
||||
return this.symbolTree.remove(removeObjectArg);
|
||||
}
|
||||
|
||||
insertAfter (referenceObject: T, newObjectArg: T) {
|
||||
return this.symbolTree.insertAfter(referenceObject, newObjectArg)
|
||||
insertBefore(referenceObjectArg: T, newObjectArg: T): T {
|
||||
return this.symbolTree.insertBefore(referenceObjectArg, newObjectArg);
|
||||
}
|
||||
|
||||
prependChild (referenceObjectArg: T, newObjectArg: T): T {
|
||||
return this.symbolTree.prependChild(referenceObjectArg, newObjectArg)
|
||||
insertAfter(referenceObject: T, newObjectArg: T) {
|
||||
return this.symbolTree.insertAfter(referenceObject, newObjectArg);
|
||||
}
|
||||
|
||||
appendChild (referenceObjectArg, newObjectArg) {
|
||||
return this.symbolTree.appendChild(referenceObjectArg, newObjectArg)
|
||||
prependChild(referenceObjectArg: T, newObjectArg: T): T {
|
||||
return this.symbolTree.prependChild(referenceObjectArg, newObjectArg);
|
||||
}
|
||||
}
|
||||
|
||||
appendChild(referenceObjectArg, newObjectArg) {
|
||||
return this.symbolTree.appendChild(referenceObjectArg, newObjectArg);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user