@inrixia/helpers 2.0.11 → 3.1.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 (163) hide show
  1. package/dist/conv.d.ts +27 -27
  2. package/dist/conv.d.ts.map +1 -1
  3. package/dist/conv.js +41 -41
  4. package/dist/{logic.d.ts → fn/Promize.d.ts} +16 -23
  5. package/dist/fn/Promize.d.ts.map +1 -0
  6. package/dist/fn/Promize.js +25 -0
  7. package/dist/fn/Promize.js.map +1 -0
  8. package/dist/fn/Semaphore.d.ts +7 -0
  9. package/dist/fn/Semaphore.d.ts.map +1 -0
  10. package/dist/fn/Semaphore.js +31 -0
  11. package/dist/fn/Semaphore.js.map +1 -0
  12. package/dist/fn/asyncDebounce.d.ts +2 -0
  13. package/dist/fn/asyncDebounce.d.ts.map +1 -0
  14. package/dist/fn/asyncDebounce.js +26 -0
  15. package/dist/fn/asyncDebounce.js.map +1 -0
  16. package/dist/fn/debounce.d.ts +2 -0
  17. package/dist/fn/debounce.d.ts.map +1 -0
  18. package/dist/fn/debounce.js +13 -0
  19. package/dist/fn/debounce.js.map +1 -0
  20. package/dist/fn/loopError.d.ts +11 -0
  21. package/dist/fn/loopError.d.ts.map +1 -0
  22. package/dist/fn/loopError.js +14 -0
  23. package/dist/fn/loopError.js.map +1 -0
  24. package/dist/fn/memoize.d.ts +2 -0
  25. package/dist/fn/memoize.d.ts.map +1 -0
  26. package/dist/fn/memoize.js +18 -0
  27. package/dist/fn/memoize.js.map +1 -0
  28. package/dist/fn/retry.d.ts +7 -0
  29. package/dist/fn/retry.d.ts.map +1 -0
  30. package/dist/{logic.js → fn/retry.js} +26 -50
  31. package/dist/fn/retry.js.map +1 -0
  32. package/dist/fn/runFor.d.ts +2 -0
  33. package/dist/fn/runFor.d.ts.map +1 -0
  34. package/dist/fn/runFor.js +11 -0
  35. package/dist/fn/runFor.js.map +1 -0
  36. package/dist/{react.d.ts → fn/toBase64Image.d.ts} +2 -2
  37. package/dist/fn/toBase64Image.d.ts.map +1 -0
  38. package/dist/{react.js → fn/toBase64Image.js} +14 -14
  39. package/dist/fn/toBase64Image.js.map +1 -0
  40. package/dist/fn/toRange.d.ts +9 -0
  41. package/dist/fn/toRange.d.ts.map +1 -0
  42. package/dist/fn/toRange.js +26 -0
  43. package/dist/fn/toRange.js.map +1 -0
  44. package/dist/fs/exists.d.ts +2 -0
  45. package/dist/fs/exists.d.ts.map +1 -0
  46. package/dist/fs/exists.js +12 -0
  47. package/dist/fs/exists.js.map +1 -0
  48. package/dist/geo.d.ts +18 -18
  49. package/dist/geo.d.ts.map +1 -1
  50. package/dist/geo.js +31 -31
  51. package/dist/index.d.ts +36 -8
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +36 -8
  54. package/dist/index.js.map +1 -1
  55. package/dist/math/angleDifference.d.ts +9 -0
  56. package/dist/math/angleDifference.d.ts.map +1 -0
  57. package/dist/math/angleDifference.js +16 -0
  58. package/dist/math/angleDifference.js.map +1 -0
  59. package/dist/math/nPad.d.ts +14 -0
  60. package/dist/math/nPad.d.ts.map +1 -0
  61. package/dist/math/nPad.js +19 -0
  62. package/dist/math/nPad.js.map +1 -0
  63. package/dist/math/qRnd.d.ts +8 -0
  64. package/dist/math/qRnd.d.ts.map +1 -0
  65. package/dist/math/qRnd.js +11 -0
  66. package/dist/math/qRnd.js.map +1 -0
  67. package/dist/math/to360.d.ts +7 -0
  68. package/dist/math/to360.d.ts.map +1 -0
  69. package/dist/math/to360.js +10 -0
  70. package/dist/math/to360.js.map +1 -0
  71. package/dist/obj/RecursiveUpdateOptions.d.ts +15 -0
  72. package/dist/obj/RecursiveUpdateOptions.d.ts.map +1 -0
  73. package/dist/obj/RecursiveUpdateOptions.js +23 -0
  74. package/dist/obj/RecursiveUpdateOptions.js.map +1 -0
  75. package/dist/obj/chunkArray.d.ts +9 -0
  76. package/dist/obj/chunkArray.d.ts.map +1 -0
  77. package/dist/obj/chunkArray.js +17 -0
  78. package/dist/obj/chunkArray.js.map +1 -0
  79. package/dist/obj/compare.d.ts +24 -0
  80. package/dist/obj/compare.d.ts.map +1 -0
  81. package/dist/obj/compare.js +59 -0
  82. package/dist/obj/compare.js.map +1 -0
  83. package/dist/obj/deepGet.d.ts +17 -0
  84. package/dist/obj/deepGet.d.ts.map +1 -0
  85. package/dist/obj/deepGet.js +21 -0
  86. package/dist/obj/deepGet.js.map +1 -0
  87. package/dist/obj/deepMerge.d.ts +8 -0
  88. package/dist/obj/deepMerge.d.ts.map +1 -0
  89. package/dist/obj/deepMerge.js +23 -0
  90. package/dist/obj/deepMerge.js.map +1 -0
  91. package/dist/obj/envOrThrow.d.ts +5 -0
  92. package/dist/obj/envOrThrow.d.ts.map +1 -0
  93. package/dist/obj/envOrThrow.js +10 -0
  94. package/dist/obj/envOrThrow.js.map +1 -0
  95. package/dist/obj/fillTemplate.d.ts +18 -0
  96. package/dist/obj/fillTemplate.d.ts.map +1 -0
  97. package/dist/obj/fillTemplate.js +27 -0
  98. package/dist/obj/fillTemplate.js.map +1 -0
  99. package/dist/obj/getEnv.d.ts +11 -0
  100. package/dist/obj/getEnv.d.ts.map +1 -0
  101. package/dist/obj/getEnv.js +43 -0
  102. package/dist/obj/getEnv.js.map +1 -0
  103. package/dist/obj/hash.d.ts +2 -0
  104. package/dist/obj/hash.d.ts.map +1 -0
  105. package/dist/obj/hash.js +12 -0
  106. package/dist/obj/hash.js.map +1 -0
  107. package/dist/{inspect.d.ts → obj/inspect.d.ts} +25 -25
  108. package/dist/obj/inspect.d.ts.map +1 -0
  109. package/dist/{inspect.js → obj/inspect.js} +35 -35
  110. package/dist/obj/inspect.js.map +1 -0
  111. package/dist/obj/objectify.d.ts +15 -0
  112. package/dist/obj/objectify.d.ts.map +1 -0
  113. package/dist/obj/objectify.js +14 -0
  114. package/dist/obj/objectify.js.map +1 -0
  115. package/dist/obj/rebuildTypes.d.ts +6 -0
  116. package/dist/obj/rebuildTypes.d.ts.map +1 -0
  117. package/dist/obj/rebuildTypes.js +24 -0
  118. package/dist/obj/rebuildTypes.js.map +1 -0
  119. package/dist/test.d.ts +26 -26
  120. package/dist/test.d.ts.map +1 -1
  121. package/dist/test.js +68 -68
  122. package/dist/test.js.map +1 -1
  123. package/dist/ts/isKeyOf.d.ts +6 -0
  124. package/dist/ts/isKeyOf.d.ts.map +1 -0
  125. package/dist/ts/isKeyOf.js +5 -0
  126. package/dist/ts/isKeyOf.js.map +1 -0
  127. package/dist/ts/isTypeOf.d.ts +12 -0
  128. package/dist/ts/isTypeOf.d.ts.map +1 -0
  129. package/dist/ts/isTypeOf.js +12 -0
  130. package/dist/ts/isTypeOf.js.map +1 -0
  131. package/dist/ts/math.d.ts +11 -11
  132. package/dist/ts/math.d.ts.map +1 -1
  133. package/dist/ts/math.js +1 -1
  134. package/dist/ts/numRange.d.ts +11 -11
  135. package/dist/ts/numRange.d.ts.map +1 -1
  136. package/dist/ts/numRange.js +1 -1
  137. package/dist/ts/typeOf.d.ts +24 -0
  138. package/dist/ts/typeOf.d.ts.map +1 -0
  139. package/dist/ts/typeOf.js +28 -0
  140. package/dist/ts/typeOf.js.map +1 -0
  141. package/dist/ts/types.d.ts +31 -0
  142. package/dist/ts/types.d.ts.map +1 -0
  143. package/dist/ts/types.js +2 -0
  144. package/dist/ts/types.js.map +1 -0
  145. package/package.json +23 -62
  146. package/dist/inspect.d.ts.map +0 -1
  147. package/dist/inspect.js.map +0 -1
  148. package/dist/logic.d.ts.map +0 -1
  149. package/dist/logic.js.map +0 -1
  150. package/dist/math.d.ts +0 -35
  151. package/dist/math.d.ts.map +0 -1
  152. package/dist/math.js +0 -53
  153. package/dist/math.js.map +0 -1
  154. package/dist/object.d.ts +0 -142
  155. package/dist/object.d.ts.map +0 -1
  156. package/dist/object.js +0 -315
  157. package/dist/object.js.map +0 -1
  158. package/dist/react.d.ts.map +0 -1
  159. package/dist/react.js.map +0 -1
  160. package/dist/ts.d.ts +0 -29
  161. package/dist/ts.d.ts.map +0 -1
  162. package/dist/ts.js +0 -6
  163. package/dist/ts.js.map +0 -1
@@ -0,0 +1,12 @@
1
+ import fs from "fs/promises";
2
+ import { constants } from "fs";
3
+ export const exists = async (path) => {
4
+ try {
5
+ await fs.access(path, constants.F_OK);
6
+ return true;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ };
12
+ //# sourceMappingURL=exists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exists.js","sourceRoot":"","sources":["../../src/fs/exists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IAC9D,IAAI,CAAC;QACJ,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC,CAAC"}
package/dist/geo.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- /**
2
- * Converts latitude or longitude to degrees, minutes & seconds.
3
- * @param coord Latitude or longitude coordinate
4
- *
5
- * @returns Coordinate in degrees, minutes & seconds
6
- */
7
- export declare const toDMS: (coord: number) => {
8
- degrees: number;
9
- minutes: number;
10
- seconds: number;
11
- };
12
- export declare const toRad: (val: number) => number;
13
- /**
14
- * Returns the distance between two LatLong's in kilometers
15
- * @param pos1 [lat, long] coordinates
16
- * @param pos2 [lat, long] coordinates
17
- */
18
- export declare const getDistance: (pos1: [number, number], pos2: [number, number]) => number;
1
+ /**
2
+ * Converts latitude or longitude to degrees, minutes & seconds.
3
+ * @param coord Latitude or longitude coordinate
4
+ *
5
+ * @returns Coordinate in degrees, minutes & seconds
6
+ */
7
+ export declare const toDMS: (coord: number) => {
8
+ degrees: number;
9
+ minutes: number;
10
+ seconds: number;
11
+ };
12
+ export declare const toRad: (val: number) => number;
13
+ /**
14
+ * Returns the distance between two LatLong's in kilometers
15
+ * @param pos1 [lat, long] coordinates
16
+ * @param pos2 [lat, long] coordinates
17
+ */
18
+ export declare const getDistance: (pos1: [number, number], pos2: [number, number]) => number;
19
19
  //# sourceMappingURL=geo.d.ts.map
package/dist/geo.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM;aAAc,MAAM;aAAW,MAAM;aAAW,MAAM;CAOxF,CAAC;AAGF,eAAO,MAAM,KAAK,QAAS,MAAM,KAAG,MAA+B,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAU,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAS5E,CAAC"}
1
+ {"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAOxF,CAAC;AAGF,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,KAAG,MAA+B,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAS5E,CAAC"}
package/dist/geo.js CHANGED
@@ -1,32 +1,32 @@
1
- /**
2
- * Converts latitude or longitude to degrees, minutes & seconds.
3
- * @param coord Latitude or longitude coordinate
4
- *
5
- * @returns Coordinate in degrees, minutes & seconds
6
- */
7
- export const toDMS = (coord) => {
8
- const absolute = Math.abs(coord);
9
- const degrees = Math.floor(absolute);
10
- const minutesNotTruncated = (absolute - degrees) * 60;
11
- const minutes = Math.floor(minutesNotTruncated);
12
- const seconds = Math.floor((minutesNotTruncated - minutes) * 60);
13
- return { degrees, minutes, seconds };
14
- };
15
- // Converts numeric degrees to radians
16
- export const toRad = (val) => (val * Math.PI) / 180;
17
- /**
18
- * Returns the distance between two LatLong's in kilometers
19
- * @param pos1 [lat, long] coordinates
20
- * @param pos2 [lat, long] coordinates
21
- */
22
- export const getDistance = (pos1, pos2) => {
23
- const [lat1, lon1] = pos1;
24
- const [lat2, lon2] = pos2;
25
- const R = 6371; // km
26
- const dLat = toRad(lat2 - lat1);
27
- const dLon = toRad(lon2 - lon1);
28
- const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(toRad(lat1)) * Math.cos(toRad(lat2));
29
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
30
- return R * c;
31
- };
1
+ /**
2
+ * Converts latitude or longitude to degrees, minutes & seconds.
3
+ * @param coord Latitude or longitude coordinate
4
+ *
5
+ * @returns Coordinate in degrees, minutes & seconds
6
+ */
7
+ export const toDMS = (coord) => {
8
+ const absolute = Math.abs(coord);
9
+ const degrees = Math.floor(absolute);
10
+ const minutesNotTruncated = (absolute - degrees) * 60;
11
+ const minutes = Math.floor(minutesNotTruncated);
12
+ const seconds = Math.floor((minutesNotTruncated - minutes) * 60);
13
+ return { degrees, minutes, seconds };
14
+ };
15
+ // Converts numeric degrees to radians
16
+ export const toRad = (val) => (val * Math.PI) / 180;
17
+ /**
18
+ * Returns the distance between two LatLong's in kilometers
19
+ * @param pos1 [lat, long] coordinates
20
+ * @param pos2 [lat, long] coordinates
21
+ */
22
+ export const getDistance = (pos1, pos2) => {
23
+ const [lat1, lon1] = pos1;
24
+ const [lat2, lon2] = pos2;
25
+ const R = 6371; // km
26
+ const dLat = toRad(lat2 - lat1);
27
+ const dLon = toRad(lon2 - lon1);
28
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(toRad(lat1)) * Math.cos(toRad(lat2));
29
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
30
+ return R * c;
31
+ };
32
32
  //# sourceMappingURL=geo.js.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,37 @@
1
- export * from "./conv.js";
2
- export * from "./geo.js";
3
- export * from "./logic.js";
4
- export * from "./math.js";
5
- export * from "./object.js";
6
- export * from "./react.js";
7
- export * from "./test.js";
8
- export * from "./ts.js";
1
+ export * from "./conv.js";
2
+ export * from "./fn/Promize.js";
3
+ export * from "./fn/Semaphore.js";
4
+ export * from "./fn/asyncDebounce.js";
5
+ export * from "./fn/debounce.js";
6
+ export * from "./fn/loopError.js";
7
+ export * from "./fn/memoize.js";
8
+ export * from "./fn/retry.js";
9
+ export * from "./fn/runFor.js";
10
+ export * from "./fn/toBase64Image.js";
11
+ export * from "./fn/toRange.js";
12
+ export * from "./fs/exists.js";
13
+ export * from "./geo.js";
14
+ export * from "./math/angleDifference.js";
15
+ export * from "./math/nPad.js";
16
+ export * from "./math/qRnd.js";
17
+ export * from "./math/to360.js";
18
+ export * from "./obj/RecursiveUpdateOptions.js";
19
+ export * from "./obj/chunkArray.js";
20
+ export * from "./obj/compare.js";
21
+ export * from "./obj/deepGet.js";
22
+ export * from "./obj/deepMerge.js";
23
+ export * from "./obj/envOrThrow.js";
24
+ export * from "./obj/fillTemplate.js";
25
+ export * from "./obj/getEnv.js";
26
+ export * from "./obj/hash.js";
27
+ export * from "./obj/inspect.js";
28
+ export * from "./obj/objectify.js";
29
+ export * from "./obj/rebuildTypes.js";
30
+ export * from "./test.js";
31
+ export * from "./ts/isKeyOf.js";
32
+ export * from "./ts/isTypeOf.js";
33
+ export * from "./ts/math.js";
34
+ export * from "./ts/numRange.js";
35
+ export * from "./ts/typeOf.js";
36
+ export * from "./ts/types.js";
9
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,37 @@
1
- export * from "./conv.js";
2
- export * from "./geo.js";
3
- export * from "./logic.js";
4
- export * from "./math.js";
5
- export * from "./object.js";
6
- export * from "./react.js";
7
- export * from "./test.js";
8
- export * from "./ts.js";
1
+ export * from "./conv.js";
2
+ export * from "./fn/Promize.js";
3
+ export * from "./fn/Semaphore.js";
4
+ export * from "./fn/asyncDebounce.js";
5
+ export * from "./fn/debounce.js";
6
+ export * from "./fn/loopError.js";
7
+ export * from "./fn/memoize.js";
8
+ export * from "./fn/retry.js";
9
+ export * from "./fn/runFor.js";
10
+ export * from "./fn/toBase64Image.js";
11
+ export * from "./fn/toRange.js";
12
+ export * from "./fs/exists.js";
13
+ export * from "./geo.js";
14
+ export * from "./math/angleDifference.js";
15
+ export * from "./math/nPad.js";
16
+ export * from "./math/qRnd.js";
17
+ export * from "./math/to360.js";
18
+ export * from "./obj/RecursiveUpdateOptions.js";
19
+ export * from "./obj/chunkArray.js";
20
+ export * from "./obj/compare.js";
21
+ export * from "./obj/deepGet.js";
22
+ export * from "./obj/deepMerge.js";
23
+ export * from "./obj/envOrThrow.js";
24
+ export * from "./obj/fillTemplate.js";
25
+ export * from "./obj/getEnv.js";
26
+ export * from "./obj/hash.js";
27
+ export * from "./obj/inspect.js";
28
+ export * from "./obj/objectify.js";
29
+ export * from "./obj/rebuildTypes.js";
30
+ export * from "./test.js";
31
+ export * from "./ts/isKeyOf.js";
32
+ export * from "./ts/isTypeOf.js";
33
+ export * from "./ts/math.js";
34
+ export * from "./ts/numRange.js";
35
+ export * from "./ts/typeOf.js";
36
+ export * from "./ts/types.js";
9
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Calculates the difference between two angles (0°-360°), `angle1` & `angle2` returned result is in decimal degrees and is signed.
3
+ * @param angle1 First angle to compare
4
+ * @param angle2 Second angle to compare
5
+ * @param signed If the result is signed or absolute
6
+ * @returns The difference in degrees
7
+ */
8
+ export declare const angleDifference: (angle1: number, angle2: number, signed?: boolean) => number;
9
+ //# sourceMappingURL=angleDifference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angleDifference.d.ts","sourceRoot":"","sources":["../../src/math/angleDifference.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,gBAAa,KAAG,MAO/E,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Calculates the difference between two angles (0°-360°), `angle1` & `angle2` returned result is in decimal degrees and is signed.
3
+ * @param angle1 First angle to compare
4
+ * @param angle2 Second angle to compare
5
+ * @param signed If the result is signed or absolute
6
+ * @returns The difference in degrees
7
+ */
8
+ export const angleDifference = (angle1, angle2, signed = true) => {
9
+ let difference = Math.abs(angle1 - angle2) % 360;
10
+ difference = difference > 180 ? 360 - difference : difference;
11
+ // Calculate sign
12
+ if (signed)
13
+ return (angle1 - angle2 >= 0 && angle1 - angle2 <= 180) || (angle1 - angle2 <= -180 && angle1 - angle2 >= -360) ? difference : difference * -1;
14
+ return difference;
15
+ };
16
+ //# sourceMappingURL=angleDifference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angleDifference.js","sourceRoot":"","sources":["../../src/math/angleDifference.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,MAAM,GAAG,IAAI,EAAU,EAAE;IACxF,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;IACjD,UAAU,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;IAE9D,iBAAiB;IACjB,IAAI,MAAM;QAAE,OAAO,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC3J,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Pad a number with 0's
3
+ * @param num Number to pad.
4
+ * @param zeros Number of digits returned number should have.
5
+ *
6
+ * @returns Padded number
7
+ * @example
8
+ * let paddedNumber = nPad(5)
9
+ * // paddedNumber = "05"
10
+ * let triplePaddedNumber = nPad(6, 3)
11
+ * // triplePaddedNumber = "006"
12
+ */
13
+ export declare const nPad: (num: number | string, zeros?: number) => string;
14
+ //# sourceMappingURL=nPad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nPad.d.ts","sourceRoot":"","sources":["../../src/math/nPad.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,GAAG,MAAM,EAAE,cAAS,KAAG,MAItD,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Pad a number with 0's
3
+ * @param num Number to pad.
4
+ * @param zeros Number of digits returned number should have.
5
+ *
6
+ * @returns Padded number
7
+ * @example
8
+ * let paddedNumber = nPad(5)
9
+ * // paddedNumber = "05"
10
+ * let triplePaddedNumber = nPad(6, 3)
11
+ * // triplePaddedNumber = "006"
12
+ */
13
+ export const nPad = (num, zeros = 2) => {
14
+ num = num.toString();
15
+ while (num.length < zeros)
16
+ num = "0" + num;
17
+ return num;
18
+ };
19
+ //# sourceMappingURL=nPad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nPad.js","sourceRoot":"","sources":["../../src/math/nPad.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAoB,EAAE,KAAK,GAAG,CAAC,EAAU,EAAE;IAC/D,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IACrB,OAAO,GAAG,CAAC,MAAM,GAAG,KAAK;QAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC3C,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Rounds a number to `digits` decimal places.
3
+ * @param num Number to round
4
+ * @param digits Decimal places to round to
5
+ * @returns Rounded number
6
+ */
7
+ export declare const qRnd: (num: number, digits?: number) => number;
8
+ //# sourceMappingURL=qRnd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qRnd.d.ts","sourceRoot":"","sources":["../../src/math/qRnd.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,EAAE,eAAU,KAAG,MAG9C,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Rounds a number to `digits` decimal places.
3
+ * @param num Number to round
4
+ * @param digits Decimal places to round to
5
+ * @returns Rounded number
6
+ */
7
+ export const qRnd = (num, digits = 0) => {
8
+ digits = 10 ** digits;
9
+ return ~~(num * digits) / digits;
10
+ };
11
+ //# sourceMappingURL=qRnd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qRnd.js","sourceRoot":"","sources":["../../src/math/qRnd.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,MAAM,GAAG,CAAC,EAAU,EAAE;IACvD,MAAM,GAAG,EAAE,IAAI,MAAM,CAAC;IACtB,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAClC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts `angle` to 0°-360°
3
+ * @param angle
4
+ * @returns `angle` in 0-360°
5
+ */
6
+ export declare const to360: (angle: number) => number;
7
+ //# sourceMappingURL=to360.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to360.d.ts","sourceRoot":"","sources":["../../src/math/to360.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,MAGrC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Converts `angle` to 0°-360°
3
+ * @param angle
4
+ * @returns `angle` in 0-360°
5
+ */
6
+ export const to360 = (angle) => {
7
+ angle = angle % 360;
8
+ return angle < 0 ? angle + 360 : angle;
9
+ };
10
+ //# sourceMappingURL=to360.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to360.js","sourceRoot":"","sources":["../../src/math/to360.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE;IAC9C,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;IACpB,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { UnknownRecord } from "../ts/types.js";
2
+ type RecursiveUpdateOptions = {
3
+ setUndefined?: boolean;
4
+ setDefined?: boolean;
5
+ };
6
+ /**
7
+ * Recursively update properties of a object with another.
8
+ * @param targetObject Object to update.
9
+ * @param newObject Object with new values to write to `targetObject`.
10
+ * @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
11
+ * @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
12
+ */
13
+ export declare const recursiveUpdate: (targetObject: UnknownRecord, newObject: UnknownRecord, options?: RecursiveUpdateOptions) => void;
14
+ export {};
15
+ //# sourceMappingURL=RecursiveUpdateOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecursiveUpdateOptions.d.ts","sourceRoot":"","sources":["../../src/obj/RecursiveUpdateOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,KAAK,sBAAsB,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC3B,cAAc,aAAa,EAC3B,WAAW,aAAa,EACxB,UAAS,sBAAkE,KACzE,IAQF,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { isObject } from "../ts/isTypeOf.js";
2
+ /**
3
+ * Recursively update properties of a object with another.
4
+ * @param targetObject Object to update.
5
+ * @param newObject Object with new values to write to `targetObject`.
6
+ * @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
7
+ * @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
8
+ */
9
+ export const recursiveUpdate = (targetObject, newObject, options = { setUndefined: true, setDefined: false }) => {
10
+ if (!isObject(targetObject))
11
+ throw new Error("targetObject is not an object!");
12
+ if (!isObject(newObject))
13
+ throw new Error("newObject is not an object!");
14
+ for (const key in newObject) {
15
+ if (isObject(targetObject[key]) && isObject(newObject[key]))
16
+ recursiveUpdate(targetObject[key], newObject[key], options);
17
+ else if (options.setUndefined && targetObject[key] === undefined)
18
+ targetObject[key] = newObject[key];
19
+ else if (options.setDefined && targetObject[key] !== undefined)
20
+ targetObject[key] = newObject[key];
21
+ }
22
+ };
23
+ //# sourceMappingURL=RecursiveUpdateOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecursiveUpdateOptions.js","sourceRoot":"","sources":["../../src/obj/RecursiveUpdateOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC9B,YAA2B,EAC3B,SAAwB,EACxB,UAAkC,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EACpE,EAAE;IACT,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC/E,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACzE,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAAE,eAAe,CAAgB,YAAY,CAAC,GAAG,CAAC,EAAiB,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;aAClJ,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aAChG,IAAI,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACpG,CAAC;AACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Breaks `array` into smaller chunks based on `chunkSize`
3
+ * @param array Array to break up.
4
+ * @param chunkSize Maximum size of array chunks.
5
+ *
6
+ * @returns Array containing array chunks.
7
+ */
8
+ export declare const chunkArray: <T extends unknown[] | string>(array: T, chunkSize: number) => T[];
9
+ //# sourceMappingURL=chunkArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunkArray.d.ts","sourceRoot":"","sources":["../../src/obj/chunkArray.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,MAAM,KAAG,CAAC,EAMvF,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Breaks `array` into smaller chunks based on `chunkSize`
3
+ * @param array Array to break up.
4
+ * @param chunkSize Maximum size of array chunks.
5
+ *
6
+ * @returns Array containing array chunks.
7
+ */
8
+ export const chunkArray = (array, chunkSize) => {
9
+ if (array.length < chunkSize)
10
+ return [array];
11
+ let i, j;
12
+ const returnArray = [];
13
+ for (i = 0, j = array.length; i < j; i += chunkSize)
14
+ returnArray.push(array.slice(i, i + chunkSize));
15
+ return returnArray;
16
+ };
17
+ //# sourceMappingURL=chunkArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunkArray.js","sourceRoot":"","sources":["../../src/obj/chunkArray.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAA+B,KAAQ,EAAE,SAAiB,EAAO,EAAE;IAC5F,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,MAAM,WAAW,GAAQ,EAAE,CAAC;IAC5B,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,SAAS;QAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAM,CAAC,CAAC;IAC1G,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { UnknownRecord } from "../ts/types.js";
2
+ export type TypeCompareResult = boolean | {
3
+ expectedType: string;
4
+ received: string;
5
+ location: string;
6
+ };
7
+ export type ObjTypes = {
8
+ [key: string]: string | string[] | ObjTypes | ObjTypes[];
9
+ };
10
+ /**
11
+ * Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
12
+ * @param target Object
13
+ * @param types Object identical to `target` but values are types
14
+ * @returns `object` if the types dont match. `True` if they do.
15
+ */
16
+ export declare const deepTypeCompare: (target: UnknownRecord, types: ObjTypes, location?: string) => TypeCompareResult;
17
+ /**
18
+ * Helper function for `deepTypeCompare` to compare a item to a type or set of types.
19
+ * @param expectedTypes Expected type/types
20
+ * @param receivedValue Object given
21
+ * @param location Location of `got` given
22
+ */
23
+ export declare const compareTwo: (expectedTypes: string | string[], receivedValue: unknown, location: string) => TypeCompareResult;
24
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/obj/compare.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACvG,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAA;CAAE,CAAC;AAEpF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,EAAE,OAAO,QAAQ,EAAE,iBAAmB,KAAG,iBA0B7F,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,GAAG,MAAM,EAAE,EAAE,eAAe,OAAO,EAAE,UAAU,MAAM,KAAG,iBAOvG,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { isObject } from "../ts/isTypeOf.js";
2
+ import { typeOf } from "../ts/typeOf.js";
3
+ /**
4
+ * Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
5
+ * @param target Object
6
+ * @param types Object identical to `target` but values are types
7
+ * @returns `object` if the types dont match. `True` if they do.
8
+ */
9
+ export const deepTypeCompare = (target, types, location = "target") => {
10
+ if (!(isObject(target) && isObject(types)))
11
+ return { location, expectedType: "object", received: `${target}:${typeOf(target)}` };
12
+ for (const key in target) {
13
+ const targetValue = target[key];
14
+ if (isObject(targetValue)) {
15
+ // If target.property is a object then check its child properties
16
+ const same = deepTypeCompare(targetValue, types[key], `${location}.${key}`);
17
+ if (same !== true)
18
+ return same;
19
+ }
20
+ else {
21
+ if (Array.isArray(targetValue) && Array.isArray(types[key])) {
22
+ // target.property and types.property are arrays
23
+ // Check each item in target.property against types.property[0]
24
+ const childCheckType = types[key];
25
+ for (const targetItem of targetValue) {
26
+ const targetType = typeOf(targetItem);
27
+ // If the array entry is a object then check it
28
+ if (targetType === "object")
29
+ return deepTypeCompare(targetItem, childCheckType, `${location}.${key}`);
30
+ else
31
+ return compareTwo(childCheckType, targetItem, `${location}.${key}`);
32
+ }
33
+ }
34
+ else {
35
+ const same = compareTwo(types[key], target[key], `${location}.${key}`);
36
+ if (same !== true)
37
+ return same;
38
+ }
39
+ }
40
+ }
41
+ return true;
42
+ };
43
+ /**
44
+ * Helper function for `deepTypeCompare` to compare a item to a type or set of types.
45
+ * @param expectedTypes Expected type/types
46
+ * @param receivedValue Object given
47
+ * @param location Location of `got` given
48
+ */
49
+ export const compareTwo = (expectedTypes, receivedValue, location) => {
50
+ if (!Array.isArray(expectedTypes))
51
+ expectedTypes = [expectedTypes];
52
+ const gotType = typeOf(receivedValue);
53
+ for (const expectedType of expectedTypes) {
54
+ if (gotType !== expectedType)
55
+ return { location, expectedType, received: `${receivedValue}:${gotType}` };
56
+ }
57
+ return true;
58
+ };
59
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/obj/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqB,EAAE,KAAe,EAAE,QAAQ,GAAG,QAAQ,EAAqB,EAAE;IACjH,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;IACjI,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3B,iEAAiE;YACjE,MAAM,IAAI,GAAG,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAa,EAAE,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;YACxF,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC;QAChC,CAAC;aAAM,CAAC;YACP,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC7D,gDAAgD;gBAChD,+DAA+D;gBAC/D,MAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;oBACtC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;oBACtC,+CAA+C;oBAC/C,IAAI,UAAU,KAAK,QAAQ;wBAAE,OAAO,eAAe,CAAC,UAAU,EAAE,cAAqC,EAAE,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;;wBACxH,OAAO,UAAU,CAAoB,cAAc,EAAE,UAAU,EAAE,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC7F,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,GAAG,UAAU,CAAoB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC1F,IAAI,IAAI,KAAK,IAAI;oBAAE,OAAO,IAAI,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,aAAgC,EAAE,aAAsB,EAAE,QAAgB,EAAqB,EAAE;IAC3H,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC;QAAE,aAAa,GAAG,CAAC,aAAa,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACtC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QAC1C,IAAI,OAAO,KAAK,YAAY;YAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,aAAa,IAAI,OAAO,EAAE,EAAE,CAAC;IAC1G,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { UnknownRecord } from "../ts/types.js";
2
+ /**
3
+ * Returns the `property` requested from `obj`
4
+ * @param obj
5
+ * @param property
6
+ * @param delimiter
7
+ * @example
8
+ * const object = {
9
+ * a: {
10
+ * child: "Hello World"
11
+ * }
12
+ * }
13
+ * const wantedProperty = "a.child"
14
+ * console.log(deepGet(object, wantedProperty)) // -> "Hello World"
15
+ */
16
+ export declare const deepGet: <T = unknown>(obj: UnknownRecord, property: string, delimiter?: string) => T | undefined;
17
+ //# sourceMappingURL=deepGet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepGet.d.ts","sourceRoot":"","sources":["../../src/obj/deepGet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,OAAO,EAAE,KAAK,aAAa,EAAE,UAAU,MAAM,EAAE,kBAAe,KAAG,CAAC,GAAG,SAIhG,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the `property` requested from `obj`
3
+ * @param obj
4
+ * @param property
5
+ * @param delimiter
6
+ * @example
7
+ * const object = {
8
+ * a: {
9
+ * child: "Hello World"
10
+ * }
11
+ * }
12
+ * const wantedProperty = "a.child"
13
+ * console.log(deepGet(object, wantedProperty)) // -> "Hello World"
14
+ */
15
+ export const deepGet = (obj, property, delimiter = ".") => {
16
+ const arr = property.split(delimiter);
17
+ while (arr.length && (obj = obj[arr.shift()]))
18
+ ;
19
+ return obj;
20
+ };
21
+ //# sourceMappingURL=deepGet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepGet.js","sourceRoot":"","sources":["../../src/obj/deepGet.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAc,GAAkB,EAAE,QAAgB,EAAE,SAAS,GAAG,GAAG,EAAiB,EAAE;IAC5G,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,EAAY,CAAkB,CAAC;QAAC,CAAC;IAC1E,OAAO,GAAQ,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { UnknownRecord } from "../ts/types.js";
2
+ /**
3
+ * Deep merge objects into target. Without modifying target.
4
+ * @param target
5
+ * @param source
6
+ */
7
+ export declare const deepMerge: <T extends S, S extends UnknownRecord = Partial<T>>(target: T, source: S) => T & S;
8
+ //# sourceMappingURL=deepMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/obj/deepMerge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C;;;;GAIG;AAEH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAG,CAAC,GAAG,CAWvG,CAAC"}