uicore-ts 1.0.525 → 1.0.527
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiledScripts/UICoreExtensions.d.ts +1 -0
- package/compiledScripts/UICoreExtensions.js +9 -0
- package/compiledScripts/UICoreExtensions.js.map +2 -2
- package/compiledScripts/UIKeyValueSorter.d.ts +42 -0
- package/compiledScripts/UIKeyValueSorter.js +155 -0
- package/compiledScripts/UIKeyValueSorter.js.map +7 -0
- package/compiledScripts/UIKeyValueSorterWebWorker.worker.d.ts +10 -0
- package/compiledScripts/UIKeyValueSorterWebWorker.worker.js +78 -0
- package/compiledScripts/UIKeyValueSorterWebWorker.worker.js.map +7 -0
- package/compiledScripts/index.d.ts +1 -1
- package/compiledScripts/index.js +1 -1
- package/compiledScripts/index.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UICoreExtensions.ts +13 -0
- package/scripts/{UIKeyValueStringSorter.ts → UIKeyValueSorter.ts} +10 -9
- package/scripts/{UIKeyValueStringSorterWebWorker.worker.ts → UIKeyValueSorterWebWorker.worker.ts} +15 -4
- package/scripts/index.ts +1 -1
|
@@ -227,6 +227,15 @@ Array.prototype.max = function() {
|
|
|
227
227
|
Array.prototype.min = function() {
|
|
228
228
|
return Math.min.apply(null, this);
|
|
229
229
|
};
|
|
230
|
+
if (!Array.prototype.average) {
|
|
231
|
+
Array.prototype.average = function() {
|
|
232
|
+
if (this.length == 0) {
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
const sum = this.reduce((a, b) => a + b, 0);
|
|
236
|
+
return sum / this.length;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
230
239
|
if ("isEqualToArray" in Array.prototype == NO) {
|
|
231
240
|
Array.prototype.isEqualToArray = function(array, keyPath) {
|
|
232
241
|
if (!array) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UICoreExtensions.ts"],
|
|
4
|
-
"sourcesContent": ["import { UICoreExtensionValueObject } from \"./UICoreExtensionValueObject\"\nimport { UIObject } from \"./UIObject\"\n\n\ndeclare global {\n \n \n interface Array<T> {\n \n removeElementAtIndex(index: number): void;\n \n removeElement(element: T): void;\n \n insertElementAtIndex(index: number, element: T): void;\n \n replaceElementAtIndex(index: number, element: T): void;\n \n \n contains(element: T): boolean;\n \n findAsyncSequential(functionToCall: (value: any) => Promise<boolean>): Promise<any>;\n \n groupedBy(keyFunction: (item: T) => any): { [key: string]: Array<T> } & Object;\n \n copy(): Array<T>;\n \n arrayByRepeating(numberOfRepetitions: number): Array<T>;\n \n arrayByTrimmingToLengthIfLonger(maxLength: number): Array<T>;\n \n anyMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n \n noneMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n \n allMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n \n firstElement: T;\n lastElement: T;\n readonly summedValue: T;\n \n everyElement: UIEveryElementItem<T>;\n \n max(): number;\n \n min(): number;\n \n isEqualToArray(array: Array<T>, keyPath?: string): boolean;\n \n }\n \n \n interface String {\n \n contains(string: string): boolean;\n \n readonly numericalValue: number;\n readonly integerValue: number;\n isAString: boolean;\n \n }\n \n \n interface Number {\n \n isANumber: boolean;\n \n readonly integerValue: number;\n \n constrainedValue(min: number, max: number): number;\n \n }\n \n \n interface Date {\n \n readonly dateString: string;\n \n }\n \n \n interface Object {\n \n forEach(callbackFunction: (value: any, key: string, stopLooping: () => void) => void): void;\n \n objectByCopyingValuesRecursivelyFromObject<T extends object>(object: T): T & this;\n \n readonly allValues: Array<any>;\n readonly allKeys: (keyof this)[];\n \n }\n \n}\n\nexport {}\n\nconst YES = true\nconst NO = false\n\nif (\"removeElementAtIndex\" in Array.prototype == NO) {\n \n (Array.prototype as any).removeElementAtIndex = function (this: Array<any>, index: number) {\n \n // @ts-ignore\n if (index >= 0 && index < this.length) {\n this.splice(index, 1)\n }\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// removeElementAtIndex(index: number);\n//\n// }\n\n\nif (\"removeElement\" in Array.prototype == NO) {\n \n (Array.prototype as any).removeElement = function (this: Array<any>, element: any) {\n this.removeElementAtIndex(this.indexOf(element))\n }\n \n}\n\n\n// interface Array<T> {\n//\n// removeElement(element: T);\n//\n// }\n\n\nif (\"insertElementAtIndex\" in Array.prototype == NO) {\n \n (Array.prototype as any).insertElementAtIndex = function (this: Array<any>, index: number, element: any) {\n \n if (index >= 0 && index <= this.length) {\n this.splice(index, 0, element)\n }\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// insertElementAtIndex(index: number, element: T);\n//\n// }\n\n\nif (\"replaceElementAtIndex\" in Array.prototype == NO) {\n \n (Array.prototype as any).replaceElementAtIndex = function (this: Array<any>, index: number, element: any) {\n \n this.removeElementAtIndex(index)\n this.insertElementAtIndex(index, element)\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// replaceElementAtIndex(index: number, element: T);\n//\n// }\n\n\nif (\"contains\" in Array.prototype == NO) {\n \n (Array.prototype as any).contains = function (this: Array<any>, element: any) {\n return (this.indexOf(element) != -1)\n }\n \n}\n\nif (\"containsAny\" in Array.prototype == NO) {\n \n (Array.prototype as any).containsAny = function (this: Array<any>, elements: any[]) {\n return this.anyMatch(element => elements.contains(element))\n }\n \n}\n\n\n// interface Array<T> {\n//\n// contains(element: T): boolean;\n//\n// containsAny(element: T[]): boolean;\n//\n// }\n\n\nif (\"anyMatch\" in Array.prototype == NO) {\n \n (Array.prototype as any).anyMatch = function (\n this: Array<any>,\n functionToCall: (value: any, index: number, array: any[]) => boolean\n ) {\n // @ts-ignore\n return (this.findIndex(functionToCall) > -1)\n }\n \n}\n\nif (\"noneMatch\" in Array.prototype == NO) {\n \n (Array.prototype as any).noneMatch = function (\n this: Array<any>,\n functionToCall: (value: any, index: number, array: any[]) => boolean\n ) {\n // @ts-ignore\n return (this.findIndex(functionToCall) == -1)\n }\n \n}\n\nif (\"allMatch\" in Array.prototype == NO) {\n \n (Array.prototype as any).allMatch = function (\n this: Array<any>,\n functionToCall: (value: any, index: number, array: any[]) => boolean\n ) {\n \n function reversedFunction(value: any, index: number, array: any[]) {\n return !functionToCall(value, index, array)\n }\n \n // @ts-ignore\n return (this.findIndex(reversedFunction) == -1)\n \n }\n \n}\n\nif (\"findAsyncSequential\" in Array.prototype == NO) {\n \n (Array.prototype as any).findAsyncSequential = function (\n this: Array<any>,\n functionToCall: (value: any) => Promise<boolean>\n ) {\n \n // https://stackoverflow.com/questions/55601062/using-an-async-function-in-array-find\n async function findAsyncSequential<T>(\n array: T[],\n predicate: (t: T) => Promise<boolean>\n ): Promise<T | undefined> {\n for (const t of array) {\n if (await predicate(t)) {\n return t\n }\n }\n return undefined\n }\n \n return findAsyncSequential(this, functionToCall)\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// anyMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n//\n// noneMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n//\n// allMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n//\n// }\n\n\nif (\"groupedBy\" in Array.prototype == NO) {\n \n Array.prototype.groupedBy = function (this: Array<any>, funcProp) {\n return this.reduce(function (acc, val) {\n (acc[funcProp(val)] = acc[funcProp(val)] || []).push(val)\n return acc\n }, {})\n }\n \n}\n\n\n// interface Array<T> {\n//\n// groupedBy(keyFunction: (item: T) => any): { [key: string]: Array<T> };\n//\n// }\n\n\nif (\"firstElement\" in Array.prototype == NO) {\n Object.defineProperty(Array.prototype, \"firstElement\", {\n get: function firstElement(this: Array<any>) {\n return this[0]\n },\n set: function (this: Array<any>, element: any) {\n if (this.length == 0) {\n this.push(element)\n return\n }\n this[0] = element\n }\n })\n}\n\nif (\"lastElement\" in Array.prototype == NO) {\n Object.defineProperty(Array.prototype, \"lastElement\", {\n get: function lastElement(this: Array<any>) {\n return this[this.length - 1]\n },\n set: function (this: Array<any>, element: any) {\n if (this.length == 0) {\n this.push(element)\n return\n }\n this[this.length - 1] = element\n }\n })\n}\n\nif (\"everyElement\" in Array.prototype == NO) {\n \n Object.defineProperty(Array.prototype, \"everyElement\", {\n \n get: function everyElement(this: Array<any>) {\n \n const valueKeys: string[] = []\n \n const targetFunction = (objects: any) => {\n \n return this.map((element) => {\n \n const thisObject = UIObject.valueForKeyPath(\n valueKeys.arrayByTrimmingToLengthIfLonger(valueKeys.length - 1).join(\".\"),\n element\n ) || element\n \n const elementFunction = (UIObject.valueForKeyPath(valueKeys.join(\".\"), element) as Function)?.bind(\n thisObject,\n objects\n )\n \n return elementFunction?.()\n \n })\n \n }\n \n const result: any = new Proxy(\n targetFunction,\n {\n \n get: (target, key: string, _receiver) => {\n \n if (key == \"UI_elementValues\") {\n return this.map(element => UIObject.valueForKeyPath(\n valueKeys.join(\".\"),\n element\n ))\n }\n \n valueKeys.push(key)\n \n return result\n \n },\n set: (target, key: string, value, _receiver) => {\n \n valueKeys.push(key)\n this.forEach(element => UIObject.setValueForKeyPath(valueKeys.join(\".\"), value, element, YES))\n return true\n \n }\n \n }\n )\n \n return result\n \n },\n set: function (this: Array<any>, element: any) {\n for (let i = 0; i < this.length; ++i) {\n this[i] = element\n }\n }\n \n })\n \n}\n\n\nexport type UIEveryElementItem<T> = {\n \n [P in keyof T]: UIEveryElementItem<T[P]>\n \n} & {\n \n UI_elementValues?: T[];\n \n} & T\n\n// interface Array<T> {\n//\n// firstElement: T;\n// lastElement: T;\n//\n// everyElement: UIEveryElementItem<T>;\n//\n// }\n\n\nif (\"copy\" in Array.prototype == NO) {\n \n (Array.prototype as any).copy = function (this: Array<any>) {\n return this.slice(0)\n }\n \n}\n\n\n// interface Array<T> {\n//\n// copy(): Array<T>;\n//\n// }\n\n\nif (\"arrayByRepeating\" in Array.prototype == NO) {\n \n (Array.prototype as any).arrayByRepeating = function (this: Array<any>, numberOfRepetitions: number) {\n const result: any[] = []\n for (let i = 0; i < numberOfRepetitions; i++) {\n this.forEach(element => result.push(element))\n }\n return result\n }\n \n}\n\n\n// interface Array<T> {\n//\n// arrayByRepeating(numberOfRepetitions: number): Array<T>;\n//\n// }\n\n\nif (\"arrayByTrimmingToLengthIfLonger\" in Array.prototype == NO) {\n (Array.prototype as any).arrayByTrimmingToLengthIfLonger = function (this: Array<any>, maxLength: number) {\n const result = []\n for (let i = 0; i < maxLength && i < this.length; i++) {\n result.push(this[i])\n }\n return result\n }\n}\n\n\n// interface Array<T> {\n//\n// arrayByTrimmingToLengthIfLonger(maxLength: number): Array<T>;\n//\n// }\n\n\nif (\"summedValue\" in Array.prototype == NO) {\n \n Object.defineProperty(Array.prototype, \"summedValue\", {\n get: function summedValue(this: Array<any>) {\n return this.reduce(function (a, b) {\n return a + b\n }, 0)\n }\n })\n \n}\n\n\n// interface Array<T> {\n//\n// readonly summedValue: T;\n//\n// max(): number;\n// min(): number;\n//\n//\n// }\n\nArray.prototype.max = function () {\n return Math.max.apply(null, this)\n}\n\nArray.prototype.min = function () {\n return Math.min.apply(null, this)\n}\n\n\n// interface Array<T> {\n//\n// isEqualToArray(array: Array<T>, keyPath?: string): boolean;\n//\n// }\n\n\nif (\"isEqualToArray\" in Array.prototype == NO) {\n \n // attach the .equals method to Array's prototype to call it on any array\n Array.prototype.isEqualToArray = function (array: any[], keyPath?: string) {\n \n // if the other array is a falsy value, return\n if (!array) {\n return false\n }\n \n // compare lengths - can save a lot of time\n if (this.length != array.length) {\n return false\n }\n \n var i = 0\n const l = this.length\n for (; i < l; i++) {\n \n // Check if we have nested arrays\n if (this[i] instanceof Array && array[i] instanceof Array && !keyPath) {\n \n // recurse into the nested arrays\n if (!this[i].isEqualToArray(array[i])) {\n return false\n }\n \n }\n else if (keyPath && UIObject.valueForKeyPath(keyPath, this[i]) != UIObject.valueForKeyPath(\n keyPath,\n array[i]\n )) {\n \n return false\n \n }\n else if (this[i] != array[i]) {\n \n // Warning - two different object instances will never be equal: {x:20} != {x:20}\n return false\n \n }\n \n }\n \n return true\n \n }\n \n // Hide method from for-in loops\n Object.defineProperty(Array.prototype, \"isEqualToArray\", { enumerable: false })\n \n}\n\n\nif (\"forEach\" in Object.prototype == NO) {\n \n (Object.prototype as any).forEach = function (\n this: Record<string, any>,\n callbackFunction: (\n value: any,\n key: string,\n stopLooping: Function\n ) => void\n ) {\n const keys = Object.keys(this)\n let shouldStopLooping = NO\n \n function stopLooping() {\n shouldStopLooping = YES\n }\n \n keys.anyMatch(key => {\n callbackFunction(this[key], key, stopLooping)\n return shouldStopLooping\n })\n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"forEach\", { enumerable: false })\n \n}\n\n\n// interface Object {\n//\n// forEach(callbackFunction: (value: any, key: string) => void): void;\n//\n// }\n\n\nif (\"allValues\" in Object.prototype == NO) {\n Object.defineProperty(Object.prototype, \"allValues\", {\n get: function (this: Object) {\n const values: any[] = []\n this.forEach((value: any) => {\n values.push(value)\n })\n return values\n },\n enumerable: NO\n })\n}\n\n\n// interface Object {\n//\n// readonly allValues: Array<any>;\n//\n// }\n\n\nif (\"allKeys\" in Object.prototype == NO) {\n Object.defineProperty(Object.prototype, \"allKeys\", {\n get: function (this: Object) {\n return Object.keys(this)\n },\n enumerable: NO\n })\n}\n\n\n// interface Object {\n//\n// readonly allKeys: string[];\n//\n// }\n\n\nif (\"objectByCopyingValuesRecursivelyFromObject\" in Object.prototype == NO) {\n \n (Object.prototype as any).objectByCopyingValuesRecursivelyFromObject = function (this: Object, object: any) {\n \n \n function isAnObject(item: any) {\n return (item && typeof item === \"object\" && !Array.isArray(item))\n }\n \n function mergeRecursively(target: any, source: any) {\n \n const output = Object.assign({}, target)\n \n if (isAnObject(target) && isAnObject(source)) {\n \n Object.keys(source).forEach(function (key) {\n \n if (isAnObject(source[key])) {\n \n // if (!(key in target)) {\n \n // Object.assign(output, { [key]: source[key] });\n \n // }\n // else {\n \n output[key] = mergeRecursively(target[key] ?? {}, source[key])\n \n //}\n \n }\n else {\n \n Object.assign(output, { [key]: source[key] })\n \n }\n \n })\n \n }\n \n return output\n \n }\n \n return mergeRecursively(this, object)\n \n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"objectByCopyingValuesRecursivelyFromObject\", { enumerable: false })\n \n}\n\n\nif (\"asValueObject\" in Object.prototype == NO) {\n \n (Object.prototype as any).asValueObject = function () {\n \n return new UICoreExtensionValueObject(this)\n \n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"asValueObject\", { enumerable: false })\n \n}\n\n\n// interface Object {\n//\n// objectByCopyingValuesRecursivelyFromObject<T>(object: T): this & T;\n//\n// asValueObject(): this;\n//\n// }\n\n// export type Unpacked<T> =\n// T extends (infer U)[]\n// ? U\n// : T extends (...args: any[]) => infer U\n// ? U\n// : T extends Promise<infer U>\n// ? U\n// : T\n//\n// export type UnpackedObject<T> = {\n// [P in keyof T]: Unpacked<T[P]>\n// }\n\n// export function promisedProperties<ObjectType extends Record<string, any>>(object: ObjectType): UnpackedObject<ObjectType> {\n//\n// let promisedProperties: any[] = []\n// const objectKeys = Object.keys(object)\n//\n// objectKeys.forEach((key) => promisedProperties.push(object[key]))\n//\n// // @ts-ignore\n// return Promise.all(promisedProperties)\n// .then((resolvedValues) => {\n// return resolvedValues.reduce((resolvedObject, property, index) => {\n// resolvedObject[objectKeys[index]] = property\n// return resolvedObject\n// }, object)\n// })\n//\n// }\n\n// if (\"promisedProperties\" in Object.prototype == NO) {\n//\n// (Object.prototype as any).promisedProperties = function () {\n//\n// const result = promisedProperties(this);\n//\n// return result\n//\n// }\n//\n// // Hide method from for-in loops\n// Object.defineProperty(Object.prototype, \"promisedProperties\", { enumerable: false });\n//\n// }\n//\n//\n// interface Object {\n//\n// readonly promisedProperties: UnpackedObject<this>;\n//\n// }\n\n\nif (\"contains\" in String.prototype == NO) {\n \n (String.prototype as any).contains = function (this: String, string: string) {\n return (this.indexOf(string) != -1)\n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"contains\", { enumerable: false })\n \n}\n\n\n// interface String {\n//\n// contains(string): boolean;\n//\n// }\n\n\nif (\"capitalizedString\" in String.prototype == NO) {\n Object.defineProperty(Object.prototype, \"capitalizedString\", {\n get: function (this: String) {\n return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase()\n },\n enumerable: NO\n })\n}\n\n\n// interface String {\n//\n// readonly capitalizedString: string;\n//\n// }\n\n\nif (\"numericalValue\" in String.prototype == NO) {\n Object.defineProperty(String.prototype, \"numericalValue\", {\n get: function numericalValue(this: string) {\n return Number(this)\n }\n })\n}\n\nif (\"integerValue\" in String.prototype == NO) {\n Object.defineProperty(String.prototype, \"integerValue\", {\n get: function integerValue(this: string) {\n return Number(this).integerValue\n }\n })\n}\n\n\n// interface String {\n//\n// readonly numericalValue: number;\n//\n// }\n\n\nif (\"isAString\" in String.prototype == NO) {\n \n (String.prototype as any).isAString = YES\n \n}\n\n\n// interface String {\n//\n// isAString: boolean;\n//\n// }\n\n\nif (\"isANumber\" in Number.prototype == NO) {\n \n (Number.prototype as any).isANumber = YES\n \n}\n\n\n// interface Number {\n//\n// isANumber: boolean;\n//\n// }\n\n\nif (\"integerValue\" in Number.prototype == NO) {\n Object.defineProperty(Number.prototype, \"integerValue\", {\n get: function (this: number) {\n return parseInt(\"\" + (Math.round(this) + 0.5))\n },\n enumerable: NO\n })\n}\n\nif (\"constrainedValue\" in Number.prototype == NO) {\n \n (Number.prototype as any).constrainedValue = function (this: number, min: number, max: number) {\n if (this < min) {\n return min;\n }\n if (this > max) {\n return max;\n }\n return this\n }\n \n // Hide method from for-in loops\n Object.defineProperty(Number.prototype, \"constrainedValue\", {\n enumerable: NO\n })\n \n}\n\n\n// interface Number {\n//\n// readonly integerValue: number;\n//\n// }\n\n\nif (\"integerValue\" in Boolean.prototype == NO) {\n \n Object.defineProperty(Boolean.prototype, \"integerValue\", {\n get: function (this: boolean) {\n if (this == true) {\n return 1\n }\n return 0\n }\n })\n \n}\n\n\n// interface Boolean {\n//\n// readonly integerValue: number;\n//\n// }\n\n\nif (\"dateString\" in Date.prototype == NO) {\n \n Object.defineProperty(Date.prototype, \"dateString\", {\n get: function dateString(this: Date) {\n return (\"0\" + this.getDate()).slice(-2) + \"-\" + (\"0\" + (this.getMonth() + 1)).slice(-2) + \"-\" +\n this.getFullYear() + \" \" + (\"0\" + this.getHours()).slice(-2) + \":\" +\n (\"0\" + this.getMinutes()).slice(-2)\n }\n })\n \n \n}\n\n\n// interface Date {\n//\n// readonly dateString: string;\n//\n// }\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wCAA2C;AAC3C,sBAAyB;
|
|
4
|
+
"sourcesContent": ["import { UICoreExtensionValueObject } from \"./UICoreExtensionValueObject\"\nimport { UIObject } from \"./UIObject\"\n\n\ndeclare global {\n \n \n interface Array<T> {\n \n removeElementAtIndex(index: number): void;\n \n removeElement(element: T): void;\n \n insertElementAtIndex(index: number, element: T): void;\n \n replaceElementAtIndex(index: number, element: T): void;\n \n \n contains(element: T): boolean;\n \n findAsyncSequential(functionToCall: (value: any) => Promise<boolean>): Promise<any>;\n \n groupedBy(keyFunction: (item: T) => any): { [key: string]: Array<T> } & Object;\n \n copy(): Array<T>;\n \n arrayByRepeating(numberOfRepetitions: number): Array<T>;\n \n arrayByTrimmingToLengthIfLonger(maxLength: number): Array<T>;\n \n anyMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n \n noneMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n \n allMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n \n firstElement: T;\n lastElement: T;\n readonly summedValue: T;\n \n everyElement: UIEveryElementItem<T>;\n \n max(): number;\n \n min(): number;\n \n average(): number;\n \n isEqualToArray(array: Array<T>, keyPath?: string): boolean;\n \n }\n \n \n interface String {\n \n contains(string: string): boolean;\n \n readonly numericalValue: number;\n readonly integerValue: number;\n isAString: boolean;\n \n }\n \n \n interface Number {\n \n isANumber: boolean;\n \n readonly integerValue: number;\n \n constrainedValue(min: number, max: number): number;\n \n }\n \n \n interface Date {\n \n readonly dateString: string;\n \n }\n \n \n interface Object {\n \n forEach(callbackFunction: (value: any, key: string, stopLooping: () => void) => void): void;\n \n objectByCopyingValuesRecursivelyFromObject<T extends object>(object: T): T & this;\n \n readonly allValues: Array<any>;\n readonly allKeys: (keyof this)[];\n \n }\n \n}\n\nexport {}\n\nconst YES = true\nconst NO = false\n\nif (\"removeElementAtIndex\" in Array.prototype == NO) {\n \n (Array.prototype as any).removeElementAtIndex = function (this: Array<any>, index: number) {\n \n // @ts-ignore\n if (index >= 0 && index < this.length) {\n this.splice(index, 1)\n }\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// removeElementAtIndex(index: number);\n//\n// }\n\n\nif (\"removeElement\" in Array.prototype == NO) {\n \n (Array.prototype as any).removeElement = function (this: Array<any>, element: any) {\n this.removeElementAtIndex(this.indexOf(element))\n }\n \n}\n\n\n// interface Array<T> {\n//\n// removeElement(element: T);\n//\n// }\n\n\nif (\"insertElementAtIndex\" in Array.prototype == NO) {\n \n (Array.prototype as any).insertElementAtIndex = function (this: Array<any>, index: number, element: any) {\n \n if (index >= 0 && index <= this.length) {\n this.splice(index, 0, element)\n }\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// insertElementAtIndex(index: number, element: T);\n//\n// }\n\n\nif (\"replaceElementAtIndex\" in Array.prototype == NO) {\n \n (Array.prototype as any).replaceElementAtIndex = function (this: Array<any>, index: number, element: any) {\n \n this.removeElementAtIndex(index)\n this.insertElementAtIndex(index, element)\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// replaceElementAtIndex(index: number, element: T);\n//\n// }\n\n\nif (\"contains\" in Array.prototype == NO) {\n \n (Array.prototype as any).contains = function (this: Array<any>, element: any) {\n return (this.indexOf(element) != -1)\n }\n \n}\n\nif (\"containsAny\" in Array.prototype == NO) {\n \n (Array.prototype as any).containsAny = function (this: Array<any>, elements: any[]) {\n return this.anyMatch(element => elements.contains(element))\n }\n \n}\n\n\n// interface Array<T> {\n//\n// contains(element: T): boolean;\n//\n// containsAny(element: T[]): boolean;\n//\n// }\n\n\nif (\"anyMatch\" in Array.prototype == NO) {\n \n (Array.prototype as any).anyMatch = function (\n this: Array<any>,\n functionToCall: (value: any, index: number, array: any[]) => boolean\n ) {\n // @ts-ignore\n return (this.findIndex(functionToCall) > -1)\n }\n \n}\n\nif (\"noneMatch\" in Array.prototype == NO) {\n \n (Array.prototype as any).noneMatch = function (\n this: Array<any>,\n functionToCall: (value: any, index: number, array: any[]) => boolean\n ) {\n // @ts-ignore\n return (this.findIndex(functionToCall) == -1)\n }\n \n}\n\nif (\"allMatch\" in Array.prototype == NO) {\n \n (Array.prototype as any).allMatch = function (\n this: Array<any>,\n functionToCall: (value: any, index: number, array: any[]) => boolean\n ) {\n \n function reversedFunction(value: any, index: number, array: any[]) {\n return !functionToCall(value, index, array)\n }\n \n // @ts-ignore\n return (this.findIndex(reversedFunction) == -1)\n \n }\n \n}\n\nif (\"findAsyncSequential\" in Array.prototype == NO) {\n \n (Array.prototype as any).findAsyncSequential = function (\n this: Array<any>,\n functionToCall: (value: any) => Promise<boolean>\n ) {\n \n // https://stackoverflow.com/questions/55601062/using-an-async-function-in-array-find\n async function findAsyncSequential<T>(\n array: T[],\n predicate: (t: T) => Promise<boolean>\n ): Promise<T | undefined> {\n for (const t of array) {\n if (await predicate(t)) {\n return t\n }\n }\n return undefined\n }\n \n return findAsyncSequential(this, functionToCall)\n \n }\n \n}\n\n\n// interface Array<T> {\n//\n// anyMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n//\n// noneMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n//\n// allMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean\n//\n// }\n\n\nif (\"groupedBy\" in Array.prototype == NO) {\n \n Array.prototype.groupedBy = function (this: Array<any>, funcProp) {\n return this.reduce(function (acc, val) {\n (acc[funcProp(val)] = acc[funcProp(val)] || []).push(val)\n return acc\n }, {})\n }\n \n}\n\n\n// interface Array<T> {\n//\n// groupedBy(keyFunction: (item: T) => any): { [key: string]: Array<T> };\n//\n// }\n\n\nif (\"firstElement\" in Array.prototype == NO) {\n Object.defineProperty(Array.prototype, \"firstElement\", {\n get: function firstElement(this: Array<any>) {\n return this[0]\n },\n set: function (this: Array<any>, element: any) {\n if (this.length == 0) {\n this.push(element)\n return\n }\n this[0] = element\n }\n })\n}\n\nif (\"lastElement\" in Array.prototype == NO) {\n Object.defineProperty(Array.prototype, \"lastElement\", {\n get: function lastElement(this: Array<any>) {\n return this[this.length - 1]\n },\n set: function (this: Array<any>, element: any) {\n if (this.length == 0) {\n this.push(element)\n return\n }\n this[this.length - 1] = element\n }\n })\n}\n\nif (\"everyElement\" in Array.prototype == NO) {\n \n Object.defineProperty(Array.prototype, \"everyElement\", {\n \n get: function everyElement(this: Array<any>) {\n \n const valueKeys: string[] = []\n \n const targetFunction = (objects: any) => {\n \n return this.map((element) => {\n \n const thisObject = UIObject.valueForKeyPath(\n valueKeys.arrayByTrimmingToLengthIfLonger(valueKeys.length - 1).join(\".\"),\n element\n ) || element\n \n const elementFunction = (UIObject.valueForKeyPath(valueKeys.join(\".\"), element) as Function)?.bind(\n thisObject,\n objects\n )\n \n return elementFunction?.()\n \n })\n \n }\n \n const result: any = new Proxy(\n targetFunction,\n {\n \n get: (target, key: string, _receiver) => {\n \n if (key == \"UI_elementValues\") {\n return this.map(element => UIObject.valueForKeyPath(\n valueKeys.join(\".\"),\n element\n ))\n }\n \n valueKeys.push(key)\n \n return result\n \n },\n set: (target, key: string, value, _receiver) => {\n \n valueKeys.push(key)\n this.forEach(element => UIObject.setValueForKeyPath(valueKeys.join(\".\"), value, element, YES))\n return true\n \n }\n \n }\n )\n \n return result\n \n },\n set: function (this: Array<any>, element: any) {\n for (let i = 0; i < this.length; ++i) {\n this[i] = element\n }\n }\n \n })\n \n}\n\n\nexport type UIEveryElementItem<T> = {\n \n [P in keyof T]: UIEveryElementItem<T[P]>\n \n} & {\n \n UI_elementValues?: T[];\n \n} & T\n\n// interface Array<T> {\n//\n// firstElement: T;\n// lastElement: T;\n//\n// everyElement: UIEveryElementItem<T>;\n//\n// }\n\n\nif (\"copy\" in Array.prototype == NO) {\n \n (Array.prototype as any).copy = function (this: Array<any>) {\n return this.slice(0)\n }\n \n}\n\n\n// interface Array<T> {\n//\n// copy(): Array<T>;\n//\n// }\n\n\nif (\"arrayByRepeating\" in Array.prototype == NO) {\n \n (Array.prototype as any).arrayByRepeating = function (this: Array<any>, numberOfRepetitions: number) {\n const result: any[] = []\n for (let i = 0; i < numberOfRepetitions; i++) {\n this.forEach(element => result.push(element))\n }\n return result\n }\n \n}\n\n\n// interface Array<T> {\n//\n// arrayByRepeating(numberOfRepetitions: number): Array<T>;\n//\n// }\n\n\nif (\"arrayByTrimmingToLengthIfLonger\" in Array.prototype == NO) {\n (Array.prototype as any).arrayByTrimmingToLengthIfLonger = function (this: Array<any>, maxLength: number) {\n const result = []\n for (let i = 0; i < maxLength && i < this.length; i++) {\n result.push(this[i])\n }\n return result\n }\n}\n\n\n// interface Array<T> {\n//\n// arrayByTrimmingToLengthIfLonger(maxLength: number): Array<T>;\n//\n// }\n\n\nif (\"summedValue\" in Array.prototype == NO) {\n \n Object.defineProperty(Array.prototype, \"summedValue\", {\n get: function summedValue(this: Array<any>) {\n return this.reduce(function (a, b) {\n return a + b\n }, 0)\n }\n })\n \n}\n\n\n// interface Array<T> {\n//\n// readonly summedValue: T;\n//\n// max(): number;\n// min(): number;\n//\n//\n// }\n\nArray.prototype.max = function () {\n return Math.max.apply(null, this)\n}\n\nArray.prototype.min = function () {\n return Math.min.apply(null, this)\n}\n\nif (!Array.prototype.average) {\n \n Array.prototype.average = function () {\n if (this.length == 0) {\n return 0;\n }\n const sum = this.reduce((a, b) => a + b, 0)\n return sum / this.length\n }\n \n}\n\n// interface Array<T> {\n//\n// isEqualToArray(array: Array<T>, keyPath?: string): boolean;\n//\n// }\n\n\nif (\"isEqualToArray\" in Array.prototype == NO) {\n \n // attach the .equals method to Array's prototype to call it on any array\n Array.prototype.isEqualToArray = function (array: any[], keyPath?: string) {\n \n // if the other array is a falsy value, return\n if (!array) {\n return false\n }\n \n // compare lengths - can save a lot of time\n if (this.length != array.length) {\n return false\n }\n \n var i = 0\n const l = this.length\n for (; i < l; i++) {\n \n // Check if we have nested arrays\n if (this[i] instanceof Array && array[i] instanceof Array && !keyPath) {\n \n // recurse into the nested arrays\n if (!this[i].isEqualToArray(array[i])) {\n return false\n }\n \n }\n else if (keyPath && UIObject.valueForKeyPath(keyPath, this[i]) != UIObject.valueForKeyPath(\n keyPath,\n array[i]\n )) {\n \n return false\n \n }\n else if (this[i] != array[i]) {\n \n // Warning - two different object instances will never be equal: {x:20} != {x:20}\n return false\n \n }\n \n }\n \n return true\n \n }\n \n // Hide method from for-in loops\n Object.defineProperty(Array.prototype, \"isEqualToArray\", { enumerable: false })\n \n}\n\n\nif (\"forEach\" in Object.prototype == NO) {\n \n (Object.prototype as any).forEach = function (\n this: Record<string, any>,\n callbackFunction: (\n value: any,\n key: string,\n stopLooping: Function\n ) => void\n ) {\n const keys = Object.keys(this)\n let shouldStopLooping = NO\n \n function stopLooping() {\n shouldStopLooping = YES\n }\n \n keys.anyMatch(key => {\n callbackFunction(this[key], key, stopLooping)\n return shouldStopLooping\n })\n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"forEach\", { enumerable: false })\n \n}\n\n\n// interface Object {\n//\n// forEach(callbackFunction: (value: any, key: string) => void): void;\n//\n// }\n\n\nif (\"allValues\" in Object.prototype == NO) {\n Object.defineProperty(Object.prototype, \"allValues\", {\n get: function (this: Object) {\n const values: any[] = []\n this.forEach((value: any) => {\n values.push(value)\n })\n return values\n },\n enumerable: NO\n })\n}\n\n\n// interface Object {\n//\n// readonly allValues: Array<any>;\n//\n// }\n\n\nif (\"allKeys\" in Object.prototype == NO) {\n Object.defineProperty(Object.prototype, \"allKeys\", {\n get: function (this: Object) {\n return Object.keys(this)\n },\n enumerable: NO\n })\n}\n\n\n// interface Object {\n//\n// readonly allKeys: string[];\n//\n// }\n\n\nif (\"objectByCopyingValuesRecursivelyFromObject\" in Object.prototype == NO) {\n \n (Object.prototype as any).objectByCopyingValuesRecursivelyFromObject = function (this: Object, object: any) {\n \n \n function isAnObject(item: any) {\n return (item && typeof item === \"object\" && !Array.isArray(item))\n }\n \n function mergeRecursively(target: any, source: any) {\n \n const output = Object.assign({}, target)\n \n if (isAnObject(target) && isAnObject(source)) {\n \n Object.keys(source).forEach(function (key) {\n \n if (isAnObject(source[key])) {\n \n // if (!(key in target)) {\n \n // Object.assign(output, { [key]: source[key] });\n \n // }\n // else {\n \n output[key] = mergeRecursively(target[key] ?? {}, source[key])\n \n //}\n \n }\n else {\n \n Object.assign(output, { [key]: source[key] })\n \n }\n \n })\n \n }\n \n return output\n \n }\n \n return mergeRecursively(this, object)\n \n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"objectByCopyingValuesRecursivelyFromObject\", { enumerable: false })\n \n}\n\n\nif (\"asValueObject\" in Object.prototype == NO) {\n \n (Object.prototype as any).asValueObject = function () {\n \n return new UICoreExtensionValueObject(this)\n \n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"asValueObject\", { enumerable: false })\n \n}\n\n\n// interface Object {\n//\n// objectByCopyingValuesRecursivelyFromObject<T>(object: T): this & T;\n//\n// asValueObject(): this;\n//\n// }\n\n// export type Unpacked<T> =\n// T extends (infer U)[]\n// ? U\n// : T extends (...args: any[]) => infer U\n// ? U\n// : T extends Promise<infer U>\n// ? U\n// : T\n//\n// export type UnpackedObject<T> = {\n// [P in keyof T]: Unpacked<T[P]>\n// }\n\n// export function promisedProperties<ObjectType extends Record<string, any>>(object: ObjectType): UnpackedObject<ObjectType> {\n//\n// let promisedProperties: any[] = []\n// const objectKeys = Object.keys(object)\n//\n// objectKeys.forEach((key) => promisedProperties.push(object[key]))\n//\n// // @ts-ignore\n// return Promise.all(promisedProperties)\n// .then((resolvedValues) => {\n// return resolvedValues.reduce((resolvedObject, property, index) => {\n// resolvedObject[objectKeys[index]] = property\n// return resolvedObject\n// }, object)\n// })\n//\n// }\n\n// if (\"promisedProperties\" in Object.prototype == NO) {\n//\n// (Object.prototype as any).promisedProperties = function () {\n//\n// const result = promisedProperties(this);\n//\n// return result\n//\n// }\n//\n// // Hide method from for-in loops\n// Object.defineProperty(Object.prototype, \"promisedProperties\", { enumerable: false });\n//\n// }\n//\n//\n// interface Object {\n//\n// readonly promisedProperties: UnpackedObject<this>;\n//\n// }\n\n\nif (\"contains\" in String.prototype == NO) {\n \n (String.prototype as any).contains = function (this: String, string: string) {\n return (this.indexOf(string) != -1)\n }\n \n // Hide method from for-in loops\n Object.defineProperty(Object.prototype, \"contains\", { enumerable: false })\n \n}\n\n\n// interface String {\n//\n// contains(string): boolean;\n//\n// }\n\n\nif (\"capitalizedString\" in String.prototype == NO) {\n Object.defineProperty(Object.prototype, \"capitalizedString\", {\n get: function (this: String) {\n return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase()\n },\n enumerable: NO\n })\n}\n\n\n// interface String {\n//\n// readonly capitalizedString: string;\n//\n// }\n\n\nif (\"numericalValue\" in String.prototype == NO) {\n Object.defineProperty(String.prototype, \"numericalValue\", {\n get: function numericalValue(this: string) {\n return Number(this)\n }\n })\n}\n\nif (\"integerValue\" in String.prototype == NO) {\n Object.defineProperty(String.prototype, \"integerValue\", {\n get: function integerValue(this: string) {\n return Number(this).integerValue\n }\n })\n}\n\n\n// interface String {\n//\n// readonly numericalValue: number;\n//\n// }\n\n\nif (\"isAString\" in String.prototype == NO) {\n \n (String.prototype as any).isAString = YES\n \n}\n\n\n// interface String {\n//\n// isAString: boolean;\n//\n// }\n\n\nif (\"isANumber\" in Number.prototype == NO) {\n \n (Number.prototype as any).isANumber = YES\n \n}\n\n\n// interface Number {\n//\n// isANumber: boolean;\n//\n// }\n\n\nif (\"integerValue\" in Number.prototype == NO) {\n Object.defineProperty(Number.prototype, \"integerValue\", {\n get: function (this: number) {\n return parseInt(\"\" + (Math.round(this) + 0.5))\n },\n enumerable: NO\n })\n}\n\nif (\"constrainedValue\" in Number.prototype == NO) {\n \n (Number.prototype as any).constrainedValue = function (this: number, min: number, max: number) {\n if (this < min) {\n return min;\n }\n if (this > max) {\n return max;\n }\n return this\n }\n \n // Hide method from for-in loops\n Object.defineProperty(Number.prototype, \"constrainedValue\", {\n enumerable: NO\n })\n \n}\n\n\n// interface Number {\n//\n// readonly integerValue: number;\n//\n// }\n\n\nif (\"integerValue\" in Boolean.prototype == NO) {\n \n Object.defineProperty(Boolean.prototype, \"integerValue\", {\n get: function (this: boolean) {\n if (this == true) {\n return 1\n }\n return 0\n }\n })\n \n}\n\n\n// interface Boolean {\n//\n// readonly integerValue: number;\n//\n// }\n\n\nif (\"dateString\" in Date.prototype == NO) {\n \n Object.defineProperty(Date.prototype, \"dateString\", {\n get: function dateString(this: Date) {\n return (\"0\" + this.getDate()).slice(-2) + \"-\" + (\"0\" + (this.getMonth() + 1)).slice(-2) + \"-\" +\n this.getFullYear() + \" \" + (\"0\" + this.getHours()).slice(-2) + \":\" +\n (\"0\" + this.getMinutes()).slice(-2)\n }\n })\n \n \n}\n\n\n// interface Date {\n//\n// readonly dateString: string;\n//\n// }\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wCAA2C;AAC3C,sBAAyB;AAgGzB,MAAM,MAAM;AACZ,MAAM,KAAK;AAEX,IAAI,0BAA0B,MAAM,aAAa,IAAI;AAEjD,EAAC,MAAM,UAAkB,uBAAuB,SAA4B,OAAe;AAGvF,QAAI,SAAS,KAAK,QAAQ,KAAK,QAAQ;AACnC,WAAK,OAAO,OAAO,CAAC;AAAA,IACxB;AAAA,EAEJ;AAEJ;AAUA,IAAI,mBAAmB,MAAM,aAAa,IAAI;A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,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AAGA,SAAO,eAAe,OAAO,WAAW,oBAAoB;AAAA,IACxD,YAAY;AAAA,EAChB,CAAC;AAEL;AAUA,IAAI,kBAAkB,QAAQ,aAAa,IAAI;AAE3C,SAAO,eAAe,QAAQ,WAAW,gBAAgB;AAAA,IACrD,KAAK,WAAyB;AAC1B,UAAI,QAAQ,MAAM;AACd,eAAO;AAAA,MACX;AACA,aAAO;AAAA,IACX;AAAA,EACJ,CAAC;AAEL;AAUA,IAAI,gBAAgB,KAAK,aAAa,IAAI;AAEtC,SAAO,eAAe,KAAK,WAAW,cAAc;AAAA,IAChD,KAAK,SAAS,aAAuB;AACjC,cAAQ,MAAM,KAAK,QAAQ,GAAG,MAAM,EAAE,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,IAAI,MAAM,EAAE,IAAI,MACtF,KAAK,YAAY,IAAI,OAAO,MAAM,KAAK,SAAS,GAAG,MAAM,EAAE,IAAI,OAC9D,MAAM,KAAK,WAAW,GAAG,MAAM,EAAE;AAAA,IAC1C;AAAA,EACJ,CAAC;AAGL;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UIObject } from "./UIObject";
|
|
2
|
+
export interface UIKeyValueStringSorterSortingInstruction {
|
|
3
|
+
keyPath: string;
|
|
4
|
+
dataType: string;
|
|
5
|
+
direction: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class UIKeyValueSorter extends UIObject {
|
|
8
|
+
static _sharedWebWorkerHolder: {
|
|
9
|
+
UICore_completionFunctions: {};
|
|
10
|
+
UICore_isWorking: boolean;
|
|
11
|
+
UICore_messagesToPost: undefined;
|
|
12
|
+
webWorker: any;
|
|
13
|
+
};
|
|
14
|
+
static _instanceNumber: number;
|
|
15
|
+
_instanceNumber: number;
|
|
16
|
+
_isThreadClosed: boolean;
|
|
17
|
+
private readonly _webWorkerHolder;
|
|
18
|
+
constructor(useSeparateWebWorkerHolder?: boolean);
|
|
19
|
+
get instanceIdentifier(): number;
|
|
20
|
+
get completionFunctions(): {
|
|
21
|
+
[x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void;
|
|
22
|
+
};
|
|
23
|
+
get messagesToPost(): any[];
|
|
24
|
+
set isWorkerBusy(isWorkerBusy: boolean);
|
|
25
|
+
get isWorkerBusy(): boolean;
|
|
26
|
+
postNextMessageIfNeeded(): void;
|
|
27
|
+
static dataType: {
|
|
28
|
+
string: string;
|
|
29
|
+
number: string;
|
|
30
|
+
};
|
|
31
|
+
static direction: {
|
|
32
|
+
descending: string;
|
|
33
|
+
ascending: string;
|
|
34
|
+
};
|
|
35
|
+
sortData<T>(data: T[], sortingInstructions: UIKeyValueStringSorterSortingInstruction[], identifier: any, completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void): void;
|
|
36
|
+
sortedData<T>(data: T[], sortingInstructions: UIKeyValueStringSorterSortingInstruction[], identifier?: any): Promise<{
|
|
37
|
+
sortedData: T[];
|
|
38
|
+
sortedIndexes: number[];
|
|
39
|
+
identifier: any;
|
|
40
|
+
}>;
|
|
41
|
+
closeThread(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var UIKeyValueSorter_exports = {};
|
|
26
|
+
__export(UIKeyValueSorter_exports, {
|
|
27
|
+
UIKeyValueSorter: () => UIKeyValueSorter
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(UIKeyValueSorter_exports);
|
|
30
|
+
var import_UIKeyValueSorterWebWorker = __toESM(require("./UIKeyValueSorterWebWorker.worker"));
|
|
31
|
+
var import_UIObject = require("./UIObject");
|
|
32
|
+
const _UIKeyValueSorter = class extends import_UIObject.UIObject {
|
|
33
|
+
constructor(useSeparateWebWorkerHolder = import_UIObject.NO) {
|
|
34
|
+
super();
|
|
35
|
+
this._isThreadClosed = import_UIObject.NO;
|
|
36
|
+
this._webWorkerHolder = _UIKeyValueSorter._sharedWebWorkerHolder;
|
|
37
|
+
if (useSeparateWebWorkerHolder) {
|
|
38
|
+
this._webWorkerHolder = {
|
|
39
|
+
webWorker: new import_UIKeyValueSorterWebWorker.default(),
|
|
40
|
+
UICore_isWorking: false,
|
|
41
|
+
UICore_messagesToPost: void 0,
|
|
42
|
+
UICore_completionFunctions: {}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
_UIKeyValueSorter._instanceNumber = _UIKeyValueSorter._instanceNumber + 1;
|
|
46
|
+
this._instanceNumber = _UIKeyValueSorter._instanceNumber;
|
|
47
|
+
if ((0, import_UIObject.IS_NOT)(this._webWorkerHolder.webWorker.onmessage)) {
|
|
48
|
+
this._webWorkerHolder.webWorker.onmessage = (message) => {
|
|
49
|
+
this.isWorkerBusy = import_UIObject.NO;
|
|
50
|
+
this.postNextMessageIfNeeded();
|
|
51
|
+
const key = "" + message.data.identifier + message.data.instanceIdentifier;
|
|
52
|
+
const completionFunction = this.completionFunctions[key];
|
|
53
|
+
if ((0, import_UIObject.IS)(completionFunction)) {
|
|
54
|
+
completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier);
|
|
55
|
+
}
|
|
56
|
+
delete this.completionFunctions[key];
|
|
57
|
+
var asd = 1;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
get instanceIdentifier() {
|
|
62
|
+
return this._instanceNumber;
|
|
63
|
+
}
|
|
64
|
+
get completionFunctions() {
|
|
65
|
+
const key = "UICore_completionFunctions";
|
|
66
|
+
var result = this._webWorkerHolder[key];
|
|
67
|
+
if ((0, import_UIObject.IS_NOT)(result)) {
|
|
68
|
+
result = {};
|
|
69
|
+
this._webWorkerHolder[key] = result;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
get messagesToPost() {
|
|
74
|
+
const key = "UICore_messagesToPost";
|
|
75
|
+
var result = this._webWorkerHolder[key];
|
|
76
|
+
if ((0, import_UIObject.IS_NOT)(result)) {
|
|
77
|
+
result = [];
|
|
78
|
+
this._webWorkerHolder[key] = result;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
set isWorkerBusy(isWorkerBusy) {
|
|
83
|
+
this._webWorkerHolder["UICore_isWorking"] = isWorkerBusy;
|
|
84
|
+
}
|
|
85
|
+
get isWorkerBusy() {
|
|
86
|
+
return (0, import_UIObject.IS)(this._webWorkerHolder["UICore_isWorking"]);
|
|
87
|
+
}
|
|
88
|
+
postNextMessageIfNeeded() {
|
|
89
|
+
if (this.messagesToPost.length && (0, import_UIObject.IS_NOT)(this.isWorkerBusy)) {
|
|
90
|
+
this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement);
|
|
91
|
+
this.messagesToPost.removeElementAtIndex(0);
|
|
92
|
+
this.isWorkerBusy = import_UIObject.YES;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
sortData(data, sortingInstructions, identifier, completion) {
|
|
96
|
+
if (this._isThreadClosed) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const instanceIdentifier = this.instanceIdentifier;
|
|
100
|
+
const key = "" + identifier + instanceIdentifier;
|
|
101
|
+
this.completionFunctions[key] = completion;
|
|
102
|
+
try {
|
|
103
|
+
this.messagesToPost.push({
|
|
104
|
+
"data": data,
|
|
105
|
+
"sortingInstructions": sortingInstructions,
|
|
106
|
+
"identifier": identifier,
|
|
107
|
+
"instanceIdentifier": instanceIdentifier
|
|
108
|
+
});
|
|
109
|
+
this.postNextMessageIfNeeded();
|
|
110
|
+
} catch (exception) {
|
|
111
|
+
completion([], [], identifier);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
sortedData(data, sortingInstructions, identifier = (0, import_UIObject.MAKE_ID)()) {
|
|
115
|
+
const result = new Promise((resolve, reject) => {
|
|
116
|
+
this.sortData(data, sortingInstructions, identifier, (sortedData, sortedIndexes, sortedIdentifier) => {
|
|
117
|
+
if (sortedIdentifier == identifier) {
|
|
118
|
+
resolve({
|
|
119
|
+
sortedData,
|
|
120
|
+
sortedIndexes,
|
|
121
|
+
identifier: sortedIdentifier
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
closeThread() {
|
|
129
|
+
this._isThreadClosed = import_UIObject.YES;
|
|
130
|
+
if (this._webWorkerHolder != _UIKeyValueSorter._sharedWebWorkerHolder) {
|
|
131
|
+
this._webWorkerHolder.webWorker.terminate();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
let UIKeyValueSorter = _UIKeyValueSorter;
|
|
136
|
+
UIKeyValueSorter._sharedWebWorkerHolder = {
|
|
137
|
+
UICore_completionFunctions: {},
|
|
138
|
+
UICore_isWorking: false,
|
|
139
|
+
UICore_messagesToPost: void 0,
|
|
140
|
+
webWorker: new import_UIKeyValueSorterWebWorker.default()
|
|
141
|
+
};
|
|
142
|
+
UIKeyValueSorter._instanceNumber = -1;
|
|
143
|
+
UIKeyValueSorter.dataType = {
|
|
144
|
+
"string": "string",
|
|
145
|
+
"number": "number"
|
|
146
|
+
};
|
|
147
|
+
UIKeyValueSorter.direction = {
|
|
148
|
+
"descending": "descending",
|
|
149
|
+
"ascending": "ascending"
|
|
150
|
+
};
|
|
151
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
152
|
+
0 && (module.exports = {
|
|
153
|
+
UIKeyValueSorter
|
|
154
|
+
});
|
|
155
|
+
//# sourceMappingURL=UIKeyValueSorter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../scripts/UIKeyValueSorter.ts"],
|
|
4
|
+
"sourcesContent": ["// @ts-ignore\nimport UIKeyValueSorterWebWorker from \"./UIKeyValueSorterWebWorker.worker\"\nimport { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from \"./UIObject\"\n\n\nexport interface UIKeyValueStringSorterSortingInstruction {\n \n keyPath: string;\n \n dataType: string;\n \n direction: string;\n \n \n}\n\n\nexport class UIKeyValueSorter extends UIObject {\n \n static _sharedWebWorkerHolder = {\n UICore_completionFunctions: {},\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n webWorker: new UIKeyValueSorterWebWorker()\n }\n \n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder: {\n webWorker: any;\n UICore_isWorking: boolean\n UICore_messagesToPost: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n } = UIKeyValueSorter._sharedWebWorkerHolder\n \n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n \n this._webWorkerHolder = {\n webWorker: new UIKeyValueSorterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n \n }\n \n UIKeyValueSorter._instanceNumber = UIKeyValueSorter._instanceNumber + 1\n this._instanceNumber = UIKeyValueSorter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; sortedData: any[]; sortedIndexes: number[]; }; }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n var result: {\n \n [x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n static dataType = {\n \n \"string\": \"string\",\n \"number\": \"number\"\n \n }\n \n \n static direction = {\n \n \"descending\": \"descending\",\n \"ascending\": \"ascending\"\n \n }\n \n \n sortData<T>(\n data: T[],\n sortingInstructions: UIKeyValueStringSorterSortingInstruction[],\n identifier: any,\n completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n \n \n const instanceIdentifier = this.instanceIdentifier\n \n const key = \"\" + identifier + instanceIdentifier\n \n this.completionFunctions[key] = completion\n \n \n try {\n \n this.messagesToPost.push({\n \n \"data\": data,\n \"sortingInstructions\": sortingInstructions,\n \"identifier\": identifier,\n \"instanceIdentifier\": instanceIdentifier\n \n })\n \n this.postNextMessageIfNeeded()\n \n } catch (exception) {\n \n completion([], [], identifier)\n \n }\n \n \n }\n \n \n sortedData<T>(\n data: T[],\n sortingInstructions: UIKeyValueStringSorterSortingInstruction[],\n identifier: any = MAKE_ID()\n ) {\n \n const result: Promise<{\n \n sortedData: T[],\n sortedIndexes: number[],\n identifier: any\n \n }> = new Promise((resolve, reject) => {\n \n this.sortData(data, sortingInstructions, identifier, (sortedData, sortedIndexes, sortedIdentifier) => {\n \n if (sortedIdentifier == identifier) {\n \n resolve({\n \n sortedData: sortedData,\n sortedIndexes: sortedIndexes,\n identifier: sortedIdentifier\n \n })\n \n }\n \n \n })\n \n \n })\n \n return result\n \n }\n \n \n closeThread() {\n \n this._isThreadClosed = YES\n \n if (this._webWorkerHolder != UIKeyValueSorter._sharedWebWorkerHolder) {\n \n this._webWorkerHolder.webWorker.terminate()\n \n }\n \n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n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AEhB,CAAC;AAAA,QAEL;AAAA,MAGJ,CAAC;AAAA,IAGL,CAAC;AAED,WAAO;AAAA,EAEX;AAAA,EAGA,cAAc;AAEV,SAAK,kBAAkB;AAEvB,QAAI,KAAK,oBAAoB,kBAAiB,wBAAwB;AAElE,WAAK,iBAAiB,UAAU,UAAU;AAAA,IAE9C;AAAA,EAGJ;AAGJ;AApQO,IAAM,mBAAN;AAAM,iBAEF,yBAAyB;AAAA,EAC5B,4BAA4B,CAAC;AAAA,EAC7B,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,WAAW,IAAI,iCAAAA,QAA0B;AAC7C;AAPS,iBASF,kBAAkB;AAThB,iBAkJF,WAAW;AAAA,EAEd,UAAU;AAAA,EACV,UAAU;AAEd;AAvJS,iBA0JF,YAAY;AAAA,EAEf,cAAc;AAAA,EACd,aAAa;AAEjB;",
|
|
6
|
+
"names": ["UIKeyValueSorterWebWorker"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare function valueForKeyPath(keyPath: string, object: any): any;
|
|
2
|
+
declare function compare(firstObject: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
}, secondObject: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
}, sortingInstructions: string | any[]): number;
|
|
7
|
+
declare function sortData(data: any[], sortingInstructions: any[]): {
|
|
8
|
+
sortedData: any[];
|
|
9
|
+
sortedIndexes: any[];
|
|
10
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
onmessage = function(event) {
|
|
3
|
+
const workerResult = sortData(
|
|
4
|
+
event.data.data,
|
|
5
|
+
event.data.sortingInstructions
|
|
6
|
+
);
|
|
7
|
+
workerResult.identifier = event.data.identifier;
|
|
8
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
9
|
+
postMessage(workerResult);
|
|
10
|
+
};
|
|
11
|
+
function valueForKeyPath(keyPath, object) {
|
|
12
|
+
var keys = keyPath.split(".");
|
|
13
|
+
var currentObject = object;
|
|
14
|
+
for (var i = 0; i < keys.length; i++) {
|
|
15
|
+
var key = keys[i];
|
|
16
|
+
if (key.substring(0, 2) == "[]") {
|
|
17
|
+
currentObject = currentObject[key.substring(2)];
|
|
18
|
+
var remainingKeyPath = keys.slice(i + 1).join(".");
|
|
19
|
+
var currentArray = currentObject;
|
|
20
|
+
currentObject = currentArray.map(function(subObject, index, array) {
|
|
21
|
+
var result = valueForKeyPath(remainingKeyPath, subObject);
|
|
22
|
+
return result;
|
|
23
|
+
});
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
currentObject = (currentObject || {})[key];
|
|
27
|
+
}
|
|
28
|
+
return currentObject;
|
|
29
|
+
}
|
|
30
|
+
function compare(firstObject, secondObject, sortingInstructions) {
|
|
31
|
+
if (sortingInstructions.length == 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
const sortingInstruction = sortingInstructions[0];
|
|
35
|
+
let directionMultiplier = 1;
|
|
36
|
+
if (sortingInstruction.direction == "descending") {
|
|
37
|
+
directionMultiplier = -1;
|
|
38
|
+
}
|
|
39
|
+
const firstDataString = firstObject[sortingInstruction.keyPath];
|
|
40
|
+
const secondDataString = secondObject[sortingInstruction.keyPath];
|
|
41
|
+
if (firstDataString < secondDataString) {
|
|
42
|
+
return -1 * directionMultiplier;
|
|
43
|
+
}
|
|
44
|
+
if (firstDataString > secondDataString) {
|
|
45
|
+
return directionMultiplier;
|
|
46
|
+
}
|
|
47
|
+
if (sortingInstructions.length > 1) {
|
|
48
|
+
const remainingSortingInstructions = sortingInstructions.slice(1);
|
|
49
|
+
return compare(firstObject, secondObject, remainingSortingInstructions);
|
|
50
|
+
}
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
function sortData(data, sortingInstructions) {
|
|
54
|
+
const sortingObjects = data.map(function(dataItem, index, array) {
|
|
55
|
+
const result = {
|
|
56
|
+
"_UIKeyValueStringSorterWebWorkerSortingObjectIndex": index
|
|
57
|
+
};
|
|
58
|
+
sortingInstructions.forEach((instruction) => {
|
|
59
|
+
if (instruction.dataType == "string") {
|
|
60
|
+
result[instruction.keyPath] = JSON.stringify(valueForKeyPath("" + instruction.keyPath, dataItem) || {}).toLowerCase();
|
|
61
|
+
} else if (instruction.dataType == "number") {
|
|
62
|
+
result[instruction.keyPath] = JSON.stringify(valueForKeyPath("" + instruction.keyPath, dataItem) || {}).toLowerCase().numericalValue;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
});
|
|
67
|
+
const sortedData = sortingObjects.sort((firstObject, secondObject) => compare(
|
|
68
|
+
firstObject,
|
|
69
|
+
secondObject,
|
|
70
|
+
sortingInstructions
|
|
71
|
+
));
|
|
72
|
+
const sortedIndexes = sortedData.map((object) => object._UIKeyValueStringSorterWebWorkerSortingObjectIndex);
|
|
73
|
+
return {
|
|
74
|
+
"sortedData": sortedIndexes.map((sortedIndex) => data[sortedIndex]),
|
|
75
|
+
"sortedIndexes": sortedIndexes
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=UIKeyValueSorterWebWorker.worker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../scripts/UIKeyValueSorterWebWorker.worker.ts"],
|
|
4
|
+
"sourcesContent": ["onmessage = function (event) {\n \n //console.log('Message received from main script');\n const workerResult = sortData(\n event.data.data,\n event.data.sortingInstructions\n )\n \n // @ts-ignore\n workerResult.identifier = event.data.identifier\n // @ts-ignore\n workerResult.instanceIdentifier = event.data.instanceIdentifier\n \n \n // @ts-ignore\n postMessage(workerResult)\n \n}\n\n\nfunction valueForKeyPath(keyPath: string, object: any) {\n \n var keys = keyPath.split(\".\")\n var currentObject = object\n \n for (var i = 0; i < keys.length; i++) {\n \n var key = keys[i]\n \n if (key.substring(0, 2) == \"[]\") {\n \n // This next object will be an array and the rest of the keys need to be run for each of the elements\n \n currentObject = currentObject[key.substring(2)]\n \n // CurrentObject is now an array\n \n var remainingKeyPath = keys.slice(i + 1).join(\".\")\n \n var currentArray = currentObject\n \n currentObject = currentArray.map(function (subObject: any, index: any, array: any) {\n \n var result = valueForKeyPath(remainingKeyPath, subObject)\n \n return result\n \n })\n \n break\n \n }\n \n currentObject = (currentObject || {})[key]\n \n \n }\n \n return currentObject\n \n}\n\n\nfunction compare(\n firstObject: { [x: string]: any },\n secondObject: { [x: string]: any },\n sortingInstructions: string | any[]\n): number {\n \n if (sortingInstructions.length == 0) {\n return 0\n }\n \n const sortingInstruction = sortingInstructions[0]\n \n let directionMultiplier = 1\n if (sortingInstruction.direction == \"descending\") {\n directionMultiplier = -1\n }\n \n const firstDataString = firstObject[sortingInstruction.keyPath]\n const secondDataString = secondObject[sortingInstruction.keyPath]\n \n if (firstDataString < secondDataString) {\n return -1 * directionMultiplier\n }\n \n if (firstDataString > secondDataString) {\n return directionMultiplier\n }\n \n if (sortingInstructions.length > 1) {\n const remainingSortingInstructions = sortingInstructions.slice(1)\n return compare(firstObject, secondObject, remainingSortingInstructions)\n }\n \n return 0\n \n}\n\n\nfunction sortData(data: any[], sortingInstructions: any[]) {\n \n \n const sortingObjects = data.map(function (dataItem: any, index: any, array: any) {\n \n const result: { _UIKeyValueStringSorterWebWorkerSortingObjectIndex: any } & Record<string, string | number> = {\n \n \"_UIKeyValueStringSorterWebWorkerSortingObjectIndex\": index\n \n }\n \n \n sortingInstructions.forEach((instruction: { keyPath: string | number, dataType:string }) => {\n \n if (instruction.dataType == \"string\") {\n \n result[instruction.keyPath] = JSON.stringify(valueForKeyPath(\"\" + instruction.keyPath, dataItem) || {})\n .toLowerCase()\n \n }\n else if (instruction.dataType == \"number\") {\n \n result[instruction.keyPath] = JSON.stringify(valueForKeyPath(\"\" + instruction.keyPath, dataItem) || {})\n .toLowerCase().numericalValue\n \n }\n \n })\n \n return result\n \n })\n \n \n const sortedData = sortingObjects.sort((firstObject: any, secondObject: any) => compare(\n firstObject,\n secondObject,\n sortingInstructions\n ))\n \n const sortedIndexes = sortedData.map((\n object: { _UIKeyValueStringSorterWebWorkerSortingObjectIndex: any }\n ) => object._UIKeyValueStringSorterWebWorkerSortingObjectIndex)\n \n return {\n \n \"sortedData\": sortedIndexes.map(sortedIndex => data[sortedIndex]),\n \"sortedIndexes\": sortedIndexes\n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,SAAU,OAAO;AAGzB,QAAM,eAAe;AAAA,IACjB,MAAM,KAAK;AAAA,IACX,MAAM,KAAK;AAAA,EACf;AAGA,eAAa,aAAa,MAAM,KAAK;AAErC,eAAa,qBAAqB,MAAM,KAAK;AAI7C,cAAY,YAAY;AAE5B;AAGA,SAAS,gBAAgB,SAAiB,QAAa;AAEnD,MAAI,OAAO,QAAQ,MAAM,GAAG;AAC5B,MAAI,gBAAgB;AAEpB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AAElC,QAAI,MAAM,KAAK;AAEf,QAAI,IAAI,UAAU,GAAG,CAAC,KAAK,MAAM;AAI7B,sBAAgB,cAAc,IAAI,UAAU,CAAC;AAI7C,UAAI,mBAAmB,KAAK,MAAM,IAAI,CAAC,EAAE,KAAK,GAAG;AAEjD,UAAI,eAAe;AAEnB,sBAAgB,aAAa,IAAI,SAAU,WAAgB,OAAY,OAAY;AAE/E,YAAI,SAAS,gBAAgB,kBAAkB,SAAS;AAExD,eAAO;AAAA,MAEX,CAAC;AAED;AAAA,IAEJ;AAEA,qBAAiB,iBAAiB,CAAC,GAAG;AAAA,EAG1C;AAEA,SAAO;AAEX;AAGA,SAAS,QACL,aACA,cACA,qBACM;AAEN,MAAI,oBAAoB,UAAU,GAAG;AACjC,WAAO;AAAA,EACX;AAEA,QAAM,qBAAqB,oBAAoB;AAE/C,MAAI,sBAAsB;AAC1B,MAAI,mBAAmB,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* from "./UILinkButton";
|
|
18
18
|
export * from "./UILayoutGrid";
|
|
19
19
|
export * from "./UIKeyValueStringFilter";
|
|
20
|
-
export * from "./
|
|
20
|
+
export * from "./UIKeyValueSorter";
|
|
21
21
|
export * from "./UIImageView";
|
|
22
22
|
export * from "./UIDialogView";
|
|
23
23
|
export * from "./UIDateTimeInput";
|
package/compiledScripts/index.js
CHANGED
|
@@ -34,7 +34,7 @@ __reExport(scripts_exports, require("./UILink"), module.exports);
|
|
|
34
34
|
__reExport(scripts_exports, require("./UILinkButton"), module.exports);
|
|
35
35
|
__reExport(scripts_exports, require("./UILayoutGrid"), module.exports);
|
|
36
36
|
__reExport(scripts_exports, require("./UIKeyValueStringFilter"), module.exports);
|
|
37
|
-
__reExport(scripts_exports, require("./
|
|
37
|
+
__reExport(scripts_exports, require("./UIKeyValueSorter"), module.exports);
|
|
38
38
|
__reExport(scripts_exports, require("./UIImageView"), module.exports);
|
|
39
39
|
__reExport(scripts_exports, require("./UIDialogView"), module.exports);
|
|
40
40
|
__reExport(scripts_exports, require("./UIDateTimeInput"), module.exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./UIObject\"\nexport * from \"./UIView\"\nexport * from \"./UIViewController\"\nexport * from \"./UITimer\"\nexport * from \"./UITextArea\"\nexport * from \"./UITextView\"\nexport * from \"./UITextField\"\nexport * from \"./UITableView\"\nexport * from \"./UIStringFilter\"\nexport * from \"./UISlideScrollerView\"\nexport * from \"./UIScrollView\"\nexport * from \"./UIRoute\"\nexport * from \"./UIRectangle\"\nexport * from \"./UIPoint\"\nexport * from \"./UINativeScrollView\"\nexport * from \"./UILink\"\nexport * from \"./UILinkButton\"\nexport * from \"./UILayoutGrid\"\nexport * from \"./UIKeyValueStringFilter\"\nexport * from \"./
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,uBAAd;AACA,4BAAc,qBADd;AAEA,4BAAc,+BAFd;AAGA,4BAAc,sBAHd;AAIA,4BAAc,yBAJd;AAKA,4BAAc,yBALd;AAMA,4BAAc,0BANd;AAOA,4BAAc,0BAPd;AAQA,4BAAc,6BARd;AASA,4BAAc,kCATd;AAUA,4BAAc,2BAVd;AAWA,4BAAc,sBAXd;AAYA,4BAAc,0BAZd;AAaA,4BAAc,sBAbd;AAcA,4BAAc,iCAdd;AAeA,4BAAc,qBAfd;AAgBA,4BAAc,2BAhBd;AAiBA,4BAAc,2BAjBd;AAkBA,4BAAc,qCAlBd;AAmBA,4BAAc
|
|
4
|
+
"sourcesContent": ["export * from \"./UIObject\"\nexport * from \"./UIView\"\nexport * from \"./UIViewController\"\nexport * from \"./UITimer\"\nexport * from \"./UITextArea\"\nexport * from \"./UITextView\"\nexport * from \"./UITextField\"\nexport * from \"./UITableView\"\nexport * from \"./UIStringFilter\"\nexport * from \"./UISlideScrollerView\"\nexport * from \"./UIScrollView\"\nexport * from \"./UIRoute\"\nexport * from \"./UIRectangle\"\nexport * from \"./UIPoint\"\nexport * from \"./UINativeScrollView\"\nexport * from \"./UILink\"\nexport * from \"./UILinkButton\"\nexport * from \"./UILayoutGrid\"\nexport * from \"./UIKeyValueStringFilter\"\nexport * from \"./UIKeyValueSorter\"\nexport * from \"./UIImageView\"\nexport * from \"./UIDialogView\"\nexport * from \"./UIDateTimeInput\"\nexport * from \"./UICoreExtensions\"\nexport * from \"./UICore\"\nexport * from \"./UIColor\"\nexport * from \"./UIBaseButton\"\nexport * from \"./UIButton\"\nexport * from \"./UIActionIndicator\"\nexport * from \"./UICoreExtensionValueObject\"\nexport * from \"./UIInterfaces\"\nexport * from \"./ClientCheckers\"\nexport * from \"./UICore\"\nexport * from \"./UIRootViewController\"\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,uBAAd;AACA,4BAAc,qBADd;AAEA,4BAAc,+BAFd;AAGA,4BAAc,sBAHd;AAIA,4BAAc,yBAJd;AAKA,4BAAc,yBALd;AAMA,4BAAc,0BANd;AAOA,4BAAc,0BAPd;AAQA,4BAAc,6BARd;AASA,4BAAc,kCATd;AAUA,4BAAc,2BAVd;AAWA,4BAAc,sBAXd;AAYA,4BAAc,0BAZd;AAaA,4BAAc,sBAbd;AAcA,4BAAc,iCAdd;AAeA,4BAAc,qBAfd;AAgBA,4BAAc,2BAhBd;AAiBA,4BAAc,2BAjBd;AAkBA,4BAAc,qCAlBd;AAmBA,4BAAc,+BAnBd;AAoBA,4BAAc,0BApBd;AAqBA,4BAAc,2BArBd;AAsBA,4BAAc,8BAtBd;AAuBA,4BAAc,+BAvBd;AAwBA,4BAAc,qBAxBd;AAyBA,4BAAc,sBAzBd;AA0BA,4BAAc,2BA1Bd;AA2BA,4BAAc,uBA3Bd;AA4BA,4BAAc,gCA5Bd;AA6BA,4BAAc,yCA7Bd;AA8BA,4BAAc,2BA9Bd;AA+BA,4BAAc,6BA/Bd;AAgCA,4BAAc,qBAhCd;AAiCA,4BAAc,mCAjCd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.527",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
|
@@ -44,6 +44,8 @@ declare global {
|
|
|
44
44
|
|
|
45
45
|
min(): number;
|
|
46
46
|
|
|
47
|
+
average(): number;
|
|
48
|
+
|
|
47
49
|
isEqualToArray(array: Array<T>, keyPath?: string): boolean;
|
|
48
50
|
|
|
49
51
|
}
|
|
@@ -503,6 +505,17 @@ Array.prototype.min = function () {
|
|
|
503
505
|
return Math.min.apply(null, this)
|
|
504
506
|
}
|
|
505
507
|
|
|
508
|
+
if (!Array.prototype.average) {
|
|
509
|
+
|
|
510
|
+
Array.prototype.average = function () {
|
|
511
|
+
if (this.length == 0) {
|
|
512
|
+
return 0;
|
|
513
|
+
}
|
|
514
|
+
const sum = this.reduce((a, b) => a + b, 0)
|
|
515
|
+
return sum / this.length
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
}
|
|
506
519
|
|
|
507
520
|
// interface Array<T> {
|
|
508
521
|
//
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
|
-
import
|
|
2
|
+
import UIKeyValueSorterWebWorker from "./UIKeyValueSorterWebWorker.worker"
|
|
3
3
|
import { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from "./UIObject"
|
|
4
4
|
|
|
5
5
|
|
|
@@ -15,13 +15,13 @@ export interface UIKeyValueStringSorterSortingInstruction {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
export class
|
|
18
|
+
export class UIKeyValueSorter extends UIObject {
|
|
19
19
|
|
|
20
20
|
static _sharedWebWorkerHolder = {
|
|
21
21
|
UICore_completionFunctions: {},
|
|
22
22
|
UICore_isWorking: false,
|
|
23
23
|
UICore_messagesToPost: undefined,
|
|
24
|
-
webWorker: new
|
|
24
|
+
webWorker: new UIKeyValueSorterWebWorker()
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
static _instanceNumber = -1
|
|
@@ -38,7 +38,7 @@ export class UIKeyValueStringSorter extends UIObject {
|
|
|
38
38
|
filteredIndexes: number[],
|
|
39
39
|
identifier: any
|
|
40
40
|
) => void>
|
|
41
|
-
} =
|
|
41
|
+
} = UIKeyValueSorter._sharedWebWorkerHolder
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
constructor(useSeparateWebWorkerHolder = NO) {
|
|
@@ -48,7 +48,7 @@ export class UIKeyValueStringSorter extends UIObject {
|
|
|
48
48
|
if (useSeparateWebWorkerHolder) {
|
|
49
49
|
|
|
50
50
|
this._webWorkerHolder = {
|
|
51
|
-
webWorker: new
|
|
51
|
+
webWorker: new UIKeyValueSorterWebWorker(),
|
|
52
52
|
UICore_isWorking: false,
|
|
53
53
|
UICore_messagesToPost: undefined,
|
|
54
54
|
UICore_completionFunctions: {}
|
|
@@ -56,8 +56,8 @@ export class UIKeyValueStringSorter extends UIObject {
|
|
|
56
56
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
this._instanceNumber =
|
|
59
|
+
UIKeyValueSorter._instanceNumber = UIKeyValueSorter._instanceNumber + 1
|
|
60
|
+
this._instanceNumber = UIKeyValueSorter._instanceNumber
|
|
61
61
|
|
|
62
62
|
if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {
|
|
63
63
|
|
|
@@ -163,7 +163,8 @@ export class UIKeyValueStringSorter extends UIObject {
|
|
|
163
163
|
|
|
164
164
|
static dataType = {
|
|
165
165
|
|
|
166
|
-
"string": "string"
|
|
166
|
+
"string": "string",
|
|
167
|
+
"number": "number"
|
|
167
168
|
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -264,7 +265,7 @@ export class UIKeyValueStringSorter extends UIObject {
|
|
|
264
265
|
|
|
265
266
|
this._isThreadClosed = YES
|
|
266
267
|
|
|
267
|
-
if (this._webWorkerHolder !=
|
|
268
|
+
if (this._webWorkerHolder != UIKeyValueSorter._sharedWebWorkerHolder) {
|
|
268
269
|
|
|
269
270
|
this._webWorkerHolder.webWorker.terminate()
|
|
270
271
|
|
package/scripts/{UIKeyValueStringSorterWebWorker.worker.ts → UIKeyValueSorterWebWorker.worker.ts}
RENAMED
|
@@ -104,17 +104,28 @@ function sortData(data: any[], sortingInstructions: any[]) {
|
|
|
104
104
|
|
|
105
105
|
const sortingObjects = data.map(function (dataItem: any, index: any, array: any) {
|
|
106
106
|
|
|
107
|
-
const result: { _UIKeyValueStringSorterWebWorkerSortingObjectIndex: any } & Record<string, string> = {
|
|
107
|
+
const result: { _UIKeyValueStringSorterWebWorkerSortingObjectIndex: any } & Record<string, string | number> = {
|
|
108
108
|
|
|
109
109
|
"_UIKeyValueStringSorterWebWorkerSortingObjectIndex": index
|
|
110
110
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
sortingInstructions.forEach((instruction: { keyPath: string | number }) => {
|
|
114
|
+
sortingInstructions.forEach((instruction: { keyPath: string | number, dataType:string }) => {
|
|
115
|
+
|
|
116
|
+
if (instruction.dataType == "string") {
|
|
117
|
+
|
|
118
|
+
result[instruction.keyPath] = JSON.stringify(valueForKeyPath("" + instruction.keyPath, dataItem) || {})
|
|
119
|
+
.toLowerCase()
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
else if (instruction.dataType == "number") {
|
|
123
|
+
|
|
124
|
+
result[instruction.keyPath] = JSON.stringify(valueForKeyPath("" + instruction.keyPath, dataItem) || {})
|
|
125
|
+
.toLowerCase().numericalValue
|
|
126
|
+
|
|
127
|
+
}
|
|
115
128
|
|
|
116
|
-
result[instruction.keyPath] = JSON.stringify(valueForKeyPath("" + instruction.keyPath, dataItem) || {})
|
|
117
|
-
.toLowerCase()
|
|
118
129
|
})
|
|
119
130
|
|
|
120
131
|
return result
|
package/scripts/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export * from "./UILink"
|
|
|
17
17
|
export * from "./UILinkButton"
|
|
18
18
|
export * from "./UILayoutGrid"
|
|
19
19
|
export * from "./UIKeyValueStringFilter"
|
|
20
|
-
export * from "./
|
|
20
|
+
export * from "./UIKeyValueSorter"
|
|
21
21
|
export * from "./UIImageView"
|
|
22
22
|
export * from "./UIDialogView"
|
|
23
23
|
export * from "./UIDateTimeInput"
|