@spscommerce/utils 5.20.2 → 5.20.3-ie

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 (209) hide show
  1. package/dist/out-tsc/array/flatten.d.ts +1 -0
  2. package/dist/out-tsc/array/flatten.js +7 -0
  3. package/dist/out-tsc/array/flatten.js.map +1 -0
  4. package/dist/out-tsc/array/flatten.spec.d.ts +1 -0
  5. package/dist/out-tsc/array/flatten.spec.js +10 -0
  6. package/dist/out-tsc/array/flatten.spec.js.map +1 -0
  7. package/dist/out-tsc/array/index.d.ts +3 -0
  8. package/dist/out-tsc/array/index.js +4 -0
  9. package/dist/out-tsc/array/index.js.map +1 -0
  10. package/dist/out-tsc/array/is-subset.d.ts +4 -0
  11. package/dist/out-tsc/array/is-subset.js +41 -0
  12. package/dist/out-tsc/array/is-subset.js.map +1 -0
  13. package/dist/out-tsc/array/is-subset.spec.d.ts +1 -0
  14. package/dist/out-tsc/array/is-subset.spec.js +41 -0
  15. package/dist/out-tsc/array/is-subset.spec.js.map +1 -0
  16. package/dist/out-tsc/array/range.d.ts +5 -0
  17. package/dist/out-tsc/array/range.js +16 -0
  18. package/dist/out-tsc/array/range.js.map +1 -0
  19. package/dist/out-tsc/array/range.spec.d.ts +1 -0
  20. package/dist/out-tsc/array/range.spec.js +26 -0
  21. package/dist/out-tsc/array/range.spec.js.map +1 -0
  22. package/dist/out-tsc/classes/custom-event.d.ts +4 -0
  23. package/dist/out-tsc/classes/custom-event.js +87 -0
  24. package/dist/out-tsc/classes/custom-event.js.map +1 -0
  25. package/dist/out-tsc/classes/index.d.ts +1 -0
  26. package/dist/out-tsc/classes/index.js +2 -0
  27. package/dist/out-tsc/classes/index.js.map +1 -0
  28. package/dist/out-tsc/data/doctypes.d.ts +4 -0
  29. package/dist/out-tsc/data/doctypes.js +302 -0
  30. package/dist/out-tsc/data/doctypes.js.map +1 -0
  31. package/dist/out-tsc/data/index.d.ts +1 -0
  32. package/dist/out-tsc/data/index.js +2 -0
  33. package/dist/out-tsc/data/index.js.map +1 -0
  34. package/dist/out-tsc/decorators/cast-to-number.d.ts +5 -0
  35. package/dist/out-tsc/decorators/cast-to-number.js +29 -0
  36. package/dist/out-tsc/decorators/cast-to-number.js.map +1 -0
  37. package/dist/out-tsc/decorators/debounced.broken_spec.d.ts +0 -0
  38. package/dist/out-tsc/decorators/debounced.broken_spec.js +38 -0
  39. package/dist/out-tsc/decorators/debounced.broken_spec.js.map +1 -0
  40. package/dist/out-tsc/decorators/debounced.d.ts +11 -0
  41. package/dist/out-tsc/decorators/debounced.js +35 -0
  42. package/dist/out-tsc/decorators/debounced.js.map +1 -0
  43. package/dist/out-tsc/decorators/index.d.ts +5 -0
  44. package/dist/out-tsc/decorators/index.js +6 -0
  45. package/dist/out-tsc/decorators/index.js.map +1 -0
  46. package/dist/out-tsc/decorators/locked-to-animation-frames.d.ts +4 -0
  47. package/dist/out-tsc/decorators/locked-to-animation-frames.js +34 -0
  48. package/dist/out-tsc/decorators/locked-to-animation-frames.js.map +1 -0
  49. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.d.ts +0 -0
  50. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js +63 -0
  51. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js.map +1 -0
  52. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.d.ts +11 -0
  53. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js +80 -0
  54. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js.map +1 -0
  55. package/dist/out-tsc/decorators/tick-delay.d.ts +6 -0
  56. package/dist/out-tsc/decorators/tick-delay.js +31 -0
  57. package/dist/out-tsc/decorators/tick-delay.js.map +1 -0
  58. package/dist/out-tsc/function/debounce.d.ts +9 -0
  59. package/dist/out-tsc/function/debounce.js +102 -0
  60. package/dist/out-tsc/function/debounce.js.map +1 -0
  61. package/dist/out-tsc/function/debounce.spec.d.ts +1 -0
  62. package/dist/out-tsc/function/debounce.spec.js +150 -0
  63. package/dist/out-tsc/function/debounce.spec.js.map +1 -0
  64. package/dist/out-tsc/function/debounced-function.interface.d.ts +10 -0
  65. package/dist/out-tsc/function/debounced-function.interface.js +2 -0
  66. package/dist/out-tsc/function/debounced-function.interface.js.map +1 -0
  67. package/dist/out-tsc/function/delayed-function.interface.d.ts +10 -0
  68. package/dist/out-tsc/function/delayed-function.interface.js +2 -0
  69. package/dist/out-tsc/function/delayed-function.interface.js.map +1 -0
  70. package/dist/out-tsc/function/index.d.ts +6 -0
  71. package/dist/out-tsc/function/index.js +7 -0
  72. package/dist/out-tsc/function/index.js.map +1 -0
  73. package/dist/out-tsc/function/lock-to-animation-frames.d.ts +7 -0
  74. package/dist/out-tsc/function/lock-to-animation-frames.js +43 -0
  75. package/dist/out-tsc/function/lock-to-animation-frames.js.map +1 -0
  76. package/dist/out-tsc/function/lock-to-animation-frames.spec.d.ts +0 -0
  77. package/dist/out-tsc/function/lock-to-animation-frames.spec.js +53 -0
  78. package/dist/out-tsc/function/lock-to-animation-frames.spec.js.map +1 -0
  79. package/dist/out-tsc/function/on-next-tick.d.ts +8 -0
  80. package/dist/out-tsc/function/on-next-tick.js +12 -0
  81. package/dist/out-tsc/function/on-next-tick.js.map +1 -0
  82. package/dist/out-tsc/function/on-next-tick.spec.d.ts +1 -0
  83. package/dist/out-tsc/function/on-next-tick.spec.js +13 -0
  84. package/dist/out-tsc/function/on-next-tick.spec.js.map +1 -0
  85. package/dist/out-tsc/function/op.d.ts +32 -0
  86. package/dist/out-tsc/function/op.js +34 -0
  87. package/dist/out-tsc/function/op.js.map +1 -0
  88. package/dist/out-tsc/function/op.spec.d.ts +1 -0
  89. package/dist/out-tsc/function/op.spec.js +94 -0
  90. package/dist/out-tsc/function/op.spec.js.map +1 -0
  91. package/dist/out-tsc/index.d.ts +9 -0
  92. package/dist/out-tsc/index.js +10 -0
  93. package/dist/out-tsc/index.js.map +1 -0
  94. package/dist/out-tsc/number/constrain.d.ts +7 -0
  95. package/dist/out-tsc/number/constrain.js +16 -0
  96. package/dist/out-tsc/number/constrain.js.map +1 -0
  97. package/dist/out-tsc/number/decimal-round.d.ts +7 -0
  98. package/dist/out-tsc/number/decimal-round.js +19 -0
  99. package/dist/out-tsc/number/decimal-round.js.map +1 -0
  100. package/dist/out-tsc/number/decimal-round.spec.d.ts +1 -0
  101. package/dist/out-tsc/number/decimal-round.spec.js +10 -0
  102. package/dist/out-tsc/number/decimal-round.spec.js.map +1 -0
  103. package/dist/out-tsc/number/index.d.ts +3 -0
  104. package/dist/out-tsc/number/index.js +4 -0
  105. package/dist/out-tsc/number/index.js.map +1 -0
  106. package/dist/out-tsc/number/to-file-size-string.d.ts +5 -0
  107. package/dist/out-tsc/number/to-file-size-string.js +24 -0
  108. package/dist/out-tsc/number/to-file-size-string.js.map +1 -0
  109. package/dist/out-tsc/object/copy-property.d.ts +6 -0
  110. package/dist/out-tsc/object/copy-property.js +9 -0
  111. package/dist/out-tsc/object/copy-property.js.map +1 -0
  112. package/dist/out-tsc/object/copy-property.spec.d.ts +1 -0
  113. package/dist/out-tsc/object/copy-property.spec.js +16 -0
  114. package/dist/out-tsc/object/copy-property.spec.js.map +1 -0
  115. package/dist/out-tsc/object/crumble-path.d.ts +6 -0
  116. package/dist/out-tsc/object/crumble-path.js +9 -0
  117. package/dist/out-tsc/object/crumble-path.js.map +1 -0
  118. package/dist/out-tsc/object/crumble-path.spec.d.ts +1 -0
  119. package/dist/out-tsc/object/crumble-path.spec.js +24 -0
  120. package/dist/out-tsc/object/crumble-path.spec.js.map +1 -0
  121. package/dist/out-tsc/object/deep-freeze.d.ts +1 -0
  122. package/dist/out-tsc/object/deep-freeze.js +36 -0
  123. package/dist/out-tsc/object/deep-freeze.js.map +1 -0
  124. package/dist/out-tsc/object/deep-freeze.spec.d.ts +1 -0
  125. package/dist/out-tsc/object/deep-freeze.spec.js +14 -0
  126. package/dist/out-tsc/object/deep-freeze.spec.js.map +1 -0
  127. package/dist/out-tsc/object/diff.d.ts +12 -0
  128. package/dist/out-tsc/object/diff.js +92 -0
  129. package/dist/out-tsc/object/diff.js.map +1 -0
  130. package/dist/out-tsc/object/diff.spec.d.ts +1 -0
  131. package/dist/out-tsc/object/diff.spec.js +40 -0
  132. package/dist/out-tsc/object/diff.spec.js.map +1 -0
  133. package/dist/out-tsc/object/for-each-entry-deep.d.ts +4 -0
  134. package/dist/out-tsc/object/for-each-entry-deep.js +38 -0
  135. package/dist/out-tsc/object/for-each-entry-deep.js.map +1 -0
  136. package/dist/out-tsc/object/for-each-entry-deep.spec.d.ts +1 -0
  137. package/dist/out-tsc/object/for-each-entry-deep.spec.js +24 -0
  138. package/dist/out-tsc/object/for-each-entry-deep.spec.js.map +1 -0
  139. package/dist/out-tsc/object/for-each-nested-object.d.ts +4 -0
  140. package/dist/out-tsc/object/for-each-nested-object.js +38 -0
  141. package/dist/out-tsc/object/for-each-nested-object.js.map +1 -0
  142. package/dist/out-tsc/object/for-each-nested-object.spec.d.ts +1 -0
  143. package/dist/out-tsc/object/for-each-nested-object.spec.js +46 -0
  144. package/dist/out-tsc/object/for-each-nested-object.spec.js.map +1 -0
  145. package/dist/out-tsc/object/get-path.d.ts +5 -0
  146. package/dist/out-tsc/object/get-path.js +67 -0
  147. package/dist/out-tsc/object/get-path.js.map +1 -0
  148. package/dist/out-tsc/object/get-path.spec.d.ts +1 -0
  149. package/dist/out-tsc/object/get-path.spec.js +44 -0
  150. package/dist/out-tsc/object/get-path.spec.js.map +1 -0
  151. package/dist/out-tsc/object/index.d.ts +13 -0
  152. package/dist/out-tsc/object/index.js +14 -0
  153. package/dist/out-tsc/object/index.js.map +1 -0
  154. package/dist/out-tsc/object/merge-deep.d.ts +4 -0
  155. package/dist/out-tsc/object/merge-deep.js +60 -0
  156. package/dist/out-tsc/object/merge-deep.js.map +1 -0
  157. package/dist/out-tsc/object/merge-deep.spec.d.ts +1 -0
  158. package/dist/out-tsc/object/merge-deep.spec.js +16 -0
  159. package/dist/out-tsc/object/merge-deep.spec.js.map +1 -0
  160. package/dist/out-tsc/object/merge-properties-deep.d.ts +4 -0
  161. package/dist/out-tsc/object/merge-properties-deep.js +61 -0
  162. package/dist/out-tsc/object/merge-properties-deep.js.map +1 -0
  163. package/dist/out-tsc/object/merge-properties-deep.spec.d.ts +1 -0
  164. package/dist/out-tsc/object/merge-properties-deep.spec.js +24 -0
  165. package/dist/out-tsc/object/merge-properties-deep.spec.js.map +1 -0
  166. package/dist/out-tsc/object/omit.d.ts +1 -0
  167. package/dist/out-tsc/object/omit.js +40 -0
  168. package/dist/out-tsc/object/omit.js.map +1 -0
  169. package/dist/out-tsc/object/omit.spec.d.ts +1 -0
  170. package/dist/out-tsc/object/omit.spec.js +10 -0
  171. package/dist/out-tsc/object/omit.spec.js.map +1 -0
  172. package/dist/out-tsc/object/set-path.d.ts +2 -0
  173. package/dist/out-tsc/object/set-path.js +45 -0
  174. package/dist/out-tsc/object/set-path.js.map +1 -0
  175. package/dist/out-tsc/object/set-path.spec.d.ts +1 -0
  176. package/dist/out-tsc/object/set-path.spec.js +36 -0
  177. package/dist/out-tsc/object/set-path.spec.js.map +1 -0
  178. package/dist/out-tsc/object/traverse-path.d.ts +2 -0
  179. package/dist/out-tsc/object/traverse-path.js +81 -0
  180. package/dist/out-tsc/object/traverse-path.js.map +1 -0
  181. package/dist/out-tsc/object/values.d.ts +2 -0
  182. package/dist/out-tsc/object/values.js +31 -0
  183. package/dist/out-tsc/object/values.js.map +1 -0
  184. package/dist/out-tsc/object/values.spec.d.ts +1 -0
  185. package/dist/out-tsc/object/values.spec.js +7 -0
  186. package/dist/out-tsc/object/values.spec.js.map +1 -0
  187. package/dist/out-tsc/string/code.template-tag.d.ts +2 -0
  188. package/dist/out-tsc/string/code.template-tag.js +38 -0
  189. package/dist/out-tsc/string/code.template-tag.js.map +1 -0
  190. package/dist/out-tsc/string/index.d.ts +3 -0
  191. package/dist/out-tsc/string/index.js +4 -0
  192. package/dist/out-tsc/string/index.js.map +1 -0
  193. package/dist/out-tsc/string/parse-file-size.d.ts +5 -0
  194. package/dist/out-tsc/string/parse-file-size.js +43 -0
  195. package/dist/out-tsc/string/parse-file-size.js.map +1 -0
  196. package/dist/out-tsc/string/template.d.ts +15 -0
  197. package/dist/out-tsc/string/template.js +28 -0
  198. package/dist/out-tsc/string/template.js.map +1 -0
  199. package/dist/out-tsc/string/template.spec.d.ts +1 -0
  200. package/dist/out-tsc/string/template.spec.js +39 -0
  201. package/dist/out-tsc/string/template.spec.js.map +1 -0
  202. package/dist/out-tsc/typings.d.ts +1 -0
  203. package/dist/out-tsc/typings.js +2 -0
  204. package/dist/out-tsc/typings.js.map +1 -0
  205. package/lib/index.cjs.js +2437 -1
  206. package/lib/index.es.js +2268 -893
  207. package/package.json +5 -5
  208. package/rollup.config.js +22 -0
  209. package/vite.config.js +1 -1
@@ -0,0 +1,31 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ /** Returns the values of an object. */
13
+ export function values(object) {
14
+ var e_1, _a;
15
+ var vals = [];
16
+ try {
17
+ for (var _b = __values(Object.keys(object)), _c = _b.next(); !_c.done; _c = _b.next()) {
18
+ var key = _c.value;
19
+ vals.push(object[key]);
20
+ }
21
+ }
22
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
23
+ finally {
24
+ try {
25
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
26
+ }
27
+ finally { if (e_1) throw e_1.error; }
28
+ }
29
+ return vals;
30
+ }
31
+ //# sourceMappingURL=values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.js","sourceRoot":"","sources":["../../../src/object/values.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAAuC;AACvC,MAAM,UAAU,MAAM,CAAC,MAAW;;IAChC,IAAM,IAAI,GAAG,EAAE,CAAC;;QAChB,KAAkB,IAAA,KAAA,SAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,gBAAA,4BAAE;YAAlC,IAAM,GAAG,WAAA;YACZ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;SACxB;;;;;;;;;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { values } from "./values";
2
+ describe("values", function () {
3
+ test("retrieves the values of an object", function () {
4
+ expect(values({ a: 10, b: "foo" })).toEqual([10, "foo"]);
5
+ });
6
+ });
7
+ //# sourceMappingURL=values.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.spec.js","sourceRoot":"","sources":["../../../src/object/values.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAQ,CAAC,QAAQ,EAAE;IACjB,IAAI,CAAC,mCAAmC,EAAE;QACxC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Template tag function for making strings containing code blocks easier to deal with. */
2
+ export declare function code(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
@@ -0,0 +1,38 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ /** Template tag function for making strings containing code blocks easier to deal with. */
27
+ export function code(strings) {
28
+ var interpolations = [];
29
+ for (var _i = 1; _i < arguments.length; _i++) {
30
+ interpolations[_i - 1] = arguments[_i];
31
+ }
32
+ var s = strings.reduce(function (a, b, i) { return "" + a + (i <= interpolations.length ? String(interpolations[i - 1]) : "") + b; });
33
+ var leadingWhitespace = Math.min.apply(Math, __spreadArray([], __read(s.split(/[\r\n]/)
34
+ .filter(function (l) { return l.trim(); })
35
+ .map(function (l) { return (/^ */.exec(l))[0].length; })), false));
36
+ return s.replace(new RegExp("^ {" + leadingWhitespace + "}", "gm"), "").trim();
37
+ }
38
+ //# sourceMappingURL=code.template-tag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.template-tag.js","sourceRoot":"","sources":["../../../src/string/code.template-tag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2FAA2F;AAC3F,MAAM,UAAU,IAAI,CAAC,OAA6B;IAAE,wBAA4B;SAA5B,UAA4B,EAA5B,qBAA4B,EAA5B,IAA4B;QAA5B,uCAA4B;;IAC9E,IAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAK,OAAA,KAAG,CAAC,IAAG,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAG,CAAG,EAA5E,CAA4E,CAAC,CAAC;IACpH,IAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,OAAR,IAAI,2BACzB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;SACjB,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,EAAE,EAAR,CAAQ,CAAC;SACvB,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAzB,CAAyB,CAAC,UACzC,CAAC;IACF,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,QAAM,iBAAiB,MAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./code.template-tag";
2
+ export * from "./parse-file-size";
3
+ export * from "./template";
@@ -0,0 +1,4 @@
1
+ export * from "./code.template-tag";
2
+ export * from "./parse-file-size";
3
+ export * from "./template";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Parses a string as a file size and returns the size in bytes. For example,
3
+ * `parseFileSize("2KB")` will return `2048`.
4
+ */
5
+ export declare function parseFileSize(fileSize: string): number;
@@ -0,0 +1,43 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ /**
18
+ * Parses a string as a file size and returns the size in bytes. For example,
19
+ * `parseFileSize("2KB")` will return `2048`.
20
+ */
21
+ export function parseFileSize(fileSize) {
22
+ var unitMatch = /[A-Z]?B$/.exec(fileSize);
23
+ if (!unitMatch) {
24
+ throw new Error("Input to parseFileSize (\"" + fileSize + "\") doesn't seem like a file size; "
25
+ + "cannot identify a unit (e.g. KB, GB)");
26
+ }
27
+ var _a = __read(unitMatch, 1), unit = _a[0];
28
+ var num = Number(fileSize.replace(unit, ""));
29
+ if (Number.isNaN(num)) {
30
+ throw new Error("Could not parse a number out of input to parseFileSize (\"" + fileSize + "\")");
31
+ }
32
+ var magnitude = ["B",
33
+ "KB",
34
+ "MB",
35
+ "GB",
36
+ "TB",
37
+ "PB"].indexOf(unit);
38
+ if (magnitude === -1) {
39
+ throw new Error("parseFileSize does not support units above PB");
40
+ }
41
+ return Math.ceil(num * (Math.pow(1024, magnitude)));
42
+ }
43
+ //# sourceMappingURL=parse-file-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-file-size.js","sourceRoot":"","sources":["../../../src/string/parse-file-size.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,IAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CACb,+BAA4B,QAAQ,wCAAoC;cAChE,sCAAsC,CAC/C,CAAC;KACH;IAEK,IAAA,KAAA,OAAS,SAAS,IAAA,EAAjB,IAAI,QAAa,CAAC;IACzB,IAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,+DAA4D,QAAQ,QAAI,CAAC,CAAC;KAC3F;IAED,IAAM,SAAS,GAAG,CAAC,GAAG;QACpB,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAA,IAAI,EAAI,SAAS,CAAA,CAAC,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,15 @@
1
+ declare type TemplateFn = (data: any) => string;
2
+ /**
3
+ * Every string templating thing out there whether lodash, doT, handlebars, etc
4
+ * is extremely complicated to cover a variety of use cases. This just has two
5
+ * very simple features and great caution should be exercised in making it any more
6
+ * complex than that. A value can be interpolated like so:
7
+ * `<%= foo.bar %>`
8
+ * And a basic "if" conditional can be used like so:
9
+ * `<%? a?.b?.c %>This part will only appear if a.b.c is truthy!</%>`
10
+ * You can put interpolations inside a conditional, as you'd expect. That's it.
11
+ */
12
+ export declare function template(string: string): TemplateFn;
13
+ export declare function isTemplate(x: any): x is string;
14
+ export declare function isTemplateFn(x: any): x is TemplateFn;
15
+ export {};
@@ -0,0 +1,28 @@
1
+ import { getPath } from "../object";
2
+ var REGEX_REPLACEMENT = /(<%=|{{)(.+?)(%>|}})/g;
3
+ var REGEX_IF = /<%\?(.+?)%>(.+?)<\/%>/g;
4
+ var SYMBOL_TEMPLATE_SOURCE = Symbol("sps.utils.templateSrc");
5
+ /**
6
+ * Every string templating thing out there whether lodash, doT, handlebars, etc
7
+ * is extremely complicated to cover a variety of use cases. This just has two
8
+ * very simple features and great caution should be exercised in making it any more
9
+ * complex than that. A value can be interpolated like so:
10
+ * `<%= foo.bar %>`
11
+ * And a basic "if" conditional can be used like so:
12
+ * `<%? a?.b?.c %>This part will only appear if a.b.c is truthy!</%>`
13
+ * You can put interpolations inside a conditional, as you'd expect. That's it.
14
+ */
15
+ export function template(string) {
16
+ var fn = function (data) { return string
17
+ .replace(REGEX_IF, function (match, pathToCheck, content) { return (getPath(data, pathToCheck.trim()) ? content : ""); })
18
+ .replace(REGEX_REPLACEMENT, function (match, _, pathToInterpolate) { return getPath(data, pathToInterpolate.trim(), ""); }); };
19
+ fn[SYMBOL_TEMPLATE_SOURCE] = string;
20
+ return fn;
21
+ }
22
+ export function isTemplate(x) {
23
+ return typeof x === "string" && (REGEX_REPLACEMENT.test(x) || REGEX_IF.test(x));
24
+ }
25
+ export function isTemplateFn(x) {
26
+ return typeof x === "function" && Object.prototype.hasOwnProperty.call(x, SYMBOL_TEMPLATE_SOURCE);
27
+ }
28
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/string/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,IAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAClD,IAAM,QAAQ,GAAG,wBAAwB,CAAC;AAE1C,IAAM,sBAAsB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAI/D;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,IAAM,EAAE,GAAG,UAAC,IAAS,IAAK,OAAA,MAAM;SAC7B,OAAO,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,WAAW,EAAE,OAAO,IAAK,OAAA,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAlD,CAAkD,CAAC;SACtG,OAAO,CAAC,iBAAiB,EAAE,UAAC,KAAK,EAAE,CAAC,EAAE,iBAAiB,IAAK,OAAA,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAA3C,CAA2C,CAAC,EAFjF,CAEiF,CAAC;IAC5G,EAAE,CAAC,sBAAsB,CAAC,GAAG,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAM;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAM;IACjC,OAAO,OAAO,CAAC,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC;AACpG,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import { template } from "./template";
2
+ describe("template", function () {
3
+ test("correctly interpolates from data", function () {
4
+ var templateString = "test ---> <%= a.b %> <--- test";
5
+ var data = { a: { b: "foo" } };
6
+ var expected = "test ---> foo <--- test";
7
+ expect(template(templateString)(data)).toBe(expected);
8
+ });
9
+ test("correctly interpolates from data, alternate", function () {
10
+ var templateString = "test ---> {{a.b}} <--- test";
11
+ var data = { a: { b: "foo" } };
12
+ var expected = "test ---> foo <--- test";
13
+ expect(template(templateString)(data)).toBe(expected);
14
+ });
15
+ test("supports optional chaining", function () {
16
+ var templateString = "test ---> <%= a?.b %> <--- test";
17
+ var data = {};
18
+ var expected = "test ---> <--- test";
19
+ expect(template(templateString)(data)).toBe(expected);
20
+ });
21
+ test("throws if non-optional chaining breaks", function () {
22
+ var templateString = "test ---> <%= a.b %> <--- test";
23
+ var data = {};
24
+ expect(function () { return template(templateString)(data); }).toThrow();
25
+ });
26
+ test("removes falsy conditionals", function () {
27
+ var templateString = "test ---><%? a.c %> <%= a.b %> <--- test</%>";
28
+ var data = { a: { b: "foo" } };
29
+ var expected = "test --->";
30
+ expect(template(templateString)(data)).toBe(expected);
31
+ });
32
+ test("retains truthy conditionals & process any interpolations within", function () {
33
+ var templateString = "test ---><%? a.c %> <%= a.b %> <--- test</%>";
34
+ var data = { a: { b: "foo", c: true } };
35
+ var expected = "test ---> foo <--- test";
36
+ expect(template(templateString)(data)).toBe(expected);
37
+ });
38
+ });
39
+ //# sourceMappingURL=template.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.spec.js","sourceRoot":"","sources":["../../../src/string/template.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,QAAQ,CAAC,UAAU,EAAE;IACnB,IAAI,CAAC,kCAAkC,EAAE;QACvC,IAAM,cAAc,GAAG,gCAAgC,CAAC;QACxD,IAAM,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACjC,IAAM,QAAQ,GAAG,yBAAyB,CAAC;QAC3C,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE;QAClD,IAAM,cAAc,GAAG,6BAA6B,CAAC;QACrD,IAAM,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACjC,IAAM,QAAQ,GAAG,yBAAyB,CAAC;QAC3C,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4BAA4B,EAAE;QACjC,IAAM,cAAc,GAAG,iCAAiC,CAAC;QACzD,IAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAM,QAAQ,GAAG,sBAAsB,CAAC;QACxC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE;QAC7C,IAAM,cAAc,GAAG,gCAAgC,CAAC;QACxD,IAAM,IAAI,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,cAAM,OAAA,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAA9B,CAA8B,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4BAA4B,EAAE;QACjC,IAAM,cAAc,GAAG,8CAA8C,CAAC;QACtE,IAAM,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACjC,IAAM,QAAQ,GAAG,WAAW,CAAC;QAC7B,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iEAAiE,EAAE;QACtE,IAAM,cAAc,GAAG,8CAA8C,CAAC;QACtE,IAAM,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QAC1C,IAAM,QAAQ,GAAG,yBAAyB,CAAC;QAC3C,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare type Eventually<T> = T | Promise<T>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=typings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typings.js","sourceRoot":"","sources":["../../src/typings.ts"],"names":[],"mappings":""}