@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.
- package/dist/out-tsc/array/flatten.d.ts +1 -0
- package/dist/out-tsc/array/flatten.js +7 -0
- package/dist/out-tsc/array/flatten.js.map +1 -0
- package/dist/out-tsc/array/flatten.spec.d.ts +1 -0
- package/dist/out-tsc/array/flatten.spec.js +10 -0
- package/dist/out-tsc/array/flatten.spec.js.map +1 -0
- package/dist/out-tsc/array/index.d.ts +3 -0
- package/dist/out-tsc/array/index.js +4 -0
- package/dist/out-tsc/array/index.js.map +1 -0
- package/dist/out-tsc/array/is-subset.d.ts +4 -0
- package/dist/out-tsc/array/is-subset.js +41 -0
- package/dist/out-tsc/array/is-subset.js.map +1 -0
- package/dist/out-tsc/array/is-subset.spec.d.ts +1 -0
- package/dist/out-tsc/array/is-subset.spec.js +41 -0
- package/dist/out-tsc/array/is-subset.spec.js.map +1 -0
- package/dist/out-tsc/array/range.d.ts +5 -0
- package/dist/out-tsc/array/range.js +16 -0
- package/dist/out-tsc/array/range.js.map +1 -0
- package/dist/out-tsc/array/range.spec.d.ts +1 -0
- package/dist/out-tsc/array/range.spec.js +26 -0
- package/dist/out-tsc/array/range.spec.js.map +1 -0
- package/dist/out-tsc/classes/custom-event.d.ts +4 -0
- package/dist/out-tsc/classes/custom-event.js +87 -0
- package/dist/out-tsc/classes/custom-event.js.map +1 -0
- package/dist/out-tsc/classes/index.d.ts +1 -0
- package/dist/out-tsc/classes/index.js +2 -0
- package/dist/out-tsc/classes/index.js.map +1 -0
- package/dist/out-tsc/data/doctypes.d.ts +4 -0
- package/dist/out-tsc/data/doctypes.js +302 -0
- package/dist/out-tsc/data/doctypes.js.map +1 -0
- package/dist/out-tsc/data/index.d.ts +1 -0
- package/dist/out-tsc/data/index.js +2 -0
- package/dist/out-tsc/data/index.js.map +1 -0
- package/dist/out-tsc/decorators/cast-to-number.d.ts +5 -0
- package/dist/out-tsc/decorators/cast-to-number.js +29 -0
- package/dist/out-tsc/decorators/cast-to-number.js.map +1 -0
- package/dist/out-tsc/decorators/debounced.broken_spec.d.ts +0 -0
- package/dist/out-tsc/decorators/debounced.broken_spec.js +38 -0
- package/dist/out-tsc/decorators/debounced.broken_spec.js.map +1 -0
- package/dist/out-tsc/decorators/debounced.d.ts +11 -0
- package/dist/out-tsc/decorators/debounced.js +35 -0
- package/dist/out-tsc/decorators/debounced.js.map +1 -0
- package/dist/out-tsc/decorators/index.d.ts +5 -0
- package/dist/out-tsc/decorators/index.js +6 -0
- package/dist/out-tsc/decorators/index.js.map +1 -0
- package/dist/out-tsc/decorators/locked-to-animation-frames.d.ts +4 -0
- package/dist/out-tsc/decorators/locked-to-animation-frames.js +34 -0
- package/dist/out-tsc/decorators/locked-to-animation-frames.js.map +1 -0
- package/dist/out-tsc/decorators/locked-to-animation-frames.spec.d.ts +0 -0
- package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js +63 -0
- package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js.map +1 -0
- package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.d.ts +11 -0
- package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js +80 -0
- package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js.map +1 -0
- package/dist/out-tsc/decorators/tick-delay.d.ts +6 -0
- package/dist/out-tsc/decorators/tick-delay.js +31 -0
- package/dist/out-tsc/decorators/tick-delay.js.map +1 -0
- package/dist/out-tsc/function/debounce.d.ts +9 -0
- package/dist/out-tsc/function/debounce.js +102 -0
- package/dist/out-tsc/function/debounce.js.map +1 -0
- package/dist/out-tsc/function/debounce.spec.d.ts +1 -0
- package/dist/out-tsc/function/debounce.spec.js +150 -0
- package/dist/out-tsc/function/debounce.spec.js.map +1 -0
- package/dist/out-tsc/function/debounced-function.interface.d.ts +10 -0
- package/dist/out-tsc/function/debounced-function.interface.js +2 -0
- package/dist/out-tsc/function/debounced-function.interface.js.map +1 -0
- package/dist/out-tsc/function/delayed-function.interface.d.ts +10 -0
- package/dist/out-tsc/function/delayed-function.interface.js +2 -0
- package/dist/out-tsc/function/delayed-function.interface.js.map +1 -0
- package/dist/out-tsc/function/index.d.ts +6 -0
- package/dist/out-tsc/function/index.js +7 -0
- package/dist/out-tsc/function/index.js.map +1 -0
- package/dist/out-tsc/function/lock-to-animation-frames.d.ts +7 -0
- package/dist/out-tsc/function/lock-to-animation-frames.js +43 -0
- package/dist/out-tsc/function/lock-to-animation-frames.js.map +1 -0
- package/dist/out-tsc/function/lock-to-animation-frames.spec.d.ts +0 -0
- package/dist/out-tsc/function/lock-to-animation-frames.spec.js +53 -0
- package/dist/out-tsc/function/lock-to-animation-frames.spec.js.map +1 -0
- package/dist/out-tsc/function/on-next-tick.d.ts +8 -0
- package/dist/out-tsc/function/on-next-tick.js +12 -0
- package/dist/out-tsc/function/on-next-tick.js.map +1 -0
- package/dist/out-tsc/function/on-next-tick.spec.d.ts +1 -0
- package/dist/out-tsc/function/on-next-tick.spec.js +13 -0
- package/dist/out-tsc/function/on-next-tick.spec.js.map +1 -0
- package/dist/out-tsc/function/op.d.ts +32 -0
- package/dist/out-tsc/function/op.js +34 -0
- package/dist/out-tsc/function/op.js.map +1 -0
- package/dist/out-tsc/function/op.spec.d.ts +1 -0
- package/dist/out-tsc/function/op.spec.js +94 -0
- package/dist/out-tsc/function/op.spec.js.map +1 -0
- package/dist/out-tsc/index.d.ts +9 -0
- package/dist/out-tsc/index.js +10 -0
- package/dist/out-tsc/index.js.map +1 -0
- package/dist/out-tsc/number/constrain.d.ts +7 -0
- package/dist/out-tsc/number/constrain.js +16 -0
- package/dist/out-tsc/number/constrain.js.map +1 -0
- package/dist/out-tsc/number/decimal-round.d.ts +7 -0
- package/dist/out-tsc/number/decimal-round.js +19 -0
- package/dist/out-tsc/number/decimal-round.js.map +1 -0
- package/dist/out-tsc/number/decimal-round.spec.d.ts +1 -0
- package/dist/out-tsc/number/decimal-round.spec.js +10 -0
- package/dist/out-tsc/number/decimal-round.spec.js.map +1 -0
- package/dist/out-tsc/number/index.d.ts +3 -0
- package/dist/out-tsc/number/index.js +4 -0
- package/dist/out-tsc/number/index.js.map +1 -0
- package/dist/out-tsc/number/to-file-size-string.d.ts +5 -0
- package/dist/out-tsc/number/to-file-size-string.js +24 -0
- package/dist/out-tsc/number/to-file-size-string.js.map +1 -0
- package/dist/out-tsc/object/copy-property.d.ts +6 -0
- package/dist/out-tsc/object/copy-property.js +9 -0
- package/dist/out-tsc/object/copy-property.js.map +1 -0
- package/dist/out-tsc/object/copy-property.spec.d.ts +1 -0
- package/dist/out-tsc/object/copy-property.spec.js +16 -0
- package/dist/out-tsc/object/copy-property.spec.js.map +1 -0
- package/dist/out-tsc/object/crumble-path.d.ts +6 -0
- package/dist/out-tsc/object/crumble-path.js +9 -0
- package/dist/out-tsc/object/crumble-path.js.map +1 -0
- package/dist/out-tsc/object/crumble-path.spec.d.ts +1 -0
- package/dist/out-tsc/object/crumble-path.spec.js +24 -0
- package/dist/out-tsc/object/crumble-path.spec.js.map +1 -0
- package/dist/out-tsc/object/deep-freeze.d.ts +1 -0
- package/dist/out-tsc/object/deep-freeze.js +36 -0
- package/dist/out-tsc/object/deep-freeze.js.map +1 -0
- package/dist/out-tsc/object/deep-freeze.spec.d.ts +1 -0
- package/dist/out-tsc/object/deep-freeze.spec.js +14 -0
- package/dist/out-tsc/object/deep-freeze.spec.js.map +1 -0
- package/dist/out-tsc/object/diff.d.ts +12 -0
- package/dist/out-tsc/object/diff.js +92 -0
- package/dist/out-tsc/object/diff.js.map +1 -0
- package/dist/out-tsc/object/diff.spec.d.ts +1 -0
- package/dist/out-tsc/object/diff.spec.js +40 -0
- package/dist/out-tsc/object/diff.spec.js.map +1 -0
- package/dist/out-tsc/object/for-each-entry-deep.d.ts +4 -0
- package/dist/out-tsc/object/for-each-entry-deep.js +38 -0
- package/dist/out-tsc/object/for-each-entry-deep.js.map +1 -0
- package/dist/out-tsc/object/for-each-entry-deep.spec.d.ts +1 -0
- package/dist/out-tsc/object/for-each-entry-deep.spec.js +24 -0
- package/dist/out-tsc/object/for-each-entry-deep.spec.js.map +1 -0
- package/dist/out-tsc/object/for-each-nested-object.d.ts +4 -0
- package/dist/out-tsc/object/for-each-nested-object.js +38 -0
- package/dist/out-tsc/object/for-each-nested-object.js.map +1 -0
- package/dist/out-tsc/object/for-each-nested-object.spec.d.ts +1 -0
- package/dist/out-tsc/object/for-each-nested-object.spec.js +46 -0
- package/dist/out-tsc/object/for-each-nested-object.spec.js.map +1 -0
- package/dist/out-tsc/object/get-path.d.ts +5 -0
- package/dist/out-tsc/object/get-path.js +67 -0
- package/dist/out-tsc/object/get-path.js.map +1 -0
- package/dist/out-tsc/object/get-path.spec.d.ts +1 -0
- package/dist/out-tsc/object/get-path.spec.js +44 -0
- package/dist/out-tsc/object/get-path.spec.js.map +1 -0
- package/dist/out-tsc/object/index.d.ts +13 -0
- package/dist/out-tsc/object/index.js +14 -0
- package/dist/out-tsc/object/index.js.map +1 -0
- package/dist/out-tsc/object/merge-deep.d.ts +4 -0
- package/dist/out-tsc/object/merge-deep.js +60 -0
- package/dist/out-tsc/object/merge-deep.js.map +1 -0
- package/dist/out-tsc/object/merge-deep.spec.d.ts +1 -0
- package/dist/out-tsc/object/merge-deep.spec.js +16 -0
- package/dist/out-tsc/object/merge-deep.spec.js.map +1 -0
- package/dist/out-tsc/object/merge-properties-deep.d.ts +4 -0
- package/dist/out-tsc/object/merge-properties-deep.js +61 -0
- package/dist/out-tsc/object/merge-properties-deep.js.map +1 -0
- package/dist/out-tsc/object/merge-properties-deep.spec.d.ts +1 -0
- package/dist/out-tsc/object/merge-properties-deep.spec.js +24 -0
- package/dist/out-tsc/object/merge-properties-deep.spec.js.map +1 -0
- package/dist/out-tsc/object/omit.d.ts +1 -0
- package/dist/out-tsc/object/omit.js +40 -0
- package/dist/out-tsc/object/omit.js.map +1 -0
- package/dist/out-tsc/object/omit.spec.d.ts +1 -0
- package/dist/out-tsc/object/omit.spec.js +10 -0
- package/dist/out-tsc/object/omit.spec.js.map +1 -0
- package/dist/out-tsc/object/set-path.d.ts +2 -0
- package/dist/out-tsc/object/set-path.js +45 -0
- package/dist/out-tsc/object/set-path.js.map +1 -0
- package/dist/out-tsc/object/set-path.spec.d.ts +1 -0
- package/dist/out-tsc/object/set-path.spec.js +36 -0
- package/dist/out-tsc/object/set-path.spec.js.map +1 -0
- package/dist/out-tsc/object/traverse-path.d.ts +2 -0
- package/dist/out-tsc/object/traverse-path.js +81 -0
- package/dist/out-tsc/object/traverse-path.js.map +1 -0
- package/dist/out-tsc/object/values.d.ts +2 -0
- package/dist/out-tsc/object/values.js +31 -0
- package/dist/out-tsc/object/values.js.map +1 -0
- package/dist/out-tsc/object/values.spec.d.ts +1 -0
- package/dist/out-tsc/object/values.spec.js +7 -0
- package/dist/out-tsc/object/values.spec.js.map +1 -0
- package/dist/out-tsc/string/code.template-tag.d.ts +2 -0
- package/dist/out-tsc/string/code.template-tag.js +38 -0
- package/dist/out-tsc/string/code.template-tag.js.map +1 -0
- package/dist/out-tsc/string/index.d.ts +3 -0
- package/dist/out-tsc/string/index.js +4 -0
- package/dist/out-tsc/string/index.js.map +1 -0
- package/dist/out-tsc/string/parse-file-size.d.ts +5 -0
- package/dist/out-tsc/string/parse-file-size.js +43 -0
- package/dist/out-tsc/string/parse-file-size.js.map +1 -0
- package/dist/out-tsc/string/template.d.ts +15 -0
- package/dist/out-tsc/string/template.js +28 -0
- package/dist/out-tsc/string/template.js.map +1 -0
- package/dist/out-tsc/string/template.spec.d.ts +1 -0
- package/dist/out-tsc/string/template.spec.js +39 -0
- package/dist/out-tsc/string/template.spec.js.map +1 -0
- package/dist/out-tsc/typings.d.ts +1 -0
- package/dist/out-tsc/typings.js +2 -0
- package/dist/out-tsc/typings.js.map +1 -0
- package/lib/index.cjs.js +2437 -1
- package/lib/index.es.js +2268 -893
- package/package.json +5 -5
- package/rollup.config.js +22 -0
- 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 @@
|
|
|
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 "" + 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 @@
|
|
|
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 (\"" + 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 @@
|
|
|
1
|
+
{"version":3,"file":"typings.js","sourceRoot":"","sources":["../../src/typings.ts"],"names":[],"mappings":""}
|