@hpcc-js/util 2.45.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 (79) hide show
  1. package/LICENSE +43 -43
  2. package/dist/index.js +2290 -2289
  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/array.js +84 -84
  8. package/lib-es6/array.js.map +1 -1
  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/graph.js.map +1 -1
  16. package/lib-es6/graph2.js +603 -603
  17. package/lib-es6/graph2.js.map +1 -1
  18. package/lib-es6/hashSum.js +49 -49
  19. package/lib-es6/immutable.js +54 -54
  20. package/lib-es6/index.js +21 -21
  21. package/lib-es6/logging.js +177 -177
  22. package/lib-es6/logging.js.map +1 -1
  23. package/lib-es6/math.js +90 -90
  24. package/lib-es6/object.js +121 -121
  25. package/lib-es6/object.js.map +1 -1
  26. package/lib-es6/observer.js +79 -79
  27. package/lib-es6/platform.js +17 -17
  28. package/lib-es6/saxParser.js +125 -125
  29. package/lib-es6/stack.js +41 -41
  30. package/lib-es6/stateful.js +170 -170
  31. package/lib-es6/string.js +22 -22
  32. package/lib-es6/url.js +32 -32
  33. package/lib-es6/url.js.map +1 -1
  34. package/package.json +6 -21
  35. package/src/__package__.ts +2 -2
  36. package/src/array.ts +98 -98
  37. package/src/cache.ts +65 -65
  38. package/src/debounce.ts +88 -88
  39. package/src/dictionary.ts +69 -69
  40. package/src/dispatch.ts +119 -119
  41. package/src/esp.ts +32 -32
  42. package/src/graph.ts +353 -353
  43. package/src/graph2.ts +661 -661
  44. package/src/hashSum.ts +55 -55
  45. package/src/immutable.ts +57 -57
  46. package/src/index.ts +21 -21
  47. package/src/logging.ts +211 -211
  48. package/src/math.ts +92 -92
  49. package/src/object.ts +117 -117
  50. package/src/observer.ts +91 -91
  51. package/src/platform.ts +20 -20
  52. package/src/saxParser.ts +135 -135
  53. package/src/stack.ts +41 -41
  54. package/src/stateful.ts +178 -178
  55. package/src/string.ts +21 -21
  56. package/src/url.ts +27 -27
  57. package/types/__package__.d.ts +3 -3
  58. package/types/array.d.ts +13 -13
  59. package/types/cache.d.ts +20 -20
  60. package/types/debounce.d.ts +12 -12
  61. package/types/dictionary.d.ts +20 -20
  62. package/types/dispatch.d.ts +26 -26
  63. package/types/esp.d.ts +1 -1
  64. package/types/graph.d.ts +73 -73
  65. package/types/graph2.d.ts +111 -111
  66. package/types/hashSum.d.ts +1 -1
  67. package/types/immutable.d.ts +2 -2
  68. package/types/index.d.ts +21 -21
  69. package/types/logging.d.ts +57 -57
  70. package/types/math.d.ts +70 -70
  71. package/types/object.d.ts +48 -48
  72. package/types/observer.d.ts +18 -18
  73. package/types/platform.d.ts +5 -5
  74. package/types/saxParser.d.ts +28 -28
  75. package/types/stack.d.ts +28 -28
  76. package/types/stateful.d.ts +33 -33
  77. package/types/string.d.ts +2 -2
  78. package/types/url.d.ts +2 -2
  79. package/types-3.4/__package__.d.ts +2 -2
package/src/hashSum.ts CHANGED
@@ -1,55 +1,55 @@
1
- // Ported to TypeScript from: https://github.com/bevacqua/hash-sum
2
-
3
- function pad(hash: string, len: number): string {
4
- while (hash.length < len) {
5
- hash = "0" + hash;
6
- }
7
- return hash;
8
- }
9
-
10
- function fold(hash: number, text: string): number {
11
- if (text.length === 0) {
12
- return hash;
13
- }
14
- for (let i = 0; i < text.length; ++i) {
15
- const chr = text.charCodeAt(i);
16
- hash = ((hash << 5) - hash) + chr;
17
- hash |= 0;
18
- }
19
- return hash < 0 ? hash * -2 : hash;
20
- }
21
-
22
- function foldObject(hash: number, o: any, seen: any[]): number {
23
- if (typeof o.hashSum === "function") {
24
- return o.hashSum();
25
- }
26
- return Object.keys(o).sort().reduce((input: any, key: string) => {
27
- return foldValue(input, o[key], key, seen);
28
- }, hash);
29
- }
30
-
31
- function foldValue(input: number, value: any, key: string, seen: any[]): number {
32
- const hash = fold(fold(fold(input, key), toString(value)), typeof value);
33
- if (value === null) {
34
- return fold(hash, "null");
35
- }
36
- if (value === undefined) {
37
- return fold(hash, "undefined");
38
- }
39
- if (typeof value === "object") {
40
- if (seen.indexOf(value) !== -1) {
41
- return fold(hash, "[Circular]" + key);
42
- }
43
- seen.push(value);
44
- return foldObject(hash, value, seen);
45
- }
46
- return fold(hash, value.toString());
47
- }
48
-
49
- function toString(o: any): string {
50
- return Object.prototype.toString.call(o);
51
- }
52
-
53
- export function hashSum(o: any): string {
54
- return pad(foldValue(0, o, "", []).toString(16), 8);
55
- }
1
+ // Ported to TypeScript from: https://github.com/bevacqua/hash-sum
2
+
3
+ function pad(hash: string, len: number): string {
4
+ while (hash.length < len) {
5
+ hash = "0" + hash;
6
+ }
7
+ return hash;
8
+ }
9
+
10
+ function fold(hash: number, text: string): number {
11
+ if (text.length === 0) {
12
+ return hash;
13
+ }
14
+ for (let i = 0; i < text.length; ++i) {
15
+ const chr = text.charCodeAt(i);
16
+ hash = ((hash << 5) - hash) + chr;
17
+ hash |= 0;
18
+ }
19
+ return hash < 0 ? hash * -2 : hash;
20
+ }
21
+
22
+ function foldObject(hash: number, o: any, seen: any[]): number {
23
+ if (typeof o.hashSum === "function") {
24
+ return o.hashSum();
25
+ }
26
+ return Object.keys(o).sort().reduce((input: any, key: string) => {
27
+ return foldValue(input, o[key], key, seen);
28
+ }, hash);
29
+ }
30
+
31
+ function foldValue(input: number, value: any, key: string, seen: any[]): number {
32
+ const hash = fold(fold(fold(input, key), toString(value)), typeof value);
33
+ if (value === null) {
34
+ return fold(hash, "null");
35
+ }
36
+ if (value === undefined) {
37
+ return fold(hash, "undefined");
38
+ }
39
+ if (typeof value === "object") {
40
+ if (seen.indexOf(value) !== -1) {
41
+ return fold(hash, "[Circular]" + key);
42
+ }
43
+ seen.push(value);
44
+ return foldObject(hash, value, seen);
45
+ }
46
+ return fold(hash, value.toString());
47
+ }
48
+
49
+ function toString(o: any): string {
50
+ return Object.prototype.toString.call(o);
51
+ }
52
+
53
+ export function hashSum(o: any): string {
54
+ return pad(foldValue(0, o, "", []).toString(16), 8);
55
+ }
package/src/immutable.ts CHANGED
@@ -1,57 +1,57 @@
1
- const isArray = Array.isArray;
2
- const keyList = Object.keys;
3
- const hasProp = Object.prototype.hasOwnProperty;
4
-
5
- export function deepEquals(a: any, b: any) {
6
- if (a === b) return true;
7
-
8
- if (a && b && typeof a === "object" && typeof b === "object") {
9
- const arrA = isArray(a);
10
- const arrB = isArray(b);
11
- let i;
12
- let length;
13
- let key;
14
-
15
- if (arrA && arrB) {
16
- length = a.length;
17
- if (length !== b.length) return false;
18
- for (i = length; i-- !== 0;)
19
- if (!deepEquals(a[i], b[i])) return false;
20
- return true;
21
- }
22
-
23
- if (arrA !== arrB) return false;
24
-
25
- const dateA = a instanceof Date;
26
- const dateB = b instanceof Date;
27
- if (dateA !== dateB) return false;
28
- if (dateA && dateB) return a.getTime() === b.getTime();
29
-
30
- const regexpA = a instanceof RegExp;
31
- const regexpB = b instanceof RegExp;
32
- if (regexpA !== regexpB) return false;
33
- if (regexpA && regexpB) return a.toString() === b.toString();
34
-
35
- const keys = keyList(a);
36
- length = keys.length;
37
-
38
- if (length !== keyList(b).length)
39
- return false;
40
-
41
- for (i = length; i-- !== 0;)
42
- if (!hasProp.call(b, keys[i])) return false;
43
-
44
- for (i = length; i-- !== 0;) {
45
- key = keys[i];
46
- if (!deepEquals(a[key], b[key])) return false;
47
- }
48
-
49
- return true;
50
- }
51
-
52
- return a !== a && b !== b;
53
- }
54
-
55
- export function update<T>(origItem: T, newItem: T): T {
56
- return deepEquals(origItem, newItem) ? origItem : newItem;
57
- }
1
+ const isArray = Array.isArray;
2
+ const keyList = Object.keys;
3
+ const hasProp = Object.prototype.hasOwnProperty;
4
+
5
+ export function deepEquals(a: any, b: any) {
6
+ if (a === b) return true;
7
+
8
+ if (a && b && typeof a === "object" && typeof b === "object") {
9
+ const arrA = isArray(a);
10
+ const arrB = isArray(b);
11
+ let i;
12
+ let length;
13
+ let key;
14
+
15
+ if (arrA && arrB) {
16
+ length = a.length;
17
+ if (length !== b.length) return false;
18
+ for (i = length; i-- !== 0;)
19
+ if (!deepEquals(a[i], b[i])) return false;
20
+ return true;
21
+ }
22
+
23
+ if (arrA !== arrB) return false;
24
+
25
+ const dateA = a instanceof Date;
26
+ const dateB = b instanceof Date;
27
+ if (dateA !== dateB) return false;
28
+ if (dateA && dateB) return a.getTime() === b.getTime();
29
+
30
+ const regexpA = a instanceof RegExp;
31
+ const regexpB = b instanceof RegExp;
32
+ if (regexpA !== regexpB) return false;
33
+ if (regexpA && regexpB) return a.toString() === b.toString();
34
+
35
+ const keys = keyList(a);
36
+ length = keys.length;
37
+
38
+ if (length !== keyList(b).length)
39
+ return false;
40
+
41
+ for (i = length; i-- !== 0;)
42
+ if (!hasProp.call(b, keys[i])) return false;
43
+
44
+ for (i = length; i-- !== 0;) {
45
+ key = keys[i];
46
+ if (!deepEquals(a[key], b[key])) return false;
47
+ }
48
+
49
+ return true;
50
+ }
51
+
52
+ return a !== a && b !== b;
53
+ }
54
+
55
+ export function update<T>(origItem: T, newItem: T): T {
56
+ return deepEquals(origItem, newItem) ? origItem : newItem;
57
+ }
package/src/index.ts CHANGED
@@ -1,21 +1,21 @@
1
- export * from "./__package__";
2
- export * from "./array";
3
- export * from "./cache";
4
- export * from "./debounce";
5
- export * from "./dictionary";
6
- export * from "./esp";
7
- export * from "./graph";
8
- export * from "./graph2";
9
- export * from "./hashSum";
10
- export * from "./immutable";
11
- export * from "./logging";
12
- export * from "./math";
13
- export * from "./object";
14
- export * from "./observer";
15
- export * from "./dispatch";
16
- export * from "./platform";
17
- export * from "./saxParser";
18
- export * from "./stack";
19
- export * from "./stateful";
20
- export * from "./string";
21
- export * from "./url";
1
+ export * from "./__package__";
2
+ export * from "./array";
3
+ export * from "./cache";
4
+ export * from "./debounce";
5
+ export * from "./dictionary";
6
+ export * from "./esp";
7
+ export * from "./graph";
8
+ export * from "./graph2";
9
+ export * from "./hashSum";
10
+ export * from "./immutable";
11
+ export * from "./logging";
12
+ export * from "./math";
13
+ export * from "./object";
14
+ export * from "./observer";
15
+ export * from "./dispatch";
16
+ export * from "./platform";
17
+ export * from "./saxParser";
18
+ export * from "./stack";
19
+ export * from "./stateful";
20
+ export * from "./string";
21
+ export * from "./url";