@dereekb/util 4.0.1 → 5.0.1
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/CHANGELOG.md +40 -0
- package/LICENSE +21 -0
- package/package.json +6 -2
- package/src/lib/array/array.boolean.d.ts +3 -3
- package/src/lib/array/array.boolean.js +4 -4
- package/src/lib/array/array.boolean.js.map +1 -1
- package/src/lib/array/array.d.ts +3 -3
- package/src/lib/array/array.filter.js +1 -1
- package/src/lib/array/array.filter.js.map +1 -1
- package/src/lib/array/array.index.d.ts +1 -1
- package/src/lib/array/array.index.js +2 -2
- package/src/lib/array/array.index.js.map +1 -1
- package/src/lib/array/array.js +3 -3
- package/src/lib/array/array.js.map +1 -1
- package/src/lib/array/array.limit.d.ts +3 -3
- package/src/lib/array/array.make.d.ts +1 -1
- package/src/lib/array/array.make.js +2 -2
- package/src/lib/array/array.make.js.map +1 -1
- package/src/lib/array/array.map.d.ts +2 -2
- package/src/lib/array/array.map.js +3 -3
- package/src/lib/array/array.map.js.map +1 -1
- package/src/lib/array/array.number.d.ts +3 -3
- package/src/lib/array/array.number.js +1 -1
- package/src/lib/array/array.number.js.map +1 -1
- package/src/lib/array/array.string.d.ts +1 -1
- package/src/lib/array/array.string.js +1 -1
- package/src/lib/array/array.string.js.map +1 -1
- package/src/lib/array/array.unique.d.ts +3 -3
- package/src/lib/array/array.unique.js.map +1 -1
- package/src/lib/array/array.value.d.ts +1 -1
- package/src/lib/array/array.value.js +2 -2
- package/src/lib/array/array.value.js.map +1 -1
- package/src/lib/assertion/assert.error.d.ts +1 -1
- package/src/lib/assertion/assert.error.js +1 -1
- package/src/lib/assertion/assert.error.js.map +1 -1
- package/src/lib/assertion/assertion.d.ts +2 -2
- package/src/lib/assertion/assertion.generic.d.ts +2 -2
- package/src/lib/assertion/assertion.js.map +1 -1
- package/src/lib/assertion/assertion.number.d.ts +1 -1
- package/src/lib/assertion/assertion.number.js.map +1 -1
- package/src/lib/auth/auth.role.claims.d.ts +43 -24
- package/src/lib/auth/auth.role.claims.js +18 -7
- package/src/lib/auth/auth.role.claims.js.map +1 -1
- package/src/lib/auth/auth.role.d.ts +1 -1
- package/src/lib/auth/auth.role.js.map +1 -1
- package/src/lib/boolean.d.ts +1 -1
- package/src/lib/boolean.js +1 -1
- package/src/lib/boolean.js.map +1 -1
- package/src/lib/contact/domain.d.ts +1 -1
- package/src/lib/contact/domain.js.map +1 -1
- package/src/lib/contact/email.d.ts +1 -2
- package/src/lib/contact/email.js +2 -2
- package/src/lib/contact/email.js.map +1 -1
- package/src/lib/date/date.d.ts +1 -1
- package/src/lib/date/date.js +1 -1
- package/src/lib/date/date.js.map +1 -1
- package/src/lib/date/date.time.d.ts +1 -1
- package/src/lib/error/error.d.ts +7 -3
- package/src/lib/error/error.js +8 -6
- package/src/lib/error/error.js.map +1 -1
- package/src/lib/error/error.server.d.ts +2 -2
- package/src/lib/error/error.server.js.map +1 -1
- package/src/lib/filter/filter.d.ts +3 -3
- package/src/lib/filter/filter.js +3 -3
- package/src/lib/filter/filter.js.map +1 -1
- package/src/lib/function/function.d.ts +7 -0
- package/src/lib/function/function.forward.d.ts +3 -3
- package/src/lib/function/function.forward.js +2 -0
- package/src/lib/function/function.forward.js.map +1 -1
- package/src/lib/function/function.js +14 -0
- package/src/lib/function/function.js.map +1 -0
- package/src/lib/function/index.d.ts +1 -0
- package/src/lib/function/index.js +1 -0
- package/src/lib/function/index.js.map +1 -1
- package/src/lib/getter/getter.cache.d.ts +3 -3
- package/src/lib/getter/getter.cache.js +2 -2
- package/src/lib/getter/getter.cache.js.map +1 -1
- package/src/lib/getter/getter.d.ts +5 -5
- package/src/lib/getter/getter.js +1 -1
- package/src/lib/getter/getter.js.map +1 -1
- package/src/lib/getter/getter.map.d.ts +2 -2
- package/src/lib/grouping.d.ts +2 -2
- package/src/lib/grouping.js +7 -7
- package/src/lib/grouping.js.map +1 -1
- package/src/lib/hash.js +2 -2
- package/src/lib/hash.js.map +1 -1
- package/src/lib/index.d.ts +1 -0
- package/src/lib/index.js +1 -0
- package/src/lib/index.js.map +1 -1
- package/src/lib/iterable/iterable.d.ts +2 -2
- package/src/lib/iterable/iterable.js +1 -1
- package/src/lib/iterable/iterable.js.map +1 -1
- package/src/lib/iterate.js.map +1 -1
- package/src/lib/key.d.ts +1 -1
- package/src/lib/map/map.d.ts +11 -3
- package/src/lib/map/map.js +15 -1
- package/src/lib/map/map.js.map +1 -1
- package/src/lib/misc/host.d.ts +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/model.conversion.d.ts +77 -50
- package/src/lib/model/model.conversion.field.d.ts +8 -0
- package/src/lib/model/model.conversion.field.js +23 -0
- package/src/lib/model/model.conversion.field.js.map +1 -0
- package/src/lib/model/model.conversion.js +45 -30
- package/src/lib/model/model.conversion.js.map +1 -1
- package/src/lib/model/model.copy.d.ts +4 -4
- package/src/lib/model/model.copy.js.map +1 -1
- package/src/lib/model/model.d.ts +1 -1
- package/src/lib/model/model.js +4 -4
- package/src/lib/model/model.js.map +1 -1
- package/src/lib/number/random.js +2 -2
- package/src/lib/number/random.js.map +1 -1
- package/src/lib/number/round.js.map +1 -1
- package/src/lib/object/object.array.d.ts +1 -1
- package/src/lib/object/object.array.js +1 -1
- package/src/lib/object/object.array.js.map +1 -1
- package/src/lib/object/object.d.ts +13 -9
- package/src/lib/object/object.js +13 -13
- package/src/lib/object/object.js.map +1 -1
- package/src/lib/object/object.map.d.ts +5 -5
- package/src/lib/object/object.map.js +1 -1
- package/src/lib/object/object.map.js.map +1 -1
- package/src/lib/page/page.calculator.d.ts +1 -1
- package/src/lib/page/page.calculator.js.map +1 -1
- package/src/lib/page/page.d.ts +1 -1
- package/src/lib/page/page.filter.d.ts +3 -3
- package/src/lib/page/page.filter.js.map +1 -1
- package/src/lib/page/page.js +1 -1
- package/src/lib/page/page.js.map +1 -1
- package/src/lib/promise/is.js +1 -1
- package/src/lib/promise/is.js.map +1 -1
- package/src/lib/promise/map.d.ts +1 -1
- package/src/lib/promise/poll.js +1 -1
- package/src/lib/promise/poll.js.map +1 -1
- package/src/lib/promise/promise.d.ts +8 -8
- package/src/lib/promise/promise.js +12 -13
- package/src/lib/promise/promise.js.map +1 -1
- package/src/lib/promise/promise.loop.d.ts +1 -1
- package/src/lib/promise/promise.loop.js +19 -21
- package/src/lib/promise/promise.loop.js.map +1 -1
- package/src/lib/promise/promise.ref.d.ts +3 -3
- package/src/lib/promise/promise.ref.js +2 -2
- package/src/lib/promise/promise.ref.js.map +1 -1
- package/src/lib/promise/wait.js +1 -1
- package/src/lib/promise/wait.js.map +1 -1
- package/src/lib/relation/relation.js +1 -2
- package/src/lib/relation/relation.js.map +1 -1
- package/src/lib/service/handler.config.d.ts +48 -0
- package/src/lib/service/handler.config.js +61 -0
- package/src/lib/service/handler.config.js.map +1 -0
- package/src/lib/service/handler.d.ts +47 -0
- package/src/lib/service/handler.js +54 -0
- package/src/lib/service/handler.js.map +1 -0
- package/src/lib/service/index.d.ts +2 -0
- package/src/lib/service/index.js +6 -0
- package/src/lib/service/index.js.map +1 -0
- package/src/lib/set/set.allowed.d.ts +1 -1
- package/src/lib/set/set.hashset.d.ts +3 -3
- package/src/lib/set/set.hashset.js +4 -4
- package/src/lib/set/set.hashset.js.map +1 -1
- package/src/lib/set/set.js +3 -3
- package/src/lib/set/set.js.map +1 -1
- package/src/lib/set/set.maybe.d.ts +1 -1
- package/src/lib/sort.js +1 -1
- package/src/lib/sort.js.map +1 -1
- package/src/lib/storage/storage.error.js +6 -2
- package/src/lib/storage/storage.error.js.map +1 -1
- package/src/lib/storage/storage.memory.d.ts +1 -1
- package/src/lib/storage/storage.memory.js +2 -1
- package/src/lib/storage/storage.memory.js.map +1 -1
- package/src/lib/storage/storage.object.js +3 -1
- package/src/lib/storage/storage.object.js.map +1 -1
- package/src/lib/string.d.ts +7 -4
- package/src/lib/string.js +2 -2
- package/src/lib/string.js.map +1 -1
- package/src/lib/tree/tree.array.d.ts +2 -2
- package/src/lib/tree/tree.array.js +2 -0
- package/src/lib/tree/tree.array.js.map +1 -1
- package/src/lib/tree/tree.expand.d.ts +2 -2
- package/src/lib/tree/tree.expand.js +4 -3
- package/src/lib/tree/tree.expand.js.map +1 -1
- package/src/lib/tree/tree.flatten.d.ts +7 -7
- package/src/lib/tree/tree.flatten.js.map +1 -1
- package/src/lib/tree/tree.js +2 -0
- package/src/lib/tree/tree.js.map +1 -1
- package/src/lib/type.d.ts +31 -5
- package/src/lib/value/build.d.ts +18 -0
- package/src/lib/value/build.js +16 -0
- package/src/lib/value/build.js.map +1 -0
- package/src/lib/value/equal.d.ts +3 -3
- package/src/lib/value/equal.js +1 -1
- package/src/lib/value/equal.js.map +1 -1
- package/src/lib/value/index.d.ts +1 -0
- package/src/lib/value/index.js +1 -0
- package/src/lib/value/index.js.map +1 -1
- package/src/lib/value/map.d.ts +25 -1
- package/src/lib/value/map.js +39 -0
- package/src/lib/value/map.js.map +1 -1
- package/src/lib/value/maybe.d.ts +12 -13
- package/src/lib/value/maybe.js +3 -13
- package/src/lib/value/maybe.js.map +1 -1
- package/src/lib/value/modifier.d.ts +2 -2
- package/src/lib/value/modifier.js.map +1 -1
- package/test/CHANGELOG.md +12 -0
- package/test/package.json +2 -3
- package/test/src/lib/jest.function.d.ts +1 -1
- package/test/src/lib/jest.js.map +1 -1
- package/test/src/lib/jest.wrap.d.ts +1 -1
- package/test/src/lib/jest.wrap.js.map +1 -1
- package/src/lib/context/context.d.ts +0 -1
- package/src/lib/context/context.js +0 -6
- package/src/lib/context/context.js.map +0 -1
- package/src/lib/context/index.d.ts +0 -0
- package/src/lib/context/index.js +0 -2
- package/src/lib/context/index.js.map +0 -1
package/src/lib/sort.js
CHANGED
|
@@ -14,7 +14,7 @@ exports.reverseCompareFn = reverseCompareFn;
|
|
|
14
14
|
* The input comparison function must be in ascending order.
|
|
15
15
|
*/
|
|
16
16
|
function compareFnOrder(ascendingCompareFn, order = 'asc') {
|
|
17
|
-
return
|
|
17
|
+
return order === 'asc' ? ascendingCompareFn : reverseCompareFn(ascendingCompareFn);
|
|
18
18
|
}
|
|
19
19
|
exports.compareFnOrder = compareFnOrder;
|
|
20
20
|
//# sourceMappingURL=sort.js.map
|
package/src/lib/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/sort.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/sort.ts"],"names":[],"mappings":";;;AAEa,QAAA,oBAAoB,GAAyB,CAAC,CAAC,CAAC;AAChD,QAAA,uBAAuB,GAAyB,CAAC,CAAC;AAClD,QAAA,gBAAgB,GAAyB,CAAC,CAAC;AAsCxD,SAAgB,gBAAgB,CAAI,SAAiC;IACnE,OAAO,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AAFD,4CAEC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAI,kBAAmD,EAAE,QAAsB,KAAK;IAChH,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;AACrF,CAAC;AAFD,wCAEC"}
|
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataIsExpiredError = exports.DataDoesNotExistError = exports.StoredDataError = void 0;
|
|
4
4
|
const make_error_1 = require("make-error");
|
|
5
5
|
class StoredDataError extends make_error_1.BaseError {
|
|
6
|
-
constructor(message) {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
exports.StoredDataError = StoredDataError;
|
|
9
11
|
class DataDoesNotExistError extends StoredDataError {
|
|
10
|
-
constructor(message) {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
exports.DataDoesNotExistError = DataDoesNotExistError;
|
|
13
17
|
class DataIsExpiredError extends StoredDataError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.error.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/storage/storage.error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAGvC,MAAa,eAAgB,SAAQ,sBAAS;
|
|
1
|
+
{"version":3,"file":"storage.error.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/storage/storage.error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAGvC,MAAa,eAAgB,SAAQ,sBAAS;IAC5C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,0CAIC;AAED,MAAa,qBAAsB,SAAQ,eAAe;IACxD,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,sDAIC;AAED,MAAa,kBAAsB,SAAQ,eAAe;IACxD,YAA4B,IAAuB,EAAE,OAAgB;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAmB;IAEnD,CAAC;CACF;AAJD,gDAIC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SHARED_MEMORY_STORAGE = exports.MemoryStorageInstance = void 0;
|
|
4
|
+
const object_1 = require("../object/object");
|
|
4
5
|
class MemoryStorageInstance {
|
|
5
6
|
constructor() {
|
|
6
7
|
this._length = 0;
|
|
@@ -14,7 +15,7 @@ class MemoryStorageInstance {
|
|
|
14
15
|
return (_a = Object.keys(this._storage)[index]) !== null && _a !== void 0 ? _a : null;
|
|
15
16
|
}
|
|
16
17
|
hasKey(key) {
|
|
17
|
-
return this._storage
|
|
18
|
+
return (0, object_1.objectHasKey)(this._storage, key);
|
|
18
19
|
}
|
|
19
20
|
getItem(key) {
|
|
20
21
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.memory.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/storage/storage.memory.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"storage.memory.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/storage/storage.memory.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAIhD,MAAa,qBAAqB;IAAlC;QACU,YAAO,GAAG,CAAC,CAAC;QACZ,aAAQ,GAA8B,EAAE,CAAC;IAyCnD,CAAC;IAvCC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,KAAa;;QACf,OAAO,MAAA,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,mCAAI,IAAI,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAA,qBAAY,EAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,GAAW;;QACjB,OAAO,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,mCAAI,IAAI,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,IAAmB;QACtC,IAAI,IAAI,IAAI,IAAI,EAAE;YAChB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;aACjC;YAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;SACnC;IACH,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,sBAAsB;YACjD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;CACF;AA3CD,sDA2CC;AAEY,QAAA,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC"}
|
|
@@ -24,7 +24,9 @@ class StorageObjectUtility {
|
|
|
24
24
|
const length = storageObject.length;
|
|
25
25
|
let result;
|
|
26
26
|
if (length > 0) {
|
|
27
|
-
result = (0, array_1.range)({ start: 0, end: length })
|
|
27
|
+
result = (0, array_1.range)({ start: 0, end: length })
|
|
28
|
+
.map((x) => storageObject.key(x))
|
|
29
|
+
.filter(array_1.filterMaybeValuesFn);
|
|
28
30
|
if (prefix) {
|
|
29
31
|
result = result.filter((x) => x.startsWith(prefix));
|
|
30
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.object.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/storage/storage.object.ts"],"names":[],"mappings":";;;AACA,oCAAsD;AAGtD;;GAEG;AACH,MAAsB,mBAAmB;
|
|
1
|
+
{"version":3,"file":"storage.object.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/storage/storage.object.ts"],"names":[],"mappings":";;;AACA,oCAAsD;AAGtD;;GAEG;AACH,MAAsB,mBAAmB;CAMxC;AAND,kDAMC;AAED;;;;GAIG;AACH,MAAsB,aAAc,SAAQ,mBAAmB;CAS9D;AATD,sCASC;AAED,MAAsB,iBAAkB,SAAQ,aAAa;CAM5D;AAND,8CAMC;AAED,MAAa,oBAAoB;IAC/B,MAAM,CAAC,wBAAwB,CAAC,aAA4B,EAAE,MAAe;QAC3E,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;QACpC,IAAI,MAA8B,CAAC;QAEnC,IAAI,MAAM,GAAG,CAAC,EAAE;YACd,MAAM,GAAG,IAAA,aAAK,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;iBACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAChC,MAAM,CAAC,2BAAmB,CAAC,CAAC;YAE/B,IAAI,MAAM,EAAE;gBACV,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;aACrD;SACF;aAAM;YACL,MAAM,GAAG,EAAE,CAAC;SACb;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnBD,oDAmBC"}
|
package/src/lib/string.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Maybe } from
|
|
1
|
+
import { MapFunction } from './value/map';
|
|
2
|
+
import { Maybe } from './value/maybe';
|
|
3
|
+
export declare type MapStringFunction<T> = MapFunction<string, T>;
|
|
3
4
|
/**
|
|
4
5
|
* Represents a string that is made up of comma-separated values.
|
|
5
6
|
*
|
|
7
|
+
* Optional generic typing exists for communicating what values are separated within the string.
|
|
8
|
+
*
|
|
6
9
|
* I.E. 0,1,2
|
|
7
10
|
*/
|
|
8
|
-
export declare type CommaSeparatedString<T =
|
|
11
|
+
export declare type CommaSeparatedString<T = unknown> = string;
|
|
9
12
|
export declare function caseInsensitiveString(input: string): string;
|
|
10
13
|
export declare function caseInsensitiveString(input: undefined): undefined;
|
|
11
14
|
export declare function caseInsensitiveString(input: Maybe<string>): Maybe<string>;
|
|
12
15
|
export declare function splitCommaSeparatedString(input: CommaSeparatedString<string>): string[];
|
|
13
|
-
export declare function splitCommaSeparatedString<T =
|
|
16
|
+
export declare function splitCommaSeparatedString<T = unknown>(input: CommaSeparatedString<T>, mapFn: MapStringFunction<T>): T[];
|
|
14
17
|
export declare function splitCommaSeparatedStringToSet(input: Maybe<CommaSeparatedString>): Set<string>;
|
|
15
18
|
/**
|
|
16
19
|
* Adds a plus prefix to the input value and converts it to a string. If the value is negative or 0, no prefix is added.
|
package/src/lib/string.js
CHANGED
|
@@ -7,7 +7,7 @@ function caseInsensitiveString(input) {
|
|
|
7
7
|
exports.caseInsensitiveString = caseInsensitiveString;
|
|
8
8
|
function splitCommaSeparatedString(input, mapFn = (x) => x) {
|
|
9
9
|
const splits = input.split(',');
|
|
10
|
-
return splits.map(x => mapFn(x.trim()));
|
|
10
|
+
return splits.map((x) => mapFn(x.trim()));
|
|
11
11
|
}
|
|
12
12
|
exports.splitCommaSeparatedString = splitCommaSeparatedString;
|
|
13
13
|
function splitCommaSeparatedStringToSet(input) {
|
|
@@ -21,7 +21,7 @@ exports.splitCommaSeparatedStringToSet = splitCommaSeparatedStringToSet;
|
|
|
21
21
|
*/
|
|
22
22
|
function addPlusPrefixToNumber(value, prefix = '+') {
|
|
23
23
|
if (value != null) {
|
|
24
|
-
return
|
|
24
|
+
return value > 0 ? `${prefix}${value}` : `${value}`;
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
return undefined;
|
package/src/lib/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/string.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/string.ts"],"names":[],"mappings":";;;AAkBA,SAAgB,qBAAqB,CAAC,KAAoB;IACxD,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB,EAAE,CAAC;AACpC,CAAC;AAFD,sDAEC;AAID,SAAgB,yBAAyB,CAAc,KAA8B,EAAE,QAA8B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAiB;IAC3I,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC;AAHD,8DAGC;AAED,SAAgB,8BAA8B,CAAC,KAAkC;IAC/E,OAAO,IAAI,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC;AAFD,wEAEC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,KAAqB,EAAE,MAAM,GAAG,GAAG;IACvE,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;KACrD;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAND,sDAMC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAFD,sDAEC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TreeNode } from
|
|
2
|
-
import { ExpandTreeFunction } from
|
|
1
|
+
import { TreeNode } from './tree';
|
|
2
|
+
import { ExpandTreeFunction } from './tree.expand';
|
|
3
3
|
import { FlattenTreeFunction } from './tree.flatten';
|
|
4
4
|
/**
|
|
5
5
|
* Function that expands the input values into a tree, and then flattens the tree to produce a single array of values of another type.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*eslint @typescript-eslint/no-explicit-any:"off"*/
|
|
3
|
+
// any is used with intent here, as the recursive TreeNode value requires its use to terminate.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.expandFlattenTreeFunction = void 0;
|
|
4
6
|
const tree_expand_1 = require("./tree.expand");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.array.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.array.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"tree.array.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.array.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,+FAA+F;;;AAG/F,+CAAgE;AAChE,iDAAmE;AAOnE;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAoD,MAAgC,EAAE,OAAkC;IAC/J,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,IAAA,2BAAY,EAAC,IAAA,yBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AAJD,8DAIC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*eslint @typescript-eslint/no-explicit-any:"off"*/
|
|
3
|
+
// any is used with intent here, as the recursive TreeNode value requires its use to terminate.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.expandTrees = exports.expandTreeFunction = void 0;
|
|
4
|
-
;
|
|
5
6
|
function expandTreeFunction(config) {
|
|
6
7
|
var _a;
|
|
7
8
|
const makeNode = (_a = config.makeNode) !== null && _a !== void 0 ? _a : ((node) => node);
|
|
8
9
|
const expandFn = (value, parent) => {
|
|
9
|
-
const depth =
|
|
10
|
+
const depth = parent ? parent.depth + 1 : 0;
|
|
10
11
|
const treeNode = {
|
|
11
12
|
depth,
|
|
12
13
|
parent,
|
|
@@ -14,7 +15,7 @@ function expandTreeFunction(config) {
|
|
|
14
15
|
};
|
|
15
16
|
const node = makeNode(treeNode);
|
|
16
17
|
const childrenValues = config.getChildren(value);
|
|
17
|
-
node.children =
|
|
18
|
+
node.children = childrenValues ? childrenValues.map((x) => expandFn(x, node)) : undefined;
|
|
18
19
|
return node;
|
|
19
20
|
};
|
|
20
21
|
return (root) => expandFn(root);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.expand.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.expand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tree.expand.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.expand.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,+FAA+F;;;AAwC/F,SAAgB,kBAAkB,CAAiD,MAAuD;;IACxI,MAAM,QAAQ,GAA6B,MAAC,MAAc,CAAC,QAAQ,mCAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAS,CAAC,CAAC;IAE7F,MAAM,QAAQ,GAAG,CAAC,KAAQ,EAAE,MAAU,EAAK,EAAE;QAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAkC;YAC9C,KAAK;YACL,MAAM;YACN,KAAK;SACN,CAAC;QAEF,MAAM,IAAI,GAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,cAAc,GAAe,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAlBD,gDAkBC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAA8B,MAAW,EAAE,QAAkC;IACtG,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAFD,kCAEC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TreeNode } from
|
|
1
|
+
import { TreeNode } from './tree';
|
|
2
2
|
/**
|
|
3
3
|
* Flattens the tree by pushing the values into the input array, or a new array and returns the value.
|
|
4
4
|
*/
|
|
5
|
-
export declare type FlattenTreeFunction<N extends TreeNode<
|
|
5
|
+
export declare type FlattenTreeFunction<N extends TreeNode<unknown>, V> = (tree: N, array?: V[]) => V[];
|
|
6
6
|
/**
|
|
7
7
|
* Traverses the tree and flattens it into all tree nodes.
|
|
8
8
|
*/
|
|
9
|
-
export declare function flattenTree<N extends TreeNode<
|
|
9
|
+
export declare function flattenTree<N extends TreeNode<unknown> = TreeNode<unknown>>(tree: N): N[];
|
|
10
10
|
/**
|
|
11
11
|
* Traverses the tree and pushes the nodes into the input array.
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@ export declare function flattenTree<N extends TreeNode<any> = TreeNode<any>>(tre
|
|
|
14
14
|
* @param array
|
|
15
15
|
* @returns
|
|
16
16
|
*/
|
|
17
|
-
export declare function flattenTreeToArray<N extends TreeNode<
|
|
18
|
-
export declare function flattenTreeToArrayFunction<N extends TreeNode<
|
|
19
|
-
export declare function flattenTreeToArrayFunction<N extends TreeNode<
|
|
17
|
+
export declare function flattenTreeToArray<N extends TreeNode<unknown> = TreeNode<unknown>>(tree: N, array: N[]): N[];
|
|
18
|
+
export declare function flattenTreeToArrayFunction<N extends TreeNode<unknown>>(): FlattenTreeFunction<N, N>;
|
|
19
|
+
export declare function flattenTreeToArrayFunction<N extends TreeNode<unknown, N>, V>(mapNodeFn?: (node: N) => V): FlattenTreeFunction<N, V>;
|
|
20
20
|
/**
|
|
21
21
|
* Convenience function for flattening multiple trees with a flatten function.
|
|
22
22
|
*
|
|
@@ -24,4 +24,4 @@ export declare function flattenTreeToArrayFunction<N extends TreeNode<any, N>, V
|
|
|
24
24
|
* @param flattenFn
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
export declare function flattenTrees<N extends TreeNode<
|
|
27
|
+
export declare function flattenTrees<N extends TreeNode<unknown, N>, V>(trees: N[], flattenFn: FlattenTreeFunction<N, V>): V[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.flatten.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.flatten.ts"],"names":[],"mappings":";;;AAQA;;GAEG;AACH,SAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"tree.flatten.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.flatten.ts"],"names":[],"mappings":";;;AAQA;;GAEG;AACH,SAAgB,WAAW,CAAkD,IAAO;IAClF,OAAO,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,kCAEC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAkD,IAAO,EAAE,KAAU;IACrG,OAAO,0BAA0B,EAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC;AAFD,gDAEC;AAID,SAAgB,0BAA0B,CAAoC,SAA0B;IACtG,MAAM,OAAO,GAAmB,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAiB,CAAC,CAAC;IAExE,MAAM,SAAS,GAAG,CAAC,IAAO,EAAE,QAAa,EAAE,EAAE,EAAE;QAC7C,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAE1B,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;SACnD;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAdD,gEAcC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAoC,KAAU,EAAE,SAAoC;IAC9G,MAAM,KAAK,GAAQ,EAAE,CAAC;IACtB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC;AAJD,oCAIC"}
|
package/src/lib/tree/tree.js
CHANGED
package/src/lib/tree/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/tree.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,+FAA+F"}
|
package/src/lib/type.d.ts
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
import { Merge, PickProperties, StrictOmit, Writable } from 'ts-essentials';
|
|
1
2
|
/**
|
|
2
3
|
* Class typing, restricted to types that have a constructor via the new keyword.
|
|
3
4
|
*/
|
|
4
|
-
export declare type ClassType<T =
|
|
5
|
-
new (...args:
|
|
5
|
+
export declare type ClassType<T = unknown> = {
|
|
6
|
+
new (...args: unknown[]): T;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* Similar to ClassType, but allows for abstract classes.
|
|
9
10
|
*/
|
|
10
|
-
export declare type ClassLikeType<T =
|
|
11
|
+
export declare type ClassLikeType<T = unknown> = abstract new (...args: unknown[]) => T;
|
|
11
12
|
/**
|
|
12
13
|
* Special type used to defined other type definitions that state the defined type has every key of one type, but each key has a single/new value type.
|
|
13
14
|
*/
|
|
14
|
-
export declare type KeyValueTransformMap<T, V,
|
|
15
|
-
[
|
|
15
|
+
export declare type KeyValueTransformMap<T, V, X extends keyof T = keyof T> = {
|
|
16
|
+
[K in X]: V;
|
|
17
|
+
};
|
|
18
|
+
export declare type StringKeyValueTransformMap<T, V> = {
|
|
19
|
+
[K in keyof T as string]: V;
|
|
20
|
+
};
|
|
21
|
+
export declare type KeysAsStrings<T> = {
|
|
22
|
+
[K in keyof T as string]: T[K];
|
|
16
23
|
};
|
|
17
24
|
export declare type BooleanKeyValueTransformMap<T> = KeyValueTransformMap<T, boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Merges the types T and R, but replaces keys within T with those in R.
|
|
27
|
+
*/
|
|
28
|
+
export declare type MergeReplace<T, R> = Merge<T, R>;
|
|
29
|
+
/**
|
|
30
|
+
* Similar to MergeReplace, but only allows keys that are defined within T.
|
|
31
|
+
*/
|
|
32
|
+
export declare type Replace<T, R> = StrictOmit<MergeReplace<T, R>, Exclude<keyof R, keyof T>>;
|
|
33
|
+
/**
|
|
34
|
+
* Similar to Replace, but all types that were not replaced are set to the third type (default unknown).
|
|
35
|
+
*/
|
|
36
|
+
export declare type ReplaceType<I extends object, O extends object, X = unknown> = {
|
|
37
|
+
[K in keyof I]: K extends keyof O ? O[K] : X;
|
|
38
|
+
};
|
|
39
|
+
export declare type OnlyStringKeys<T> = PickProperties<T, 'string'>;
|
|
18
40
|
export declare type RemoveIndex<T> = {
|
|
19
41
|
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
20
42
|
};
|
|
@@ -24,3 +46,7 @@ export declare type RemoveIndex<T> = {
|
|
|
24
46
|
* https://stackoverflow.com/questions/51954558/how-can-i-remove-a-wider-type-from-a-union-type-without-removing-its-subtypes-in/51955852#51955852
|
|
25
47
|
*/
|
|
26
48
|
export declare type KnownKeys<T> = keyof RemoveIndex<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Makes a readonly type able to be configured. Useful for configurating readonly types before they are used.
|
|
51
|
+
*/
|
|
52
|
+
export declare type Configurable<T> = Writable<T>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Configurable } from '../type';
|
|
2
|
+
/**
|
|
3
|
+
* Denotes a typically read-only like model is being built/configured.
|
|
4
|
+
*/
|
|
5
|
+
export declare type Building<T> = Partial<Configurable<T>>;
|
|
6
|
+
export declare type BuildFunction<T> = (base: Building<T>) => void;
|
|
7
|
+
export interface BuildConfig<T extends object> {
|
|
8
|
+
base?: Building<T>;
|
|
9
|
+
build: BuildFunction<T>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Convenience function that is used to "build" an object of a specific type.
|
|
13
|
+
*
|
|
14
|
+
* @param base
|
|
15
|
+
* @param buildFn
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function build<T extends object>({ base, build }: BuildConfig<T>): T;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Convenience function that is used to "build" an object of a specific type.
|
|
6
|
+
*
|
|
7
|
+
* @param base
|
|
8
|
+
* @param buildFn
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function build({ base, build }) {
|
|
12
|
+
build(base !== null && base !== void 0 ? base : {});
|
|
13
|
+
return base;
|
|
14
|
+
}
|
|
15
|
+
exports.build = build;
|
|
16
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/build.ts"],"names":[],"mappings":";;;AAcA;;;;;;GAMG;AACH,SAAgB,KAAK,CAAmB,EAAE,IAAI,EAAE,KAAK,EAAkB;IACrE,KAAK,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,CAAC;IAClB,OAAO,IAAS,CAAC;AACnB,CAAC;AAHD,sBAGC"}
|
package/src/lib/value/equal.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ import { IterableOrValue } from './../iterable/iterable';
|
|
|
2
2
|
/**
|
|
3
3
|
* Function used for equivalence comparisons on an object.
|
|
4
4
|
*/
|
|
5
|
-
export declare type IsEqualFunction<T =
|
|
5
|
+
export declare type IsEqualFunction<T = unknown> = (a: T, b: T) => boolean;
|
|
6
6
|
/**
|
|
7
7
|
* Used to check if the input object is considered equal to the current context.
|
|
8
8
|
*/
|
|
9
|
-
export declare type IsEqualContext<T =
|
|
9
|
+
export declare type IsEqualContext<T = unknown> = (x: T) => boolean;
|
|
10
10
|
/**
|
|
11
11
|
* Similar to IsEqualContext, but supports an array of objects.
|
|
12
12
|
*
|
|
13
13
|
* Used to check if the input object or array of objects are considered equal to the current context.
|
|
14
14
|
*/
|
|
15
|
-
export declare type AreEqualContext<T =
|
|
15
|
+
export declare type AreEqualContext<T = unknown> = (x: IterableOrValue<T>) => boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Creates an IsEqualContext
|
|
18
18
|
*
|
package/src/lib/value/equal.js
CHANGED
|
@@ -48,7 +48,7 @@ exports.areEqualContext = areEqualContext;
|
|
|
48
48
|
function allObjectsAreEqual(values, fn) {
|
|
49
49
|
if ((0, iterable_1.isIterable)(values)) {
|
|
50
50
|
const firstValues = (0, iterable_1.takeValuesFromIterable)(values, 2);
|
|
51
|
-
return
|
|
51
|
+
return firstValues.length > 1 ? areEqualContext(firstValues[0], fn)(values) : true;
|
|
52
52
|
}
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/equal.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/equal.ts"],"names":[],"mappings":";;;AAAA,qDAA+G;AAmB/G;;;;;;GAMG;AACH,SAAgB,cAAc,CAAI,YAAe,EAAE,EAAsB;IACvE,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAJD,wCAIC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAI,YAAe,EAAE,EAAsB;IACxE,MAAM,OAAO,GAAG,cAAc,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAEjD,OAAO,CAAC,KAAyB,EAAE,EAAE;QACnC,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,IAAI,IAAA,qBAAU,EAAC,KAAK,CAAC,EAAE;YACrB,QAAQ,GAAG,CAAC,IAAA,2BAAgB,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SACzD;aAAM;YACL,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAdD,0CAcC;AAED;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAI,MAA0B,EAAE,EAAsB;IACtF,IAAI,IAAA,qBAAU,EAAC,MAAM,CAAC,EAAE;QACtB,MAAM,WAAW,GAAG,IAAA,iCAAsB,EAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtD,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACpF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAPD,gDAOC"}
|
package/src/lib/value/index.d.ts
CHANGED
package/src/lib/value/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./build"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./equal"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./map"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./maybe"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,gDAAsB;AACtB,kDAAwB;AACxB,qDAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,kDAAwB;AACxB,gDAAsB;AACtB,kDAAwB;AACxB,qDAA2B"}
|
package/src/lib/value/map.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Maybe } from
|
|
1
|
+
import { Maybe } from './maybe';
|
|
2
2
|
/**
|
|
3
3
|
* Converts one value to another.
|
|
4
4
|
*/
|
|
@@ -11,3 +11,27 @@ export declare type ApplyMapFunction<I, O> = (input: I, target?: Maybe<Partial<O
|
|
|
11
11
|
* Converts values from the input, and applies them to the target if a target is supplied.
|
|
12
12
|
*/
|
|
13
13
|
export declare type ApplyMapFunctionWithOptions<I, O, C> = (input: I, target?: Maybe<Partial<O>>, options?: Maybe<C>) => O;
|
|
14
|
+
export declare type MapFunctionOutputPair<O, I = unknown> = {
|
|
15
|
+
input: I;
|
|
16
|
+
output: O;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Wraps a MapFunction to instead provide the input and output values.
|
|
20
|
+
*
|
|
21
|
+
* @param fn
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function mapFunctionOutputPair<O, I = unknown>(fn: MapFunction<I, O>): MapFunction<I, MapFunctionOutputPair<O, I>>;
|
|
25
|
+
/**
|
|
26
|
+
* MapFunction output value that captures the input it was derived from.
|
|
27
|
+
*/
|
|
28
|
+
export declare type MapFunctionOutput<O extends object, I = unknown> = O & {
|
|
29
|
+
readonly _input: I;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param fn
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare function wrapMapFunctionOutput<O extends object, I = unknown>(fn: MapFunction<I, O>): MapFunction<I, MapFunctionOutput<O, I>>;
|
|
37
|
+
export declare function mapFunctionOutput<O extends object, I = unknown>(output: O, input: I): MapFunctionOutput<O, I>;
|
package/src/lib/value/map.js
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapFunctionOutput = exports.wrapMapFunctionOutput = exports.mapFunctionOutputPair = void 0;
|
|
4
|
+
const build_1 = require("./build");
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a MapFunction to instead provide the input and output values.
|
|
7
|
+
*
|
|
8
|
+
* @param fn
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function mapFunctionOutputPair(fn) {
|
|
12
|
+
return (input) => {
|
|
13
|
+
const output = fn(input);
|
|
14
|
+
return {
|
|
15
|
+
input,
|
|
16
|
+
output
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.mapFunctionOutputPair = mapFunctionOutputPair;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param fn
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
function wrapMapFunctionOutput(fn) {
|
|
27
|
+
return (input) => {
|
|
28
|
+
const result = fn(input);
|
|
29
|
+
return mapFunctionOutput(result, input);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.wrapMapFunctionOutput = wrapMapFunctionOutput;
|
|
33
|
+
function mapFunctionOutput(output, input) {
|
|
34
|
+
return (0, build_1.build)({
|
|
35
|
+
base: output,
|
|
36
|
+
build: (x) => {
|
|
37
|
+
x._input = input;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.mapFunctionOutput = mapFunctionOutput;
|
|
3
42
|
//# sourceMappingURL=map.js.map
|
package/src/lib/value/map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/map.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/map.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAwBhC;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAiB,EAAqB;IACzE,OAAO,CAAC,KAAQ,EAAE,EAAE;QAClB,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAEzB,OAAO;YACL,KAAK;YACL,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AATD,sDASC;AAQD;;;;GAIG;AACH,SAAgB,qBAAqB,CAAgC,EAAqB;IACxF,OAAO,CAAC,KAAQ,EAAE,EAAE;QAClB,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QACzB,OAAO,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC;AALD,sDAKC;AAED,SAAgB,iBAAiB,CAAgC,MAAS,EAAE,KAAQ;IAClF,OAAO,IAAA,aAAK,EAA0B;QACpC,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,CAAC,CAAC,MAAM,GAAG,KAA0C,CAAC;QACxD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAPD,8CAOC"}
|
package/src/lib/value/maybe.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NonNever } from 'ts-essentials';
|
|
1
2
|
/**
|
|
2
3
|
* A null/undefined value.
|
|
3
4
|
*/
|
|
@@ -5,11 +6,17 @@ export declare type MaybeNot = null | undefined;
|
|
|
5
6
|
/**
|
|
6
7
|
* A non-null/undefined value.
|
|
7
8
|
*/
|
|
8
|
-
export declare type MaybeSo<T =
|
|
9
|
+
export declare type MaybeSo<T = unknown> = T extends MaybeNot ? never : T;
|
|
9
10
|
/**
|
|
10
11
|
* A value that might exist, or be null/undefined instead.
|
|
11
12
|
*/
|
|
12
13
|
export declare type Maybe<T> = T | MaybeNot;
|
|
14
|
+
/**
|
|
15
|
+
* Turns all key values in an object into a Maybe value.
|
|
16
|
+
*/
|
|
17
|
+
export declare type MaybeMap<T extends object> = NonNever<{
|
|
18
|
+
[K in keyof T]: T[K] extends MaybeNot ? never : Maybe<T[K]>;
|
|
19
|
+
}>;
|
|
13
20
|
/**
|
|
14
21
|
* Returns true if the value is not null or undefined.
|
|
15
22
|
*
|
|
@@ -17,7 +24,6 @@ export declare type Maybe<T> = T | MaybeNot;
|
|
|
17
24
|
* @returns
|
|
18
25
|
*/
|
|
19
26
|
export declare function hasNonNullValue<T>(value: Maybe<T>): value is T;
|
|
20
|
-
export declare function hasNonNullValue(value: any): boolean;
|
|
21
27
|
export declare function hasNonNullValue(value: true): true;
|
|
22
28
|
export declare function hasNonNullValue(value: false): true;
|
|
23
29
|
export declare function hasNonNullValue(value: number): true;
|
|
@@ -34,27 +40,20 @@ export declare function hasNonNullValue(value: undefined): false;
|
|
|
34
40
|
*
|
|
35
41
|
* NaN has undefined behavior.
|
|
36
42
|
*/
|
|
37
|
-
export declare function hasValueOrNotEmpty(value:
|
|
43
|
+
export declare function hasValueOrNotEmpty<T>(value: T): boolean;
|
|
38
44
|
export declare function hasValueOrNotEmpty(value: true): true;
|
|
39
45
|
export declare function hasValueOrNotEmpty(value: false): true;
|
|
40
46
|
export declare function hasValueOrNotEmpty(value: number): true;
|
|
41
47
|
export declare function hasValueOrNotEmpty(value: ''): false;
|
|
42
48
|
export declare function hasValueOrNotEmpty(value: null): false;
|
|
43
49
|
export declare function hasValueOrNotEmpty(value: undefined): false;
|
|
44
|
-
/**
|
|
45
|
-
* True if the input is MaybeNot and not false.
|
|
46
|
-
*
|
|
47
|
-
* @param value
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
export declare function isMaybeNotAndNotFalse(value: any): boolean;
|
|
51
50
|
/**
|
|
52
51
|
* True if the input is MaybeNot.
|
|
53
52
|
*
|
|
54
53
|
* @param value
|
|
55
54
|
* @returns
|
|
56
55
|
*/
|
|
57
|
-
export declare function isMaybeNot(value:
|
|
56
|
+
export declare function isMaybeNot(value: unknown): value is MaybeNot;
|
|
58
57
|
/**
|
|
59
58
|
* True if the input is MaybeSo
|
|
60
59
|
*
|
|
@@ -68,14 +67,14 @@ export declare function isMaybeSo<T>(value: Maybe<T>): value is MaybeSo<T>;
|
|
|
68
67
|
* @param value
|
|
69
68
|
* @returns
|
|
70
69
|
*/
|
|
71
|
-
export declare function isMaybeNotOrTrue(value:
|
|
70
|
+
export declare function isMaybeNotOrTrue(value: unknown): value is MaybeNot | true;
|
|
72
71
|
/**
|
|
73
72
|
* True if the input is not null/undefined/false.
|
|
74
73
|
*
|
|
75
74
|
* @param value
|
|
76
75
|
* @returns
|
|
77
76
|
*/
|
|
78
|
-
export declare function isDefinedAndNotFalse(value:
|
|
77
|
+
export declare function isDefinedAndNotFalse(value: unknown): boolean;
|
|
79
78
|
/**
|
|
80
79
|
* Returns true if both the inputs are not null/undefined but the same value.
|
|
81
80
|
*
|