@esmalley/ts-utils 2.1.0 → 4.0.0

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 (88) hide show
  1. package/dist/cjs/index.js +16 -27
  2. package/dist/cjs/index.js.map +7 -0
  3. package/dist/esm/index.js +16 -11
  4. package/dist/esm/index.js.map +7 -0
  5. package/dist/{cjs → types}/Kontororu/Socket.d.ts +9 -4
  6. package/dist/types/Kontororu/Socket.d.ts.map +1 -0
  7. package/package.json +9 -7
  8. package/dist/cjs/Arithmetic.js +0 -9
  9. package/dist/cjs/Arrayifier.js +0 -69
  10. package/dist/cjs/CSV.js +0 -39
  11. package/dist/cjs/Color.js +0 -348
  12. package/dist/cjs/Dates.js +0 -358
  13. package/dist/cjs/Kontororu/Socket.d.ts.map +0 -1
  14. package/dist/cjs/Kontororu/Socket.js +0 -221
  15. package/dist/cjs/Kontororu.js +0 -27
  16. package/dist/cjs/Objector.js +0 -124
  17. package/dist/cjs/Sorter.js +0 -32
  18. package/dist/cjs/Style.js +0 -475
  19. package/dist/cjs/Text.js +0 -39
  20. package/dist/cjs/Theme.js +0 -507
  21. package/dist/cjs/Toaster.js +0 -49
  22. package/dist/esm/Arithmetic.d.ts +0 -4
  23. package/dist/esm/Arithmetic.d.ts.map +0 -1
  24. package/dist/esm/Arithmetic.js +0 -5
  25. package/dist/esm/Arrayifier.d.ts +0 -29
  26. package/dist/esm/Arrayifier.d.ts.map +0 -1
  27. package/dist/esm/Arrayifier.js +0 -65
  28. package/dist/esm/CSV.d.ts +0 -10
  29. package/dist/esm/CSV.d.ts.map +0 -1
  30. package/dist/esm/CSV.js +0 -35
  31. package/dist/esm/Color.d.ts +0 -93
  32. package/dist/esm/Color.d.ts.map +0 -1
  33. package/dist/esm/Color.js +0 -344
  34. package/dist/esm/Dates.d.ts +0 -51
  35. package/dist/esm/Dates.d.ts.map +0 -1
  36. package/dist/esm/Dates.js +0 -354
  37. package/dist/esm/Kontororu/Socket.d.ts +0 -44
  38. package/dist/esm/Kontororu/Socket.d.ts.map +0 -1
  39. package/dist/esm/Kontororu/Socket.js +0 -218
  40. package/dist/esm/Kontororu.d.ts +0 -8
  41. package/dist/esm/Kontororu.d.ts.map +0 -1
  42. package/dist/esm/Kontororu.js +0 -23
  43. package/dist/esm/Objector.d.ts +0 -32
  44. package/dist/esm/Objector.d.ts.map +0 -1
  45. package/dist/esm/Objector.js +0 -120
  46. package/dist/esm/Sorter.d.ts +0 -8
  47. package/dist/esm/Sorter.d.ts.map +0 -1
  48. package/dist/esm/Sorter.js +0 -28
  49. package/dist/esm/Style.d.ts +0 -63
  50. package/dist/esm/Style.d.ts.map +0 -1
  51. package/dist/esm/Style.js +0 -471
  52. package/dist/esm/Text.d.ts +0 -5
  53. package/dist/esm/Text.d.ts.map +0 -1
  54. package/dist/esm/Text.js +0 -35
  55. package/dist/esm/Theme.d.ts +0 -1413
  56. package/dist/esm/Theme.d.ts.map +0 -1
  57. package/dist/esm/Theme.js +0 -503
  58. package/dist/esm/Toaster.d.ts +0 -24
  59. package/dist/esm/Toaster.d.ts.map +0 -1
  60. package/dist/esm/Toaster.js +0 -46
  61. package/dist/esm/index.d.ts +0 -12
  62. package/dist/esm/index.d.ts.map +0 -1
  63. /package/dist/{cjs → types}/Arithmetic.d.ts +0 -0
  64. /package/dist/{cjs → types}/Arithmetic.d.ts.map +0 -0
  65. /package/dist/{cjs → types}/Arrayifier.d.ts +0 -0
  66. /package/dist/{cjs → types}/Arrayifier.d.ts.map +0 -0
  67. /package/dist/{cjs → types}/CSV.d.ts +0 -0
  68. /package/dist/{cjs → types}/CSV.d.ts.map +0 -0
  69. /package/dist/{cjs → types}/Color.d.ts +0 -0
  70. /package/dist/{cjs → types}/Color.d.ts.map +0 -0
  71. /package/dist/{cjs → types}/Dates.d.ts +0 -0
  72. /package/dist/{cjs → types}/Dates.d.ts.map +0 -0
  73. /package/dist/{cjs → types}/Kontororu.d.ts +0 -0
  74. /package/dist/{cjs → types}/Kontororu.d.ts.map +0 -0
  75. /package/dist/{cjs → types}/Objector.d.ts +0 -0
  76. /package/dist/{cjs → types}/Objector.d.ts.map +0 -0
  77. /package/dist/{cjs → types}/Sorter.d.ts +0 -0
  78. /package/dist/{cjs → types}/Sorter.d.ts.map +0 -0
  79. /package/dist/{cjs → types}/Style.d.ts +0 -0
  80. /package/dist/{cjs → types}/Style.d.ts.map +0 -0
  81. /package/dist/{cjs → types}/Text.d.ts +0 -0
  82. /package/dist/{cjs → types}/Text.d.ts.map +0 -0
  83. /package/dist/{cjs → types}/Theme.d.ts +0 -0
  84. /package/dist/{cjs → types}/Theme.d.ts.map +0 -0
  85. /package/dist/{cjs → types}/Toaster.d.ts +0 -0
  86. /package/dist/{cjs → types}/Toaster.d.ts.map +0 -0
  87. /package/dist/{cjs → types}/index.d.ts +0 -0
  88. /package/dist/{cjs → types}/index.d.ts.map +0 -0
@@ -1,32 +0,0 @@
1
- type Merge<T, U> = Omit<T, keyof U> & U;
2
- type MergeAll<T extends object[]> = T extends [infer First, ...infer Rest] ? First extends object ? Rest extends object[] ? Merge<First, MergeAll<Rest>> : First : unknown : unknown;
3
- /**
4
- * Class to manipulate objects
5
- */
6
- export declare class Objector {
7
- static deepClone<T>(obj: T, memo?: WeakMap<any, any>): T;
8
- /**
9
- * Deeply merges one or more source objects into a target object.
10
- *
11
- * - Each property from the sources is deep-cloned before being assigned.
12
- * - Existing properties in the target are overwritten by matching keys in later sources.
13
- * - Does not use spread or Object.assign.
14
- * - Mutates and returns the target object.
15
- *
16
- * @template T - The type of the target object.
17
- * @param {T} target - The object to extend.
18
- * @param {...U[]} sources - One or more source objects whose properties will be copied to the target.
19
- * @returns {T & U} The mutated target object containing all deep-cloned properties from the sources.
20
- *
21
- * @throws {TypeError} If the target is null or undefined.
22
- *
23
- * @example
24
- * const target = { a: 1 };
25
- * const source = { b: { nested: 2 } };
26
- * Objector.extender(target, source);
27
- * // target is now { a: 1, b: { nested: 2 } }
28
- */
29
- static extender<T extends object, U extends object[]>(target: T, ...sources: U): MergeAll<[T, ...U]>;
30
- }
31
- export {};
32
- //# sourceMappingURL=Objector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Objector.d.ts","sourceRoot":"","sources":["../../src/Objector.ts"],"names":[],"mappings":"AAEA,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;AAExC,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,IAC9B,CAAC,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAClC,KAAK,SAAS,MAAM,GAClB,IAAI,SAAS,MAAM,EAAE,GACnB,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAC5B,KAAK,GACP,OAAO,GACT,OAAO,CAAC;AAEd;;GAEG;AACH,qBAAa,QAAQ;WAKL,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,oBAA0B,GAAG,CAAC;IAwErE;;;;;;;;;;;;;;;;;;;;OAoBG;WACW,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,EACzD,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,CAAC,GACZ,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;CA+BvB"}
@@ -1,120 +0,0 @@
1
- /* eslint-disable no-restricted-syntax */
2
- /**
3
- * Class to manipulate objects
4
- */
5
- export class Objector {
6
- // constructor() {
7
- // }
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- static deepClone(obj, memo = new WeakMap()) {
10
- // Check if the input is null or not an object/array
11
- if (obj === null || typeof obj !== 'object') {
12
- return obj;
13
- }
14
- // Check if the object is already in the memo
15
- if (memo.has(obj)) {
16
- return memo.get(obj);
17
- }
18
- // Handle built-in types
19
- if (obj instanceof Date) {
20
- return new Date(obj.getTime());
21
- }
22
- if (obj instanceof RegExp) {
23
- return new RegExp(obj.source, obj.flags);
24
- }
25
- if (obj instanceof Map) {
26
- const clonedMap = new Map();
27
- memo.set(obj, clonedMap);
28
- obj.forEach((value, key) => clonedMap.set(key, Objector.deepClone(value, memo)));
29
- return clonedMap;
30
- }
31
- if (obj instanceof Set) {
32
- const newSet = new Set();
33
- for (const item of obj) {
34
- newSet.add(Objector.deepClone(item));
35
- }
36
- return newSet;
37
- }
38
- // Handle arrays
39
- if (Array.isArray(obj)) {
40
- const clonedArray = obj.map((item) => Objector.deepClone(item, memo));
41
- memo.set(obj, clonedArray);
42
- return clonedArray;
43
- }
44
- // Handle objects
45
- const clonedObj = Object.create(Object.getPrototypeOf(obj));
46
- memo.set(obj, clonedObj);
47
- // Cast the source 'obj' to a record so we can read its keys dynamically
48
- const sourceObj = obj;
49
- // per Gemini
50
- /**
51
- * While it appears to be two steps, the first step (Object.keys()) is a native C++ function in the JavaScript engine.
52
- * It's highly optimized for this specific task and is often faster than the JIT compiler can make the for...in loop with its conditional checks.
53
- */
54
- Object.keys(sourceObj).forEach((key) => {
55
- clonedObj[key] = Objector.deepClone(sourceObj[key], memo);
56
- });
57
- /*
58
- for (const key in obj) {
59
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
60
- clonedObj[key] = Objector.deepClone(obj[key], memo);
61
- }
62
- }
63
- */
64
- // Symbol keys
65
- Object.getOwnPropertySymbols(sourceObj).forEach((sym) => {
66
- if (Object.prototype.propertyIsEnumerable.call(sourceObj, sym)) {
67
- clonedObj[sym] = Objector.deepClone(sourceObj[sym], memo);
68
- }
69
- });
70
- return clonedObj;
71
- }
72
- /**
73
- * Deeply merges one or more source objects into a target object.
74
- *
75
- * - Each property from the sources is deep-cloned before being assigned.
76
- * - Existing properties in the target are overwritten by matching keys in later sources.
77
- * - Does not use spread or Object.assign.
78
- * - Mutates and returns the target object.
79
- *
80
- * @template T - The type of the target object.
81
- * @param {T} target - The object to extend.
82
- * @param {...U[]} sources - One or more source objects whose properties will be copied to the target.
83
- * @returns {T & U} The mutated target object containing all deep-cloned properties from the sources.
84
- *
85
- * @throws {TypeError} If the target is null or undefined.
86
- *
87
- * @example
88
- * const target = { a: 1 };
89
- * const source = { b: { nested: 2 } };
90
- * Objector.extender(target, source);
91
- * // target is now { a: 1, b: { nested: 2 } }
92
- */
93
- static extender(target, ...sources) {
94
- if (target == null) {
95
- throw new TypeError('Cannot convert undefined or null to object');
96
- }
97
- const to = Object(target);
98
- // eslint-disable-next-line no-restricted-syntax
99
- for (const source of sources) {
100
- if (source != null) {
101
- // Cast the source to an indexable record
102
- const s = source;
103
- // String keys
104
- // eslint-disable-next-line no-restricted-syntax
105
- for (const key of Object.keys(s)) {
106
- to[key] = Objector.deepClone(s[key]);
107
- }
108
- // Symbol keys
109
- const symbols = Object.getOwnPropertySymbols(s);
110
- // eslint-disable-next-line no-restricted-syntax
111
- for (const sym of symbols) {
112
- if (Object.prototype.propertyIsEnumerable.call(s, sym)) {
113
- to[sym] = Objector.deepClone(s[sym]);
114
- }
115
- }
116
- }
117
- }
118
- return to;
119
- }
120
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Table sorting helper utility
3
- */
4
- export declare class Sorter {
5
- static descendingComparator(a: Record<string, string | number>, b: Record<string, string | number>, orderBy: string, direction_?: string): number;
6
- static getComparator(order: string, orderBy: string, direction?: string): (a: Record<string, string | number>, b: Record<string, string | number>) => number;
7
- }
8
- //# sourceMappingURL=Sorter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Sorter.d.ts","sourceRoot":"","sources":["../../src/Sorter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,MAAM;WACH,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;WAsB1I,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM;CAKpK"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Table sorting helper utility
3
- */
4
- export class Sorter {
5
- static descendingComparator(a, b, orderBy, direction_) {
6
- if ((orderBy in a) && b[orderBy] === null) {
7
- return 1;
8
- }
9
- if (a[orderBy] === null && (orderBy in b)) {
10
- return -1;
11
- }
12
- const a_value = a[orderBy];
13
- const b_value = b[orderBy];
14
- const direction = direction_ || 'lower';
15
- if (b_value < a_value) {
16
- return direction === 'higher' ? 1 : -1;
17
- }
18
- if (b_value > a_value) {
19
- return direction === 'higher' ? -1 : 1;
20
- }
21
- return 0;
22
- }
23
- static getComparator(order, orderBy, direction) {
24
- return order === 'desc'
25
- ? (a, b) => this.descendingComparator(a, b, orderBy, direction)
26
- : (a, b) => -this.descendingComparator(a, b, orderBy, direction);
27
- }
28
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * Class to get the style
3
- * Has base CSS functions
4
- */
5
- export declare class Style {
6
- static getStyle(): {
7
- zIndex: {
8
- appBar: number;
9
- drawer: number;
10
- fab: number;
11
- calendar: number;
12
- mobileStepper: number;
13
- modal: number;
14
- toast: number;
15
- speedDial: number;
16
- tooltip: number;
17
- };
18
- };
19
- static getZIndex(): {
20
- appBar: number;
21
- drawer: number;
22
- fab: number;
23
- calendar: number;
24
- mobileStepper: number;
25
- modal: number;
26
- toast: number;
27
- speedDial: number;
28
- tooltip: number;
29
- };
30
- static getNavBar(): {
31
- width: string;
32
- display: string;
33
- justifyContent: string;
34
- zIndex: number;
35
- position: string;
36
- overflowX: string;
37
- overflowY: string;
38
- scrollbarWidth: string;
39
- };
40
- static getShadow(depth: number): string;
41
- /**
42
- *
43
- *
44
- *
45
- *
46
- * Below is all the CSS injection from js
47
- *
48
- *
49
- *
50
- */
51
- /**
52
- * Call this to add css as a style-sheet, so you can do css selectors like hover td {} etc
53
- */
54
- static getStyleClassName(cssString: string | object, debug?: boolean): string;
55
- static getCSS(): string;
56
- static flush(): void;
57
- private static styleCache;
58
- private static cssMap;
59
- private static hashCSS;
60
- private static injectStyle;
61
- private static processCSS;
62
- }
63
- //# sourceMappingURL=Style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Style.d.ts","sourceRoot":"","sources":["../../src/Style.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,qBAAa,KAAK;WACF,QAAQ;;;;;;;;;;;;;WAMR,SAAS;;;;;;;;;;;WAcT,SAAS;;;;;;;;;;WAaT,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAoC9C;;;;;;;;;OASG;IAEH;;OAEG;WACW,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,UAAQ;WAa3D,MAAM,IAAI,MAAM;WAMhB,KAAK,IAAI,IAAI;IAK3B,OAAO,CAAC,MAAM,CAAC,UAAU,CAA0B;IAEnD,OAAO,CAAC,MAAM,CAAC,MAAM,CAAqB;IAE1C,OAAO,CAAC,MAAM,CAAC,OAAO;IAqDtB,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,UAAU;CAsW1B"}