@sparted/shared-library 0.0.14 → 0.0.16

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 (111) hide show
  1. package/_virtual/_tslib.js +6 -1
  2. package/_virtual/_tslib.js.map +1 -1
  3. package/array/array-to-map.js +5 -1
  4. package/array/array-to-map.js.map +1 -1
  5. package/array/get-values-from-keys.js +5 -1
  6. package/array/get-values-from-keys.js.map +1 -1
  7. package/array/index.js +11 -2
  8. package/array/index.js.map +1 -1
  9. package/date/constants.js +8 -1
  10. package/date/constants.js.map +1 -1
  11. package/date/convert.js +9 -4
  12. package/date/convert.js.map +1 -1
  13. package/date/format-minutes.js +5 -1
  14. package/date/format-minutes.js.map +1 -1
  15. package/date/get-time-diff-as-string.js +13 -9
  16. package/date/get-time-diff-as-string.js.map +1 -1
  17. package/date/index.js +16 -3
  18. package/date/index.js.map +1 -1
  19. package/formatting/format-number.js +5 -1
  20. package/formatting/format-number.js.map +1 -1
  21. package/formatting/index.js +9 -1
  22. package/formatting/index.js.map +1 -1
  23. package/fp/index.js +9 -1
  24. package/fp/index.js.map +1 -1
  25. package/fp/run-while.js +5 -1
  26. package/fp/run-while.js.map +1 -1
  27. package/http/encode-search-object.js +6 -1
  28. package/http/encode-search-object.js.map +1 -1
  29. package/http/fetch-with-timeout.js +7 -3
  30. package/http/fetch-with-timeout.js.map +1 -1
  31. package/http/index.js +12 -2
  32. package/http/index.js.map +1 -1
  33. package/index.js +67 -27
  34. package/index.js.map +1 -1
  35. package/linked-list/apply-diff-linked-list.js +5 -1
  36. package/linked-list/apply-diff-linked-list.js.map +1 -1
  37. package/linked-list/create-linked-list.js +30 -26
  38. package/linked-list/create-linked-list.js.map +1 -1
  39. package/linked-list/find-linked-list.d.ts +2 -2
  40. package/linked-list/find-linked-list.js +7 -3
  41. package/linked-list/find-linked-list.js.map +1 -1
  42. package/linked-list/get-linked-list.d.ts +2 -2
  43. package/linked-list/get-linked-list.js +5 -1
  44. package/linked-list/get-linked-list.js.map +1 -1
  45. package/linked-list/index.js +9 -1
  46. package/linked-list/index.js.map +1 -1
  47. package/linked-list/insert-linked-list.js +16 -11
  48. package/linked-list/insert-linked-list.js.map +1 -1
  49. package/linked-list/linked-list-utils.d.ts +4 -4
  50. package/linked-list/linked-list-utils.js +21 -6
  51. package/linked-list/linked-list-utils.js.map +1 -1
  52. package/linked-list/reduce-linked-list.d.ts +2 -2
  53. package/linked-list/reduce-linked-list.js +7 -3
  54. package/linked-list/reduce-linked-list.js.map +1 -1
  55. package/linked-list/remove-linked-list.js +12 -7
  56. package/linked-list/remove-linked-list.js.map +1 -1
  57. package/linked-list/type.d.ts +6 -5
  58. package/linked-list/update-linked-list.js +9 -5
  59. package/linked-list/update-linked-list.js.map +1 -1
  60. package/linked-list/while-linked-list.d.ts +2 -2
  61. package/linked-list/while-linked-list.js +7 -3
  62. package/linked-list/while-linked-list.js.map +1 -1
  63. package/math/clamp-number.js +7 -3
  64. package/math/clamp-number.js.map +1 -1
  65. package/math/index.js +16 -4
  66. package/math/index.js.map +1 -1
  67. package/math/interpolate.js +7 -3
  68. package/math/interpolate.js.map +1 -1
  69. package/math/number-range.js +6 -1
  70. package/math/number-range.js.map +1 -1
  71. package/math/random-number.js +7 -3
  72. package/math/random-number.js.map +1 -1
  73. package/object/index.js +9 -1
  74. package/object/index.js.map +1 -1
  75. package/object/merge-deep.js +5 -1
  76. package/object/merge-deep.js.map +1 -1
  77. package/package.json +1 -1
  78. package/parsing/index.js +13 -3
  79. package/parsing/index.js.map +1 -1
  80. package/parsing/parse-boolean.js +5 -1
  81. package/parsing/parse-boolean.js.map +1 -1
  82. package/parsing/parse-enum.js +5 -1
  83. package/parsing/parse-enum.js.map +1 -1
  84. package/parsing/parse-number.js +5 -1
  85. package/parsing/parse-number.js.map +1 -1
  86. package/predicates/index.js +18 -5
  87. package/predicates/index.js.map +1 -1
  88. package/predicates/is-function.js +5 -1
  89. package/predicates/is-function.js.map +1 -1
  90. package/predicates/is-null.js +5 -1
  91. package/predicates/is-null.js.map +1 -1
  92. package/predicates/is-object.js +5 -1
  93. package/predicates/is-object.js.map +1 -1
  94. package/predicates/is-primitive.js +6 -1
  95. package/predicates/is-primitive.js.map +1 -1
  96. package/predicates/is-undefined.js +5 -1
  97. package/predicates/is-undefined.js.map +1 -1
  98. package/promise/delay.js +5 -1
  99. package/promise/delay.js.map +1 -1
  100. package/promise/execute-or-resolve-default.js +5 -1
  101. package/promise/execute-or-resolve-default.js.map +1 -1
  102. package/promise/execute-with-delay.js +9 -5
  103. package/promise/execute-with-delay.js.map +1 -1
  104. package/promise/index.js +13 -3
  105. package/promise/index.js.map +1 -1
  106. package/string/index.js +9 -1
  107. package/string/index.js.map +1 -1
  108. package/string/replace-in-template.js +7 -3
  109. package/string/replace-in-template.js.map +1 -1
  110. package/types/index.js +1 -0
  111. package/types/index.js.map +1 -1
package/math/index.js CHANGED
@@ -1,5 +1,17 @@
1
- export { clampNumber } from './clamp-number.js';
2
- export { interpolate } from './interpolate.js';
3
- export { assertNumberRange, isNumberInRange } from './number-range.js';
4
- export { randomNumber } from './random-number.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var clampNumber = require('./clamp-number.js');
6
+ var interpolate = require('./interpolate.js');
7
+ var numberRange = require('./number-range.js');
8
+ var randomNumber = require('./random-number.js');
9
+
10
+
11
+
12
+ exports.clampNumber = clampNumber.clampNumber;
13
+ exports.interpolate = interpolate.interpolate;
14
+ exports.assertNumberRange = numberRange.assertNumberRange;
15
+ exports.isNumberInRange = numberRange.isNumberInRange;
16
+ exports.randomNumber = randomNumber.randomNumber;
5
17
  //# sourceMappingURL=index.js.map
package/math/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -1,4 +1,8 @@
1
- import { isNumberInRange } from './number-range.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var numberRange = require('./number-range.js');
2
6
 
3
7
  const interpolate = (num, inputRange, outputRange) => {
4
8
  const [x1, x2] = inputRange;
@@ -6,11 +10,11 @@ const interpolate = (num, inputRange, outputRange) => {
6
10
  if (x1 > x2) {
7
11
  throw new Error('interpolate: inputRange[0] should not be superior to inputRange[1]');
8
12
  }
9
- if (!isNumberInRange(num, { min: x1, max: x2 })) {
13
+ if (!numberRange.isNumberInRange(num, { min: x1, max: x2 })) {
10
14
  throw new Error(`interpolate: input number {${num}} is not in range of {${x1}}-{${x2}}`);
11
15
  }
12
16
  return y1 + ((num - x1) / (x2 - x1)) * (y2 - y1);
13
17
  };
14
18
 
15
- export { interpolate };
19
+ exports.interpolate = interpolate;
16
20
  //# sourceMappingURL=interpolate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interpolate.js","sources":["../../src/math/interpolate.ts"],"sourcesContent":["import { isNumberInRange } from './number-range';\n\nexport type RangeArray = [number, number];\n\nexport const interpolate = (num: number, inputRange: RangeArray, outputRange: RangeArray) => {\n const [x1, x2] = inputRange;\n const [y1, y2] = outputRange;\n\n if (x1 > x2) {\n throw new Error('interpolate: inputRange[0] should not be superior to inputRange[1]');\n }\n\n if (!isNumberInRange(num, { min: x1, max: x2 })) {\n throw new Error(`interpolate: input number {${num}} is not in range of {${x1}}-{${x2}}`);\n }\n\n return y1 + ((num - x1) / (x2 - x1)) * (y2 - y1);\n};"],"names":[],"mappings":";;AAIa,MAAA,WAAW,GAAG,CAAC,GAAW,EAAE,UAAsB,EAAE,WAAuB,KAAI;AAC1F,IAAA,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC;AAC5B,IAAA,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC;IAE7B,IAAI,EAAE,GAAG,EAAE,EAAE;AACX,QAAA,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACvF,KAAA;AAED,IAAA,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,CAA8B,2BAAA,EAAA,GAAG,CAAyB,sBAAA,EAAA,EAAE,CAAM,GAAA,EAAA,EAAE,CAAG,CAAA,CAAA,CAAC,CAAC;AAC1F,KAAA;IAED,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AACnD;;;;"}
1
+ {"version":3,"file":"interpolate.js","sources":["../../src/math/interpolate.ts"],"sourcesContent":["import { isNumberInRange } from './number-range';\n\nexport type RangeArray = [number, number];\n\nexport const interpolate = (num: number, inputRange: RangeArray, outputRange: RangeArray) => {\n const [x1, x2] = inputRange;\n const [y1, y2] = outputRange;\n\n if (x1 > x2) {\n throw new Error('interpolate: inputRange[0] should not be superior to inputRange[1]');\n }\n\n if (!isNumberInRange(num, { min: x1, max: x2 })) {\n throw new Error(`interpolate: input number {${num}} is not in range of {${x1}}-{${x2}}`);\n }\n\n return y1 + ((num - x1) / (x2 - x1)) * (y2 - y1);\n};"],"names":["isNumberInRange"],"mappings":";;;;;;AAIa,MAAA,WAAW,GAAG,CAAC,GAAW,EAAE,UAAsB,EAAE,WAAuB,KAAI;AAC1F,IAAA,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC;AAC5B,IAAA,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC;IAE7B,IAAI,EAAE,GAAG,EAAE,EAAE;AACX,QAAA,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACvF,KAAA;AAED,IAAA,IAAI,CAACA,2BAAe,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,CAA8B,2BAAA,EAAA,GAAG,CAAyB,sBAAA,EAAA,EAAE,CAAM,GAAA,EAAA,EAAE,CAAG,CAAA,CAAA,CAAC,CAAC;AAC1F,KAAA;IAED,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AACnD;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const assertNumberRange = (range) => {
2
6
  if (range.min > range.max) {
3
7
  throw new Error('Invalid number range: min must be lower than or equal to max');
@@ -8,5 +12,6 @@ const isNumberInRange = (num, { min, max }) => {
8
12
  return num >= min && num <= max;
9
13
  };
10
14
 
11
- export { assertNumberRange, isNumberInRange };
15
+ exports.assertNumberRange = assertNumberRange;
16
+ exports.isNumberInRange = isNumberInRange;
12
17
  //# sourceMappingURL=number-range.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"number-range.js","sources":["../../src/math/number-range.ts"],"sourcesContent":["export type NumberRange = {\n min: number,\n max: number,\n};\n\nexport const assertNumberRange = (range: NumberRange) => {\n if (range.min > range.max) {\n throw new Error('Invalid number range: min must be lower than or equal to max');\n }\n};\n\nexport const isNumberInRange = (num: number, { min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return num >= min && num <= max;\n};\n"],"names":[],"mappings":"AAKa,MAAA,iBAAiB,GAAG,CAAC,KAAkB,KAAI;AACtD,IAAA,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;AACjF,KAAA;AACH,EAAE;AAEK,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,GAAG,EAAE,GAAG,EAAe,KAAI;AACxE,IAAA,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;AAClC;;;;"}
1
+ {"version":3,"file":"number-range.js","sources":["../../src/math/number-range.ts"],"sourcesContent":["export type NumberRange = {\n min: number,\n max: number,\n};\n\nexport const assertNumberRange = (range: NumberRange) => {\n if (range.min > range.max) {\n throw new Error('Invalid number range: min must be lower than or equal to max');\n }\n};\n\nexport const isNumberInRange = (num: number, { min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return num >= min && num <= max;\n};\n"],"names":[],"mappings":";;;;AAKa,MAAA,iBAAiB,GAAG,CAAC,KAAkB,KAAI;AACtD,IAAA,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;AACjF,KAAA;AACH,EAAE;AAEK,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,GAAG,EAAE,GAAG,EAAe,KAAI;AACxE,IAAA,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;AAClC;;;;;"}
@@ -1,9 +1,13 @@
1
- import { assertNumberRange } from './number-range.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var numberRange = require('./number-range.js');
2
6
 
3
7
  const randomNumber = ({ min, max }) => {
4
- assertNumberRange({ min, max });
8
+ numberRange.assertNumberRange({ min, max });
5
9
  return Math.floor(Math.random() * (max - min) + min);
6
10
  };
7
11
 
8
- export { randomNumber };
12
+ exports.randomNumber = randomNumber;
9
13
  //# sourceMappingURL=random-number.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"random-number.js","sources":["../../src/math/random-number.ts"],"sourcesContent":["import { assertNumberRange } from './number-range';\nimport type { NumberRange } from './number-range';\n\nexport const randomNumber = ({ min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return Math.floor(\n Math.random() * (max - min) + min,\n );\n};\n"],"names":[],"mappings":";;AAGa,MAAA,YAAY,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAe,KAAI;AACxD,IAAA,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAClC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"random-number.js","sources":["../../src/math/random-number.ts"],"sourcesContent":["import { assertNumberRange } from './number-range';\nimport type { NumberRange } from './number-range';\n\nexport const randomNumber = ({ min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return Math.floor(\n Math.random() * (max - min) + min,\n );\n};\n"],"names":["assertNumberRange"],"mappings":";;;;;;AAGa,MAAA,YAAY,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAe,KAAI;AACxD,IAAAA,6BAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAClC,CAAC;AACJ;;;;"}
package/object/index.js CHANGED
@@ -1,2 +1,10 @@
1
- export { mergeDeep } from './merge-deep.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var mergeDeep = require('./merge-deep.js');
6
+
7
+
8
+
9
+ exports.mergeDeep = mergeDeep.mergeDeep;
2
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  // https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350
2
6
  const isObject = (a) => typeof a === 'object' && a !== null;
3
7
  const isValueType = (a) => (!isObject(a) || Array.isArray(a));
@@ -17,5 +21,5 @@ const mergeDeep = (a, b) => {
17
21
  }, a);
18
22
  };
19
23
 
20
- export { mergeDeep };
24
+ exports.mergeDeep = mergeDeep;
21
25
  //# sourceMappingURL=merge-deep.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge-deep.js","sources":["../../src/object/merge-deep.ts"],"sourcesContent":["import type { DeepPartial, ValueType } from '../types';\n\n// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350\nconst isObject = (a: any) => typeof a === 'object' && a !== null;\nconst isValueType = (a: any): a is ValueType => (\n !isObject(a) || Array.isArray(a)\n);\n\nexport const mergeDeep = <T>(a: T, b: DeepPartial<T>): T => {\n if (isValueType(a) || isValueType(b)) {\n return b as T;\n }\n\n return (Object.keys(b) as (keyof T)[]).reduce((acc, key) => {\n if (!(key in a)) {\n return acc;\n }\n\n if (b[key] === a[key]) {\n return acc;\n }\n\n const merged = mergeDeep(a[key], (b[key] as DeepPartial<T[keyof T]>));\n\n return { ...acc, [key]: merged };\n }, a);\n};\n"],"names":[],"mappings":"AAEA;AACA,MAAM,QAAQ,GAAG,CAAC,CAAM,KAAK,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;AACjE,MAAM,WAAW,GAAG,CAAC,CAAM,MACzB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACjC,CAAC;MAEW,SAAS,GAAG,CAAI,CAAI,EAAE,CAAiB,KAAO;IACzD,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;AACpC,QAAA,OAAO,CAAM,CAAC;AACf,KAAA;AAED,IAAA,OAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAI;AACzD,QAAA,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE;AACf,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE;AACrB,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;AAED,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC,GAAG,CAA6B,CAAC,CAAC;AAEtE,QAAA,OAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAY,GAAG,CAAE,EAAA,EAAA,CAAC,GAAG,GAAG,MAAM,EAAG,CAAA,CAAA;KAClC,EAAE,CAAC,CAAC,CAAC;AACR;;;;"}
1
+ {"version":3,"file":"merge-deep.js","sources":["../../src/object/merge-deep.ts"],"sourcesContent":["import type { DeepPartial, ValueType } from '../types';\n\n// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350\nconst isObject = (a: any) => typeof a === 'object' && a !== null;\nconst isValueType = (a: any): a is ValueType => (\n !isObject(a) || Array.isArray(a)\n);\n\nexport const mergeDeep = <T>(a: T, b: DeepPartial<T>): T => {\n if (isValueType(a) || isValueType(b)) {\n return b as T;\n }\n\n return (Object.keys(b) as (keyof T)[]).reduce((acc, key) => {\n if (!(key in a)) {\n return acc;\n }\n\n if (b[key] === a[key]) {\n return acc;\n }\n\n const merged = mergeDeep(a[key], (b[key] as DeepPartial<T[keyof T]>));\n\n return { ...acc, [key]: merged };\n }, a);\n};\n"],"names":[],"mappings":";;;;AAEA;AACA,MAAM,QAAQ,GAAG,CAAC,CAAM,KAAK,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;AACjE,MAAM,WAAW,GAAG,CAAC,CAAM,MACzB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACjC,CAAC;MAEW,SAAS,GAAG,CAAI,CAAI,EAAE,CAAiB,KAAO;IACzD,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;AACpC,QAAA,OAAO,CAAM,CAAC;AACf,KAAA;AAED,IAAA,OAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAI;AACzD,QAAA,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE;AACf,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE;AACrB,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;AAED,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC,GAAG,CAA6B,CAAC,CAAC;AAEtE,QAAA,OAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAY,GAAG,CAAE,EAAA,EAAA,CAAC,GAAG,GAAG,MAAM,EAAG,CAAA,CAAA;KAClC,EAAE,CAAC,CAAC,CAAC;AACR;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparted/shared-library",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": "Thomas <duprethomasfr@gmail.com>",
6
6
  "license": "MIT",
package/parsing/index.js CHANGED
@@ -1,4 +1,14 @@
1
- export { parseBoolean } from './parse-boolean.js';
2
- export { createEnumParser } from './parse-enum.js';
3
- export { parseNumber } from './parse-number.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var parseBoolean = require('./parse-boolean.js');
6
+ var parseEnum = require('./parse-enum.js');
7
+ var parseNumber = require('./parse-number.js');
8
+
9
+
10
+
11
+ exports.parseBoolean = parseBoolean.parseBoolean;
12
+ exports.createEnumParser = parseEnum.createEnumParser;
13
+ exports.parseNumber = parseNumber.parseNumber;
4
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  /**
2
6
  * Parse a string to a boolean. Throw error if string is neither "true" nor "false"
3
7
  */
@@ -8,5 +12,5 @@ const parseBoolean = (value) => {
8
12
  return value === 'true';
9
13
  };
10
14
 
11
- export { parseBoolean };
15
+ exports.parseBoolean = parseBoolean;
12
16
  //# sourceMappingURL=parse-boolean.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-boolean.js","sources":["../../src/parsing/parse-boolean.ts"],"sourcesContent":["/**\n * Parse a string to a boolean. Throw error if string is neither \"true\" nor \"false\"\n */\n export const parseBoolean = (value: string): boolean => {\n if (value !== 'true' && value !== 'false') {\n throw new Error('Cannot parse value');\n }\n\n return value === 'true';\n};\n"],"names":[],"mappings":"AAAA;;AAEG;AACW,MAAA,YAAY,GAAG,CAAC,KAAa,KAAa;AACtD,IAAA,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,EAAE;AACzC,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACvC,KAAA;IAED,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"parse-boolean.js","sources":["../../src/parsing/parse-boolean.ts"],"sourcesContent":["/**\n * Parse a string to a boolean. Throw error if string is neither \"true\" nor \"false\"\n */\n export const parseBoolean = (value: string): boolean => {\n if (value !== 'true' && value !== 'false') {\n throw new Error('Cannot parse value');\n }\n\n return value === 'true';\n};\n"],"names":[],"mappings":";;;;AAAA;;AAEG;AACW,MAAA,YAAY,GAAG,CAAC,KAAa,KAAa;AACtD,IAAA,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,EAAE;AACzC,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACvC,KAAA;IAED,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  /**
2
6
  * Factory to build enum to parse a string to an enum. Throw error if string is not an enum value
3
7
  */
@@ -9,5 +13,5 @@ const createEnumParser = (enumType) => ((value) => {
9
13
  return value;
10
14
  });
11
15
 
12
- export { createEnumParser };
16
+ exports.createEnumParser = createEnumParser;
13
17
  //# sourceMappingURL=parse-enum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-enum.js","sources":["../../src/parsing/parse-enum.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Factory to build enum to parse a string to an enum. Throw error if string is not an enum value\n */\n export const createEnumParser = <E extends Record<string, Primitive>>(enumType: E) => (\n (value: string) => {\n const enumValues = Object.values(enumType);\n\n if (!enumValues.includes(value as any)) {\n throw new Error('Can\\'t parse this value');\n }\n\n return value as unknown as E;\n }\n);"],"names":[],"mappings":"AAEA;;AAEG;AACK,MAAM,gBAAgB,GAAG,CAAsC,QAAW,MAChF,CAAC,KAAa,KAAI;IAChB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE3C,IAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAY,CAAC,EAAE;AACtC,QAAA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC5C,KAAA;AAED,IAAA,OAAO,KAAqB,CAAC;AAC/B,CAAC;;;;"}
1
+ {"version":3,"file":"parse-enum.js","sources":["../../src/parsing/parse-enum.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Factory to build enum to parse a string to an enum. Throw error if string is not an enum value\n */\n export const createEnumParser = <E extends Record<string, Primitive>>(enumType: E) => (\n (value: string) => {\n const enumValues = Object.values(enumType);\n\n if (!enumValues.includes(value as any)) {\n throw new Error('Can\\'t parse this value');\n }\n\n return value as unknown as E;\n }\n);"],"names":[],"mappings":";;;;AAEA;;AAEG;AACK,MAAM,gBAAgB,GAAG,CAAsC,QAAW,MAChF,CAAC,KAAa,KAAI;IAChB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE3C,IAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAY,CAAC,EAAE;AACtC,QAAA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC5C,KAAA;AAED,IAAA,OAAO,KAAqB,CAAC;AAC/B,CAAC;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  /**
2
6
  * Parse a string to a number. Throw error if string is NaN
3
7
  */
@@ -9,5 +13,5 @@ const parseNumber = (value) => {
9
13
  return number;
10
14
  };
11
15
 
12
- export { parseNumber };
16
+ exports.parseNumber = parseNumber;
13
17
  //# sourceMappingURL=parse-number.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-number.js","sources":["../../src/parsing/parse-number.ts"],"sourcesContent":["/**\n * Parse a string to a number. Throw error if string is NaN\n */\n export const parseNumber = (value: string): number => {\n const number = parseInt(value, 10);\n\n if (Number.isNaN(number)) {\n throw new Error('Cannot parse value');\n }\n\n return number;\n};"],"names":[],"mappings":"AAAA;;AAEG;AACW,MAAA,WAAW,GAAG,CAAC,KAAa,KAAY;IACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEnC,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACvC,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
1
+ {"version":3,"file":"parse-number.js","sources":["../../src/parsing/parse-number.ts"],"sourcesContent":["/**\n * Parse a string to a number. Throw error if string is NaN\n */\n export const parseNumber = (value: string): number => {\n const number = parseInt(value, 10);\n\n if (Number.isNaN(number)) {\n throw new Error('Cannot parse value');\n }\n\n return number;\n};"],"names":[],"mappings":";;;;AAAA;;AAEG;AACW,MAAA,WAAW,GAAG,CAAC,KAAa,KAAY;IACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEnC,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACvC,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
@@ -1,6 +1,19 @@
1
- export { isFunction } from './is-function.js';
2
- export { isNull } from './is-null.js';
3
- export { isObject } from './is-object.js';
4
- export { isArrayOfPrimitive, isPrimitive } from './is-primitive.js';
5
- export { isUndefined } from './is-undefined.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var isFunction = require('./is-function.js');
6
+ var isNull = require('./is-null.js');
7
+ var isObject = require('./is-object.js');
8
+ var isPrimitive = require('./is-primitive.js');
9
+ var isUndefined = require('./is-undefined.js');
10
+
11
+
12
+
13
+ exports.isFunction = isFunction.isFunction;
14
+ exports.isNull = isNull.isNull;
15
+ exports.isObject = isObject.isObject;
16
+ exports.isArrayOfPrimitive = isPrimitive.isArrayOfPrimitive;
17
+ exports.isPrimitive = isPrimitive.isPrimitive;
18
+ exports.isUndefined = isUndefined.isUndefined;
6
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const isFunction = (value) => {
2
6
  return typeof value === 'function';
3
7
  };
4
8
 
5
- export { isFunction };
9
+ exports.isFunction = isFunction;
6
10
  //# sourceMappingURL=is-function.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-function.js","sources":["../../src/predicates/is-function.ts"],"sourcesContent":["export const isFunction = (value: any): value is Function => {\n return typeof value === 'function';\n};\n"],"names":[],"mappings":"AAAa,MAAA,UAAU,GAAG,CAAC,KAAU,KAAuB;AAC1D,IAAA,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC;;;;"}
1
+ {"version":3,"file":"is-function.js","sources":["../../src/predicates/is-function.ts"],"sourcesContent":["export const isFunction = (value: any): value is Function => {\n return typeof value === 'function';\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,UAAU,GAAG,CAAC,KAAU,KAAuB;AAC1D,IAAA,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC;;;;"}
@@ -1,6 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const isNull = (value) => {
2
6
  return value === null;
3
7
  };
4
8
 
5
- export { isNull };
9
+ exports.isNull = isNull;
6
10
  //# sourceMappingURL=is-null.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-null.js","sources":["../../src/predicates/is-null.ts"],"sourcesContent":["export const isNull = (value: any): value is null => {\n return value === null;\n};\n"],"names":[],"mappings":"AAAa,MAAA,MAAM,GAAG,CAAC,KAAU,KAAmB;IAClD,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB;;;;"}
1
+ {"version":3,"file":"is-null.js","sources":["../../src/predicates/is-null.ts"],"sourcesContent":["export const isNull = (value: any): value is null => {\n return value === null;\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,MAAM,GAAG,CAAC,KAAU,KAAmB;IAClD,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB;;;;"}
@@ -1,6 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const isObject = (value) => {
2
6
  return typeof value === 'object';
3
7
  };
4
8
 
5
- export { isObject };
9
+ exports.isObject = isObject;
6
10
  //# sourceMappingURL=is-object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-object.js","sources":["../../src/predicates/is-object.ts"],"sourcesContent":["export const isObject = (value: any): value is Object => {\n return typeof value === 'object';\n};\n"],"names":[],"mappings":"AAAa,MAAA,QAAQ,GAAG,CAAC,KAAU,KAAqB;AACtD,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC;;;;"}
1
+ {"version":3,"file":"is-object.js","sources":["../../src/predicates/is-object.ts"],"sourcesContent":["export const isObject = (value: any): value is Object => {\n return typeof value === 'object';\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,QAAQ,GAAG,CAAC,KAAU,KAAqB;AACtD,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const PRIMITIVE_TYPES = [
2
6
  'string',
3
7
  'boolean',
@@ -13,5 +17,6 @@ const isArrayOfPrimitive = (value) => {
13
17
  return value.every((arrayValue) => isPrimitive(arrayValue));
14
18
  };
15
19
 
16
- export { isArrayOfPrimitive, isPrimitive };
20
+ exports.isArrayOfPrimitive = isArrayOfPrimitive;
21
+ exports.isPrimitive = isPrimitive;
17
22
  //# sourceMappingURL=is-primitive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-primitive.js","sources":["../../src/predicates/is-primitive.ts"],"sourcesContent":["import { Primitive } from '../types/general';\n\nconst PRIMITIVE_TYPES = [\n 'string',\n 'boolean',\n 'number',\n];\n\nexport const isPrimitive = (value: any): value is Primitive => {\n return PRIMITIVE_TYPES.includes(typeof value);\n};\n\nexport const isArrayOfPrimitive = (value: any): value is Array<Primitive> => {\n if (!Array.isArray(value)) {\n return false;\n }\n\n return value.every((arrayValue) => isPrimitive(arrayValue));\n};\n"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG;IACtB,QAAQ;IACR,SAAS;IACT,QAAQ;CACT,CAAC;AAEW,MAAA,WAAW,GAAG,CAAC,KAAU,KAAwB;AAC5D,IAAA,OAAO,eAAe,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAChD,EAAE;AAEW,MAAA,kBAAkB,GAAG,CAAC,KAAU,KAA+B;AAC1E,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,KAAK,CAAC;AACd,KAAA;AAED,IAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,UAAU,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;AAC9D;;;;"}
1
+ {"version":3,"file":"is-primitive.js","sources":["../../src/predicates/is-primitive.ts"],"sourcesContent":["import { Primitive } from '../types/general';\n\nconst PRIMITIVE_TYPES = [\n 'string',\n 'boolean',\n 'number',\n];\n\nexport const isPrimitive = (value: any): value is Primitive => {\n return PRIMITIVE_TYPES.includes(typeof value);\n};\n\nexport const isArrayOfPrimitive = (value: any): value is Array<Primitive> => {\n if (!Array.isArray(value)) {\n return false;\n }\n\n return value.every((arrayValue) => isPrimitive(arrayValue));\n};\n"],"names":[],"mappings":";;;;AAEA,MAAM,eAAe,GAAG;IACtB,QAAQ;IACR,SAAS;IACT,QAAQ;CACT,CAAC;AAEW,MAAA,WAAW,GAAG,CAAC,KAAU,KAAwB;AAC5D,IAAA,OAAO,eAAe,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAChD,EAAE;AAEW,MAAA,kBAAkB,GAAG,CAAC,KAAU,KAA+B;AAC1E,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,KAAK,CAAC;AACd,KAAA;AAED,IAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,UAAU,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;AAC9D;;;;;"}
@@ -1,6 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const isUndefined = (value) => {
2
6
  return value === undefined;
3
7
  };
4
8
 
5
- export { isUndefined };
9
+ exports.isUndefined = isUndefined;
6
10
  //# sourceMappingURL=is-undefined.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-undefined.js","sources":["../../src/predicates/is-undefined.ts"],"sourcesContent":["export const isUndefined = (value: any): value is undefined => {\n return value === undefined;\n};\n"],"names":[],"mappings":"AAAa,MAAA,WAAW,GAAG,CAAC,KAAU,KAAwB;IAC5D,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B;;;;"}
1
+ {"version":3,"file":"is-undefined.js","sources":["../../src/predicates/is-undefined.ts"],"sourcesContent":["export const isUndefined = (value: any): value is undefined => {\n return value === undefined;\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,WAAW,GAAG,CAAC,KAAU,KAAwB;IAC5D,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B;;;;"}
package/promise/delay.js CHANGED
@@ -1,6 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const delay = (time) => new Promise((resolve) => {
2
6
  setTimeout(resolve, time);
3
7
  });
4
8
 
5
- export { delay };
9
+ exports.delay = delay;
6
10
  //# sourceMappingURL=delay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delay.js","sources":["../../src/promise/delay.ts"],"sourcesContent":["export const delay = (time: number) => new Promise((resolve) => {\n setTimeout(resolve, time);\n});\n"],"names":[],"mappings":"AAAO,MAAM,KAAK,GAAG,CAAC,IAAY,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;AAC7D,IAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;;;;"}
1
+ {"version":3,"file":"delay.js","sources":["../../src/promise/delay.ts"],"sourcesContent":["export const delay = (time: number) => new Promise((resolve) => {\n setTimeout(resolve, time);\n});\n"],"names":[],"mappings":";;;;AAAO,MAAM,KAAK,GAAG,CAAC,IAAY,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;AAC7D,IAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;;;;"}
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
1
5
  const executeOrResolveDefault = (callback, config) => {
2
6
  const { execute, defaultValue } = config;
3
7
  if (execute) {
@@ -6,5 +10,5 @@ const executeOrResolveDefault = (callback, config) => {
6
10
  return Promise.resolve(defaultValue);
7
11
  };
8
12
 
9
- export { executeOrResolveDefault };
13
+ exports.executeOrResolveDefault = executeOrResolveDefault;
10
14
  //# sourceMappingURL=execute-or-resolve-default.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute-or-resolve-default.js","sources":["../../src/promise/execute-or-resolve-default.ts"],"sourcesContent":["export type ExecutionConfig<Default> = {\n execute: boolean,\n defaultValue: Default,\n};\n\nexport const executeOrResolveDefault = <T, Default>(callback: () => Promise<T>, config: ExecutionConfig<Default>): Promise<T | Default> => {\n const { execute, defaultValue } = config;\n\n if (execute) {\n return callback();\n }\n\n return Promise.resolve(defaultValue);\n};\n"],"names":[],"mappings":"MAKa,uBAAuB,GAAG,CAAa,QAA0B,EAAE,MAAgC,KAA0B;AACxI,IAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;AAEzC,IAAA,IAAI,OAAO,EAAE;QACX,OAAO,QAAQ,EAAE,CAAC;AACnB,KAAA;AAED,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC;;;;"}
1
+ {"version":3,"file":"execute-or-resolve-default.js","sources":["../../src/promise/execute-or-resolve-default.ts"],"sourcesContent":["export type ExecutionConfig<Default> = {\n execute: boolean,\n defaultValue: Default,\n};\n\nexport const executeOrResolveDefault = <T, Default>(callback: () => Promise<T>, config: ExecutionConfig<Default>): Promise<T | Default> => {\n const { execute, defaultValue } = config;\n\n if (execute) {\n return callback();\n }\n\n return Promise.resolve(defaultValue);\n};\n"],"names":[],"mappings":";;;;MAKa,uBAAuB,GAAG,CAAa,QAA0B,EAAE,MAAgC,KAA0B;AACxI,IAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;AAEzC,IAAA,IAAI,OAAO,EAAE;QACX,OAAO,QAAQ,EAAE,CAAC;AACnB,KAAA;AAED,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC;;;;"}
@@ -1,10 +1,14 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
- import { delay } from './delay.js';
1
+ 'use strict';
3
2
 
4
- const executeWithDelay = (callback, time) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield delay(time);
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../_virtual/_tslib.js');
6
+ var delay = require('./delay.js');
7
+
8
+ const executeWithDelay = (callback, time) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
9
+ yield delay.delay(time);
6
10
  return callback();
7
11
  });
8
12
 
9
- export { executeWithDelay };
13
+ exports.executeWithDelay = executeWithDelay;
10
14
  //# sourceMappingURL=execute-with-delay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute-with-delay.js","sources":["../../src/promise/execute-with-delay.ts"],"sourcesContent":["import { delay } from './delay';\n\nexport const executeWithDelay = async <T>(callback: () => T, time: number): Promise<T> => {\n await delay(time);\n return callback();\n};\n"],"names":[],"mappings":";;;MAEa,gBAAgB,GAAG,CAAU,QAAiB,EAAE,IAAY,KAAgB,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACvF,IAAA,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,QAAQ,EAAE,CAAC;AACpB,CAAC;;;;"}
1
+ {"version":3,"file":"execute-with-delay.js","sources":["../../src/promise/execute-with-delay.ts"],"sourcesContent":["import { delay } from './delay';\n\nexport const executeWithDelay = async <T>(callback: () => T, time: number): Promise<T> => {\n await delay(time);\n return callback();\n};\n"],"names":["__awaiter","delay"],"mappings":";;;;;;;MAEa,gBAAgB,GAAG,CAAU,QAAiB,EAAE,IAAY,KAAgBA,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACvF,IAAA,MAAMC,WAAK,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,QAAQ,EAAE,CAAC;AACpB,CAAC;;;;"}
package/promise/index.js CHANGED
@@ -1,4 +1,14 @@
1
- export { executeOrResolveDefault } from './execute-or-resolve-default.js';
2
- export { executeWithDelay } from './execute-with-delay.js';
3
- export { delay } from './delay.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var executeOrResolveDefault = require('./execute-or-resolve-default.js');
6
+ var executeWithDelay = require('./execute-with-delay.js');
7
+ var delay = require('./delay.js');
8
+
9
+
10
+
11
+ exports.executeOrResolveDefault = executeOrResolveDefault.executeOrResolveDefault;
12
+ exports.executeWithDelay = executeWithDelay.executeWithDelay;
13
+ exports.delay = delay.delay;
4
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
package/string/index.js CHANGED
@@ -1,2 +1,10 @@
1
- export { replaceInTemplate } from './replace-in-template.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var replaceInTemplate = require('./replace-in-template.js');
6
+
7
+
8
+
9
+ exports.replaceInTemplate = replaceInTemplate.replaceInTemplate;
2
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1,4 +1,8 @@
1
- import { isPrimitive, isArrayOfPrimitive } from '../predicates/is-primitive.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var isPrimitive = require('../predicates/is-primitive.js');
2
6
 
3
7
  const defaultConfig = {
4
8
  delimiter: {
@@ -20,7 +24,7 @@ const replaceInTemplate = (template, params, config = defaultConfig) => {
20
24
  return Object
21
25
  .entries(params)
22
26
  .reduce((acc, [key, value]) => {
23
- if (!isPrimitive(value) && !isArrayOfPrimitive(value)) {
27
+ if (!isPrimitive.isPrimitive(value) && !isPrimitive.isArrayOfPrimitive(value)) {
24
28
  return acc;
25
29
  }
26
30
  const searchValue = `${leftDelimiter}${key}${rightDelimiter}`;
@@ -29,5 +33,5 @@ const replaceInTemplate = (template, params, config = defaultConfig) => {
29
33
  }, template);
30
34
  };
31
35
 
32
- export { replaceInTemplate };
36
+ exports.replaceInTemplate = replaceInTemplate;
33
37
  //# sourceMappingURL=replace-in-template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"replace-in-template.js","sources":["../../src/string/replace-in-template.ts"],"sourcesContent":["import { isArrayOfPrimitive, isPrimitive } from '../predicates';\n\nexport type ReplaceConfig = {\n delimiter: string | {\n left: string,\n right: string,\n },\n};\n\nconst defaultConfig: ReplaceConfig = {\n delimiter: {\n left: '{{',\n right: '}}',\n },\n};\n\n/**\n * Replace string inside a template. For now, only works with\n * an object containing promirives or array of primitives. If\n * it contains other objects, they will be ignored.\n *\n * Uses the mustache syntax by default.\n */\nexport const replaceInTemplate = (\n template: string,\n params: Record<string, any>,\n config: ReplaceConfig = defaultConfig,\n) => {\n const { delimiter } = config;\n const leftDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.left;\n const rightDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.right;\n\n return Object\n .entries(params)\n .reduce((acc, [key, value]) => {\n if (!isPrimitive(value) && !isArrayOfPrimitive(value)) {\n return acc;\n }\n\n const searchValue = `${leftDelimiter}${key}${rightDelimiter}`;\n const replaceBy = Array.isArray(value) ? value.join(', ') : String(value);\n\n return acc.replace(searchValue, replaceBy);\n }, template);\n};\n"],"names":[],"mappings":";;AASA,MAAM,aAAa,GAAkB;AACnC,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,KAAK,EAAE,IAAI;AACZ,KAAA;CACF,CAAC;AAEF;;;;;;AAMG;AACI,MAAM,iBAAiB,GAAG,CAC/B,QAAgB,EAChB,MAA2B,EAC3B,MAAA,GAAwB,aAAa,KACnC;AACF,IAAA,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;AAC7B,IAAA,MAAM,aAAa,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;AACjF,IAAA,MAAM,cAAc,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC;AAEnF,IAAA,OAAO,MAAM;SACV,OAAO,CAAC,MAAM,CAAC;SACf,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;QAC5B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;AACrD,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,MAAM,WAAW,GAAG,CAAG,EAAA,aAAa,GAAG,GAAG,CAAA,EAAG,cAAc,CAAA,CAAE,CAAC;QAC9D,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAE1E,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KAC5C,EAAE,QAAQ,CAAC,CAAC;AACjB;;;;"}
1
+ {"version":3,"file":"replace-in-template.js","sources":["../../src/string/replace-in-template.ts"],"sourcesContent":["import { isArrayOfPrimitive, isPrimitive } from '../predicates';\n\nexport type ReplaceConfig = {\n delimiter: string | {\n left: string,\n right: string,\n },\n};\n\nconst defaultConfig: ReplaceConfig = {\n delimiter: {\n left: '{{',\n right: '}}',\n },\n};\n\n/**\n * Replace string inside a template. For now, only works with\n * an object containing promirives or array of primitives. If\n * it contains other objects, they will be ignored.\n *\n * Uses the mustache syntax by default.\n */\nexport const replaceInTemplate = (\n template: string,\n params: Record<string, any>,\n config: ReplaceConfig = defaultConfig,\n) => {\n const { delimiter } = config;\n const leftDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.left;\n const rightDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.right;\n\n return Object\n .entries(params)\n .reduce((acc, [key, value]) => {\n if (!isPrimitive(value) && !isArrayOfPrimitive(value)) {\n return acc;\n }\n\n const searchValue = `${leftDelimiter}${key}${rightDelimiter}`;\n const replaceBy = Array.isArray(value) ? value.join(', ') : String(value);\n\n return acc.replace(searchValue, replaceBy);\n }, template);\n};\n"],"names":["isPrimitive","isArrayOfPrimitive"],"mappings":";;;;;;AASA,MAAM,aAAa,GAAkB;AACnC,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,KAAK,EAAE,IAAI;AACZ,KAAA;CACF,CAAC;AAEF;;;;;;AAMG;AACI,MAAM,iBAAiB,GAAG,CAC/B,QAAgB,EAChB,MAA2B,EAC3B,MAAA,GAAwB,aAAa,KACnC;AACF,IAAA,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;AAC7B,IAAA,MAAM,aAAa,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;AACjF,IAAA,MAAM,cAAc,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC;AAEnF,IAAA,OAAO,MAAM;SACV,OAAO,CAAC,MAAM,CAAC;SACf,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;QAC5B,IAAI,CAACA,uBAAW,CAAC,KAAK,CAAC,IAAI,CAACC,8BAAkB,CAAC,KAAK,CAAC,EAAE;AACrD,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,MAAM,WAAW,GAAG,CAAG,EAAA,aAAa,GAAG,GAAG,CAAA,EAAG,cAAc,CAAA,CAAE,CAAC;QAC9D,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAE1E,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KAC5C,EAAE,QAAQ,CAAC,CAAC;AACjB;;;;"}
package/types/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ 'use strict';
1
2
 
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}