@dereekb/util 1.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -9
- package/README.md +1 -1
- package/package.json +8 -5
- package/src/index.js +2 -2
- package/src/index.js.map +1 -1
- package/src/lib/array/array.boolean.d.ts +4 -2
- package/src/lib/array/array.boolean.js +11 -1
- package/src/lib/array/array.boolean.js.map +1 -1
- package/src/lib/array/array.d.ts +24 -2
- package/src/lib/array/array.index.d.ts +1 -1
- package/src/lib/array/array.js +37 -2
- package/src/lib/array/array.js.map +1 -1
- package/src/lib/array/array.limit.d.ts +1 -1
- 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 +1 -1
- package/src/lib/array/array.set.d.ts +2 -16
- package/src/lib/array/array.set.js +21 -55
- package/src/lib/array/array.set.js.map +1 -1
- package/src/lib/array/array.string.d.ts +7 -5
- package/src/lib/array/array.string.js +14 -4
- package/src/lib/array/array.string.js.map +1 -1
- package/src/lib/array/array.unique.d.ts +1 -1
- package/src/lib/array/array.value.d.ts +15 -1
- package/src/lib/array/array.value.js +21 -1
- package/src/lib/array/array.value.js.map +1 -1
- package/src/lib/array/index.js +12 -12
- package/src/lib/array/index.js.map +1 -1
- package/src/lib/assertion/index.js +5 -5
- package/src/lib/assertion/index.js.map +1 -1
- package/src/lib/auth/auth.role.claims.d.ts +98 -0
- package/src/lib/auth/auth.role.claims.js +93 -0
- package/src/lib/auth/auth.role.claims.js.map +1 -0
- package/src/lib/auth/auth.role.d.ts +22 -0
- package/src/lib/auth/auth.role.js +17 -0
- package/src/lib/auth/auth.role.js.map +1 -0
- package/src/lib/auth/index.d.ts +2 -0
- package/src/lib/auth/index.js +6 -0
- package/src/lib/auth/index.js.map +1 -0
- package/src/lib/contact/index.js +3 -3
- package/src/lib/contact/index.js.map +1 -1
- package/src/lib/date/date.d.ts +1 -1
- package/src/lib/date/date.time.d.ts +4 -2
- package/src/lib/date/date.time.js +13 -1
- package/src/lib/date/date.time.js.map +1 -1
- package/src/lib/date/index.js +2 -2
- package/src/lib/date/index.js.map +1 -1
- package/src/lib/error/error.d.ts +6 -1
- package/src/lib/error/error.js +8 -1
- package/src/lib/error/error.js.map +1 -1
- package/src/lib/error/error.server.d.ts +5 -12
- package/src/lib/error/error.server.js.map +1 -1
- package/src/lib/error/index.js +2 -2
- package/src/lib/error/index.js.map +1 -1
- package/src/lib/filter/index.js +1 -1
- package/src/lib/filter/index.js.map +1 -1
- package/src/lib/function/function.forward.d.ts +9 -0
- package/src/lib/function/function.forward.js +18 -0
- package/src/lib/function/function.forward.js.map +1 -0
- package/src/lib/function/index.d.ts +1 -0
- package/src/lib/function/index.js +5 -0
- package/src/lib/function/index.js.map +1 -0
- package/src/lib/getter/getter.cache.d.ts +38 -0
- package/src/lib/getter/getter.cache.js +23 -0
- package/src/lib/getter/getter.cache.js.map +1 -0
- package/src/lib/getter/getter.d.ts +61 -0
- package/src/lib/getter/getter.js +48 -0
- package/src/lib/getter/getter.js.map +1 -0
- package/src/lib/getter/getter.map.d.ts +15 -0
- package/src/lib/getter/getter.map.js +24 -0
- package/src/lib/getter/getter.map.js.map +1 -0
- package/src/lib/getter/index.d.ts +3 -0
- package/src/lib/getter/index.js +7 -0
- package/src/lib/getter/index.js.map +1 -0
- package/src/lib/grouping.d.ts +4 -4
- package/src/lib/index.d.ts +9 -5
- package/src/lib/index.js +31 -28
- package/src/lib/index.js.map +1 -1
- package/src/lib/iterable/index.d.ts +2 -0
- package/src/lib/iterable/index.js +6 -0
- package/src/lib/iterable/index.js.map +1 -0
- package/src/lib/iterable/iterable.d.ts +53 -0
- package/src/lib/iterable/iterable.js +113 -0
- package/src/lib/iterable/iterable.js.map +1 -0
- package/src/lib/iterable/iterable.map.d.ts +8 -0
- package/src/lib/iterable/iterable.map.js +18 -0
- package/src/lib/iterable/iterable.map.js.map +1 -0
- package/src/lib/iterate.js +1 -1
- package/src/lib/key.d.ts +1 -1
- package/src/lib/map/index.d.ts +2 -0
- package/src/lib/map/index.js +6 -0
- package/src/lib/map/index.js.map +1 -0
- package/src/lib/map/map.d.ts +9 -0
- package/src/lib/map/map.intersection.d.ts +15 -0
- package/src/lib/map/map.intersection.js +24 -0
- package/src/lib/map/map.intersection.js.map +1 -0
- package/src/lib/map/map.js +17 -0
- package/src/lib/map/map.js.map +1 -0
- package/src/lib/misc/host.d.ts +5 -0
- package/src/lib/misc/host.js +13 -0
- package/src/lib/misc/host.js.map +1 -0
- package/src/lib/misc/index.d.ts +1 -0
- package/src/lib/misc/index.js +5 -0
- package/src/lib/misc/index.js.map +1 -0
- package/src/lib/model/index.d.ts +3 -0
- package/src/lib/model/index.js +7 -0
- package/src/lib/model/index.js.map +1 -0
- package/src/lib/model/model.conversion.d.ts +63 -0
- package/src/lib/model/model.conversion.js +66 -0
- package/src/lib/model/model.conversion.js.map +1 -0
- package/src/lib/model/model.copy.d.ts +16 -0
- package/src/lib/model/model.copy.js +20 -0
- package/src/lib/model/model.copy.js.map +1 -0
- package/src/lib/{model.d.ts → model/model.d.ts} +2 -2
- package/src/lib/{model.js → model/model.js} +3 -3
- package/src/lib/model/model.js.map +1 -0
- package/src/lib/number/factory.d.ts +22 -0
- package/src/lib/number/factory.js +22 -0
- package/src/lib/number/factory.js.map +1 -0
- package/src/lib/number/index.d.ts +3 -0
- package/src/lib/number/index.js +7 -0
- package/src/lib/number/index.js.map +1 -0
- package/src/lib/number/random.d.ts +13 -0
- package/src/lib/number/random.js +22 -0
- package/src/lib/number/random.js.map +1 -0
- package/src/lib/{number.d.ts → number/round.d.ts} +0 -13
- package/src/lib/{number.js → number/round.js} +2 -20
- package/src/lib/number/round.js.map +1 -0
- package/src/lib/object/index.d.ts +1 -0
- package/src/lib/object/index.js +4 -3
- package/src/lib/object/index.js.map +1 -1
- package/src/lib/object/object.d.ts +69 -8
- package/src/lib/object/object.equal.d.ts +1 -1
- package/src/lib/object/object.equal.js +3 -3
- package/src/lib/object/object.equal.js.map +1 -1
- package/src/lib/object/object.js +117 -11
- package/src/lib/object/object.js.map +1 -1
- package/src/lib/object/object.map.d.ts +35 -0
- package/src/lib/object/object.map.js +40 -0
- package/src/lib/object/object.map.js.map +1 -0
- package/src/lib/page/index.js +3 -3
- package/src/lib/page/index.js.map +1 -1
- package/src/lib/page/page.d.ts +1 -1
- package/src/lib/page/page.filter.js +1 -1
- package/src/lib/promise/index.d.ts +3 -0
- package/src/lib/promise/index.js +7 -4
- package/src/lib/promise/index.js.map +1 -1
- package/src/lib/promise/is.d.ts +7 -0
- package/src/lib/promise/is.js +15 -0
- package/src/lib/promise/is.js.map +1 -0
- package/src/lib/promise/map.d.ts +10 -0
- package/src/lib/promise/map.js +14 -0
- package/src/lib/promise/map.js.map +1 -0
- package/src/lib/promise/promise.d.ts +13 -1
- package/src/lib/promise/promise.js +26 -8
- package/src/lib/promise/promise.js.map +1 -1
- package/src/lib/promise/promise.loop.d.ts +18 -3
- package/src/lib/promise/promise.loop.js +18 -2
- package/src/lib/promise/promise.loop.js.map +1 -1
- package/src/lib/promise/promise.ref.d.ts +10 -0
- package/src/lib/promise/promise.ref.js +19 -0
- package/src/lib/promise/promise.ref.js.map +1 -0
- package/src/lib/promise/wait.js +2 -2
- package/src/lib/promise/wait.js.map +1 -1
- package/src/lib/relation/index.js +1 -1
- package/src/lib/relation/index.js.map +1 -1
- package/src/lib/relation/relation.js +2 -2
- package/src/lib/set/index.d.ts +4 -0
- package/src/lib/set/index.js +8 -0
- package/src/lib/set/index.js.map +1 -0
- package/src/lib/set/set.allowed.d.ts +23 -0
- package/src/lib/set/set.allowed.js +29 -0
- package/src/lib/set/set.allowed.js.map +1 -0
- package/src/lib/set/set.d.ts +53 -0
- package/src/lib/{set.hashset.d.ts → set/set.hashset.d.ts} +2 -2
- package/src/lib/{set.hashset.js → set/set.hashset.js} +0 -0
- package/src/lib/set/set.hashset.js.map +1 -0
- package/src/lib/set/set.js +114 -0
- package/src/lib/set/set.js.map +1 -0
- package/src/lib/set/set.maybe.d.ts +11 -0
- package/src/lib/set/set.maybe.js +22 -0
- package/src/lib/set/set.maybe.js.map +1 -0
- package/src/lib/sort.d.ts +1 -4
- package/src/lib/sort.js +3 -8
- package/src/lib/sort.js.map +1 -1
- package/src/lib/storage/index.js +4 -4
- package/src/lib/storage/index.js.map +1 -1
- package/src/lib/storage/storage.memory.d.ts +1 -1
- package/src/lib/storage/storage.object.d.ts +1 -1
- package/src/lib/string.d.ts +9 -2
- package/src/lib/string.js +11 -1
- package/src/lib/string.js.map +1 -1
- package/src/lib/tree/index.js +4 -4
- package/src/lib/tree/index.js.map +1 -1
- package/src/lib/tree/tree.expand.d.ts +1 -1
- package/src/lib/type.d.ts +17 -1
- package/src/lib/value/equal.d.ts +41 -0
- package/src/lib/value/equal.js +56 -0
- package/src/lib/value/equal.js.map +1 -0
- package/src/lib/value/index.d.ts +4 -0
- package/src/lib/value/index.js +8 -0
- package/src/lib/value/index.js.map +1 -0
- package/src/lib/value/map.d.ts +13 -0
- package/src/lib/{map.js → value/map.js} +0 -0
- package/src/lib/value/map.js.map +1 -0
- package/src/lib/{value.d.ts → value/maybe.d.ts} +45 -2
- package/src/lib/value/maybe.js +78 -0
- package/src/lib/value/maybe.js.map +1 -0
- package/src/lib/value/modifier.d.ts +58 -0
- package/src/lib/value/modifier.js +69 -0
- package/src/lib/value/modifier.js.map +1 -0
- package/src/test/index.d.ts +1 -0
- package/src/test/index.js +3 -2
- package/src/test/index.js.map +1 -1
- package/src/test/jest.d.ts +21 -1
- package/src/test/jest.function.d.ts +9 -0
- package/src/test/jest.function.js +14 -0
- package/src/test/jest.function.js.map +1 -0
- package/src/test/jest.js +64 -36
- package/src/test/jest.js.map +1 -1
- package/src/test/jest.wrap.js +5 -5
- package/src/test/jest.wrap.js.map +1 -1
- package/src/lib/getter.d.ts +0 -26
- package/src/lib/getter.js +0 -13
- package/src/lib/getter.js.map +0 -1
- package/src/lib/map.d.ts +0 -2
- package/src/lib/map.js.map +0 -1
- package/src/lib/model.js.map +0 -1
- package/src/lib/number.js.map +0 -1
- package/src/lib/set.d.ts +0 -0
- package/src/lib/set.hashset.js.map +0 -1
- package/src/lib/set.js +0 -2
- package/src/lib/set.js.map +0 -1
- package/src/lib/value.js +0 -28
- package/src/lib/value.js.map +0 -1
package/src/lib/string.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MapStringFn } from "./map";
|
|
2
|
-
import { Maybe } from "./value";
|
|
1
|
+
import { MapStringFn } from "./map/map";
|
|
2
|
+
import { Maybe } from "./value/maybe";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a string that is made up of comma-separated values.
|
|
5
5
|
*
|
|
@@ -18,3 +18,10 @@ export declare function splitCommaSeparatedStringToSet(input: Maybe<CommaSeparat
|
|
|
18
18
|
* Undefined is returned if a null/undefined value is input.
|
|
19
19
|
*/
|
|
20
20
|
export declare function addPlusPrefixToNumber(value?: Maybe<number>, prefix?: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Capitalizes the first letter of the input.
|
|
23
|
+
*
|
|
24
|
+
* @param value
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function capitalizeFirstLetter(value: string): string;
|
package/src/lib/string.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addPlusPrefixToNumber = exports.splitCommaSeparatedStringToSet = exports.splitCommaSeparatedString = exports.caseInsensitiveString = void 0;
|
|
3
|
+
exports.capitalizeFirstLetter = exports.addPlusPrefixToNumber = exports.splitCommaSeparatedStringToSet = exports.splitCommaSeparatedString = exports.caseInsensitiveString = void 0;
|
|
4
4
|
function caseInsensitiveString(input) {
|
|
5
5
|
return input === null || input === void 0 ? void 0 : input.toLocaleLowerCase();
|
|
6
6
|
}
|
|
@@ -28,4 +28,14 @@ function addPlusPrefixToNumber(value, prefix = '+') {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.addPlusPrefixToNumber = addPlusPrefixToNumber;
|
|
31
|
+
/**
|
|
32
|
+
* Capitalizes the first letter of the input.
|
|
33
|
+
*
|
|
34
|
+
* @param value
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
function capitalizeFirstLetter(value) {
|
|
38
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
39
|
+
}
|
|
40
|
+
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
31
41
|
//# sourceMappingURL=string.js.map
|
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":";;;AAcA,SAAgB,qBAAqB,CAAC,KAAU;IAC9C,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB,EAAE,CAAC;AACpC,CAAC;AAFD,sDAEC;AAID,SAAgB,yBAAyB,CAAU,KAA8B,EAAE,QAAwB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAQ;IACxH,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1C,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,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;KACvD;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"}
|
package/src/lib/tree/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./tree"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./tree.expand"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./tree.flatten"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./tree.array"), exports);
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/tree/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,wDAA8B;AAC9B,yDAA+B;AAC/B,uDAA6B"}
|
package/src/lib/type.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Class typing, restricted to types that have a constructor via the new keyword.
|
|
3
|
+
*/
|
|
4
|
+
export declare type ClassType<T = any> = {
|
|
2
5
|
new (...args: any[]): T;
|
|
3
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Similar to ClassType, but allows for abstract classes.
|
|
9
|
+
*/
|
|
10
|
+
export declare type ClassLikeType<T = any> = abstract new (...args: any[]) => T;
|
|
4
11
|
/**
|
|
5
12
|
* 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.
|
|
6
13
|
*/
|
|
@@ -8,3 +15,12 @@ export declare type KeyValueTransformMap<T, V, K extends keyof T = keyof T> = {
|
|
|
8
15
|
[k in K]: V;
|
|
9
16
|
};
|
|
10
17
|
export declare type BooleanKeyValueTransformMap<T> = KeyValueTransformMap<T, boolean>;
|
|
18
|
+
export declare type RemoveIndex<T> = {
|
|
19
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Custom typing used to only retain known keys on types that have a [key: string] in their type.
|
|
23
|
+
*
|
|
24
|
+
* https://stackoverflow.com/questions/51954558/how-can-i-remove-a-wider-type-from-a-union-type-without-removing-its-subtypes-in/51955852#51955852
|
|
25
|
+
*/
|
|
26
|
+
export declare type KnownKeys<T> = keyof RemoveIndex<T>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IterableOrValue } from './../iterable/iterable';
|
|
2
|
+
/**
|
|
3
|
+
* Function used for equivalence comparisons on an object.
|
|
4
|
+
*/
|
|
5
|
+
export declare type IsEqualFunction<T = any> = (a: T, b: T) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Used to check if the input object is considered equal to the current context.
|
|
8
|
+
*/
|
|
9
|
+
export declare type IsEqualContext<T = any> = (x: T) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Similar to IsEqualContext, but supports an array of objects.
|
|
12
|
+
*
|
|
13
|
+
* Used to check if the input object or array of objects are considered equal to the current context.
|
|
14
|
+
*/
|
|
15
|
+
export declare type AreEqualContext<T = any> = (x: IterableOrValue<T>) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Creates an IsEqualContext
|
|
18
|
+
*
|
|
19
|
+
* @param contextValue
|
|
20
|
+
* @param fn
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function isEqualContext<T>(contextValue: T, fn: IsEqualFunction<T>): IsEqualContext<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates an AreEqualContext
|
|
26
|
+
*
|
|
27
|
+
* @param contextValue
|
|
28
|
+
* @param fn
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare function areEqualContext<T>(contextValue: T, fn: IsEqualFunction<T>): AreEqualContext<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if all input values are equal.
|
|
34
|
+
*
|
|
35
|
+
* Arrays that are empty or have one value will return true by default.
|
|
36
|
+
*
|
|
37
|
+
* @param values
|
|
38
|
+
* @param fn
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function allObjectsAreEqual<T>(values: IterableOrValue<T>, fn: IsEqualFunction<T>): boolean;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allObjectsAreEqual = exports.areEqualContext = exports.isEqualContext = void 0;
|
|
4
|
+
const iterable_1 = require("./../iterable/iterable");
|
|
5
|
+
/**
|
|
6
|
+
* Creates an IsEqualContext
|
|
7
|
+
*
|
|
8
|
+
* @param contextValue
|
|
9
|
+
* @param fn
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function isEqualContext(contextValue, fn) {
|
|
13
|
+
return (value) => {
|
|
14
|
+
return fn(contextValue, value);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.isEqualContext = isEqualContext;
|
|
18
|
+
/**
|
|
19
|
+
* Creates an AreEqualContext
|
|
20
|
+
*
|
|
21
|
+
* @param contextValue
|
|
22
|
+
* @param fn
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function areEqualContext(contextValue, fn) {
|
|
26
|
+
const isEqual = isEqualContext(contextValue, fn);
|
|
27
|
+
return (input) => {
|
|
28
|
+
let areEqual = false;
|
|
29
|
+
if ((0, iterable_1.isIterable)(input)) {
|
|
30
|
+
areEqual = !(0, iterable_1.existsInIterable)(input, (x) => !isEqual(x));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
areEqual = isEqual(input);
|
|
34
|
+
}
|
|
35
|
+
return areEqual;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.areEqualContext = areEqualContext;
|
|
39
|
+
/**
|
|
40
|
+
* Returns true if all input values are equal.
|
|
41
|
+
*
|
|
42
|
+
* Arrays that are empty or have one value will return true by default.
|
|
43
|
+
*
|
|
44
|
+
* @param values
|
|
45
|
+
* @param fn
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
function allObjectsAreEqual(values, fn) {
|
|
49
|
+
if ((0, iterable_1.isIterable)(values)) {
|
|
50
|
+
const firstValues = (0, iterable_1.takeValuesFromIterable)(values, 2);
|
|
51
|
+
return (firstValues.length > 1) ? areEqualContext(firstValues[0], fn)(values) : true;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
exports.allObjectsAreEqual = allObjectsAreEqual;
|
|
56
|
+
//# sourceMappingURL=equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/equal.ts"],"names":[],"mappings":";;;AAAA,qDAAuJ;AAmBvJ;;;;;;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,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACtF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAPD,gDAOC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./equal"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./map"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./maybe"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./modifier"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Maybe } from "./maybe";
|
|
2
|
+
/**
|
|
3
|
+
* Converts one value to another.
|
|
4
|
+
*/
|
|
5
|
+
export declare type MapFunction<I, O> = (input: I) => O;
|
|
6
|
+
/**
|
|
7
|
+
* Converts values from the input, and applies them to the target if a target is supplied.
|
|
8
|
+
*/
|
|
9
|
+
export declare type ApplyMapFunction<I, O> = (input: I, target?: Maybe<Partial<O>>) => O;
|
|
10
|
+
/**
|
|
11
|
+
* Converts values from the input, and applies them to the target if a target is supplied.
|
|
12
|
+
*/
|
|
13
|
+
export declare type ApplyMapFunctionWithOptions<I, O, C> = (input: I, target?: Maybe<Partial<O>>, options?: Maybe<C>) => O;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/map.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A null/undefined value.
|
|
3
|
+
*/
|
|
4
|
+
export declare type MaybeNot = null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* A non-null/undefined value.
|
|
7
|
+
*/
|
|
8
|
+
export declare type MaybeSo<T = any> = T extends MaybeNot ? never : T;
|
|
1
9
|
/**
|
|
2
10
|
* A value that might exist, or be null/undefined instead.
|
|
3
11
|
*/
|
|
4
|
-
export declare type Maybe<T> = T |
|
|
12
|
+
export declare type Maybe<T> = T | MaybeNot;
|
|
5
13
|
/**
|
|
6
14
|
* Returns true if the value is not null or undefined.
|
|
7
15
|
*
|
|
@@ -33,6 +41,41 @@ export declare function hasValueOrNotEmpty(value: number): true;
|
|
|
33
41
|
export declare function hasValueOrNotEmpty(value: ''): false;
|
|
34
42
|
export declare function hasValueOrNotEmpty(value: null): false;
|
|
35
43
|
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
|
+
/**
|
|
52
|
+
* True if the input is MaybeNot.
|
|
53
|
+
*
|
|
54
|
+
* @param value
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
export declare function isMaybeNot(value: any): value is MaybeNot;
|
|
58
|
+
/**
|
|
59
|
+
* True if the input is MaybeSo
|
|
60
|
+
*
|
|
61
|
+
* @param value
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
export declare function isMaybeSo<T>(value: Maybe<T>): value is MaybeSo<T>;
|
|
65
|
+
/**
|
|
66
|
+
* True if the input is MaybeNot and true.
|
|
67
|
+
*
|
|
68
|
+
* @param value
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
export declare function isMaybeNotOrTrue(value: any): value is MaybeNot | true;
|
|
72
|
+
/**
|
|
73
|
+
* True if the input is not null/undefined/false.
|
|
74
|
+
*
|
|
75
|
+
* @param value
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
export declare function isDefinedAndNotFalse(value: any): boolean;
|
|
36
79
|
/**
|
|
37
80
|
* Returns true if both the inputs are not null/undefined but the same value.
|
|
38
81
|
*
|
|
@@ -40,4 +83,4 @@ export declare function hasValueOrNotEmpty(value: undefined): false;
|
|
|
40
83
|
* @param b
|
|
41
84
|
* @returns
|
|
42
85
|
*/
|
|
43
|
-
export declare function isSameNonNullValue<T>(a: Maybe<T>, b: Maybe<T>): a is T
|
|
86
|
+
export declare function isSameNonNullValue<T>(a: Maybe<T>, b: Maybe<T>): a is NonNullable<T>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSameNonNullValue = exports.isDefinedAndNotFalse = exports.isMaybeNotOrTrue = exports.isMaybeSo = exports.isMaybeNot = exports.isMaybeNotAndNotFalse = exports.hasValueOrNotEmpty = exports.hasNonNullValue = void 0;
|
|
4
|
+
function hasNonNullValue(value) {
|
|
5
|
+
return value != null;
|
|
6
|
+
}
|
|
7
|
+
exports.hasNonNullValue = hasNonNullValue;
|
|
8
|
+
function hasValueOrNotEmpty(value) {
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return value.length > 0;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return value != null && value !== '';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.hasValueOrNotEmpty = hasValueOrNotEmpty;
|
|
17
|
+
/**
|
|
18
|
+
* True if the input is MaybeNot and not false.
|
|
19
|
+
*
|
|
20
|
+
* @param value
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
function isMaybeNotAndNotFalse(value) {
|
|
24
|
+
return value == null && value !== false;
|
|
25
|
+
}
|
|
26
|
+
exports.isMaybeNotAndNotFalse = isMaybeNotAndNotFalse;
|
|
27
|
+
/**
|
|
28
|
+
* True if the input is MaybeNot.
|
|
29
|
+
*
|
|
30
|
+
* @param value
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
function isMaybeNot(value) {
|
|
34
|
+
return value == null;
|
|
35
|
+
}
|
|
36
|
+
exports.isMaybeNot = isMaybeNot;
|
|
37
|
+
/**
|
|
38
|
+
* True if the input is MaybeSo
|
|
39
|
+
*
|
|
40
|
+
* @param value
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
function isMaybeSo(value) {
|
|
44
|
+
return !isMaybeNot(value);
|
|
45
|
+
}
|
|
46
|
+
exports.isMaybeSo = isMaybeSo;
|
|
47
|
+
/**
|
|
48
|
+
* True if the input is MaybeNot and true.
|
|
49
|
+
*
|
|
50
|
+
* @param value
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
function isMaybeNotOrTrue(value) {
|
|
54
|
+
return value == null || value === true;
|
|
55
|
+
}
|
|
56
|
+
exports.isMaybeNotOrTrue = isMaybeNotOrTrue;
|
|
57
|
+
/**
|
|
58
|
+
* True if the input is not null/undefined/false.
|
|
59
|
+
*
|
|
60
|
+
* @param value
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
function isDefinedAndNotFalse(value) {
|
|
64
|
+
return value != null && value !== false;
|
|
65
|
+
}
|
|
66
|
+
exports.isDefinedAndNotFalse = isDefinedAndNotFalse;
|
|
67
|
+
/**
|
|
68
|
+
* Returns true if both the inputs are not null/undefined but the same value.
|
|
69
|
+
*
|
|
70
|
+
* @param a
|
|
71
|
+
* @param b
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
function isSameNonNullValue(a, b) {
|
|
75
|
+
return (a === b && a != null);
|
|
76
|
+
}
|
|
77
|
+
exports.isSameNonNullValue = isSameNonNullValue;
|
|
78
|
+
//# sourceMappingURL=maybe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybe.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/maybe.ts"],"names":[],"mappings":";;;AA8BA,SAAgB,eAAe,CAAI,KAAe;IAChD,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAFD,0CAEC;AAmBD,SAAgB,kBAAkB,CAAC,KAAU;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;KACzB;SAAM;QACL,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;KACtC;AACH,CAAC;AAND,gDAMC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,KAAU;IAC9C,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;AAC1C,CAAC;AAFD,sDAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,KAAe;IAC1C,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAU;IACzC,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC;AACzC,CAAC;AAFD,4CAEC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,KAAU;IAC7C,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;AAC1C,CAAC;AAFD,oDAEC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAI,CAAW,EAAE,CAAW;IAC5D,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;AAChC,CAAC;AAFD,gDAEC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ArrayOrValue } from "../array";
|
|
2
|
+
import { Maybe } from "./maybe";
|
|
3
|
+
/**
|
|
4
|
+
* Modifier key
|
|
5
|
+
*/
|
|
6
|
+
export declare type ModifierKey = string;
|
|
7
|
+
/**
|
|
8
|
+
* Modifies the input value.
|
|
9
|
+
*/
|
|
10
|
+
export declare type ModifierFunction<T> = (input: T) => void;
|
|
11
|
+
/**
|
|
12
|
+
* A modifier that has a key and modify function.
|
|
13
|
+
*/
|
|
14
|
+
export interface Modifier<T> {
|
|
15
|
+
/**
|
|
16
|
+
* Modifier key.
|
|
17
|
+
*/
|
|
18
|
+
readonly key: ModifierKey;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
readonly modify: ModifierFunction<T>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new modifier
|
|
26
|
+
*
|
|
27
|
+
* @param key
|
|
28
|
+
* @param modify
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare function modifier<T>(key: string, modify: ModifierFunction<T>): Modifier<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Map of Modifiers keyed by the modifier key.
|
|
34
|
+
*/
|
|
35
|
+
export declare type ModifierMap<T> = Map<ModifierKey, Modifier<T>>;
|
|
36
|
+
/**
|
|
37
|
+
* Adds a modifier to the modifier map and returns the map.
|
|
38
|
+
*
|
|
39
|
+
* @param modifier
|
|
40
|
+
* @param map
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function addModifiers<T>(modifiers: ArrayOrValue<Modifier<T>>, map?: Maybe<ModifierMap<T>>): ModifierMap<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Removes a modifier from the modifier map and returns the map.
|
|
46
|
+
*
|
|
47
|
+
* @param modifier
|
|
48
|
+
* @param map
|
|
49
|
+
*/
|
|
50
|
+
export declare function removeModifiers<T>(modifiers: ArrayOrValue<Modifier<T>>, map: Maybe<ModifierMap<T>>): ModifierMap<T>;
|
|
51
|
+
export declare function modifierMapToFunction<T>(map: Maybe<ModifierMap<T>>): ModifierFunction<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Converts a ModifierMap to a ModifierFunction if the map is input or has functions. Otherwise returns undefined.
|
|
54
|
+
*
|
|
55
|
+
* @param map
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
export declare function maybeModifierMapToFunction<T>(map: Maybe<ModifierMap<T>>): Maybe<ModifierFunction<T>>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maybeModifierMapToFunction = exports.modifierMapToFunction = exports.removeModifiers = exports.addModifiers = exports.modifier = void 0;
|
|
4
|
+
const array_1 = require("../array");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new modifier
|
|
7
|
+
*
|
|
8
|
+
* @param key
|
|
9
|
+
* @param modify
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function modifier(key, modify) {
|
|
13
|
+
return {
|
|
14
|
+
key,
|
|
15
|
+
modify
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.modifier = modifier;
|
|
19
|
+
/**
|
|
20
|
+
* Adds a modifier to the modifier map and returns the map.
|
|
21
|
+
*
|
|
22
|
+
* @param modifier
|
|
23
|
+
* @param map
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
function addModifiers(modifiers, map) {
|
|
27
|
+
if (!map) {
|
|
28
|
+
map = new Map();
|
|
29
|
+
}
|
|
30
|
+
(0, array_1.forEachWithArray)(modifiers, (modifier) => map.set(modifier.key, modifier));
|
|
31
|
+
return map;
|
|
32
|
+
}
|
|
33
|
+
exports.addModifiers = addModifiers;
|
|
34
|
+
/**
|
|
35
|
+
* Removes a modifier from the modifier map and returns the map.
|
|
36
|
+
*
|
|
37
|
+
* @param modifier
|
|
38
|
+
* @param map
|
|
39
|
+
*/
|
|
40
|
+
function removeModifiers(modifiers, map) {
|
|
41
|
+
if (map) {
|
|
42
|
+
(0, array_1.forEachWithArray)(modifiers, (modifier) => map.delete(modifier.key));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
map = new Map();
|
|
46
|
+
}
|
|
47
|
+
return map;
|
|
48
|
+
}
|
|
49
|
+
exports.removeModifiers = removeModifiers;
|
|
50
|
+
function modifierMapToFunction(map) {
|
|
51
|
+
var _a;
|
|
52
|
+
return (_a = maybeModifierMapToFunction(map)) !== null && _a !== void 0 ? _a : (() => undefined);
|
|
53
|
+
}
|
|
54
|
+
exports.modifierMapToFunction = modifierMapToFunction;
|
|
55
|
+
/**
|
|
56
|
+
* Converts a ModifierMap to a ModifierFunction if the map is input or has functions. Otherwise returns undefined.
|
|
57
|
+
*
|
|
58
|
+
* @param map
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
function maybeModifierMapToFunction(map) {
|
|
62
|
+
const fns = [];
|
|
63
|
+
map === null || map === void 0 ? void 0 : map.forEach((x) => fns.push(x.modify));
|
|
64
|
+
return (input) => {
|
|
65
|
+
fns.forEach((fn) => fn(input));
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.maybeModifierMapToFunction = maybeModifierMapToFunction;
|
|
69
|
+
//# sourceMappingURL=modifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifier.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/modifier.ts"],"names":[],"mappings":";;;AAAA,oCAA0D;AA8B1D;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAI,GAAW,EAAE,MAA2B;IAClE,OAAO;QACL,GAAG;QACH,MAAM;KACP,CAAC;AACJ,CAAC;AALD,4BAKC;AAOD;;;;;;GAMG;AACH,SAAgB,YAAY,CAAI,SAAoC,EAAE,GAA2B;IAC/F,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;KACjB;IAED,IAAA,wBAAgB,EAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5E,OAAO,GAAG,CAAC;AACb,CAAC;AARD,oCAQC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAI,SAAoC,EAAE,GAA0B;IACjG,IAAI,GAAG,EAAE;QACP,IAAA,wBAAgB,EAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;KACtE;SAAM;QACL,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;KACjB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AARD,0CAQC;AAGD,SAAgB,qBAAqB,CAAI,GAA0B;;IACjE,OAAO,MAAA,0BAA0B,CAAC,GAAG,CAAC,mCAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC9D,CAAC;AAFD,sDAEC;AAGD;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAI,GAA0B;IACtE,MAAM,GAAG,GAA0B,EAAE,CAAC;IACtC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAND,gEAMC"}
|
package/src/test/index.d.ts
CHANGED
package/src/test/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
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./jest"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./jest.wrap"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./jest.function"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/src/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/util/src/test/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/util/src/test/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,sDAA4B;AAC5B,0DAAgC"}
|
package/src/test/jest.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PromiseOrValue } from '@dereekb/util';
|
|
1
2
|
/**
|
|
2
3
|
* A fixture instance that is generated new for each test run.
|
|
3
4
|
*/
|
|
@@ -13,6 +14,8 @@ export interface JestTestFixture<I> {
|
|
|
13
14
|
export declare type JestTestContextFixtureClearInstanceFunction = () => void;
|
|
14
15
|
/**
|
|
15
16
|
* JestTestFixture with additional functions that the JestTestContextFactory sees for managing the instance.
|
|
17
|
+
*
|
|
18
|
+
* The fixture is used as a refernce point for the Instance that is changed between each test.
|
|
16
19
|
*/
|
|
17
20
|
export interface JestTestContextFixture<I> extends JestTestFixture<I> {
|
|
18
21
|
/**
|
|
@@ -32,6 +35,13 @@ export declare abstract class AbstractJestTestContextFixture<I> implements JestT
|
|
|
32
35
|
get instance(): I;
|
|
33
36
|
setInstance(instance: I): JestTestContextFixtureClearInstanceFunction;
|
|
34
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Abstract JestTestContextFixture instance with a parent.
|
|
40
|
+
*/
|
|
41
|
+
export declare abstract class AbstractChildJestTestContextFixture<I, P extends JestTestContextFixture<any>> extends AbstractJestTestContextFixture<I> {
|
|
42
|
+
readonly parent: P;
|
|
43
|
+
constructor(parent: P);
|
|
44
|
+
}
|
|
35
45
|
export declare type JestBuildTestsWithContextFunction<F> = (fixture: F) => void;
|
|
36
46
|
/**
|
|
37
47
|
* Used for Jest tests to execute a number of tests using the fixture.
|
|
@@ -49,7 +59,7 @@ export interface JestTestContextBuilderConfig<I, F extends JestTestContextFixtur
|
|
|
49
59
|
*/
|
|
50
60
|
buildConfig: (config?: Partial<C>) => C;
|
|
51
61
|
/**
|
|
52
|
-
* Builds a new fixture to use across all
|
|
62
|
+
* Builds a new fixture to use across all encapsulated tests.
|
|
53
63
|
*/
|
|
54
64
|
buildFixture: (config: C) => F;
|
|
55
65
|
/**
|
|
@@ -78,3 +88,13 @@ export interface JestTestContextBuilderConfig<I, F extends JestTestContextFixtur
|
|
|
78
88
|
* @returns
|
|
79
89
|
*/
|
|
80
90
|
export declare function jestTestContextBuilder<I, F extends JestTestContextFixture<I>, C>(builder: JestTestContextBuilderConfig<I, F, C>): JestTestContextBuilderFunction<I, F, C>;
|
|
91
|
+
export interface UseJestContextFixture<C extends JestTestContextFixture<I>, I> {
|
|
92
|
+
readonly fixture: C;
|
|
93
|
+
readonly buildTests: JestBuildTestsWithContextFunction<C>;
|
|
94
|
+
initInstance(): PromiseOrValue<I>;
|
|
95
|
+
destroyInstance?(instance: I): PromiseOrValue<void>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a test context and jest configurations that will initialize an instance
|
|
99
|
+
*/
|
|
100
|
+
export declare function useJestContextFixture<C extends JestTestContextFixture<I>, I>(config: UseJestContextFixture<C, I>): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Getter } from "../lib/getter/getter";
|
|
2
|
+
export interface UseJestFunctionFixture<I extends (...args: any[]) => O, O = any> {
|
|
3
|
+
fn: Getter<I>;
|
|
4
|
+
}
|
|
5
|
+
export declare type JestFunctionFixtureBuildTests<I> = (fn: I) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a test context and jest configurations that provides a function to build tests based on the configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useJestFunctionFixture<I extends (...args: any[]) => O, O = any>(config: UseJestFunctionFixture<I, O>, buildTests: JestFunctionFixtureBuildTests<I>): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useJestFunctionFixture = void 0;
|
|
4
|
+
const function_forward_1 = require("../lib/function/function.forward");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a test context and jest configurations that provides a function to build tests based on the configuration.
|
|
7
|
+
*/
|
|
8
|
+
function useJestFunctionFixture(config, buildTests) {
|
|
9
|
+
const { fn } = config;
|
|
10
|
+
const forward = (0, function_forward_1.forwardFunction)(fn);
|
|
11
|
+
buildTests(forward);
|
|
12
|
+
}
|
|
13
|
+
exports.useJestFunctionFixture = useJestFunctionFixture;
|
|
14
|
+
//# sourceMappingURL=jest.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.function.js","sourceRoot":"","sources":["../../../../../packages/util/src/test/jest.function.ts"],"names":[],"mappings":";;;AAAA,uEAAmE;AASnE;;GAEG;AACH,SAAgB,sBAAsB,CAA2C,MAAoC,EAAE,UAA4C;IACjK,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;IAEtB,MAAM,OAAO,GAAG,IAAA,kCAAe,EAAC,EAAE,CAAC,CAAC;IACpC,UAAU,CAAC,OAAO,CAAC,CAAC;AACtB,CAAC;AALD,wDAKC"}
|