@spscommerce/utils 5.4.1 → 5.5.0-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 (210) hide show
  1. package/.pnpm-debug.log +20 -0
  2. package/{lib → dist/out-tsc}/array/flatten.d.ts +0 -0
  3. package/dist/out-tsc/array/flatten.js +7 -0
  4. package/dist/out-tsc/array/flatten.js.map +1 -0
  5. package/{lib → dist/out-tsc}/array/flatten.spec.d.ts +0 -0
  6. package/dist/out-tsc/array/flatten.spec.js +10 -0
  7. package/dist/out-tsc/array/flatten.spec.js.map +1 -0
  8. package/{lib → dist/out-tsc}/array/index.d.ts +0 -0
  9. package/dist/out-tsc/array/index.js +4 -0
  10. package/dist/out-tsc/array/index.js.map +1 -0
  11. package/{lib → dist/out-tsc}/array/is-subset.d.ts +0 -0
  12. package/dist/out-tsc/array/is-subset.js +41 -0
  13. package/dist/out-tsc/array/is-subset.js.map +1 -0
  14. package/{lib → dist/out-tsc}/array/is-subset.spec.d.ts +0 -0
  15. package/dist/out-tsc/array/is-subset.spec.js +41 -0
  16. package/dist/out-tsc/array/is-subset.spec.js.map +1 -0
  17. package/{lib → dist/out-tsc}/array/range.d.ts +0 -0
  18. package/dist/out-tsc/array/range.js +16 -0
  19. package/dist/out-tsc/array/range.js.map +1 -0
  20. package/{lib → dist/out-tsc}/array/range.spec.d.ts +0 -0
  21. package/dist/out-tsc/array/range.spec.js +26 -0
  22. package/dist/out-tsc/array/range.spec.js.map +1 -0
  23. package/{lib → dist/out-tsc}/classes/custom-event.d.ts +0 -0
  24. package/dist/out-tsc/classes/custom-event.js +87 -0
  25. package/dist/out-tsc/classes/custom-event.js.map +1 -0
  26. package/{lib → dist/out-tsc}/classes/index.d.ts +0 -0
  27. package/dist/out-tsc/classes/index.js +2 -0
  28. package/dist/out-tsc/classes/index.js.map +1 -0
  29. package/{lib → dist/out-tsc}/data/doctypes.d.ts +0 -0
  30. package/dist/out-tsc/data/doctypes.js +302 -0
  31. package/dist/out-tsc/data/doctypes.js.map +1 -0
  32. package/{lib → dist/out-tsc}/data/index.d.ts +0 -0
  33. package/dist/out-tsc/data/index.js +2 -0
  34. package/dist/out-tsc/data/index.js.map +1 -0
  35. package/{lib → dist/out-tsc}/decorators/cast-to-number.d.ts +0 -0
  36. package/dist/out-tsc/decorators/cast-to-number.js +29 -0
  37. package/dist/out-tsc/decorators/cast-to-number.js.map +1 -0
  38. package/{lib → dist/out-tsc}/decorators/debounced.broken_spec.d.ts +0 -0
  39. package/dist/out-tsc/decorators/debounced.broken_spec.js +38 -0
  40. package/dist/out-tsc/decorators/debounced.broken_spec.js.map +1 -0
  41. package/{lib → dist/out-tsc}/decorators/debounced.d.ts +0 -0
  42. package/dist/out-tsc/decorators/debounced.js +35 -0
  43. package/dist/out-tsc/decorators/debounced.js.map +1 -0
  44. package/{lib → dist/out-tsc}/decorators/index.d.ts +0 -0
  45. package/dist/out-tsc/decorators/index.js +6 -0
  46. package/dist/out-tsc/decorators/index.js.map +1 -0
  47. package/{lib → dist/out-tsc}/decorators/locked-to-animation-frames.d.ts +0 -0
  48. package/dist/out-tsc/decorators/locked-to-animation-frames.js +34 -0
  49. package/dist/out-tsc/decorators/locked-to-animation-frames.js.map +1 -0
  50. package/{lib → dist/out-tsc}/decorators/locked-to-animation-frames.spec.d.ts +0 -0
  51. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js +63 -0
  52. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js.map +1 -0
  53. package/{lib → dist/out-tsc}/decorators/simple-metadata-decorator-applicator.d.ts +0 -0
  54. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js +80 -0
  55. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js.map +1 -0
  56. package/{lib → dist/out-tsc}/decorators/tick-delay.d.ts +0 -0
  57. package/dist/out-tsc/decorators/tick-delay.js +31 -0
  58. package/dist/out-tsc/decorators/tick-delay.js.map +1 -0
  59. package/{lib → dist/out-tsc}/function/debounce.d.ts +0 -0
  60. package/dist/out-tsc/function/debounce.js +102 -0
  61. package/dist/out-tsc/function/debounce.js.map +1 -0
  62. package/{lib → dist/out-tsc}/function/debounce.spec.d.ts +0 -0
  63. package/dist/out-tsc/function/debounce.spec.js +150 -0
  64. package/dist/out-tsc/function/debounce.spec.js.map +1 -0
  65. package/{lib → dist/out-tsc}/function/debounced-function.interface.d.ts +0 -0
  66. package/dist/out-tsc/function/debounced-function.interface.js +2 -0
  67. package/dist/out-tsc/function/debounced-function.interface.js.map +1 -0
  68. package/{lib → dist/out-tsc}/function/delayed-function.interface.d.ts +0 -0
  69. package/dist/out-tsc/function/delayed-function.interface.js +2 -0
  70. package/dist/out-tsc/function/delayed-function.interface.js.map +1 -0
  71. package/{lib → dist/out-tsc}/function/index.d.ts +0 -0
  72. package/dist/out-tsc/function/index.js +7 -0
  73. package/dist/out-tsc/function/index.js.map +1 -0
  74. package/{lib → dist/out-tsc}/function/lock-to-animation-frames.d.ts +0 -0
  75. package/dist/out-tsc/function/lock-to-animation-frames.js +43 -0
  76. package/dist/out-tsc/function/lock-to-animation-frames.js.map +1 -0
  77. package/{lib → dist/out-tsc}/function/lock-to-animation-frames.spec.d.ts +0 -0
  78. package/dist/out-tsc/function/lock-to-animation-frames.spec.js +53 -0
  79. package/dist/out-tsc/function/lock-to-animation-frames.spec.js.map +1 -0
  80. package/{lib → dist/out-tsc}/function/on-next-tick.d.ts +0 -0
  81. package/dist/out-tsc/function/on-next-tick.js +12 -0
  82. package/dist/out-tsc/function/on-next-tick.js.map +1 -0
  83. package/{lib → dist/out-tsc}/function/on-next-tick.spec.d.ts +0 -0
  84. package/dist/out-tsc/function/on-next-tick.spec.js +13 -0
  85. package/dist/out-tsc/function/on-next-tick.spec.js.map +1 -0
  86. package/{lib → dist/out-tsc}/function/op.d.ts +0 -0
  87. package/dist/out-tsc/function/op.js +34 -0
  88. package/dist/out-tsc/function/op.js.map +1 -0
  89. package/{lib → dist/out-tsc}/function/op.spec.d.ts +0 -0
  90. package/dist/out-tsc/function/op.spec.js +94 -0
  91. package/dist/out-tsc/function/op.spec.js.map +1 -0
  92. package/{lib → dist/out-tsc}/index.d.ts +0 -0
  93. package/dist/out-tsc/index.js +10 -0
  94. package/dist/out-tsc/index.js.map +1 -0
  95. package/{lib → dist/out-tsc}/number/constrain.d.ts +0 -0
  96. package/dist/out-tsc/number/constrain.js +16 -0
  97. package/dist/out-tsc/number/constrain.js.map +1 -0
  98. package/{lib → dist/out-tsc}/number/decimal-round.d.ts +0 -0
  99. package/dist/out-tsc/number/decimal-round.js +19 -0
  100. package/dist/out-tsc/number/decimal-round.js.map +1 -0
  101. package/{lib → dist/out-tsc}/number/decimal-round.spec.d.ts +0 -0
  102. package/dist/out-tsc/number/decimal-round.spec.js +10 -0
  103. package/dist/out-tsc/number/decimal-round.spec.js.map +1 -0
  104. package/{lib → dist/out-tsc}/number/index.d.ts +0 -0
  105. package/dist/out-tsc/number/index.js +4 -0
  106. package/dist/out-tsc/number/index.js.map +1 -0
  107. package/{lib → dist/out-tsc}/number/to-file-size-string.d.ts +0 -0
  108. package/dist/out-tsc/number/to-file-size-string.js +24 -0
  109. package/dist/out-tsc/number/to-file-size-string.js.map +1 -0
  110. package/{lib → dist/out-tsc}/object/copy-property.d.ts +0 -0
  111. package/dist/out-tsc/object/copy-property.js +9 -0
  112. package/dist/out-tsc/object/copy-property.js.map +1 -0
  113. package/{lib → dist/out-tsc}/object/copy-property.spec.d.ts +0 -0
  114. package/dist/out-tsc/object/copy-property.spec.js +16 -0
  115. package/dist/out-tsc/object/copy-property.spec.js.map +1 -0
  116. package/{lib → dist/out-tsc}/object/crumble-path.d.ts +0 -0
  117. package/dist/out-tsc/object/crumble-path.js +9 -0
  118. package/dist/out-tsc/object/crumble-path.js.map +1 -0
  119. package/{lib → dist/out-tsc}/object/crumble-path.spec.d.ts +0 -0
  120. package/dist/out-tsc/object/crumble-path.spec.js +24 -0
  121. package/dist/out-tsc/object/crumble-path.spec.js.map +1 -0
  122. package/{lib → dist/out-tsc}/object/deep-freeze.d.ts +0 -0
  123. package/dist/out-tsc/object/deep-freeze.js +36 -0
  124. package/dist/out-tsc/object/deep-freeze.js.map +1 -0
  125. package/{lib → dist/out-tsc}/object/deep-freeze.spec.d.ts +0 -0
  126. package/dist/out-tsc/object/deep-freeze.spec.js +14 -0
  127. package/dist/out-tsc/object/deep-freeze.spec.js.map +1 -0
  128. package/{lib → dist/out-tsc}/object/diff.d.ts +0 -0
  129. package/dist/out-tsc/object/diff.js +92 -0
  130. package/dist/out-tsc/object/diff.js.map +1 -0
  131. package/{lib → dist/out-tsc}/object/diff.spec.d.ts +0 -0
  132. package/dist/out-tsc/object/diff.spec.js +40 -0
  133. package/dist/out-tsc/object/diff.spec.js.map +1 -0
  134. package/{lib → dist/out-tsc}/object/for-each-entry-deep.d.ts +0 -0
  135. package/dist/out-tsc/object/for-each-entry-deep.js +38 -0
  136. package/dist/out-tsc/object/for-each-entry-deep.js.map +1 -0
  137. package/{lib → dist/out-tsc}/object/for-each-entry-deep.spec.d.ts +0 -0
  138. package/dist/out-tsc/object/for-each-entry-deep.spec.js +24 -0
  139. package/dist/out-tsc/object/for-each-entry-deep.spec.js.map +1 -0
  140. package/{lib → dist/out-tsc}/object/for-each-nested-object.d.ts +0 -0
  141. package/dist/out-tsc/object/for-each-nested-object.js +38 -0
  142. package/dist/out-tsc/object/for-each-nested-object.js.map +1 -0
  143. package/{lib → dist/out-tsc}/object/for-each-nested-object.spec.d.ts +0 -0
  144. package/dist/out-tsc/object/for-each-nested-object.spec.js +46 -0
  145. package/dist/out-tsc/object/for-each-nested-object.spec.js.map +1 -0
  146. package/{lib → dist/out-tsc}/object/get-path.d.ts +0 -0
  147. package/dist/out-tsc/object/get-path.js +67 -0
  148. package/dist/out-tsc/object/get-path.js.map +1 -0
  149. package/{lib → dist/out-tsc}/object/get-path.spec.d.ts +0 -0
  150. package/dist/out-tsc/object/get-path.spec.js +44 -0
  151. package/dist/out-tsc/object/get-path.spec.js.map +1 -0
  152. package/{lib → dist/out-tsc}/object/index.d.ts +0 -0
  153. package/dist/out-tsc/object/index.js +14 -0
  154. package/dist/out-tsc/object/index.js.map +1 -0
  155. package/{lib → dist/out-tsc}/object/merge-deep.d.ts +0 -0
  156. package/dist/out-tsc/object/merge-deep.js +60 -0
  157. package/dist/out-tsc/object/merge-deep.js.map +1 -0
  158. package/{lib → dist/out-tsc}/object/merge-deep.spec.d.ts +0 -0
  159. package/dist/out-tsc/object/merge-deep.spec.js +16 -0
  160. package/dist/out-tsc/object/merge-deep.spec.js.map +1 -0
  161. package/{lib → dist/out-tsc}/object/merge-properties-deep.d.ts +0 -0
  162. package/dist/out-tsc/object/merge-properties-deep.js +61 -0
  163. package/dist/out-tsc/object/merge-properties-deep.js.map +1 -0
  164. package/{lib → dist/out-tsc}/object/merge-properties-deep.spec.d.ts +0 -0
  165. package/dist/out-tsc/object/merge-properties-deep.spec.js +24 -0
  166. package/dist/out-tsc/object/merge-properties-deep.spec.js.map +1 -0
  167. package/{lib → dist/out-tsc}/object/omit.d.ts +0 -0
  168. package/dist/out-tsc/object/omit.js +40 -0
  169. package/dist/out-tsc/object/omit.js.map +1 -0
  170. package/{lib → dist/out-tsc}/object/omit.spec.d.ts +0 -0
  171. package/dist/out-tsc/object/omit.spec.js +10 -0
  172. package/dist/out-tsc/object/omit.spec.js.map +1 -0
  173. package/{lib → dist/out-tsc}/object/set-path.d.ts +0 -0
  174. package/dist/out-tsc/object/set-path.js +45 -0
  175. package/dist/out-tsc/object/set-path.js.map +1 -0
  176. package/{lib → dist/out-tsc}/object/set-path.spec.d.ts +0 -0
  177. package/dist/out-tsc/object/set-path.spec.js +36 -0
  178. package/dist/out-tsc/object/set-path.spec.js.map +1 -0
  179. package/{lib → dist/out-tsc}/object/traverse-path.d.ts +0 -0
  180. package/dist/out-tsc/object/traverse-path.js +81 -0
  181. package/dist/out-tsc/object/traverse-path.js.map +1 -0
  182. package/{lib → dist/out-tsc}/object/values.d.ts +0 -0
  183. package/dist/out-tsc/object/values.js +31 -0
  184. package/dist/out-tsc/object/values.js.map +1 -0
  185. package/{lib → dist/out-tsc}/object/values.spec.d.ts +0 -0
  186. package/dist/out-tsc/object/values.spec.js +7 -0
  187. package/dist/out-tsc/object/values.spec.js.map +1 -0
  188. package/{lib → dist/out-tsc}/string/code.template-tag.d.ts +0 -0
  189. package/dist/out-tsc/string/code.template-tag.js +38 -0
  190. package/dist/out-tsc/string/code.template-tag.js.map +1 -0
  191. package/{lib → dist/out-tsc}/string/index.d.ts +0 -0
  192. package/dist/out-tsc/string/index.js +4 -0
  193. package/dist/out-tsc/string/index.js.map +1 -0
  194. package/{lib → dist/out-tsc}/string/parse-file-size.d.ts +0 -0
  195. package/dist/out-tsc/string/parse-file-size.js +43 -0
  196. package/dist/out-tsc/string/parse-file-size.js.map +1 -0
  197. package/{lib → dist/out-tsc}/string/template.d.ts +0 -0
  198. package/dist/out-tsc/string/template.js +28 -0
  199. package/dist/out-tsc/string/template.js.map +1 -0
  200. package/{lib → dist/out-tsc}/string/template.spec.d.ts +0 -0
  201. package/dist/out-tsc/string/template.spec.js +39 -0
  202. package/dist/out-tsc/string/template.spec.js.map +1 -0
  203. package/{lib → dist/out-tsc}/typings.d.ts +0 -0
  204. package/dist/out-tsc/typings.js +2 -0
  205. package/dist/out-tsc/typings.js.map +1 -0
  206. package/package.json +5 -5
  207. package/rollup.config.js +22 -0
  208. package/vite.config.js +1 -1
  209. package/lib/index.cjs.js +0 -1
  210. package/lib/index.es.js +0 -1024
@@ -0,0 +1,60 @@
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
+ import isPlainObject from "lodash.isplainobject";
13
+ /**
14
+ * Recursive merge of any number of objects
15
+ */
16
+ export function mergeDeep() {
17
+ var e_1, _a, e_2, _b;
18
+ var objectsToMerge = [];
19
+ for (var _i = 0; _i < arguments.length; _i++) {
20
+ objectsToMerge[_i] = arguments[_i];
21
+ }
22
+ var result = {};
23
+ try {
24
+ for (var objectsToMerge_1 = __values(objectsToMerge), objectsToMerge_1_1 = objectsToMerge_1.next(); !objectsToMerge_1_1.done; objectsToMerge_1_1 = objectsToMerge_1.next()) {
25
+ var mergee = objectsToMerge_1_1.value;
26
+ try {
27
+ for (var _c = (e_2 = void 0, __values(Object.keys(mergee))), _d = _c.next(); !_d.done; _d = _c.next()) {
28
+ var key = _d.value;
29
+ if (Object.prototype.hasOwnProperty.call(result, key)
30
+ && Object.getOwnPropertyDescriptor(result, key).writable
31
+ && isPlainObject(result[key])) {
32
+ result[key] = mergeDeep(result[key], mergee[key]);
33
+ }
34
+ else if (isPlainObject(mergee[key])) {
35
+ result[key] = mergeDeep({}, mergee[key]);
36
+ }
37
+ else {
38
+ result[key] = mergee[key];
39
+ }
40
+ }
41
+ }
42
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
43
+ finally {
44
+ try {
45
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
46
+ }
47
+ finally { if (e_2) throw e_2.error; }
48
+ }
49
+ }
50
+ }
51
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
52
+ finally {
53
+ try {
54
+ if (objectsToMerge_1_1 && !objectsToMerge_1_1.done && (_a = objectsToMerge_1.return)) _a.call(objectsToMerge_1);
55
+ }
56
+ finally { if (e_1) throw e_1.error; }
57
+ }
58
+ return result;
59
+ }
60
+ //# sourceMappingURL=merge-deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-deep.js","sourceRoot":"","sources":["../../../src/object/merge-deep.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,SAAS;;IAAC,wBAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,mCAAwB;;IAChD,IAAM,MAAM,GAAG,EAAE,CAAC;;QAClB,KAAqB,IAAA,mBAAA,SAAA,cAAc,CAAA,8CAAA,0EAAE;YAAhC,IAAM,MAAM,2BAAA;;gBACf,KAAkB,IAAA,oBAAA,SAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAA,gBAAA,4BAAE;oBAAlC,IAAM,GAAG,WAAA;oBACZ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;2BACxC,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ;2BACrD,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EACrC;wBACA,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;qBACnD;yBAAM,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;wBACrC,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;qBAC1C;yBAAM;wBACL,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;qBAC3B;iBACF;;;;;;;;;SACF;;;;;;;;;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { mergeDeep } from "./merge-deep";
2
+ describe("mergeDeep", function () {
3
+ test("should recursively merge objects", function () {
4
+ var obj1 = { a: 0, b: { c: 1 } };
5
+ var obj2 = { b: { d: 2 }, e: 3 };
6
+ expect(mergeDeep(obj1, obj2)).toEqual({
7
+ a: 0,
8
+ b: {
9
+ c: 1,
10
+ d: 2,
11
+ },
12
+ e: 3,
13
+ });
14
+ });
15
+ });
16
+ //# sourceMappingURL=merge-deep.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-deep.spec.js","sourceRoot":"","sources":["../../../src/object/merge-deep.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,QAAQ,CAAC,WAAW,EAAE;IACpB,IAAI,CAAC,kCAAkC,EAAE;QACvC,IAAM,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAM,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YACpC,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE;gBACD,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,CAAC;aACL;YACD,CAAC,EAAE,CAAC;SACL,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,61 @@
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
+ import isPlainObject from "lodash.isplainobject";
13
+ import { copyProperty } from "./copy-property";
14
+ /**
15
+ * Recursive merge of any number of objects using `copyProperty()` rather than assignment
16
+ */
17
+ export function mergePropertiesDeep() {
18
+ var e_1, _a, e_2, _b;
19
+ var objectsToMerge = [];
20
+ for (var _i = 0; _i < arguments.length; _i++) {
21
+ objectsToMerge[_i] = arguments[_i];
22
+ }
23
+ var result = {};
24
+ try {
25
+ for (var objectsToMerge_1 = __values(objectsToMerge), objectsToMerge_1_1 = objectsToMerge_1.next(); !objectsToMerge_1_1.done; objectsToMerge_1_1 = objectsToMerge_1.next()) {
26
+ var mergee = objectsToMerge_1_1.value;
27
+ try {
28
+ for (var _c = (e_2 = void 0, __values(Object.keys(mergee))), _d = _c.next(); !_d.done; _d = _c.next()) {
29
+ var key = _d.value;
30
+ if (Object.prototype.hasOwnProperty.call(result, key)
31
+ && Object.getOwnPropertyDescriptor(result, key).writable
32
+ && isPlainObject(result[key])) {
33
+ result[key] = mergePropertiesDeep(result[key], mergee[key]);
34
+ }
35
+ else if (isPlainObject(mergee[key])) {
36
+ result[key] = mergePropertiesDeep({}, mergee[key]);
37
+ }
38
+ else {
39
+ copyProperty(key, mergee, result);
40
+ }
41
+ }
42
+ }
43
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
44
+ finally {
45
+ try {
46
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
47
+ }
48
+ finally { if (e_2) throw e_2.error; }
49
+ }
50
+ }
51
+ }
52
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
53
+ finally {
54
+ try {
55
+ if (objectsToMerge_1_1 && !objectsToMerge_1_1.done && (_a = objectsToMerge_1.return)) _a.call(objectsToMerge_1);
56
+ }
57
+ finally { if (e_1) throw e_1.error; }
58
+ }
59
+ return result;
60
+ }
61
+ //# sourceMappingURL=merge-properties-deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-properties-deep.js","sourceRoot":"","sources":["../../../src/object/merge-properties-deep.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,mBAAmB;;IAAC,wBAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,mCAAwB;;IAC1D,IAAM,MAAM,GAAG,EAAE,CAAC;;QAClB,KAAqB,IAAA,mBAAA,SAAA,cAAc,CAAA,8CAAA,0EAAE;YAAhC,IAAM,MAAM,2BAAA;;gBACf,KAAkB,IAAA,oBAAA,SAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAA,gBAAA,4BAAE;oBAAlC,IAAM,GAAG,WAAA;oBACZ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;2BACxC,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ;2BACrD,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EACrC;wBACA,MAAM,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;qBAC7D;yBAAM,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;wBACrC,MAAM,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;qBACpD;yBAAM;wBACL,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;qBACnC;iBACF;;;;;;;;;SACF;;;;;;;;;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { mergePropertiesDeep } from "./merge-properties-deep";
2
+ describe("mergePropertiesDeep", function () {
3
+ test("recursively merges properties using copyProperty()", function () {
4
+ var objectA = {
5
+ a: 1,
6
+ b: { n: 2 },
7
+ };
8
+ var objectB = {
9
+ a: 4,
10
+ b: {
11
+ get nn() {
12
+ return this.n * this.n;
13
+ },
14
+ },
15
+ c: 3,
16
+ };
17
+ var result = mergePropertiesDeep(objectA, objectB);
18
+ expect(result.a).toBe(4);
19
+ expect(result.b.n).toBe(2);
20
+ expect(result.b.nn).toBe(4);
21
+ expect(result.c).toBe(3);
22
+ });
23
+ });
24
+ //# sourceMappingURL=merge-properties-deep.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-properties-deep.spec.js","sourceRoot":"","sources":["../../../src/object/merge-properties-deep.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,QAAQ,CAAC,qBAAqB,EAAE;IAC9B,IAAI,CAAC,oDAAoD,EAAE;QACzD,IAAM,OAAO,GAAG;YACd,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;SACZ,CAAC;QACF,IAAM,OAAO,GAAG;YACd,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE;gBACD,IAAI,EAAE;oBACJ,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBACzB,CAAC;aACF;YACD,CAAC,EAAE,CAAC;SACL,CAAC;QACF,IAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
File without changes
@@ -0,0 +1,40 @@
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
+ /*
13
+ * Return a copy of `obj` without the key `key`
14
+ */
15
+ export function omit(obj) {
16
+ var e_1, _a;
17
+ var keys = [];
18
+ for (var _i = 1; _i < arguments.length; _i++) {
19
+ keys[_i - 1] = arguments[_i];
20
+ }
21
+ var keySet = new Set(keys);
22
+ var result = {};
23
+ try {
24
+ for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
25
+ var k = _c.value;
26
+ if (!keySet.has(k)) {
27
+ result[k] = obj[k];
28
+ }
29
+ }
30
+ }
31
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
32
+ finally {
33
+ try {
34
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
35
+ }
36
+ finally { if (e_1) throw e_1.error; }
37
+ }
38
+ return result;
39
+ }
40
+ //# sourceMappingURL=omit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.js","sourceRoot":"","sources":["../../../src/object/omit.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,GAAG;;IAAE,cAAsB;SAAtB,UAAsB,EAAtB,qBAAsB,EAAtB,IAAsB;QAAtB,6BAAsB;;IAC9C,IAAM,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAM,MAAM,GAAG,EAAE,CAAC;;QAClB,KAAgB,IAAA,KAAA,SAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,gBAAA,4BAAE;YAA7B,IAAM,CAAC,WAAA;YACV,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBAClB,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;aACpB;SACF;;;;;;;;;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
File without changes
@@ -0,0 +1,10 @@
1
+ import { omit } from "./omit";
2
+ describe("omit", function () {
3
+ test("should return a copy of the object with the specified keys omitted", function () {
4
+ var obj = { a: "a", b: "b", c: "c" };
5
+ expect(omit(obj, "a", "c")).toEqual({ b: "b" });
6
+ // Check that it was a copy and original is not mutated
7
+ expect(obj).toEqual({ a: "a", b: "b", c: "c" });
8
+ });
9
+ });
10
+ //# sourceMappingURL=omit.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.spec.js","sourceRoot":"","sources":["../../../src/object/omit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAQ,CAAC,MAAM,EAAE;IACf,IAAI,CAAC,oEAAoE,EAAE;QACzE,IAAM,GAAG,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,uDAAuD;QACvD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
File without changes
@@ -0,0 +1,45 @@
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
+ import * as isEmptyImport from "lodash.isempty";
13
+ import { crumblePath } from "./crumble-path";
14
+ var isEmpty = isEmptyImport.default || isEmptyImport;
15
+ /** Set the value at `path` on `object`. */
16
+ export function setPath(object, path, newValue) {
17
+ var e_1, _a;
18
+ if (typeof object !== "object") {
19
+ throw new Error("object is required");
20
+ }
21
+ if (isEmpty(path)) {
22
+ throw new Error("path is required");
23
+ }
24
+ var crumbs = crumblePath(path);
25
+ var finalCrumb = crumbs.splice(crumbs.length - 1, 1)[0];
26
+ var current = object;
27
+ try {
28
+ for (var crumbs_1 = __values(crumbs), crumbs_1_1 = crumbs_1.next(); !crumbs_1_1.done; crumbs_1_1 = crumbs_1.next()) {
29
+ var crumb = crumbs_1_1.value;
30
+ current = current[crumb];
31
+ if (typeof current !== "object") {
32
+ throw new Error("Cannot set value at given path: Path deadends at ".concat(String(crumb)));
33
+ }
34
+ }
35
+ }
36
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
37
+ finally {
38
+ try {
39
+ if (crumbs_1_1 && !crumbs_1_1.done && (_a = crumbs_1.return)) _a.call(crumbs_1);
40
+ }
41
+ finally { if (e_1) throw e_1.error; }
42
+ }
43
+ current[finalCrumb] = newValue;
44
+ }
45
+ //# sourceMappingURL=set-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-path.js","sourceRoot":"","sources":["../../../src/object/set-path.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,IAAM,OAAO,GAAI,aAAqB,CAAC,OAAO,IAAI,aAAa,CAAC;AAEhE,2CAA2C;AAC3C,MAAM,UAAU,OAAO,CAAC,MAAW,EAAE,IAAiC,EAAE,QAAa;;IACnF,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;IAED,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IAED,IAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,IAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1D,IAAI,OAAO,GAAG,MAAM,CAAC;;QACrB,KAAoB,IAAA,WAAA,SAAA,MAAM,CAAA,8BAAA,kDAAE;YAAvB,IAAM,KAAK,mBAAA;YACd,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBAC/B,MAAM,IAAI,KAAK,CAAC,2DAAoD,MAAM,CAAC,KAAK,CAAC,CAAE,CAAC,CAAC;aACtF;SACF;;;;;;;;;IAED,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;AACjC,CAAC"}
File without changes
@@ -0,0 +1,36 @@
1
+ import { setPath } from "./set-path";
2
+ describe("setPath", function () {
3
+ test("sets the value at the given path", function () {
4
+ var obj = {
5
+ a: { b: { c: false } },
6
+ };
7
+ setPath(obj, "a.b.c", true);
8
+ expect(obj.a.b.c).toBe(true);
9
+ });
10
+ test("sets the value at the given path when an array is involved", function () {
11
+ var obj = {
12
+ a: {
13
+ b: {
14
+ c: [2,
15
+ 4,
16
+ 5],
17
+ },
18
+ },
19
+ };
20
+ setPath(obj, "a.b.c[2]", 6);
21
+ expect(obj.a.b.c[2]).toBe(6);
22
+ });
23
+ test("errors if object isn't provided", function () {
24
+ expect(function () { return setPath(undefined, "foo", "bar"); }).toThrow();
25
+ });
26
+ test("errors if path isn't provided", function () {
27
+ expect(function () { return setPath({}, undefined, "bar"); }).toThrow();
28
+ });
29
+ test("errors if path deadends", function () {
30
+ var obj = {
31
+ a: {},
32
+ };
33
+ expect(function () { return setPath(obj, "a.b.c", true); }).toThrow();
34
+ });
35
+ });
36
+ //# sourceMappingURL=set-path.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-path.spec.js","sourceRoot":"","sources":["../../../src/object/set-path.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,QAAQ,CAAC,SAAS,EAAE;IAClB,IAAI,CAAC,kCAAkC,EAAE;QACvC,IAAM,GAAG,GAAG;YACV,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;SACvB,CAAC;QACF,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4DAA4D,EAAE;QACjE,IAAM,GAAG,GAAG;YACV,CAAC,EAAE;gBACD,CAAC,EAAE;oBACD,CAAC,EAAE,CAAC,CAAC;wBACH,CAAC;wBACD,CAAC,CAAC;iBACL;aACF;SACF,CAAC;QACF,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iCAAiC,EAAE;QACtC,MAAM,CAAC,cAAM,OAAA,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,EAAhC,CAAgC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+BAA+B,EAAE;QACpC,MAAM,CAAC,cAAM,OAAA,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,EAA7B,CAA6B,CAAC,CAAC,OAAO,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yBAAyB,EAAE;QAC9B,IAAM,GAAG,GAAG;YACV,CAAC,EAAE,EAAE;SACN,CAAC;QAEF,MAAM,CAAC,cAAM,OAAA,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAA3B,CAA2B,CAAC,CAAC,OAAO,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
File without changes
@@ -0,0 +1,81 @@
1
+ var __generator = (this && this.__generator) || function (thisArg, body) {
2
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4
+ function verb(n) { return function (v) { return step([n, v]); }; }
5
+ function step(op) {
6
+ if (f) throw new TypeError("Generator is already executing.");
7
+ while (_) try {
8
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
9
+ if (y = 0, t) op = [op[0] & 2, t.value];
10
+ switch (op[0]) {
11
+ case 0: case 1: t = op; break;
12
+ case 4: _.label++; return { value: op[1], done: false };
13
+ case 5: _.label++; y = op[1]; op = [0]; continue;
14
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
15
+ default:
16
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
17
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
18
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
19
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
20
+ if (t[2]) _.ops.pop();
21
+ _.trys.pop(); continue;
22
+ }
23
+ op = body.call(thisArg, _);
24
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
25
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
26
+ }
27
+ };
28
+ var __values = (this && this.__values) || function(o) {
29
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
+ if (m) return m.call(o);
31
+ if (o && typeof o.length === "number") return {
32
+ next: function () {
33
+ if (o && i >= o.length) o = void 0;
34
+ return { value: o && o[i++], done: !o };
35
+ }
36
+ };
37
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
+ };
39
+ import { crumblePath } from "./crumble-path";
40
+ /** Generator for iterating down a path on an object. */
41
+ export function traversePath(object, path) {
42
+ var obj, _a, _b, crumb, e_1_1;
43
+ var e_1, _c;
44
+ return __generator(this, function (_d) {
45
+ switch (_d.label) {
46
+ case 0: return [4 /*yield*/, object];
47
+ case 1:
48
+ _d.sent();
49
+ obj = object;
50
+ _d.label = 2;
51
+ case 2:
52
+ _d.trys.push([2, 7, 8, 9]);
53
+ _a = __values(crumblePath(path)), _b = _a.next();
54
+ _d.label = 3;
55
+ case 3:
56
+ if (!!_b.done) return [3 /*break*/, 6];
57
+ crumb = _b.value;
58
+ obj = obj[crumb];
59
+ return [4 /*yield*/, obj];
60
+ case 4:
61
+ _d.sent();
62
+ _d.label = 5;
63
+ case 5:
64
+ _b = _a.next();
65
+ return [3 /*break*/, 3];
66
+ case 6: return [3 /*break*/, 9];
67
+ case 7:
68
+ e_1_1 = _d.sent();
69
+ e_1 = { error: e_1_1 };
70
+ return [3 /*break*/, 9];
71
+ case 8:
72
+ try {
73
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
74
+ }
75
+ finally { if (e_1) throw e_1.error; }
76
+ return [7 /*endfinally*/];
77
+ case 9: return [2 /*return*/];
78
+ }
79
+ });
80
+ }
81
+ //# sourceMappingURL=traverse-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traverse-path.js","sourceRoot":"","sources":["../../../src/object/traverse-path.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,wDAAwD;AACxD,MAAM,UAAW,YAAY,CAAC,MAAM,EAAE,IAAI;;;;;oBACxC,qBAAM,MAAM,EAAA;;gBAAZ,SAAY,CAAC;gBACT,GAAG,GAAG,MAAM,CAAC;;;;gBACG,KAAA,SAAA,WAAW,CAAC,IAAI,CAAC,CAAA;;;;gBAA1B,KAAK;gBACd,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;gBACjB,qBAAM,GAAG,EAAA;;gBAAT,SAAS,CAAC;;;;;;;;;;;;;;;;;;;CAEb"}
File without changes
@@ -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"}
File without changes
@@ -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,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 "".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
@@ -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,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"}
File without changes
@@ -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,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 (\"".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
@@ -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,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"}
File without changes
@@ -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