@inrixia/helpers 2.0.10 → 3.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 (167) hide show
  1. package/dist/{logic.d.ts → fn/Promize.d.ts} +1 -8
  2. package/dist/fn/Promize.d.ts.map +1 -0
  3. package/dist/fn/Promize.js +25 -0
  4. package/dist/fn/Promize.js.map +1 -0
  5. package/dist/fn/Semaphore.d.ts +7 -0
  6. package/dist/fn/Semaphore.d.ts.map +1 -0
  7. package/dist/fn/Semaphore.js +31 -0
  8. package/dist/fn/Semaphore.js.map +1 -0
  9. package/dist/fn/asyncDebounce.d.ts +2 -0
  10. package/dist/fn/asyncDebounce.d.ts.map +1 -0
  11. package/dist/fn/asyncDebounce.js +26 -0
  12. package/dist/fn/asyncDebounce.js.map +1 -0
  13. package/dist/fn/debounce.d.ts +2 -0
  14. package/dist/fn/debounce.d.ts.map +1 -0
  15. package/dist/fn/debounce.js +13 -0
  16. package/dist/fn/debounce.js.map +1 -0
  17. package/dist/fn/index.d.ts +11 -0
  18. package/dist/fn/index.d.ts.map +1 -0
  19. package/dist/fn/index.js +11 -0
  20. package/dist/fn/index.js.map +1 -0
  21. package/dist/fn/loopError.d.ts +11 -0
  22. package/dist/fn/loopError.d.ts.map +1 -0
  23. package/dist/fn/loopError.js +14 -0
  24. package/dist/fn/loopError.js.map +1 -0
  25. package/dist/fn/memoize.d.ts +2 -0
  26. package/dist/fn/memoize.d.ts.map +1 -0
  27. package/dist/fn/memoize.js +18 -0
  28. package/dist/fn/memoize.js.map +1 -0
  29. package/dist/fn/retry.d.ts +8 -0
  30. package/dist/fn/retry.d.ts.map +1 -0
  31. package/dist/{logic.js → fn/retry.js} +1 -25
  32. package/dist/fn/retry.js.map +1 -0
  33. package/dist/fn/runFor.d.ts +2 -0
  34. package/dist/fn/runFor.d.ts.map +1 -0
  35. package/dist/fn/runFor.js +11 -0
  36. package/dist/fn/runFor.js.map +1 -0
  37. package/dist/{react.d.ts → fn/toBase64Image.d.ts} +1 -1
  38. package/dist/fn/toBase64Image.d.ts.map +1 -0
  39. package/dist/{react.js → fn/toBase64Image.js} +1 -1
  40. package/dist/fn/toBase64Image.js.map +1 -0
  41. package/dist/fn/toRange.d.ts +9 -0
  42. package/dist/fn/toRange.d.ts.map +1 -0
  43. package/dist/fn/toRange.js +26 -0
  44. package/dist/fn/toRange.js.map +1 -0
  45. package/dist/fs/exists.d.ts +2 -0
  46. package/dist/fs/exists.d.ts.map +1 -0
  47. package/dist/fs/exists.js +12 -0
  48. package/dist/fs/exists.js.map +1 -0
  49. package/dist/fs/index.d.ts +2 -0
  50. package/dist/fs/index.d.ts.map +1 -0
  51. package/dist/fs/index.js +2 -0
  52. package/dist/fs/index.js.map +1 -0
  53. package/dist/index.d.ts +0 -5
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +0 -5
  56. package/dist/index.js.map +1 -1
  57. package/dist/math/angleDifference.d.ts +9 -0
  58. package/dist/math/angleDifference.d.ts.map +1 -0
  59. package/dist/math/angleDifference.js +16 -0
  60. package/dist/math/angleDifference.js.map +1 -0
  61. package/dist/math/index.d.ts +5 -0
  62. package/dist/math/index.d.ts.map +1 -0
  63. package/dist/math/index.js +5 -0
  64. package/dist/math/index.js.map +1 -0
  65. package/dist/math/nPad.d.ts +14 -0
  66. package/dist/math/nPad.d.ts.map +1 -0
  67. package/dist/math/nPad.js +19 -0
  68. package/dist/math/nPad.js.map +1 -0
  69. package/dist/math/qRnd.d.ts +8 -0
  70. package/dist/math/qRnd.d.ts.map +1 -0
  71. package/dist/math/qRnd.js +11 -0
  72. package/dist/math/qRnd.js.map +1 -0
  73. package/dist/math/to360.d.ts +7 -0
  74. package/dist/math/to360.d.ts.map +1 -0
  75. package/dist/math/to360.js +10 -0
  76. package/dist/math/to360.js.map +1 -0
  77. package/dist/obj/RecursiveUpdateOptions.d.ts +15 -0
  78. package/dist/obj/RecursiveUpdateOptions.d.ts.map +1 -0
  79. package/dist/obj/RecursiveUpdateOptions.js +23 -0
  80. package/dist/obj/RecursiveUpdateOptions.js.map +1 -0
  81. package/dist/obj/chunkArray.d.ts +9 -0
  82. package/dist/obj/chunkArray.d.ts.map +1 -0
  83. package/dist/obj/chunkArray.js +17 -0
  84. package/dist/obj/chunkArray.js.map +1 -0
  85. package/dist/obj/compare.d.ts +24 -0
  86. package/dist/obj/compare.d.ts.map +1 -0
  87. package/dist/obj/compare.js +59 -0
  88. package/dist/obj/compare.js.map +1 -0
  89. package/dist/obj/deepGet.d.ts +17 -0
  90. package/dist/obj/deepGet.d.ts.map +1 -0
  91. package/dist/obj/deepGet.js +21 -0
  92. package/dist/obj/deepGet.js.map +1 -0
  93. package/dist/obj/deepMerge.d.ts +8 -0
  94. package/dist/obj/deepMerge.d.ts.map +1 -0
  95. package/dist/obj/deepMerge.js +23 -0
  96. package/dist/obj/deepMerge.js.map +1 -0
  97. package/dist/obj/envOrThrow.d.ts +5 -0
  98. package/dist/obj/envOrThrow.d.ts.map +1 -0
  99. package/dist/obj/envOrThrow.js +10 -0
  100. package/dist/obj/envOrThrow.js.map +1 -0
  101. package/dist/obj/fillTemplate.d.ts +18 -0
  102. package/dist/obj/fillTemplate.d.ts.map +1 -0
  103. package/dist/obj/fillTemplate.js +27 -0
  104. package/dist/obj/fillTemplate.js.map +1 -0
  105. package/dist/obj/getEnv.d.ts +11 -0
  106. package/dist/obj/getEnv.d.ts.map +1 -0
  107. package/dist/obj/getEnv.js +43 -0
  108. package/dist/obj/getEnv.js.map +1 -0
  109. package/dist/obj/hash.d.ts +2 -0
  110. package/dist/obj/hash.d.ts.map +1 -0
  111. package/dist/obj/hash.js +12 -0
  112. package/dist/obj/hash.js.map +1 -0
  113. package/dist/obj/index.d.ts +13 -0
  114. package/dist/obj/index.d.ts.map +1 -0
  115. package/dist/obj/index.js +13 -0
  116. package/dist/obj/index.js.map +1 -0
  117. package/dist/obj/inspect.d.ts +26 -0
  118. package/dist/obj/inspect.d.ts.map +1 -0
  119. package/dist/obj/inspect.js +36 -0
  120. package/dist/obj/inspect.js.map +1 -0
  121. package/dist/obj/objectify.d.ts +15 -0
  122. package/dist/obj/objectify.d.ts.map +1 -0
  123. package/dist/obj/objectify.js +14 -0
  124. package/dist/obj/objectify.js.map +1 -0
  125. package/dist/obj/rebuildTypes.d.ts +6 -0
  126. package/dist/obj/rebuildTypes.d.ts.map +1 -0
  127. package/dist/obj/rebuildTypes.js +24 -0
  128. package/dist/obj/rebuildTypes.js.map +1 -0
  129. package/dist/test.d.ts +4 -6
  130. package/dist/test.d.ts.map +1 -1
  131. package/dist/test.js.map +1 -1
  132. package/dist/ts/index.d.ts +7 -0
  133. package/dist/ts/index.d.ts.map +1 -0
  134. package/dist/ts/index.js +7 -0
  135. package/dist/ts/index.js.map +1 -0
  136. package/dist/ts/isKeyOf.d.ts +6 -0
  137. package/dist/ts/isKeyOf.d.ts.map +1 -0
  138. package/dist/ts/isKeyOf.js +5 -0
  139. package/dist/ts/isKeyOf.js.map +1 -0
  140. package/dist/ts/isTypeOf.d.ts +12 -0
  141. package/dist/ts/isTypeOf.d.ts.map +1 -0
  142. package/dist/ts/isTypeOf.js +12 -0
  143. package/dist/ts/isTypeOf.js.map +1 -0
  144. package/dist/ts/typeOf.d.ts +24 -0
  145. package/dist/ts/typeOf.d.ts.map +1 -0
  146. package/dist/ts/typeOf.js +28 -0
  147. package/dist/ts/typeOf.js.map +1 -0
  148. package/dist/{ts.d.ts → ts/types.d.ts} +13 -11
  149. package/dist/ts/types.d.ts.map +1 -0
  150. package/dist/ts/types.js +2 -0
  151. package/dist/ts/types.js.map +1 -0
  152. package/package.json +47 -62
  153. package/dist/logic.d.ts.map +0 -1
  154. package/dist/logic.js.map +0 -1
  155. package/dist/math.d.ts +0 -35
  156. package/dist/math.d.ts.map +0 -1
  157. package/dist/math.js +0 -53
  158. package/dist/math.js.map +0 -1
  159. package/dist/object.d.ts +0 -166
  160. package/dist/object.d.ts.map +0 -1
  161. package/dist/object.js +0 -350
  162. package/dist/object.js.map +0 -1
  163. package/dist/react.d.ts.map +0 -1
  164. package/dist/react.js.map +0 -1
  165. package/dist/ts.d.ts.map +0 -1
  166. package/dist/ts.js +0 -6
  167. package/dist/ts.js.map +0 -1
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- export declare const sleep: typeof import("timers/promises").setTimeout;
3
1
  export declare class Promize<T> {
4
2
  p: Promise<T>;
5
3
  res: (value: T) => void;
@@ -15,9 +13,4 @@ export declare class Promize<T> {
15
13
  */
16
14
  set(resValue?: T): void;
17
15
  }
18
- export declare const retry: <T>(func: () => T | Promise<T>, options?: {
19
- onErr?: ((error: unknown, retryCount: number) => void) | undefined;
20
- timeoutMultiplier?: number | undefined;
21
- maxRetries?: number | undefined;
22
- } | undefined) => () => Promise<T>;
23
- //# sourceMappingURL=logic.d.ts.map
16
+ //# sourceMappingURL=Promize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Promize.d.ts","sourceRoot":"","sources":["../../src/fn/Promize.ts"],"names":[],"mappings":"AAAA,qBAAa,OAAO,CAAC,CAAC;IACd,CAAC,EAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,GAAG,EAAG,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB,GAAG,EAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAE7B;;;OAGG;gBACS,QAAQ,CAAC,EAAE,CAAC;IAIxB;;;OAGG;IACH,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI;CAOvB"}
@@ -0,0 +1,25 @@
1
+ export class Promize {
2
+ p;
3
+ res;
4
+ rej;
5
+ /**
6
+ * Returns a new instance of a `Promize`, a externally resolvable Promise.
7
+ * @param resValue If not undefined, resolves the internal promise with given value on creation.
8
+ */
9
+ constructor(resValue) {
10
+ this.set(resValue);
11
+ }
12
+ /**
13
+ * Recreate the promise
14
+ * @param resValue If not undefined, resolves the internal promise with given value on creation.
15
+ */
16
+ set(resValue) {
17
+ this.p = new Promise((res, rej) => {
18
+ this.res = res;
19
+ this.rej = rej;
20
+ });
21
+ if (resValue !== undefined)
22
+ this.res(resValue);
23
+ }
24
+ }
25
+ //# sourceMappingURL=Promize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Promize.js","sourceRoot":"","sources":["../../src/fn/Promize.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IACZ,CAAC,CAAc;IACtB,GAAG,CAAsB;IACzB,GAAG,CAA0B;IAE7B;;;OAGG;IACH,YAAY,QAAY;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,QAAY;QACf,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACpC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,IAAI,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ export declare class Semaphore {
2
+ private avalibleSlots;
3
+ private readonly _queue;
4
+ constructor(avalibleSlots: number);
5
+ obtain(): Promise<() => void>;
6
+ }
7
+ //# sourceMappingURL=Semaphore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Semaphore.d.ts","sourceRoot":"","sources":["../../src/fn/Semaphore.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;IAET,OAAO,CAAC,aAAa;IADjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBACzB,aAAa,EAAE,MAAM;IAE5B,MAAM,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC;CAuB1C"}
@@ -0,0 +1,31 @@
1
+ export class Semaphore {
2
+ avalibleSlots;
3
+ _queue = [];
4
+ constructor(avalibleSlots) {
5
+ this.avalibleSlots = avalibleSlots;
6
+ }
7
+ async obtain() {
8
+ let released = false;
9
+ const release = () => {
10
+ if (released)
11
+ return;
12
+ released = true;
13
+ this.avalibleSlots++;
14
+ // If there are queued requests, resolve the first one in the queue
15
+ this._queue.shift()?.();
16
+ };
17
+ // If there is an available request slot, proceed immediately
18
+ if (this.avalibleSlots > 0) {
19
+ this.avalibleSlots--;
20
+ return release;
21
+ }
22
+ // Otherwise, wait for a request slot to become available
23
+ return new Promise((r) => {
24
+ this._queue.push(() => {
25
+ this.avalibleSlots--;
26
+ r(release);
27
+ });
28
+ });
29
+ }
30
+ }
31
+ //# sourceMappingURL=Semaphore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Semaphore.js","sourceRoot":"","sources":["../../src/fn/Semaphore.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IAED;IADH,MAAM,GAAmB,EAAE,CAAC;IAC7C,YAAoB,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;IAAG,CAAC;IAEtC,KAAK,CAAC,MAAM;QAClB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,mEAAmE;YACnE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;QACF,6DAA6D;QAC7D,IAAI,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE;YAC3B,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC;SACf;QAED,yDAAyD;QACzD,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;gBACrB,IAAI,CAAC,aAAa,EAAE,CAAC;gBACrB,CAAC,CAAC,OAAO,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,2 @@
1
+ export declare const asyncDebounce: <A extends any[], V>(generator: (...args: A) => Promise<V>) => (...args: A) => Promise<V>;
2
+ //# sourceMappingURL=asyncDebounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncDebounce.d.ts","sourceRoot":"","sources":["../../src/fn/asyncDebounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,2FAqBzB,CAAC"}
@@ -0,0 +1,26 @@
1
+ export const asyncDebounce = (generator) => {
2
+ if (generator.length === 0) {
3
+ let _current;
4
+ const _func = () => {
5
+ if (_current)
6
+ return _current;
7
+ _current = generator();
8
+ _current.finally(() => (_current = undefined));
9
+ return _current;
10
+ };
11
+ return _func;
12
+ }
13
+ else {
14
+ const _current = {};
15
+ const _func = (...args) => {
16
+ const key = JSON.stringify(args);
17
+ if (key in _current)
18
+ return _current[key];
19
+ _current[key] = generator(...args);
20
+ _current[key].finally(() => delete _current[key]);
21
+ return _current[key];
22
+ };
23
+ return _func;
24
+ }
25
+ };
26
+ //# sourceMappingURL=asyncDebounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncDebounce.js","sourceRoot":"","sources":["../../src/fn/asyncDebounce.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAqB,SAAqC,EAAE,EAAE;IAC1F,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,IAAI,QAAgC,CAAC;QACrC,MAAM,KAAK,GAAG,GAAe,EAAE;YAC9B,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC;YAC9B,QAAQ,GAAI,SAA8B,EAAE,CAAC;YAC7C,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC;YAC/C,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC;QACF,OAAO,KAAK,CAAC;KACb;SAAM;QACN,MAAM,QAAQ,GAA+B,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAO,EAAc,EAAE;YACxC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,GAAG,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1C,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;YACnC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC;QACF,OAAO,KAAK,CAAC;KACb;AACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => (...args: Parameters<T>) => void;
2
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/fn/debounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,uBAAwB,GAAG,EAAE,KAAK,GAAG,iBAAiB,MAAM,iCAAgC,IAUhH,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const debounce = (func, wait) => {
2
+ let timeout;
3
+ return async function (...args) {
4
+ const context = this;
5
+ if (timeout)
6
+ clearTimeout(timeout);
7
+ timeout = setTimeout(async () => {
8
+ timeout = null;
9
+ func.apply(context, args);
10
+ }, wait);
11
+ };
12
+ };
13
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/fn/debounce.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAoC,IAAO,EAAE,IAAY,EAAsC,EAAE;IACxH,IAAI,OAA8B,CAAC;IACnC,OAAO,KAAK,WAAuC,GAAG,IAAmB;QACxE,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,IAAI,OAAO;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE;YAC/B,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3B,CAAC,EAAE,IAAI,CAAC,CAAC;IACV,CAAC,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from "./Promize.js";
2
+ export * from "./Semaphore.js";
3
+ export * from "./asyncDebounce.js";
4
+ export * from "./debounce.js";
5
+ export * from "./loopError.js";
6
+ export * from "./memoize.js";
7
+ export * from "./retry.js";
8
+ export * from "./runFor.js";
9
+ export * from "./toBase64Image.js";
10
+ export * from "./toRange.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fn/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from "./Promize.js";
2
+ export * from "./Semaphore.js";
3
+ export * from "./asyncDebounce.js";
4
+ export * from "./debounce.js";
5
+ export * from "./loopError.js";
6
+ export * from "./memoize.js";
7
+ export * from "./retry.js";
8
+ export * from "./runFor.js";
9
+ export * from "./toBase64Image.js";
10
+ export * from "./toRange.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fn/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { AsyncFunction } from "../ts/types.js";
2
+ type ErrorHandler = (err: Error) => Promise<void>;
3
+ /**
4
+ * Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
5
+ * @param func Function to execute
6
+ * @param errorHandler Function to execute when a error occours
7
+ * @returns Return value of `func` on success
8
+ */
9
+ export declare const loopError: <F extends AsyncFunction>(func: F, errorHandler?: ErrorHandler) => ReturnType<F>;
10
+ export {};
11
+ //# sourceMappingURL=loopError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopError.d.ts","sourceRoot":"","sources":["../../src/fn/loopError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD;;;;;GAKG;AAEH,eAAO,MAAM,SAAS,oDAAoD,YAAY,kBAOlE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
3
+ * @param func Function to execute
4
+ * @param errorHandler Function to execute when a error occours
5
+ * @returns Return value of `func` on success
6
+ */
7
+ export const loopError = (func, errorHandler = (err) => new Promise((_res, r) => r(err))) => new Promise((resolve) => {
8
+ func()
9
+ .then(resolve)
10
+ .catch(async (err) => {
11
+ errorHandler(err).then(() => resolve(loopError(func, errorHandler)));
12
+ });
13
+ });
14
+ //# sourceMappingURL=loopError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopError.js","sourceRoot":"","sources":["../../src/fn/loopError.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CAA0B,IAAO,EAAE,eAA6B,CAAC,GAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAiB,EAAE,CAC3J,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACvB,IAAI,EAAE;SACJ,IAAI,CAAC,OAAO,CAAC;SACb,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACpB,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const memoize: <G extends Function>(generator: G) => G;
2
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/fn/memoize.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,yCAcnB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export const memoize = (generator) => {
2
+ if (generator.length === 0) {
3
+ let cache;
4
+ return (() => {
5
+ if (cache)
6
+ return cache;
7
+ return (cache = generator());
8
+ });
9
+ }
10
+ const cache = {};
11
+ return ((...args) => {
12
+ const key = JSON.stringify(args);
13
+ if (key in cache)
14
+ return cache[key];
15
+ return (cache[key] ??= generator(...args));
16
+ });
17
+ };
18
+ //# sourceMappingURL=memoize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/fn/memoize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAqB,SAAY,EAAK,EAAE;IAC9D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,IAAI,KAAc,CAAC;QACnB,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;YACxB,OAAO,CAAC,KAAK,GAAG,SAAS,EAAE,CAAC,CAAC;QAC9B,CAAC,CAAiB,CAAC;KACnB;IACD,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,OAAO,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,GAAG,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAiB,CAAC;AACpB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ export declare const sleep: typeof import("timers/promises").setTimeout;
3
+ export declare const retry: <T>(func: () => T | Promise<T>, options?: {
4
+ onErr?: ((error: unknown, retryCount: number) => void) | undefined;
5
+ timeoutMultiplier?: number | undefined;
6
+ maxRetries?: number | undefined;
7
+ } | undefined) => () => Promise<T>;
8
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/fn/retry.ts"],"names":[],"mappings":";AACA,eAAO,MAAM,KAAK,6CAAwB,CAAC;AAE3C,eAAO,MAAM,KAAK;qBAEW,OAAO,cAAc,MAAM,KAAK,IAAI;;;kCAoBhE,CAAC"}
@@ -1,29 +1,5 @@
1
1
  import { promisify } from "util";
2
2
  export const sleep = promisify(setTimeout);
3
- export class Promize {
4
- p;
5
- res;
6
- rej;
7
- /**
8
- * Returns a new instance of a `Promize`, a externally resolvable Promise.
9
- * @param resValue If not undefined, resolves the internal promise with given value on creation.
10
- */
11
- constructor(resValue) {
12
- this.set(resValue);
13
- }
14
- /**
15
- * Recreate the promise
16
- * @param resValue If not undefined, resolves the internal promise with given value on creation.
17
- */
18
- set(resValue) {
19
- this.p = new Promise((res, rej) => {
20
- this.res = res;
21
- this.rej = rej;
22
- });
23
- if (resValue !== undefined)
24
- this.res(resValue);
25
- }
26
- }
27
3
  export const retry = (func, options) => {
28
4
  let retryCount = 0;
29
5
  const maxRetries = options?.maxRetries ?? 10;
@@ -47,4 +23,4 @@ export const retry = (func, options) => {
47
23
  };
48
24
  return tryAgain;
49
25
  };
50
- //# sourceMappingURL=logic.js.map
26
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/fn/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,IAA0B,EAC1B,OAAmH,EAC9F,EAAE;IACvB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;IAC7C,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,IAAI,CAAC;IAC7D,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAC7B,MAAM,QAAQ,GAAG,KAAK,IAAgB,EAAE;QACvC,IAAI;YACH,OAAO,MAAM,IAAI,EAAE,CAAC;SACpB;QAAC,OAAO,CAAC,EAAE;YACX,IAAI,KAAK,KAAK,SAAS;gBAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;YAC9C,IAAI,UAAU,GAAG,UAAU,EAAE;gBAC5B,UAAU,EAAE,CAAC;gBACb,IAAI,iBAAiB,GAAG,CAAC;oBAAE,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CAAC;gBAC1E,OAAO,QAAQ,EAAE,CAAC;aAClB;YACD,MAAM,CAAC,CAAC;SACR;IACF,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const runFor: (fn: () => true | undefined, timeoutMs: number) => Promise<void>;
2
+ //# sourceMappingURL=runFor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runFor.d.ts","sourceRoot":"","sources":["../../src/fn/runFor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,OAAc,MAAM,IAAI,GAAG,SAAS,aAAa,MAAM,kBAOzE,CAAC"}
@@ -0,0 +1,11 @@
1
+ export const runFor = async (fn, timeoutMs) => {
2
+ const expires = Date.now() + timeoutMs;
3
+ while (true) {
4
+ if (fn())
5
+ return;
6
+ if (Date.now() > expires)
7
+ return;
8
+ await new Promise((res) => setTimeout(res));
9
+ }
10
+ };
11
+ //# sourceMappingURL=runFor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runFor.js","sourceRoot":"","sources":["../../src/fn/runFor.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,EAA0B,EAAE,SAAiB,EAAE,EAAE;IAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACvC,OAAO,IAAI,EAAE;QACZ,IAAI,EAAE,EAAE;YAAE,OAAO;QACjB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;YAAE,OAAO;QACjC,MAAM,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;KAC5C;AACF,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
1
  export declare const toBase64: (file: File) => Promise<string | ArrayBuffer>;
2
- //# sourceMappingURL=react.d.ts.map
2
+ //# sourceMappingURL=toBase64Image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toBase64Image.d.ts","sourceRoot":"","sources":["../../src/fn/toBase64Image.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,SAAgB,IAAI,KAAG,QAAQ,MAAM,GAAG,WAAW,CAUvE,CAAC"}
@@ -11,4 +11,4 @@ export const toBase64 = async (file) => {
11
11
  throw new Error(`Failed to convert file ${file.name} to base64.`);
12
12
  return base64Image;
13
13
  };
14
- //# sourceMappingURL=react.js.map
14
+ //# sourceMappingURL=toBase64Image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toBase64Image.js","sourceRoot":"","sources":["../../src/fn/toBase64Image.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAU,EAAiC,EAAE;IAC3E,MAAM,WAAW,GAAG,MAAM,IAAI,OAAO,CAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtF,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,WAAW,YAAY,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,IAAI,gBAAgB,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5H,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC;IACzH,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @param array
3
+ * @returns string containing ranges of numbers.
4
+ * @example
5
+ * const range = toRange([1, 2, 3, 12, 6, 7, 5, 27, 28, 29, 40, 41, 25, 42, 12])
6
+ * // range = "1-3 & 5-7 & 12 & 25 & 27-29 & 40-42"
7
+ */
8
+ export declare const toRange: (array: number[]) => string;
9
+ //# sourceMappingURL=toRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toRange.d.ts","sourceRoot":"","sources":["../../src/fn/toRange.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,UAAW,MAAM,EAAE,KAAG,MAezC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @param array
3
+ * @returns string containing ranges of numbers.
4
+ * @example
5
+ * const range = toRange([1, 2, 3, 12, 6, 7, 5, 27, 28, 29, 40, 41, 25, 42, 12])
6
+ * // range = "1-3 & 5-7 & 12 & 25 & 27-29 & 40-42"
7
+ */
8
+ export const toRange = (array) => {
9
+ array = array
10
+ .filter((a, pos) => array.indexOf(a) === pos)
11
+ .sort((a, b) => a - b)
12
+ .map((a) => +a);
13
+ let sum = `${array[0]}`;
14
+ let lastValue = array[0];
15
+ for (let i = 1; i <= array.length; i++) {
16
+ if (!(array[i] - 1 === array[i - 1])) {
17
+ if (array[i - 1] !== lastValue)
18
+ sum += `-${array[i - 1]}`;
19
+ if (array[i] !== undefined)
20
+ sum += ` & ${array[i]}`;
21
+ lastValue = array[i];
22
+ }
23
+ }
24
+ return sum;
25
+ };
26
+ //# sourceMappingURL=toRange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toRange.js","sourceRoot":"","sources":["../../src/fn/toRange.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAe,EAAU,EAAE;IAClD,KAAK,GAAG,KAAK;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;SAC5C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACjB,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,IAAI,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACrC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,SAAS;gBAAE,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC1D,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS;gBAAE,GAAG,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACpD,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SACrB;KACD;IACD,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const exists: (path: string) => Promise<boolean>;
2
+ //# sourceMappingURL=exists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../src/fs/exists.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,SAAgB,MAAM,KAAG,QAAQ,OAAO,CAO1D,CAAC"}
@@ -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;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;KACZ;IAAC,MAAM;QACP,OAAO,KAAK,CAAC;KACb;AACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./exists.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./exists.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  export * from "./conv.js";
2
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
3
  export * from "./test.js";
8
- export * from "./ts.js";
9
4
  //# 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,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,4 @@
1
1
  export * from "./conv.js";
2
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
3
  export * from "./test.js";
8
- export * from "./ts.js";
9
4
  //# 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,UAAU,CAAC;AACzB,cAAc,WAAW,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,WAAY,MAAM,UAAU,MAAM,uBAAkB,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,5 @@
1
+ export * from "./angleDifference.js";
2
+ export * from "./nPad.js";
3
+ export * from "./qRnd.js";
4
+ export * from "./to360.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./angleDifference.js";
2
+ export * from "./nPad.js";
3
+ export * from "./qRnd.js";
4
+ export * from "./to360.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,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,QAAS,MAAM,GAAG,MAAM,qBAAc,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,QAAS,MAAM,sBAAe,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