@spscommerce/utils 5.5.0-ie → 5.7.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 (210) hide show
  1. package/{dist/out-tsc → lib}/array/flatten.d.ts +0 -0
  2. package/{dist/out-tsc → lib}/array/flatten.spec.d.ts +0 -0
  3. package/{dist/out-tsc → lib}/array/index.d.ts +0 -0
  4. package/{dist/out-tsc → lib}/array/is-subset.d.ts +0 -0
  5. package/{dist/out-tsc → lib}/array/is-subset.spec.d.ts +0 -0
  6. package/{dist/out-tsc → lib}/array/range.d.ts +0 -0
  7. package/{dist/out-tsc → lib}/array/range.spec.d.ts +0 -0
  8. package/{dist/out-tsc → lib}/classes/custom-event.d.ts +0 -0
  9. package/{dist/out-tsc → lib}/classes/index.d.ts +0 -0
  10. package/{dist/out-tsc → lib}/data/doctypes.d.ts +0 -0
  11. package/{dist/out-tsc → lib}/data/index.d.ts +0 -0
  12. package/{dist/out-tsc → lib}/decorators/cast-to-number.d.ts +0 -0
  13. package/{dist/out-tsc → lib}/decorators/debounced.broken_spec.d.ts +0 -0
  14. package/{dist/out-tsc → lib}/decorators/debounced.d.ts +0 -0
  15. package/{dist/out-tsc → lib}/decorators/index.d.ts +0 -0
  16. package/{dist/out-tsc → lib}/decorators/locked-to-animation-frames.d.ts +0 -0
  17. package/{dist/out-tsc → lib}/decorators/locked-to-animation-frames.spec.d.ts +0 -0
  18. package/{dist/out-tsc → lib}/decorators/simple-metadata-decorator-applicator.d.ts +0 -0
  19. package/{dist/out-tsc → lib}/decorators/tick-delay.d.ts +0 -0
  20. package/{dist/out-tsc → lib}/function/debounce.d.ts +0 -0
  21. package/{dist/out-tsc → lib}/function/debounce.spec.d.ts +0 -0
  22. package/{dist/out-tsc → lib}/function/debounced-function.interface.d.ts +0 -0
  23. package/{dist/out-tsc → lib}/function/delayed-function.interface.d.ts +0 -0
  24. package/{dist/out-tsc → lib}/function/index.d.ts +0 -0
  25. package/{dist/out-tsc → lib}/function/lock-to-animation-frames.d.ts +0 -0
  26. package/{dist/out-tsc → lib}/function/lock-to-animation-frames.spec.d.ts +0 -0
  27. package/{dist/out-tsc → lib}/function/on-next-tick.d.ts +0 -0
  28. package/{dist/out-tsc → lib}/function/on-next-tick.spec.d.ts +0 -0
  29. package/{dist/out-tsc → lib}/function/op.d.ts +0 -0
  30. package/{dist/out-tsc → lib}/function/op.spec.d.ts +0 -0
  31. package/lib/index.cjs.js +1 -0
  32. package/{dist/out-tsc → lib}/index.d.ts +0 -0
  33. package/lib/index.es.js +1024 -0
  34. package/{dist/out-tsc → lib}/number/constrain.d.ts +0 -0
  35. package/{dist/out-tsc → lib}/number/decimal-round.d.ts +0 -0
  36. package/{dist/out-tsc → lib}/number/decimal-round.spec.d.ts +0 -0
  37. package/{dist/out-tsc → lib}/number/index.d.ts +0 -0
  38. package/{dist/out-tsc → lib}/number/to-file-size-string.d.ts +0 -0
  39. package/{dist/out-tsc → lib}/object/copy-property.d.ts +0 -0
  40. package/{dist/out-tsc → lib}/object/copy-property.spec.d.ts +0 -0
  41. package/{dist/out-tsc → lib}/object/crumble-path.d.ts +0 -0
  42. package/{dist/out-tsc → lib}/object/crumble-path.spec.d.ts +0 -0
  43. package/{dist/out-tsc → lib}/object/deep-freeze.d.ts +0 -0
  44. package/{dist/out-tsc → lib}/object/deep-freeze.spec.d.ts +0 -0
  45. package/{dist/out-tsc → lib}/object/diff.d.ts +0 -0
  46. package/{dist/out-tsc → lib}/object/diff.spec.d.ts +0 -0
  47. package/{dist/out-tsc → lib}/object/for-each-entry-deep.d.ts +0 -0
  48. package/{dist/out-tsc → lib}/object/for-each-entry-deep.spec.d.ts +0 -0
  49. package/{dist/out-tsc → lib}/object/for-each-nested-object.d.ts +0 -0
  50. package/{dist/out-tsc → lib}/object/for-each-nested-object.spec.d.ts +0 -0
  51. package/{dist/out-tsc → lib}/object/get-path.d.ts +0 -0
  52. package/{dist/out-tsc → lib}/object/get-path.spec.d.ts +0 -0
  53. package/{dist/out-tsc → lib}/object/index.d.ts +0 -0
  54. package/{dist/out-tsc → lib}/object/merge-deep.d.ts +0 -0
  55. package/{dist/out-tsc → lib}/object/merge-deep.spec.d.ts +0 -0
  56. package/{dist/out-tsc → lib}/object/merge-properties-deep.d.ts +0 -0
  57. package/{dist/out-tsc → lib}/object/merge-properties-deep.spec.d.ts +0 -0
  58. package/{dist/out-tsc → lib}/object/omit.d.ts +0 -0
  59. package/{dist/out-tsc → lib}/object/omit.spec.d.ts +0 -0
  60. package/{dist/out-tsc → lib}/object/set-path.d.ts +0 -0
  61. package/{dist/out-tsc → lib}/object/set-path.spec.d.ts +0 -0
  62. package/{dist/out-tsc → lib}/object/traverse-path.d.ts +0 -0
  63. package/{dist/out-tsc → lib}/object/values.d.ts +0 -0
  64. package/{dist/out-tsc → lib}/object/values.spec.d.ts +0 -0
  65. package/{dist/out-tsc → lib}/string/code.template-tag.d.ts +0 -0
  66. package/{dist/out-tsc → lib}/string/index.d.ts +0 -0
  67. package/{dist/out-tsc → lib}/string/parse-file-size.d.ts +0 -0
  68. package/{dist/out-tsc → lib}/string/template.d.ts +0 -0
  69. package/{dist/out-tsc → lib}/string/template.spec.d.ts +0 -0
  70. package/{dist/out-tsc → lib}/typings.d.ts +0 -0
  71. package/package.json +5 -5
  72. package/vite.config.js +1 -1
  73. package/.pnpm-debug.log +0 -20
  74. package/dist/out-tsc/array/flatten.js +0 -7
  75. package/dist/out-tsc/array/flatten.js.map +0 -1
  76. package/dist/out-tsc/array/flatten.spec.js +0 -10
  77. package/dist/out-tsc/array/flatten.spec.js.map +0 -1
  78. package/dist/out-tsc/array/index.js +0 -4
  79. package/dist/out-tsc/array/index.js.map +0 -1
  80. package/dist/out-tsc/array/is-subset.js +0 -41
  81. package/dist/out-tsc/array/is-subset.js.map +0 -1
  82. package/dist/out-tsc/array/is-subset.spec.js +0 -41
  83. package/dist/out-tsc/array/is-subset.spec.js.map +0 -1
  84. package/dist/out-tsc/array/range.js +0 -16
  85. package/dist/out-tsc/array/range.js.map +0 -1
  86. package/dist/out-tsc/array/range.spec.js +0 -26
  87. package/dist/out-tsc/array/range.spec.js.map +0 -1
  88. package/dist/out-tsc/classes/custom-event.js +0 -87
  89. package/dist/out-tsc/classes/custom-event.js.map +0 -1
  90. package/dist/out-tsc/classes/index.js +0 -2
  91. package/dist/out-tsc/classes/index.js.map +0 -1
  92. package/dist/out-tsc/data/doctypes.js +0 -302
  93. package/dist/out-tsc/data/doctypes.js.map +0 -1
  94. package/dist/out-tsc/data/index.js +0 -2
  95. package/dist/out-tsc/data/index.js.map +0 -1
  96. package/dist/out-tsc/decorators/cast-to-number.js +0 -29
  97. package/dist/out-tsc/decorators/cast-to-number.js.map +0 -1
  98. package/dist/out-tsc/decorators/debounced.broken_spec.js +0 -38
  99. package/dist/out-tsc/decorators/debounced.broken_spec.js.map +0 -1
  100. package/dist/out-tsc/decorators/debounced.js +0 -35
  101. package/dist/out-tsc/decorators/debounced.js.map +0 -1
  102. package/dist/out-tsc/decorators/index.js +0 -6
  103. package/dist/out-tsc/decorators/index.js.map +0 -1
  104. package/dist/out-tsc/decorators/locked-to-animation-frames.js +0 -34
  105. package/dist/out-tsc/decorators/locked-to-animation-frames.js.map +0 -1
  106. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js +0 -63
  107. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js.map +0 -1
  108. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js +0 -80
  109. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js.map +0 -1
  110. package/dist/out-tsc/decorators/tick-delay.js +0 -31
  111. package/dist/out-tsc/decorators/tick-delay.js.map +0 -1
  112. package/dist/out-tsc/function/debounce.js +0 -102
  113. package/dist/out-tsc/function/debounce.js.map +0 -1
  114. package/dist/out-tsc/function/debounce.spec.js +0 -150
  115. package/dist/out-tsc/function/debounce.spec.js.map +0 -1
  116. package/dist/out-tsc/function/debounced-function.interface.js +0 -2
  117. package/dist/out-tsc/function/debounced-function.interface.js.map +0 -1
  118. package/dist/out-tsc/function/delayed-function.interface.js +0 -2
  119. package/dist/out-tsc/function/delayed-function.interface.js.map +0 -1
  120. package/dist/out-tsc/function/index.js +0 -7
  121. package/dist/out-tsc/function/index.js.map +0 -1
  122. package/dist/out-tsc/function/lock-to-animation-frames.js +0 -43
  123. package/dist/out-tsc/function/lock-to-animation-frames.js.map +0 -1
  124. package/dist/out-tsc/function/lock-to-animation-frames.spec.js +0 -53
  125. package/dist/out-tsc/function/lock-to-animation-frames.spec.js.map +0 -1
  126. package/dist/out-tsc/function/on-next-tick.js +0 -12
  127. package/dist/out-tsc/function/on-next-tick.js.map +0 -1
  128. package/dist/out-tsc/function/on-next-tick.spec.js +0 -13
  129. package/dist/out-tsc/function/on-next-tick.spec.js.map +0 -1
  130. package/dist/out-tsc/function/op.js +0 -34
  131. package/dist/out-tsc/function/op.js.map +0 -1
  132. package/dist/out-tsc/function/op.spec.js +0 -94
  133. package/dist/out-tsc/function/op.spec.js.map +0 -1
  134. package/dist/out-tsc/index.js +0 -10
  135. package/dist/out-tsc/index.js.map +0 -1
  136. package/dist/out-tsc/number/constrain.js +0 -16
  137. package/dist/out-tsc/number/constrain.js.map +0 -1
  138. package/dist/out-tsc/number/decimal-round.js +0 -19
  139. package/dist/out-tsc/number/decimal-round.js.map +0 -1
  140. package/dist/out-tsc/number/decimal-round.spec.js +0 -10
  141. package/dist/out-tsc/number/decimal-round.spec.js.map +0 -1
  142. package/dist/out-tsc/number/index.js +0 -4
  143. package/dist/out-tsc/number/index.js.map +0 -1
  144. package/dist/out-tsc/number/to-file-size-string.js +0 -24
  145. package/dist/out-tsc/number/to-file-size-string.js.map +0 -1
  146. package/dist/out-tsc/object/copy-property.js +0 -9
  147. package/dist/out-tsc/object/copy-property.js.map +0 -1
  148. package/dist/out-tsc/object/copy-property.spec.js +0 -16
  149. package/dist/out-tsc/object/copy-property.spec.js.map +0 -1
  150. package/dist/out-tsc/object/crumble-path.js +0 -9
  151. package/dist/out-tsc/object/crumble-path.js.map +0 -1
  152. package/dist/out-tsc/object/crumble-path.spec.js +0 -24
  153. package/dist/out-tsc/object/crumble-path.spec.js.map +0 -1
  154. package/dist/out-tsc/object/deep-freeze.js +0 -36
  155. package/dist/out-tsc/object/deep-freeze.js.map +0 -1
  156. package/dist/out-tsc/object/deep-freeze.spec.js +0 -14
  157. package/dist/out-tsc/object/deep-freeze.spec.js.map +0 -1
  158. package/dist/out-tsc/object/diff.js +0 -92
  159. package/dist/out-tsc/object/diff.js.map +0 -1
  160. package/dist/out-tsc/object/diff.spec.js +0 -40
  161. package/dist/out-tsc/object/diff.spec.js.map +0 -1
  162. package/dist/out-tsc/object/for-each-entry-deep.js +0 -38
  163. package/dist/out-tsc/object/for-each-entry-deep.js.map +0 -1
  164. package/dist/out-tsc/object/for-each-entry-deep.spec.js +0 -24
  165. package/dist/out-tsc/object/for-each-entry-deep.spec.js.map +0 -1
  166. package/dist/out-tsc/object/for-each-nested-object.js +0 -38
  167. package/dist/out-tsc/object/for-each-nested-object.js.map +0 -1
  168. package/dist/out-tsc/object/for-each-nested-object.spec.js +0 -46
  169. package/dist/out-tsc/object/for-each-nested-object.spec.js.map +0 -1
  170. package/dist/out-tsc/object/get-path.js +0 -67
  171. package/dist/out-tsc/object/get-path.js.map +0 -1
  172. package/dist/out-tsc/object/get-path.spec.js +0 -44
  173. package/dist/out-tsc/object/get-path.spec.js.map +0 -1
  174. package/dist/out-tsc/object/index.js +0 -14
  175. package/dist/out-tsc/object/index.js.map +0 -1
  176. package/dist/out-tsc/object/merge-deep.js +0 -60
  177. package/dist/out-tsc/object/merge-deep.js.map +0 -1
  178. package/dist/out-tsc/object/merge-deep.spec.js +0 -16
  179. package/dist/out-tsc/object/merge-deep.spec.js.map +0 -1
  180. package/dist/out-tsc/object/merge-properties-deep.js +0 -61
  181. package/dist/out-tsc/object/merge-properties-deep.js.map +0 -1
  182. package/dist/out-tsc/object/merge-properties-deep.spec.js +0 -24
  183. package/dist/out-tsc/object/merge-properties-deep.spec.js.map +0 -1
  184. package/dist/out-tsc/object/omit.js +0 -40
  185. package/dist/out-tsc/object/omit.js.map +0 -1
  186. package/dist/out-tsc/object/omit.spec.js +0 -10
  187. package/dist/out-tsc/object/omit.spec.js.map +0 -1
  188. package/dist/out-tsc/object/set-path.js +0 -45
  189. package/dist/out-tsc/object/set-path.js.map +0 -1
  190. package/dist/out-tsc/object/set-path.spec.js +0 -36
  191. package/dist/out-tsc/object/set-path.spec.js.map +0 -1
  192. package/dist/out-tsc/object/traverse-path.js +0 -81
  193. package/dist/out-tsc/object/traverse-path.js.map +0 -1
  194. package/dist/out-tsc/object/values.js +0 -31
  195. package/dist/out-tsc/object/values.js.map +0 -1
  196. package/dist/out-tsc/object/values.spec.js +0 -7
  197. package/dist/out-tsc/object/values.spec.js.map +0 -1
  198. package/dist/out-tsc/string/code.template-tag.js +0 -38
  199. package/dist/out-tsc/string/code.template-tag.js.map +0 -1
  200. package/dist/out-tsc/string/index.js +0 -4
  201. package/dist/out-tsc/string/index.js.map +0 -1
  202. package/dist/out-tsc/string/parse-file-size.js +0 -43
  203. package/dist/out-tsc/string/parse-file-size.js.map +0 -1
  204. package/dist/out-tsc/string/template.js +0 -28
  205. package/dist/out-tsc/string/template.js.map +0 -1
  206. package/dist/out-tsc/string/template.spec.js +0 -39
  207. package/dist/out-tsc/string/template.spec.js.map +0 -1
  208. package/dist/out-tsc/typings.js +0 -2
  209. package/dist/out-tsc/typings.js.map +0 -1
  210. package/rollup.config.js +0 -22
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,38 +0,0 @@
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 "".concat(a).concat(i <= interpolations.length ? String(interpolations[i - 1]) : "").concat(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("^ {".concat(leadingWhitespace, "}"), "gm"), "").trim();
37
- }
38
- //# sourceMappingURL=code.template-tag.js.map
@@ -1 +0,0 @@
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,UAAG,CAAC,SAAG,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAG,CAAC,CAAE,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,aAAM,iBAAiB,MAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5E,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from "./code.template-tag";
2
- export * from "./parse-file-size";
3
- export * from "./template";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,43 +0,0 @@
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 (\"".concat(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 (\"".concat(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
@@ -1 +0,0 @@
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,oCAA4B,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,oEAA4D,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"}
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,39 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=typings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typings.js","sourceRoot":"","sources":["../../src/typings.ts"],"names":[],"mappings":""}
package/rollup.config.js DELETED
@@ -1,22 +0,0 @@
1
- import commonjs from "@rollup/plugin-commonjs";
2
- import resolve from "@rollup/plugin-node-resolve";
3
- import pkg from "./package.json";
4
-
5
- export default {
6
- input: "dist/out-tsc/index.js",
7
- output: [
8
- {
9
- file: pkg.main,
10
- format: "cjs",
11
- },
12
- {
13
- file: pkg.module,
14
- format: "es",
15
- },
16
- ],
17
- external: Object.keys(pkg.peerDependencies || {}),
18
- plugins: [
19
- resolve(),
20
- commonjs(),
21
- ],
22
- };