@hpcc-js/util 2.42.0 → 2.46.1

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.
Files changed (75) hide show
  1. package/LICENSE +43 -43
  2. package/dist/index.js +2281 -2281
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/lib-es6/__package__.js +3 -3
  7. package/lib-es6/__package__.js.map +1 -1
  8. package/lib-es6/array.js +84 -84
  9. package/lib-es6/cache.js +60 -60
  10. package/lib-es6/debounce.js +85 -85
  11. package/lib-es6/dictionary.js +61 -61
  12. package/lib-es6/dispatch.js +101 -101
  13. package/lib-es6/esp.js +32 -32
  14. package/lib-es6/graph.js +348 -348
  15. package/lib-es6/graph2.js +603 -603
  16. package/lib-es6/hashSum.js +49 -49
  17. package/lib-es6/immutable.js +54 -54
  18. package/lib-es6/index.js +21 -21
  19. package/lib-es6/logging.js +177 -177
  20. package/lib-es6/math.js +90 -90
  21. package/lib-es6/object.js +121 -121
  22. package/lib-es6/observer.js +79 -79
  23. package/lib-es6/platform.js +17 -17
  24. package/lib-es6/saxParser.js +125 -125
  25. package/lib-es6/stack.js +41 -41
  26. package/lib-es6/stateful.js +170 -170
  27. package/lib-es6/string.js +22 -22
  28. package/lib-es6/url.js +32 -32
  29. package/package.json +7 -21
  30. package/src/__package__.ts +2 -2
  31. package/src/array.ts +98 -98
  32. package/src/cache.ts +65 -65
  33. package/src/debounce.ts +88 -88
  34. package/src/dictionary.ts +69 -69
  35. package/src/dispatch.ts +119 -119
  36. package/src/esp.ts +32 -32
  37. package/src/graph.ts +353 -353
  38. package/src/graph2.ts +661 -661
  39. package/src/hashSum.ts +55 -55
  40. package/src/immutable.ts +57 -57
  41. package/src/index.ts +21 -21
  42. package/src/logging.ts +211 -211
  43. package/src/math.ts +92 -92
  44. package/src/object.ts +117 -117
  45. package/src/observer.ts +91 -91
  46. package/src/platform.ts +20 -20
  47. package/src/saxParser.ts +135 -135
  48. package/src/stack.ts +41 -41
  49. package/src/stateful.ts +178 -178
  50. package/src/string.ts +21 -21
  51. package/src/url.ts +27 -27
  52. package/types/__package__.d.ts +3 -3
  53. package/types/__package__.d.ts.map +1 -1
  54. package/types/array.d.ts +13 -13
  55. package/types/cache.d.ts +20 -20
  56. package/types/debounce.d.ts +12 -12
  57. package/types/dictionary.d.ts +20 -20
  58. package/types/dispatch.d.ts +26 -26
  59. package/types/esp.d.ts +1 -1
  60. package/types/graph.d.ts +73 -73
  61. package/types/graph2.d.ts +111 -111
  62. package/types/hashSum.d.ts +1 -1
  63. package/types/immutable.d.ts +2 -2
  64. package/types/index.d.ts +21 -21
  65. package/types/logging.d.ts +57 -57
  66. package/types/math.d.ts +70 -70
  67. package/types/object.d.ts +48 -48
  68. package/types/observer.d.ts +18 -18
  69. package/types/platform.d.ts +5 -5
  70. package/types/saxParser.d.ts +28 -28
  71. package/types/stack.d.ts +28 -28
  72. package/types/stateful.d.ts +33 -33
  73. package/types/string.d.ts +2 -2
  74. package/types/url.d.ts +2 -2
  75. package/types-3.4/__package__.d.ts +2 -2
package/lib-es6/string.js CHANGED
@@ -1,23 +1,23 @@
1
- export function trim(str, char) {
2
- if (typeof char !== "string")
3
- return str;
4
- if (char.length === 0)
5
- return str;
6
- while (str.indexOf(char) === 0) {
7
- str = str.substring(1);
8
- }
9
- while (endsWith(str, char)) {
10
- str = str.substring(0, str.length - 1);
11
- }
12
- return str;
13
- }
14
- export function endsWith(origString, searchString, position) {
15
- var subjectString = origString.toString();
16
- if (typeof position !== "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
17
- position = subjectString.length;
18
- }
19
- position -= searchString.length;
20
- var lastIndex = subjectString.lastIndexOf(searchString, position);
21
- return lastIndex !== -1 && lastIndex === position;
22
- }
1
+ export function trim(str, char) {
2
+ if (typeof char !== "string")
3
+ return str;
4
+ if (char.length === 0)
5
+ return str;
6
+ while (str.indexOf(char) === 0) {
7
+ str = str.substring(1);
8
+ }
9
+ while (endsWith(str, char)) {
10
+ str = str.substring(0, str.length - 1);
11
+ }
12
+ return str;
13
+ }
14
+ export function endsWith(origString, searchString, position) {
15
+ var subjectString = origString.toString();
16
+ if (typeof position !== "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
17
+ position = subjectString.length;
18
+ }
19
+ position -= searchString.length;
20
+ var lastIndex = subjectString.lastIndexOf(searchString, position);
21
+ return lastIndex !== -1 && lastIndex === position;
22
+ }
23
23
  //# sourceMappingURL=string.js.map
package/lib-es6/url.js CHANGED
@@ -1,33 +1,33 @@
1
- import { __spreadArray } from "tslib";
2
- export function join() {
3
- var segments = [];
4
- for (var _i = 0; _i < arguments.length; _i++) {
5
- segments[_i] = arguments[_i];
6
- }
7
- var parts = segments.reduce(function (parts, segment) {
8
- // Remove leading slashes from non-first part.
9
- if (parts.length > 0) {
10
- segment = segment.replace(/^\//, "");
11
- }
12
- // Remove trailing slashes.
13
- segment = segment.replace(/\/$/, "");
14
- return __spreadArray(__spreadArray([], parts, true), segment.split("/"), true);
15
- }, []);
16
- var resultParts = [];
17
- for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
18
- var part = parts_1[_a];
19
- if (part === ".") {
20
- continue;
21
- }
22
- if (part === "..") {
23
- resultParts.pop();
24
- continue;
25
- }
26
- resultParts.push(part);
27
- }
28
- return resultParts.join("/");
29
- }
30
- export function dirname(path) {
31
- return join(path, "..");
32
- }
1
+ import { __spreadArray } from "tslib";
2
+ export function join() {
3
+ var segments = [];
4
+ for (var _i = 0; _i < arguments.length; _i++) {
5
+ segments[_i] = arguments[_i];
6
+ }
7
+ var parts = segments.reduce(function (parts, segment) {
8
+ // Remove leading slashes from non-first part.
9
+ if (parts.length > 0) {
10
+ segment = segment.replace(/^\//, "");
11
+ }
12
+ // Remove trailing slashes.
13
+ segment = segment.replace(/\/$/, "");
14
+ return __spreadArray(__spreadArray([], parts, true), segment.split("/"), true);
15
+ }, []);
16
+ var resultParts = [];
17
+ for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
18
+ var part = parts_1[_a];
19
+ if (part === ".") {
20
+ continue;
21
+ }
22
+ if (part === "..") {
23
+ resultParts.pop();
24
+ continue;
25
+ }
26
+ resultParts.push(part);
27
+ }
28
+ return resultParts.join("/");
29
+ }
30
+ export function dirname(path) {
31
+ return join(path, "..");
32
+ }
33
33
  //# sourceMappingURL=url.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/util",
3
- "version": "2.42.0",
3
+ "version": "2.46.1",
4
4
  "description": "hpcc-js - Utilities",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib-es6/index",
@@ -33,31 +33,17 @@
33
33
  "gen-legacy-types": "downlevel-dts ./types ./types-3.4",
34
34
  "build": "npm run compile-es6 && npm run bundle",
35
35
  "watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch",
36
- "stamp": "node node_modules/@hpcc-js/bundle/src/stamp.js",
36
+ "stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js",
37
37
  "lint": "eslint src/**/*.ts",
38
- "docs": "typedoc --options tdoptions.json ."
38
+ "docs": "typedoc --options tdoptions.json .",
39
+ "update": "npx npm-check-updates -u -t minor"
39
40
  },
40
41
  "dependencies": {
41
42
  "tslib": "2.3.1"
42
43
  },
43
44
  "devDependencies": {
44
- "@hpcc-js/bundle": "^2.10.21",
45
- "@rollup/plugin-alias": "3.1.9",
46
- "@rollup/plugin-commonjs": "21.0.1",
47
- "@rollup/plugin-node-resolve": "13.1.3",
48
- "@typescript-eslint/eslint-plugin": "5.10.1",
49
- "@typescript-eslint/parser": "5.10.1",
50
- "downlevel-dts": "0.6.0",
51
- "eslint": "8.8.0",
52
- "eslint-plugin-react-hooks": "^4.3.0",
53
- "npm-run-all": "4.1.5",
54
- "rimraf": "3.0.2",
55
- "rollup": "2.66.1",
56
- "rollup-plugin-postcss": "4.0.2",
57
- "rollup-plugin-sourcemaps": "0.6.3",
58
- "terser": "5.10.0",
59
- "typedoc": "0.22.11",
60
- "typescript": "4.5.5"
45
+ "@hpcc-js/bundle": "^2.11.1",
46
+ "rimraf": "2.7.1"
61
47
  },
62
48
  "repository": {
63
49
  "type": "git",
@@ -70,5 +56,5 @@
70
56
  "url": "https://github.com/hpcc-systems/Visualization/issues"
71
57
  },
72
58
  "homepage": "https://github.com/hpcc-systems/Visualization",
73
- "gitHead": "481c2fc2b4389cb32900bf2735bed31e7bfb7dfd"
59
+ "gitHead": "bc245d3dccc358e21bc1b2103f6d88bb75b9f999"
74
60
  }
@@ -1,3 +1,3 @@
1
1
  export const PKG_NAME = "@hpcc-js/util";
2
- export const PKG_VERSION = "2.42.0";
3
- export const BUILD_VERSION = "2.97.0";
2
+ export const PKG_VERSION = "2.46.1";
3
+ export const BUILD_VERSION = "2.102.1";
package/src/array.ts CHANGED
@@ -1,98 +1,98 @@
1
- // Based on: https://tc39.github.io/ecma262/#sec-array.prototype.find
2
- export function find<T>(o: ReadonlyArray<T>, predicate: (value: T, index: number) => boolean) {
3
- // 1. Let O be ? ToObject(this value).
4
- if (o == null) {
5
- throw new TypeError('"o" is null or not defined');
6
- }
7
-
8
- // 2. Let len be ? ToLength(? Get(O, "length")).
9
- const len = o.length >>> 0;
10
-
11
- // 3. If IsCallable(predicate) is false, throw a TypeError exception.
12
- if (typeof predicate !== "function") {
13
- throw new TypeError("predicate must be a function");
14
- }
15
-
16
- // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
17
- const thisArg = arguments[1];
18
-
19
- // 5. Let k be 0.
20
- let k = 0;
21
-
22
- // 6. Repeat, while k < len
23
- while (k < len) {
24
- // a. Let Pk be ! ToString(k).
25
- // b. Let kValue be ? Get(O, Pk).
26
- // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
27
- // d. If testResult is true, return kValue.
28
- const kValue = o[k];
29
- if (predicate.call(thisArg, kValue, k, o)) {
30
- return kValue;
31
- }
32
- // e. Increase k by 1.
33
- k++;
34
- }
35
-
36
- // 7. Return undefined.
37
- return undefined;
38
- }
39
-
40
- export interface IDifferences2<T> {
41
- update: T[];
42
- exit: T[];
43
- enter: T[];
44
- }
45
-
46
- export function compare<T>(before: readonly T[], after: readonly T[]): IDifferences2<T> {
47
- const retVal: IDifferences2<T> = {
48
- update: [],
49
- exit: [],
50
- enter: [...after]
51
- };
52
- for (const row of before) {
53
- const otherIdx = retVal.enter.indexOf(row);
54
- if (otherIdx >= 0) {
55
- retVal.update.push(row);
56
- retVal.enter.splice(otherIdx, 1);
57
- } else {
58
- retVal.exit.push(row);
59
- }
60
- }
61
- return retVal;
62
- }
63
-
64
- export interface IDifferences2<T> {
65
- enter: T[];
66
- update: T[];
67
- exit: T[];
68
- }
69
-
70
- export function compare2<T>(before: readonly T[], after: readonly T[], idFunc: (itme: T) => string | number, updateFunc: (before: T, after: T) => T = (before, after) => after): IDifferences2<T> {
71
- const retVal: IDifferences2<T> = {
72
- update: [],
73
- exit: [],
74
- enter: []
75
- };
76
- if (before === after) {
77
- retVal.update = before as T[];
78
- return retVal;
79
- }
80
- const unknownMap: { [key: string]: T } = {};
81
- after.forEach(item => {
82
- unknownMap[idFunc(item)] = item;
83
- });
84
- for (const row of before) {
85
- const id = idFunc(row);
86
- const item = unknownMap[id];
87
- if (item !== undefined) {
88
- delete unknownMap[id];
89
- retVal.update.push(updateFunc(row, item));
90
- } else {
91
- retVal.exit.push(row);
92
- }
93
- }
94
- for (const key in unknownMap) {
95
- retVal.enter.push(unknownMap[key]);
96
- }
97
- return retVal;
98
- }
1
+ // Based on: https://tc39.github.io/ecma262/#sec-array.prototype.find
2
+ export function find<T>(o: ReadonlyArray<T>, predicate: (value: T, index: number) => boolean) {
3
+ // 1. Let O be ? ToObject(this value).
4
+ if (o == null) {
5
+ throw new TypeError('"o" is null or not defined');
6
+ }
7
+
8
+ // 2. Let len be ? ToLength(? Get(O, "length")).
9
+ const len = o.length >>> 0;
10
+
11
+ // 3. If IsCallable(predicate) is false, throw a TypeError exception.
12
+ if (typeof predicate !== "function") {
13
+ throw new TypeError("predicate must be a function");
14
+ }
15
+
16
+ // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
17
+ const thisArg = arguments[1];
18
+
19
+ // 5. Let k be 0.
20
+ let k = 0;
21
+
22
+ // 6. Repeat, while k < len
23
+ while (k < len) {
24
+ // a. Let Pk be ! ToString(k).
25
+ // b. Let kValue be ? Get(O, Pk).
26
+ // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
27
+ // d. If testResult is true, return kValue.
28
+ const kValue = o[k];
29
+ if (predicate.call(thisArg, kValue, k, o)) {
30
+ return kValue;
31
+ }
32
+ // e. Increase k by 1.
33
+ k++;
34
+ }
35
+
36
+ // 7. Return undefined.
37
+ return undefined;
38
+ }
39
+
40
+ export interface IDifferences2<T> {
41
+ update: T[];
42
+ exit: T[];
43
+ enter: T[];
44
+ }
45
+
46
+ export function compare<T>(before: readonly T[], after: readonly T[]): IDifferences2<T> {
47
+ const retVal: IDifferences2<T> = {
48
+ update: [],
49
+ exit: [],
50
+ enter: [...after]
51
+ };
52
+ for (const row of before) {
53
+ const otherIdx = retVal.enter.indexOf(row);
54
+ if (otherIdx >= 0) {
55
+ retVal.update.push(row);
56
+ retVal.enter.splice(otherIdx, 1);
57
+ } else {
58
+ retVal.exit.push(row);
59
+ }
60
+ }
61
+ return retVal;
62
+ }
63
+
64
+ export interface IDifferences2<T> {
65
+ enter: T[];
66
+ update: T[];
67
+ exit: T[];
68
+ }
69
+
70
+ export function compare2<T>(before: readonly T[], after: readonly T[], idFunc: (itme: T) => string | number, updateFunc: (before: T, after: T) => T = (before, after) => after): IDifferences2<T> {
71
+ const retVal: IDifferences2<T> = {
72
+ update: [],
73
+ exit: [],
74
+ enter: []
75
+ };
76
+ if (before === after) {
77
+ retVal.update = before as T[];
78
+ return retVal;
79
+ }
80
+ const unknownMap: { [key: string]: T } = {};
81
+ after.forEach(item => {
82
+ unknownMap[idFunc(item)] = item;
83
+ });
84
+ for (const row of before) {
85
+ const id = idFunc(row);
86
+ const item = unknownMap[id];
87
+ if (item !== undefined) {
88
+ delete unknownMap[id];
89
+ retVal.update.push(updateFunc(row, item));
90
+ } else {
91
+ retVal.exit.push(row);
92
+ }
93
+ }
94
+ for (const key in unknownMap) {
95
+ retVal.enter.push(unknownMap[key]);
96
+ }
97
+ return retVal;
98
+ }
package/src/cache.ts CHANGED
@@ -1,65 +1,65 @@
1
- import { hashSum } from "./hashSum";
2
-
3
- export class Cache<I, C> {
4
- private _cache: { [id: string]: C } = {};
5
- private _calcID: (espObj: I | C) => string;
6
-
7
- static hash(...args: any[]) {
8
- return hashSum({ ...args });
9
- }
10
-
11
- constructor(calcID: (espObj: I | C) => string) {
12
- this._calcID = calcID;
13
- }
14
-
15
- has(espObj: I): boolean {
16
- return this._calcID(espObj) in this._cache;
17
- }
18
-
19
- set(obj: C): C {
20
- this._cache[this._calcID(obj)] = obj;
21
- return obj;
22
- }
23
-
24
- get(espObj: I): C | null;
25
- get(espObj: I, factory: () => C): C;
26
- get(espObj: I, factory?: () => C): C | null {
27
- const retVal = this._cache[this._calcID(espObj)];
28
- if (!retVal) {
29
- return factory ? this.set(factory()) : null;
30
- }
31
- return retVal;
32
- }
33
- }
34
-
35
- export class AsyncCache<I, C> {
36
- private _cache: { [id: string]: Promise<C> } = {};
37
- private _calcID: (espObj: I | C) => string;
38
-
39
- static hash(...args: any[]) {
40
- return hashSum({ ...args });
41
- }
42
-
43
- constructor(calcID: (espObj: I | C) => string) {
44
- this._calcID = calcID;
45
- }
46
-
47
- has(espObj: I): boolean {
48
- return this._calcID(espObj) in this._cache;
49
- }
50
-
51
- set(espObj: I, obj: Promise<C>): Promise<C> {
52
- this._cache[this._calcID(espObj)] = obj;
53
- return obj;
54
- }
55
-
56
- get(espObj: I): Promise<C | null>;
57
- get(espObj: I, factory: () => Promise<C>): Promise<C>;
58
- get(espObj: I, factory?: () => Promise<C>): Promise<C | null> {
59
- const retVal = this._cache[this._calcID(espObj)];
60
- if (!retVal) {
61
- return factory ? this.set(espObj, factory()) : Promise.resolve(null);
62
- }
63
- return retVal;
64
- }
65
- }
1
+ import { hashSum } from "./hashSum";
2
+
3
+ export class Cache<I, C> {
4
+ private _cache: { [id: string]: C } = {};
5
+ private _calcID: (espObj: I | C) => string;
6
+
7
+ static hash(...args: any[]) {
8
+ return hashSum({ ...args });
9
+ }
10
+
11
+ constructor(calcID: (espObj: I | C) => string) {
12
+ this._calcID = calcID;
13
+ }
14
+
15
+ has(espObj: I): boolean {
16
+ return this._calcID(espObj) in this._cache;
17
+ }
18
+
19
+ set(obj: C): C {
20
+ this._cache[this._calcID(obj)] = obj;
21
+ return obj;
22
+ }
23
+
24
+ get(espObj: I): C | null;
25
+ get(espObj: I, factory: () => C): C;
26
+ get(espObj: I, factory?: () => C): C | null {
27
+ const retVal = this._cache[this._calcID(espObj)];
28
+ if (!retVal) {
29
+ return factory ? this.set(factory()) : null;
30
+ }
31
+ return retVal;
32
+ }
33
+ }
34
+
35
+ export class AsyncCache<I, C> {
36
+ private _cache: { [id: string]: Promise<C> } = {};
37
+ private _calcID: (espObj: I | C) => string;
38
+
39
+ static hash(...args: any[]) {
40
+ return hashSum({ ...args });
41
+ }
42
+
43
+ constructor(calcID: (espObj: I | C) => string) {
44
+ this._calcID = calcID;
45
+ }
46
+
47
+ has(espObj: I): boolean {
48
+ return this._calcID(espObj) in this._cache;
49
+ }
50
+
51
+ set(espObj: I, obj: Promise<C>): Promise<C> {
52
+ this._cache[this._calcID(espObj)] = obj;
53
+ return obj;
54
+ }
55
+
56
+ get(espObj: I): Promise<C | null>;
57
+ get(espObj: I, factory: () => Promise<C>): Promise<C>;
58
+ get(espObj: I, factory?: () => Promise<C>): Promise<C | null> {
59
+ const retVal = this._cache[this._calcID(espObj)];
60
+ if (!retVal) {
61
+ return factory ? this.set(espObj, factory()) : Promise.resolve(null);
62
+ }
63
+ return retVal;
64
+ }
65
+ }