type-fns 1.20.2 → 1.21.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/dist/checks/hasMetadata.d.ts +1 -1
- package/dist/checks/hasMetadata.js +4 -1
- package/dist/checks/hasMetadata.js.map +1 -1
- package/dist/checks/isOfEnum.d.ts +1 -1
- package/dist/checks/isOfEnum.js.map +1 -1
- package/dist/checks/isPresent.assess.d.ts +2 -2
- package/dist/checks/isPresent.assess.js.map +1 -1
- package/dist/checks/isPresent.d.ts +2 -2
- package/dist/checks/isPresent.js +1 -3
- package/dist/checks/isPresent.js.map +1 -1
- package/dist/companions/omit.js.map +1 -1
- package/dist/companions/pick.js.map +1 -1
- package/dist/{domain → domain.objects}/constants.d.ts +1 -0
- package/dist/{domain → domain.objects}/constants.js +1 -0
- package/dist/domain.objects/constants.js.map +1 -0
- package/dist/guards/assure.d.ts +16 -0
- package/dist/guards/assure.js +27 -0
- package/dist/guards/assure.js.map +1 -0
- package/dist/index.d.ts +11 -10
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/types/ArrayWith.d.ts +2 -1
- package/dist/types/ArrayWith.js +1 -0
- package/dist/wrappers/withAssure.js +1 -3
- package/dist/wrappers/withAssure.js.map +1 -1
- package/package.json +62 -40
- package/readme.md +25 -0
- package/dist/checks/hasId.test.d.ts +0 -1
- package/dist/checks/hasId.test.js +0 -16
- package/dist/checks/hasId.test.js.map +0 -1
- package/dist/checks/hasMetadata.test.d.ts +0 -1
- package/dist/checks/hasMetadata.test.js +0 -29
- package/dist/checks/hasMetadata.test.js.map +0 -1
- package/dist/checks/hasUuid.test.d.ts +0 -1
- package/dist/checks/hasUuid.test.js +0 -16
- package/dist/checks/hasUuid.test.js.map +0 -1
- package/dist/checks/isAPromise.test.d.ts +0 -1
- package/dist/checks/isAPromise.test.js +0 -25
- package/dist/checks/isAPromise.test.js.map +0 -1
- package/dist/checks/isNotNull.test.d.ts +0 -1
- package/dist/checks/isNotNull.test.js +0 -19
- package/dist/checks/isNotNull.test.js.map +0 -1
- package/dist/checks/isNotUndefined.test.d.ts +0 -1
- package/dist/checks/isNotUndefined.test.js +0 -19
- package/dist/checks/isNotUndefined.test.js.map +0 -1
- package/dist/checks/isOfEnum.test.d.ts +0 -1
- package/dist/checks/isOfEnum.test.js +0 -38
- package/dist/checks/isOfEnum.test.js.map +0 -1
- package/dist/checks/isPresent.test.d.ts +0 -1
- package/dist/checks/isPresent.test.js +0 -78
- package/dist/checks/isPresent.test.js.map +0 -1
- package/dist/companions/omit.test.d.ts +0 -1
- package/dist/companions/omit.test.js +0 -11
- package/dist/companions/omit.test.js.map +0 -1
- package/dist/companions/pick.test.d.ts +0 -1
- package/dist/companions/pick.test.js +0 -11
- package/dist/companions/pick.test.js.map +0 -1
- package/dist/domain/constants.js.map +0 -1
- package/dist/types/ArrayWith.test.d.ts +0 -1
- package/dist/types/ArrayWith.test.js +0 -37
- package/dist/types/ArrayWith.test.js.map +0 -1
- package/dist/types/DropFirst.test.d.ts +0 -1
- package/dist/types/DropFirst.test.js +0 -12
- package/dist/types/DropFirst.test.js.map +0 -1
- package/dist/types/Literalize.test.d.ts +0 -1
- package/dist/types/Literalize.test.js +0 -18
- package/dist/types/Literalize.test.js.map +0 -1
- package/dist/types/PickAny.test.d.ts +0 -1
- package/dist/types/PickAny.test.js +0 -36
- package/dist/types/PickAny.test.js.map +0 -1
- package/dist/types/PickOne.test.d.ts +0 -1
- package/dist/types/PickOne.test.js +0 -35
- package/dist/types/PickOne.test.js.map +0 -1
- package/dist/wrappers/withAssure.test.d.ts +0 -1
- package/dist/wrappers/withAssure.test.js +0 -49
- package/dist/wrappers/withAssure.test.js.map +0 -1
- package/dist/wrappers/withNot.test.d.ts +0 -1
- package/dist/wrappers/withNot.test.js +0 -17
- package/dist/wrappers/withNot.test.js.map +0 -1
|
@@ -5,7 +5,7 @@ declare const typicalMetadataKeys: readonly ["id", "uuid", "createdAt", "updated
|
|
|
5
5
|
/**
|
|
6
6
|
* these are the keys most commonly used metadata keys
|
|
7
7
|
*/
|
|
8
|
-
type TypicalMetadataKeys = typeof typicalMetadataKeys[number];
|
|
8
|
+
type TypicalMetadataKeys = (typeof typicalMetadataKeys)[number];
|
|
9
9
|
/**
|
|
10
10
|
* asserts that any optional metadata keys of the object will now be required
|
|
11
11
|
*
|
|
@@ -25,6 +25,9 @@ const typicalMetadataKeys = [
|
|
|
25
25
|
*
|
|
26
26
|
* see more information about the `HasMetadata` type in its jsdoc on-hover documentation
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
// biome-ignore lint/suspicious/noExplicitAny: generic constraint requires any for flexibility
|
|
29
|
+
const hasMetadata = (obj,
|
|
30
|
+
// biome-ignore lint/suspicious/noExplicitAny: type cast required for default parameter
|
|
31
|
+
keys = typicalMetadataKeys) => keys.every((key) => obj[key] !== undefined);
|
|
29
32
|
exports.hasMetadata = hasMetadata;
|
|
30
33
|
//# sourceMappingURL=hasMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasMetadata.js","sourceRoot":"","sources":["../../src/checks/hasMetadata.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,mBAAmB,GAAG;IAC1B,IAAI;IACJ,MAAM;IACN,WAAW;IACX,WAAW;IACX,WAAW;IACX,aAAa;CACL,CAAC;
|
|
1
|
+
{"version":3,"file":"hasMetadata.js","sourceRoot":"","sources":["../../src/checks/hasMetadata.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,mBAAmB,GAAG;IAC1B,IAAI;IACJ,MAAM;IACN,WAAW;IACX,WAAW;IACX,WAAW;IACX,aAAa;CACL,CAAC;AA4DX;;;;;;;;;;;;GAYG;AACH,8FAA8F;AACvF,MAAM,WAAW,GAAG,CAIzB,GAAM;AACN,uFAAuF;AACvF,OAAuB,mBAA4C,EACrB,EAAE,CAChD,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;AARjC,QAAA,WAAW,eAQsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isOfEnum.js","sourceRoot":"","sources":["../../src/checks/isOfEnum.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"isOfEnum.js","sourceRoot":"","sources":["../../src/checks/isOfEnum.ts"],"names":[],"mappings":";;;AAAA,yDAA6E;AAE7E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,cAAc,GAAG,CAG5B,CAAI,EACoD,EAAE;IAC1D,MAAM,KAAK,GAAG,CAAC,KAA+B,EAAuB,EAAE,CACrE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAmB,CAAC,CAAC;IACjD,OAAO,IAAA,uBAAU,EAAC,KAAK,CAAC,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NotNull } from './isNotNull';
|
|
2
|
-
import { IsDefined } from './isNotUndefined';
|
|
1
|
+
import { type NotNull } from './isNotNull';
|
|
2
|
+
import { type IsDefined } from './isNotUndefined';
|
|
3
3
|
declare const assess: <T>(t: T) => t is NotNull<IsDefined<T>>;
|
|
4
4
|
export { assess as isPresentAssess };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPresent.assess.js","sourceRoot":"","sources":["../../src/checks/isPresent.assess.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"isPresent.assess.js","sourceRoot":"","sources":["../../src/checks/isPresent.assess.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AACtD,qDAA6D;AAE7D,MAAM,MAAM,GAAG,CAAI,CAAI,EAA8B,EAAE,CACrD,IAAA,qBAAS,EAAC,CAAC,CAAC,IAAI,IAAA,0BAAS,EAAC,CAAC,CAAC,CAAC;AAGZ,iCAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NotNull } from './isNotNull';
|
|
2
|
-
import { IsDefined } from './isNotUndefined';
|
|
1
|
+
import type { NotNull } from './isNotNull';
|
|
2
|
+
import type { IsDefined } from './isNotUndefined';
|
|
3
3
|
import { isPresentAssess as assess } from './isPresent.assess';
|
|
4
4
|
declare const assure: <T>(input: T) => NotNull<IsDefined<T>>;
|
|
5
5
|
interface IsPresentWithAssure {
|
package/dist/checks/isPresent.js
CHANGED
|
@@ -10,9 +10,7 @@ const assure = (0, withAssure_1.asAssure)(isPresent_assess_1.isPresentAssess, {
|
|
|
10
10
|
* refs
|
|
11
11
|
* - https://github.com/microsoft/TypeScript/issues/16069#issuecomment-566222173
|
|
12
12
|
*/
|
|
13
|
-
const isPresentWithAssure =
|
|
14
|
-
return (0, isPresent_assess_1.isPresentAssess)(...input);
|
|
15
|
-
};
|
|
13
|
+
const isPresentWithAssure = ((...input) => (0, isPresent_assess_1.isPresentAssess)(...input));
|
|
16
14
|
exports.isPresent = isPresentWithAssure;
|
|
17
15
|
isPresentWithAssure.assess = isPresent_assess_1.isPresentAssess;
|
|
18
16
|
isPresentWithAssure.assure = assure;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPresent.js","sourceRoot":"","sources":["../../src/checks/isPresent.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"isPresent.js","sourceRoot":"","sources":["../../src/checks/isPresent.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAIpD,yDAA+D;AAE/D,MAAM,MAAM,GAAG,IAAA,qBAAQ,EAAC,kCAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAQvD;;;;;GAKG;AACH,MAAM,mBAAmB,GAAwB,CAAC,CAChD,GAAG,KAAgC,EACR,EAAE,CAAC,IAAA,kCAAM,EAAC,GAAG,KAAK,CAAC,CAG/C,CAAC;AAI8B,wCAAS;AAHzC,mBAAmB,CAAC,MAAM,GAAG,kCAAM,CAAC;AACpC,mBAAmB,CAAC,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/companions/omit.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,IAAI,GAAG,CAIlB,GAAM,EACN,IAAO,EACa,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/companions/omit.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,IAAI,GAAG,CAIlB,GAAM,EACN,IAAO,EACa,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CACxB,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IACxB,iEAAiE;IACjE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAEvC,6CAA6C;IAC7C,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC,EACD,EAAyB,CACnB,CAAC;AAhBE,QAAA,IAAI,QAgBN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../src/companions/pick.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,IAAI,GAAG,CAIlB,GAAM,EACN,IAAO,EACa,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../src/companions/pick.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,IAAI,GAAG,CAIlB,GAAM,EACN,IAAO,EACa,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CACxB,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IACxB,qEAAqE;IACrE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAExC,yCAAyC;IACzC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC,EACD,EAAyB,CACnB,CAAC;AAhBE,QAAA,IAAI,QAgBN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/domain.objects/constants.ts"],"names":[],"mappings":";;AAAA;;GAEG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AssessIsOfTypeMethod } from '../wrappers/withAssure';
|
|
2
|
+
/**
|
|
3
|
+
* what: a standalone assure function that takes a value and a type.check, returning the value if it passes or throwing if it doesn't
|
|
4
|
+
* why:
|
|
5
|
+
* - enables inline type narrowing with runtime validation in a single expression
|
|
6
|
+
* - useful when you want to assure a value satisfies a type guard without pre-wrapping the guard with `asAssure` or `withAssure`
|
|
7
|
+
*
|
|
8
|
+
* example:
|
|
9
|
+
* ```ts
|
|
10
|
+
* const uuid: Uuid = assure('821e33d6-a330-425d-a393-f97e39113046', isUuid); // passes
|
|
11
|
+
* const uuid: Uuid = assure('not a uuid', isUuid); // throws AssureIsOfTypeRejectionError
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const assure: <I, C extends I>(input: I, check: AssessIsOfTypeMethod<I, C>, options?: {
|
|
15
|
+
name: string;
|
|
16
|
+
}) => C;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assure = void 0;
|
|
4
|
+
const withAssure_1 = require("../wrappers/withAssure");
|
|
5
|
+
/**
|
|
6
|
+
* what: a standalone assure function that takes a value and a type.check, returning the value if it passes or throwing if it doesn't
|
|
7
|
+
* why:
|
|
8
|
+
* - enables inline type narrowing with runtime validation in a single expression
|
|
9
|
+
* - useful when you want to assure a value satisfies a type guard without pre-wrapping the guard with `asAssure` or `withAssure`
|
|
10
|
+
*
|
|
11
|
+
* example:
|
|
12
|
+
* ```ts
|
|
13
|
+
* const uuid: Uuid = assure('821e33d6-a330-425d-a393-f97e39113046', isUuid); // passes
|
|
14
|
+
* const uuid: Uuid = assure('not a uuid', isUuid); // throws AssureIsOfTypeRejectionError
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const assure = (input, check, options) => {
|
|
18
|
+
const name = options?.name ?? check.name;
|
|
19
|
+
if (check(input))
|
|
20
|
+
return input;
|
|
21
|
+
throw new withAssure_1.AssureIsOfTypeRejectionError(`assure.rejection: input does not satisfy type.check '${name}'`, {
|
|
22
|
+
check: name,
|
|
23
|
+
input: input === undefined ? 'undefined' : input,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.assure = assure;
|
|
27
|
+
//# sourceMappingURL=assure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assure.js","sourceRoot":"","sources":["../../src/guards/assure.ts"],"names":[],"mappings":";;;AAAA,yDAGkC;AAElC;;;;;;;;;;;GAWG;AACI,MAAM,MAAM,GAAG,CACpB,KAAQ,EACR,KAAiC,EACjC,OAA0B,EACvB,EAAE;IACL,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;IACzC,IAAI,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/B,MAAM,IAAI,yCAA4B,CACpC,wDAAwD,IAAI,GAAG,EAC/D;QACE,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK;KACjD,CACF,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,MAAM,UAcjB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export * from './checks/hasId';
|
|
2
|
-
export * from './checks/hasUuid';
|
|
3
2
|
export * from './checks/hasMetadata';
|
|
4
|
-
export * from './checks/
|
|
5
|
-
export * from './checks/isOfEnum';
|
|
6
|
-
export * from './wrappers/withNot';
|
|
3
|
+
export * from './checks/hasUuid';
|
|
7
4
|
export * from './checks/isAFunction';
|
|
8
5
|
export * from './checks/isAPromise';
|
|
9
|
-
export * from './
|
|
6
|
+
export * from './checks/isKeyOf';
|
|
10
7
|
export * from './checks/isNotNull';
|
|
11
|
-
export * from './checks/isNotUndefined';
|
|
12
8
|
export * from './checks/isNotPromise';
|
|
13
|
-
export * from './
|
|
9
|
+
export * from './checks/isNotUndefined';
|
|
10
|
+
export * from './checks/isOfEnum';
|
|
11
|
+
export * from './checks/isPresent';
|
|
14
12
|
export * from './companions/omit';
|
|
15
13
|
export * from './companions/pick';
|
|
14
|
+
export * from './guards/assure';
|
|
15
|
+
export * from './types/DropFirst';
|
|
16
|
+
export * from './types/Empty';
|
|
16
17
|
export * from './types/Literalize';
|
|
17
|
-
export * from './wrappers/withAssure';
|
|
18
|
-
export * from './checks/isKeyOf';
|
|
19
18
|
export * from './types/PickAny';
|
|
20
|
-
export * from './types/
|
|
19
|
+
export * from './types/PickOne';
|
|
20
|
+
export * from './wrappers/withAssure';
|
|
21
|
+
export * from './wrappers/withNot';
|
package/dist/index.js
CHANGED
|
@@ -15,23 +15,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./checks/hasId"), exports);
|
|
18
|
-
__exportStar(require("./checks/hasUuid"), exports);
|
|
19
18
|
__exportStar(require("./checks/hasMetadata"), exports);
|
|
20
|
-
__exportStar(require("./checks/
|
|
21
|
-
__exportStar(require("./checks/isOfEnum"), exports);
|
|
22
|
-
__exportStar(require("./wrappers/withNot"), exports);
|
|
19
|
+
__exportStar(require("./checks/hasUuid"), exports);
|
|
23
20
|
__exportStar(require("./checks/isAFunction"), exports);
|
|
24
21
|
__exportStar(require("./checks/isAPromise"), exports);
|
|
25
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./checks/isKeyOf"), exports);
|
|
26
23
|
__exportStar(require("./checks/isNotNull"), exports);
|
|
27
|
-
__exportStar(require("./checks/isNotUndefined"), exports);
|
|
28
24
|
__exportStar(require("./checks/isNotPromise"), exports);
|
|
29
|
-
__exportStar(require("./
|
|
25
|
+
__exportStar(require("./checks/isNotUndefined"), exports);
|
|
26
|
+
__exportStar(require("./checks/isOfEnum"), exports);
|
|
27
|
+
__exportStar(require("./checks/isPresent"), exports);
|
|
30
28
|
__exportStar(require("./companions/omit"), exports);
|
|
31
29
|
__exportStar(require("./companions/pick"), exports);
|
|
30
|
+
__exportStar(require("./guards/assure"), exports);
|
|
31
|
+
__exportStar(require("./types/DropFirst"), exports);
|
|
32
|
+
__exportStar(require("./types/Empty"), exports);
|
|
32
33
|
__exportStar(require("./types/Literalize"), exports);
|
|
33
|
-
__exportStar(require("./wrappers/withAssure"), exports);
|
|
34
|
-
__exportStar(require("./checks/isKeyOf"), exports);
|
|
35
34
|
__exportStar(require("./types/PickAny"), exports);
|
|
36
|
-
__exportStar(require("./types/
|
|
35
|
+
__exportStar(require("./types/PickOne"), exports);
|
|
36
|
+
__exportStar(require("./wrappers/withAssure"), exports);
|
|
37
|
+
__exportStar(require("./wrappers/withNot"), exports);
|
|
37
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,mDAAiC;AACjC,uDAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,uDAAqC;AACrC,mDAAiC;AACjC,uDAAqC;AACrC,sDAAoC;AACpC,mDAAiC;AACjC,qDAAmC;AACnC,wDAAsC;AACtC,0DAAwC;AACxC,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,oDAAkC;AAClC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,qDAAmC;AACnC,kDAAgC;AAChC,kDAAgC;AAChC,wDAAsC;AACtC,qDAAmC"}
|
|
@@ -8,5 +8,6 @@ TLength extends number, TType, TCurrent extends TType[]> = TCurrent['length'] ex
|
|
|
8
8
|
/**
|
|
9
9
|
* declares a type of array with a check on its length
|
|
10
10
|
*/
|
|
11
|
-
type ArrayWith<TCheck extends 'len' | 'min', // todo: support 'max' too?
|
|
11
|
+
export type ArrayWith<TCheck extends 'len' | 'min', // todo: support 'max' too?
|
|
12
12
|
TLength extends number, TType> = BuildArrayWith<TCheck, TLength, TType, []>;
|
|
13
|
+
export {};
|
package/dist/types/ArrayWith.js
CHANGED
|
@@ -46,9 +46,7 @@ exports.asAssure = asAssure;
|
|
|
46
46
|
*/
|
|
47
47
|
const withAssure = (assess, options) => {
|
|
48
48
|
const assure = (0, exports.asAssure)(assess, options);
|
|
49
|
-
const result =
|
|
50
|
-
return assess(...input);
|
|
51
|
-
};
|
|
49
|
+
const result = ((...input) => assess(...input));
|
|
52
50
|
result.assess = assess;
|
|
53
51
|
result.assure = assure;
|
|
54
52
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAssure.js","sourceRoot":"","sources":["../../src/wrappers/withAssure.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAU9C,MAAa,4BAA6B,SAAQ,6BAAY;CAAG;AAAjE,oEAAiE;AAEjE;;;;;;;;;;GAUG;AACI,MAAM,QAAQ,GAAG,CACtB,MAAkC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wD,IAAI,GAAG,EAC/D;gBACE,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK;aACjD,CACF,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACX,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAlBW,QAAA,QAAQ,YAkBnB;AAEF;;;;;;;;;;;;;;GAcG;AACI,MAAM,UAAU,GAAG,CACxB,MAAkC,EAClC,OAA0B,EACF,EAAE;IAC1B,MAAM,MAAM,GAAG,IAAA,gBAAQ,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,CAAC,CACd,GAAG,KAAgC,EACR,EAAE,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAM/C,CAAC;IACF,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAjBW,QAAA,UAAU,cAiBrB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "type-fns",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "A set of types, type checks, and type guards for simpler, safer, and easier to read code.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.21.1",
|
|
6
6
|
"repository": "ehmpathy/type-fns",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/type-fns",
|
|
8
8
|
"keywords": [
|
|
@@ -26,64 +26,86 @@
|
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
28
|
"commit:with-cli": "npx cz",
|
|
29
|
-
"fix:format:
|
|
30
|
-
"fix:format": "npm run fix:format:
|
|
31
|
-
"fix:lint": "
|
|
29
|
+
"fix:format:biome": "biome check --write",
|
|
30
|
+
"fix:format": "npm run fix:format:biome",
|
|
31
|
+
"fix:lint": "biome check --write",
|
|
32
|
+
"fix": "npm run fix:format && npm run fix:lint",
|
|
32
33
|
"build:artifact": "echo 'no artifact'",
|
|
33
|
-
"build:clean": "rm
|
|
34
|
-
"build:
|
|
35
|
-
"build": "npm run build:clean && npm run build:
|
|
34
|
+
"build:clean:bun": "rm -f ./bin/*.bc",
|
|
35
|
+
"build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
|
|
36
|
+
"build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
|
|
37
|
+
"build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
38
|
+
"build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
|
|
39
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
36
40
|
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
37
|
-
"test:types": "tsc -p ./tsconfig.
|
|
38
|
-
"test:format:
|
|
39
|
-
"test:format": "npm run test:format:
|
|
40
|
-
"test:lint:deps": "npx depcheck -c
|
|
41
|
-
"test:lint:
|
|
42
|
-
"test:lint": "
|
|
43
|
-
"test:
|
|
44
|
-
"test:
|
|
45
|
-
"test:
|
|
46
|
-
"test": "
|
|
47
|
-
"test
|
|
41
|
+
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
42
|
+
"test:format:biome": "biome format",
|
|
43
|
+
"test:format": "npm run test:format:biome",
|
|
44
|
+
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
45
|
+
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
46
|
+
"test:lint:biome:all": "biome check",
|
|
47
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
48
|
+
"test:unit": "set -eu && jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ -z \"${THOROUGH:-}\" ] && echo '--changedSince=main') $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
|
|
49
|
+
"test:integration": "set -eu && jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ -z \"${THOROUGH:-}\" ] && echo '--changedSince=main') $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
|
|
50
|
+
"test:acceptance:locally": "set -eu && npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
|
|
51
|
+
"test": "set -eu && npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
52
|
+
"test:acceptance": "set -eu && npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
|
|
48
53
|
"prepush": "npm run test && npm run build",
|
|
49
54
|
"prepublish": "npm run build",
|
|
50
55
|
"preversion": "npm run prepush",
|
|
51
56
|
"postversion": "git push origin HEAD --tags --no-verify",
|
|
52
|
-
"
|
|
53
|
-
"prepare:
|
|
57
|
+
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
58
|
+
"prepare:rhachet": "rhachet init --keys --hooks --roles mechanic behaver driver reviewer librarian ergonomist architect",
|
|
59
|
+
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi",
|
|
60
|
+
"test:lint:cycles": "dpdm --no-warning --no-tree --exit-code circular:1 --exclude '^$' 'src/**/*.ts'",
|
|
61
|
+
"upgrade:rhachet": "rhachet upgrade"
|
|
54
62
|
},
|
|
55
63
|
"dependencies": {
|
|
56
|
-
"
|
|
64
|
+
"domain-objects": "0.31.10",
|
|
65
|
+
"helpful-errors": "1.7.2",
|
|
66
|
+
"type-fns": "1.21.0"
|
|
57
67
|
},
|
|
58
68
|
"devDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@commitlint/
|
|
61
|
-
"@
|
|
69
|
+
"@biomejs/biome": "2.3.8",
|
|
70
|
+
"@commitlint/cli": "19.5.0",
|
|
71
|
+
"@commitlint/config-conventional": "19.5.0",
|
|
72
|
+
"@jest/globals": "30.2.0",
|
|
73
|
+
"@swc/core": "1.15.3",
|
|
74
|
+
"@swc/jest": "0.2.39",
|
|
62
75
|
"@tsconfig/node-lts-strictest": "18.12.1",
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
76
|
+
"@tsconfig/node20": "20.1.5",
|
|
77
|
+
"@tsconfig/strictest": "2.0.5",
|
|
78
|
+
"@types/jest": "30.0.0",
|
|
79
|
+
"@types/node": "22.15.21",
|
|
66
80
|
"core-js": "3.26.1",
|
|
67
|
-
"cz-conventional-changelog": "3.0
|
|
68
|
-
"declapract": "0.
|
|
69
|
-
"declapract-typescript-ehmpathy": "0.
|
|
81
|
+
"cz-conventional-changelog": "3.3.0",
|
|
82
|
+
"declapract": "0.13.18",
|
|
83
|
+
"declapract-typescript-ehmpathy": "0.47.58",
|
|
84
|
+
"declastruct": "1.7.3",
|
|
85
|
+
"declastruct-github": "1.3.5",
|
|
70
86
|
"depcheck": "1.4.3",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"eslint-config-prettier": "8.5.0",
|
|
74
|
-
"eslint-plugin-import": "2.26.0",
|
|
75
|
-
"eslint-plugin-prettier": "4.2.1",
|
|
87
|
+
"dpdm": "4.0.1",
|
|
88
|
+
"esbuild-register": "3.6.0",
|
|
76
89
|
"husky": "8.0.3",
|
|
77
|
-
"jest": "
|
|
78
|
-
"
|
|
79
|
-
"
|
|
90
|
+
"jest": "30.2.0",
|
|
91
|
+
"rhachet": "1.39.8",
|
|
92
|
+
"rhachet-brains-anthropic": "0.4.0",
|
|
93
|
+
"rhachet-brains-xai": "0.3.3",
|
|
94
|
+
"rhachet-roles-bhrain": "0.23.10",
|
|
95
|
+
"rhachet-roles-bhuild": "0.15.1",
|
|
96
|
+
"rhachet-roles-ehmpathy": "1.34.20",
|
|
97
|
+
"test-fns": "1.15.7",
|
|
80
98
|
"ts-jest": "29.1.3",
|
|
81
99
|
"ts-node": "10.9.2",
|
|
82
|
-
"
|
|
100
|
+
"tsc-alias": "1.8.10",
|
|
101
|
+
"tsx": "4.20.6",
|
|
102
|
+
"typescript": "5.4.5",
|
|
103
|
+
"yalc": "1.0.0-pre.53"
|
|
83
104
|
},
|
|
84
105
|
"config": {
|
|
85
106
|
"commitizen": {
|
|
86
107
|
"path": "./node_modules/cz-conventional-changelog"
|
|
87
108
|
}
|
|
88
|
-
}
|
|
109
|
+
},
|
|
110
|
+
"packageManager": "pnpm@10.24.0"
|
|
89
111
|
}
|
package/readme.md
CHANGED
|
@@ -182,3 +182,28 @@ const superCoolApi = async ({
|
|
|
182
182
|
: getConfig; // otherwise, it is the config object already
|
|
183
183
|
}
|
|
184
184
|
```
|
|
185
|
+
|
|
186
|
+
### `assure`
|
|
187
|
+
|
|
188
|
+
The `assure` function takes a value and a type check, returns the value narrowed to the checked type if it passes, or throws an error if it doesn't.
|
|
189
|
+
|
|
190
|
+
This is useful to narrow types inline with runtime validation in a single expression, without needing to wrap your type checks with `withAssure` first.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { assure } from 'type-fns';
|
|
194
|
+
|
|
195
|
+
// define or import a type check
|
|
196
|
+
type Uuid = string & { __brand: 'Uuid' };
|
|
197
|
+
const isUuid = (value: string): value is Uuid =>
|
|
198
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
199
|
+
|
|
200
|
+
// use assure to narrow and validate in one expression
|
|
201
|
+
const uuid: Uuid = assure('821e33d6-a330-425d-a393-f97e39113046', isUuid); // returns the value as Uuid
|
|
202
|
+
const bad: Uuid = assure('not-a-uuid', isUuid); // throws AssureIsOfTypeRejectionError
|
|
203
|
+
|
|
204
|
+
// works great for inline validation
|
|
205
|
+
const processUser = (input: { uuid: string }) => {
|
|
206
|
+
const userUuid: Uuid = assure(input.uuid, isUuid); // throws if invalid, narrows type if valid
|
|
207
|
+
// ...
|
|
208
|
+
};
|
|
209
|
+
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hasId_1 = require("./hasId");
|
|
4
|
-
describe('hasId', () => {
|
|
5
|
-
it('should return true if an object has an id', () => {
|
|
6
|
-
const obj = { id: 821, name: 'bob' };
|
|
7
|
-
const itHasId = (0, hasId_1.hasId)(obj);
|
|
8
|
-
expect(itHasId).toEqual(true);
|
|
9
|
-
});
|
|
10
|
-
it('should return false if an object does not have an id', () => {
|
|
11
|
-
const obj = { name: 'bob' };
|
|
12
|
-
const itHasId = (0, hasId_1.hasId)(obj);
|
|
13
|
-
expect(itHasId).toEqual(false);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=hasId.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hasId.test.js","sourceRoot":"","sources":["../../src/checks/hasId.test.ts"],"names":[],"mappings":";;AAAA,mCAAgC;AAEhC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,GAAG,GAAkC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACpE,MAAM,OAAO,GAAG,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,GAAG,GAAkC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC3D,MAAM,OAAO,GAAG,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const __1 = require("..");
|
|
4
|
-
describe('HasMetadata', () => {
|
|
5
|
-
it('should enable accessing an optional metadata property of a type', () => {
|
|
6
|
-
const pot = { id: 123, age: 72 };
|
|
7
|
-
expect(pot.id.toFixed).toBeDefined(); // no type errors
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
describe('OmitMetadata', () => {
|
|
11
|
-
it('should prevent specifying a metadata property of a type', () => {
|
|
12
|
-
// @ts-expect-error - should not be able to set id
|
|
13
|
-
const pot = { id: 123, age: 72 };
|
|
14
|
-
});
|
|
15
|
-
it('should prevent accessing a metadata property of a type', () => {
|
|
16
|
-
const pot = { age: 72 };
|
|
17
|
-
// @ts-expect-error - should not be able to get id
|
|
18
|
-
expect(pot.id).not.toBeDefined();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('hasMetadata', () => {
|
|
22
|
-
it('should enable accessing an optional metadata property of a type', () => {
|
|
23
|
-
const pot = { id: 123, age: 72 };
|
|
24
|
-
if (!(0, __1.hasMetadata)(pot, ['id']))
|
|
25
|
-
throw new Error('doesnt have metadata');
|
|
26
|
-
expect(pot.id.toFixed).toBeDefined();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
//# sourceMappingURL=hasMetadata.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hasUuid_1 = require("./hasUuid");
|
|
4
|
-
describe('hasUuid', () => {
|
|
5
|
-
it('should return true if an object has an id', () => {
|
|
6
|
-
const obj = { uuid: 'uuid', name: 'bob' };
|
|
7
|
-
const itHasUuid = (0, hasUuid_1.hasUuid)(obj);
|
|
8
|
-
expect(itHasUuid).toEqual(true);
|
|
9
|
-
});
|
|
10
|
-
it('should return false if an object does not have an id', () => {
|
|
11
|
-
const obj = { name: 'bob' };
|
|
12
|
-
const itHasUuid = (0, hasUuid_1.hasUuid)(obj);
|
|
13
|
-
expect(itHasUuid).toEqual(false);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=hasUuid.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hasUuid.test.js","sourceRoot":"","sources":["../../src/checks/hasUuid.test.ts"],"names":[],"mappings":";;AAAA,uCAAoC;AAEpC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,GAAG,GAAoC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC3E,MAAM,SAAS,GAAG,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,GAAG,GAAoC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC7D,MAAM,SAAS,GAAG,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const isAPromise_1 = require("./isAPromise");
|
|
4
|
-
describe('isAPromise', () => {
|
|
5
|
-
it('should return true for promises', () => {
|
|
6
|
-
const descision = (0, isAPromise_1.isAPromise)(Promise.resolve('hello'));
|
|
7
|
-
expect(descision).toEqual(true);
|
|
8
|
-
});
|
|
9
|
-
it('should return false for not promises', () => {
|
|
10
|
-
const descision = (0, isAPromise_1.isAPromise)('hello');
|
|
11
|
-
expect(descision).toEqual(false);
|
|
12
|
-
});
|
|
13
|
-
it('should be usable to narrow the typescript type', () => {
|
|
14
|
-
// imagine we didn't know whether soonerOrLater is a promise or a string
|
|
15
|
-
const soonerOrLater = Promise.resolve('hello');
|
|
16
|
-
// we can use this check to narrow down the typescript type and do operations specific to each type
|
|
17
|
-
if ((0, isAPromise_1.isAPromise)(soonerOrLater)) {
|
|
18
|
-
void soonerOrLater.then(() => 'done');
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
void soonerOrLater.toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
//# sourceMappingURL=isAPromise.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isAPromise.test.js","sourceRoot":"","sources":["../../src/checks/isAPromise.test.ts"],"names":[],"mappings":";;AAAA,6CAA0C;AAE1C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,SAAS,GAAG,IAAA,uBAAU,EAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,SAAS,GAAG,IAAA,uBAAU,EAAC,OAAO,CAAC,CAAC;QACtC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,wEAAwE;QACxE,MAAM,aAAa,GAA6B,OAAO,CAAC,OAAO,CAC7D,OAAO,CACD,CAAC;QAET,mGAAmG;QACnG,IAAI,IAAA,uBAAU,EAAC,aAAa,CAAC,EAAE,CAAC;YAC9B,KAAK,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,KAAK,aAAa,CAAC,WAAW,EAAE,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
-
const __1 = require("..");
|
|
5
|
-
describe('isNotNull', () => {
|
|
6
|
-
it('should constrain type correctly', async () => {
|
|
7
|
-
const maybeNumber = undefined; // valid
|
|
8
|
-
if ((0, __1.isNotNull)(maybeNumber)) {
|
|
9
|
-
const defNumber = maybeNumber; // valid
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe('NotNull', () => {
|
|
14
|
-
it('should constrain type correctly', async () => {
|
|
15
|
-
const notMaybeNumber = 821;
|
|
16
|
-
const onlyNumber = notMaybeNumber; // valid
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=isNotNull.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isNotNull.test.js","sourceRoot":"","sources":["../../src/checks/isNotNull.test.ts"],"names":[],"mappings":";;AAAA,sDAAsD;AACtD,0BAAwC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAG/C,MAAM,WAAW,GAAgB,SAAgB,CAAC,CAAC,QAAQ;QAE3D,IAAI,IAAA,aAAS,EAAC,WAAW,CAAC,EAAE,CAAC;YAC3B,MAAM,SAAS,GAAW,WAAW,CAAC,CAAC,QAAQ;QACjD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAG/C,MAAM,cAAc,GAAyB,GAAU,CAAC;QACxD,MAAM,UAAU,GAAW,cAAc,CAAC,CAAC,QAAQ;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
-
const __1 = require("..");
|
|
5
|
-
describe('isNotUndefined', () => {
|
|
6
|
-
it('should constrain type correctly', async () => {
|
|
7
|
-
const maybeNumber = undefined; // valid
|
|
8
|
-
if ((0, __1.isNotUndefined)(maybeNumber)) {
|
|
9
|
-
const defNumber = maybeNumber; // valid
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe('NotUndefined', () => {
|
|
14
|
-
it('should constrain type correctly', async () => {
|
|
15
|
-
const notMaybeNumber = 821;
|
|
16
|
-
const onlyNumber = notMaybeNumber; // valid
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=isNotUndefined.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isNotUndefined.test.js","sourceRoot":"","sources":["../../src/checks/isNotUndefined.test.ts"],"names":[],"mappings":";;AAAA,sDAAsD;AACtD,0BAAkD;AAElD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAG/C,MAAM,WAAW,GAAgB,SAAgB,CAAC,CAAC,QAAQ;QAE3D,IAAI,IAAA,kBAAc,EAAC,WAAW,CAAC,EAAE,CAAC;YAChC,MAAM,SAAS,GAAW,WAAW,CAAC,CAAC,QAAQ;QACjD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAG/C,MAAM,cAAc,GAA8B,GAAU,CAAC;QAC7D,MAAM,UAAU,GAAW,cAAc,CAAC,CAAC,QAAQ;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const isOfEnum_1 = require("./isOfEnum");
|
|
4
|
-
describe('isOfEnum', () => {
|
|
5
|
-
let Planet;
|
|
6
|
-
(function (Planet) {
|
|
7
|
-
Planet["VENUS"] = "VENUS";
|
|
8
|
-
Planet["EARTH"] = "EARTH";
|
|
9
|
-
Planet["MARS"] = "MARS";
|
|
10
|
-
})(Planet || (Planet = {}));
|
|
11
|
-
it('can be used to assess correctly, default call', () => {
|
|
12
|
-
const isPlanet = (0, isOfEnum_1.createIsOfEnum)(Planet);
|
|
13
|
-
const earthIsPlanet = isPlanet('EARTH');
|
|
14
|
-
const plutoIsPlanet = isPlanet('PLUTO');
|
|
15
|
-
expect(earthIsPlanet).toEqual(true);
|
|
16
|
-
expect(plutoIsPlanet).toEqual(false);
|
|
17
|
-
});
|
|
18
|
-
it('can be used to assess correctly, named call', () => {
|
|
19
|
-
const isPlanet = (0, isOfEnum_1.createIsOfEnum)(Planet);
|
|
20
|
-
const earthIsPlanet = isPlanet.assess('EARTH');
|
|
21
|
-
const plutoIsPlanet = isPlanet.assess('PLUTO');
|
|
22
|
-
expect(earthIsPlanet).toEqual(true);
|
|
23
|
-
expect(plutoIsPlanet).toEqual(false);
|
|
24
|
-
});
|
|
25
|
-
it('can be used to create type guarded branches', () => {
|
|
26
|
-
const isPlanet = (0, isOfEnum_1.createIsOfEnum)(Planet);
|
|
27
|
-
const earth = 'EARTH';
|
|
28
|
-
if (isPlanet.assess(earth)) {
|
|
29
|
-
const home = earth; // no type error
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
it('can be used to create type asserted casts', () => {
|
|
33
|
-
const isPlanet = (0, isOfEnum_1.createIsOfEnum)(Planet);
|
|
34
|
-
const earth = 'EARTH';
|
|
35
|
-
const home = isPlanet.assure(earth);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=isOfEnum.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isOfEnum.test.js","sourceRoot":"","sources":["../../src/checks/isOfEnum.test.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAE5C,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAK,MAIJ;IAJD,WAAK,MAAM;QACT,yBAAe,CAAA;QACf,yBAAe,CAAA;QACf,uBAAa,CAAA;IACf,CAAC,EAJI,MAAM,KAAN,MAAM,QAIV;IACD,EAAE,CAAC,+CAA+C,EAAE,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AC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const test_fns_1 = require("test-fns");
|
|
4
|
-
const isPresent_1 = require("./isPresent");
|
|
5
|
-
describe('isPresent', () => {
|
|
6
|
-
(0, test_fns_1.given)('direct calls should assess by default', () => {
|
|
7
|
-
(0, test_fns_1.when)('called directly', () => {
|
|
8
|
-
(0, test_fns_1.then)('it should return true if is some number, for example', () => {
|
|
9
|
-
const input = 21;
|
|
10
|
-
expect((0, isPresent_1.isPresent)(input)).toEqual(true);
|
|
11
|
-
if (!(0, isPresent_1.isPresent)(input)) {
|
|
12
|
-
const shouldBeNever = input;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
(0, test_fns_1.then)('it should return false if is null', () => {
|
|
16
|
-
const input = null;
|
|
17
|
-
expect((0, isPresent_1.isPresent)(input)).toEqual(false);
|
|
18
|
-
if ((0, isPresent_1.isPresent)(input)) {
|
|
19
|
-
const shouldBeNever = input;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
(0, test_fns_1.then)('it should return false if is undefined', () => {
|
|
23
|
-
const input = undefined;
|
|
24
|
-
expect((0, isPresent_1.isPresent)(input)).toEqual(false);
|
|
25
|
-
if ((0, isPresent_1.isPresent)(input)) {
|
|
26
|
-
const shouldBeNever = input;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
(0, test_fns_1.then)('it should return true if is falsy', () => {
|
|
30
|
-
expect((0, isPresent_1.isPresent)(false)).toEqual(true);
|
|
31
|
-
expect((0, isPresent_1.isPresent)(0)).toEqual(true);
|
|
32
|
-
expect((0, isPresent_1.isPresent)('')).toEqual(true);
|
|
33
|
-
});
|
|
34
|
-
(0, test_fns_1.then)('it should be useful in having correct types after filtering', () => {
|
|
35
|
-
const stringsOrNulls = ['hello', '', null, 'world', undefined]; // type = `(string | null | undefined)[]`
|
|
36
|
-
const strings = stringsOrNulls.filter(isPresent_1.isPresent); // type = string[]
|
|
37
|
-
// check that it did what we expected in runtime
|
|
38
|
-
expect(strings).toEqual(['hello', '', 'world']);
|
|
39
|
-
// check that it successfully informed typescript of this too
|
|
40
|
-
strings.map((string) => string.toUpperCase()); // This should not throw a type error, because the filter should have told typescript it took out the nulls
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
(0, test_fns_1.given)('it has an assess', () => {
|
|
45
|
-
(0, test_fns_1.when)('.assess is called', () => {
|
|
46
|
-
(0, test_fns_1.then)('it should assess correctly', () => {
|
|
47
|
-
expect(isPresent_1.isPresent.assess(21)).toEqual(true);
|
|
48
|
-
expect(isPresent_1.isPresent.assess(null)).toEqual(false);
|
|
49
|
-
expect(isPresent_1.isPresent.assess(undefined)).toEqual(false);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
(0, test_fns_1.given)('it has an assure', () => {
|
|
54
|
-
(0, test_fns_1.when)('.assure is called', () => {
|
|
55
|
-
(0, test_fns_1.then)('it should assure correctly, for a number, for example', () => {
|
|
56
|
-
const input = 21;
|
|
57
|
-
const shouldWork = isPresent_1.isPresent.assure(input);
|
|
58
|
-
// @ts-expect-error // input could be null or undefined
|
|
59
|
-
const shouldFail = input;
|
|
60
|
-
});
|
|
61
|
-
(0, test_fns_1.then)('it should assure correctly, for null', () => {
|
|
62
|
-
const input = null;
|
|
63
|
-
const error = (0, test_fns_1.getError)(() => {
|
|
64
|
-
const shouldWork = isPresent_1.isPresent.assure(input);
|
|
65
|
-
});
|
|
66
|
-
expect(error.message).toContain(`assure.rejection: input does not satisfy type.check 'isPresent'`);
|
|
67
|
-
});
|
|
68
|
-
(0, test_fns_1.then)('it should assure correctly, for undefined', () => {
|
|
69
|
-
const input = undefined;
|
|
70
|
-
const error = (0, test_fns_1.getError)(() => {
|
|
71
|
-
const shouldWork = isPresent_1.isPresent.assure(input);
|
|
72
|
-
});
|
|
73
|
-
expect(error.message).toContain(`assure.rejection: input does not satisfy type.check 'isPresent'`);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=isPresent.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isPresent.test.js","sourceRoot":"","sources":["../../src/checks/isPresent.test.ts"],"names":[],"mappings":";;AAAA,uCAAuD;AAEvD,2CAAwC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAA,gBAAK,EAAC,uCAAuC,EAAE,GAAG,EAAE;QAClD,IAAA,eAAI,EAAC,iBAAiB,EAAE,GAAG,EAAE;YAC3B,IAAA,eAAI,EAAC,sDAAsD,EAAE,GAAG,EAAE;gBAChE,MAAM,KAAK,GAAkB,EAAE,CAAC;gBAEhC,MAAM,CAAC,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEvC,IAAI,CAAC,IAAA,qBAAS,EAAC,KAAK,CAAC,EAAE,CAAC;oBACtB,MAAM,aAAa,GAAU,KAAK,CAAC;gBACrC,CAAC;YACH,CAAC,CAAC,CAAC;YACH,IAAA,eAAI,EAAC,mCAAmC,EAAE,GAAG,EAAE;gBAC7C,MAAM,KAAK,GAAkB,IAAI,CAAC;gBAElC,MAAM,CAAC,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAExC,IAAI,IAAA,qBAAS,EAAC,KAAK,CAAC,EAAE,CAAC;oBACrB,MAAM,aAAa,GAAU,KAAK,CAAC;gBACrC,CAAC;YACH,CAAC,CAAC,CAAC;YACH,IAAA,eAAI,EAAC,wCAAwC,EAAE,GAAG,EAAE;gBAClD,MAAM,KAAK,GAAuB,SAAS,CAAC;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AG,IAAA,mBAAQ,EAAC,GAAG,EAAE;oBAC1B,MAAM,UAAU,GAAW,qBAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrD,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAC7B,iEAAiE,CAClE,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const omit_1 = require("./omit");
|
|
4
|
-
describe('omit', () => {
|
|
5
|
-
it('should satisfy the standard Omit type', () => {
|
|
6
|
-
const withKey = { a: 1, b: 2 };
|
|
7
|
-
const omitKeyTypeFound = (0, omit_1.omit)(withKey, ['a']);
|
|
8
|
-
const omitKeyTypeCheck = omitKeyTypeFound;
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=omit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omit.test.js","sourceRoot":"","sources":["../../src/companions/omit.test.ts"],"names":[],"mappings":";;AAAA,iCAA8B;AAE9B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QAE/B,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9C,MAAM,gBAAgB,GAA8B,gBAAgB,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const pick_1 = require("./pick");
|
|
4
|
-
describe('pick', () => {
|
|
5
|
-
it('should satisfy the standard Pick type', () => {
|
|
6
|
-
const withAll = { a: 1, b: 2 };
|
|
7
|
-
const pickKeyTypeFound = (0, pick_1.pick)(withAll, ['a']);
|
|
8
|
-
const pickKeyTypeCheck = pickKeyTypeFound;
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=pick.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pick.test.js","sourceRoot":"","sources":["../../src/companions/pick.test.ts"],"names":[],"mappings":";;AAAA,iCAA8B;AAE9B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QAE/B,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9C,MAAM,gBAAgB,GAA8B,gBAAgB,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/domain/constants.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const test_fns_1 = require("test-fns");
|
|
4
|
-
describe('ArrayWith', () => {
|
|
5
|
-
(0, test_fns_1.given)('desire for array with min length', () => {
|
|
6
|
-
(0, test_fns_1.then)('we can declare the type', () => {
|
|
7
|
-
let products;
|
|
8
|
-
});
|
|
9
|
-
(0, test_fns_1.then)('it allows arrays of exactly the min length to it', () => {
|
|
10
|
-
const products = ['doughnut']; // 🍩
|
|
11
|
-
});
|
|
12
|
-
(0, test_fns_1.then)('it allows arrays with more than the min length to it', () => {
|
|
13
|
-
const products = ['doughnut', 'waffle']; // 🍩, 🧇
|
|
14
|
-
});
|
|
15
|
-
(0, test_fns_1.then)('it blocks arrays with less than the min length to it', () => {
|
|
16
|
-
// @ts-expect-error; Type '[]' is not assignable to type '[string, ...string[]]'. Source has 0 element(s) but target requires 1.ts(2322)
|
|
17
|
-
const products = []; // 🍩, 🧇
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
(0, test_fns_1.given)('desire for array with exact length', () => {
|
|
21
|
-
(0, test_fns_1.then)('we can declare the type', () => {
|
|
22
|
-
let products;
|
|
23
|
-
});
|
|
24
|
-
(0, test_fns_1.then)('it allows arrays of exactly the desired length to it', () => {
|
|
25
|
-
const products = ['doughnut']; // 🍩
|
|
26
|
-
});
|
|
27
|
-
(0, test_fns_1.then)('it allows arrays with more than the desired length to it', () => {
|
|
28
|
-
// @ts-expect-error; Type '[string, string]' is not assignable to type '[string]'.Source has 2 element(s) but target allows only 1.
|
|
29
|
-
const products = ['doughnut', 'waffle']; // 🍩, 🧇
|
|
30
|
-
});
|
|
31
|
-
(0, test_fns_1.then)('it blocks arrays with less than the desired length to it', () => {
|
|
32
|
-
// @ts-expect-error; Type '[]' is not assignable to type '[string]'. Source has 0 element(s) but target requires 1.ts(2322)
|
|
33
|
-
const products = [];
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=ArrayWith.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayWith.test.js","sourceRoot":"","sources":["../../src/types/ArrayWith.test.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAE7C,QAAQ,CAAC,WAAW,EAAE,GA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CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
-
describe('DropFirst', () => {
|
|
5
|
-
it('should be drop the first type in an array', () => {
|
|
6
|
-
const numStrStr = [1, '2', '3'];
|
|
7
|
-
const strStr = ['1', '2'];
|
|
8
|
-
const str = strStr[0];
|
|
9
|
-
const num = numStrStr[0];
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
//# sourceMappingURL=DropFirst.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropFirst.test.js","sourceRoot":"","sources":["../../src/types/DropFirst.test.ts"],"names":[],"mappings":";;AAEA,sDAAsD;AACtD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QAEnD,MAAM,SAAS,GAAuB,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACpD,MAAM,MAAM,GAAkC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzD,MAAM,GAAG,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAW,SAAS,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
describe('Literalize', () => {
|
|
4
|
-
it('should be able to cast enum into union of literals or enum values', () => {
|
|
5
|
-
let Berry;
|
|
6
|
-
(function (Berry) {
|
|
7
|
-
Berry["RASPBERRY"] = "raspberry";
|
|
8
|
-
Berry["STRAWBERRY"] = "strawberry";
|
|
9
|
-
Berry["BLUEBERRY"] = "blueberry";
|
|
10
|
-
})(Berry || (Berry = {}));
|
|
11
|
-
// @ts-expect-error // 🛑 Type '"raspberry"' is not assignable to type 'Berries'.ts(2322)
|
|
12
|
-
const before = 'raspberry';
|
|
13
|
-
// after
|
|
14
|
-
const literally = 'raspberry';
|
|
15
|
-
const originally = Berry.STRAWBERRY;
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=Literalize.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Literalize.test.js","sourceRoot":"","sources":["../../src/types/Literalize.test.ts"],"names":[],"mappings":";;AAEA,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,IAAK,KAIJ;QAJD,WAAK,KAAK;YACR,gCAAuB,CAAA;YACvB,kCAAyB,CAAA;YACzB,gCAAuB,CAAA;QACzB,CAAC,EAJI,KAAK,KAAL,KAAK,QAIT;QAID,yFAAyF;QACzF,MAAM,MAAM,GAAU,WAAW,CAAC;QAElC,QAAQ;QACR,MAAM,SAAS,GAAa,WAAW,CAAC;QACxC,MAAM,UAAU,GAAa,KAAK,CAAC,UAAU,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
describe('PickAny', () => {
|
|
4
|
-
it('should constrain type correctly', async () => {
|
|
5
|
-
const findFlowers = async (input) => {
|
|
6
|
-
// ...
|
|
7
|
-
};
|
|
8
|
-
// you can find by color
|
|
9
|
-
await findFlowers({
|
|
10
|
-
color: {
|
|
11
|
-
petals: 'white',
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
// you can find by size
|
|
15
|
-
await findFlowers({
|
|
16
|
-
size: {
|
|
17
|
-
choice: 'LARGE',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
// you can find by both
|
|
21
|
-
await findFlowers({
|
|
22
|
-
color: {
|
|
23
|
-
petals: 'white',
|
|
24
|
-
},
|
|
25
|
-
size: {
|
|
26
|
-
choice: 'LARGE',
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
// you can't find by neither
|
|
30
|
-
await findFlowers({
|
|
31
|
-
// @ts-expect-error - cant be neither
|
|
32
|
-
size: {},
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=PickAny.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PickAny.test.js","sourceRoot":"","sources":["../../src/types/PickAny.test.ts"],"names":[],"mappings":";;AAEA,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,WAAW,GAAG,KAAK,EACvB,KAOE,EACF,EAAE;YACF,MAAM;QACR,CAAC,CAAC;QAEF,wBAAwB;QACxB,MAAM,WAAW,CAAC;YAChB,KAAK,EAAE;gBACL,MAAM,EAAE,OAAO;aAChB;SACF,CAAC,CAAC;QAEH,uBAAuB;QACvB,MAAM,WAAW,CAAC;YAChB,IAAI,EAAE;gBACJ,MAAM,EAAE,OAAO;aAChB;SACF,CAAC,CAAC;QAEH,uBAAuB;QACvB,MAAM,WAAW,CAAC;YAChB,KAAK,EAAE;gBACL,MAAM,EAAE,OAAO;aAChB;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,OAAO;aAChB;SACF,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,WAAW,CAAC;YAChB,qCAAqC;YACrC,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
describe('PickOne', () => {
|
|
4
|
-
it('should constrain type correctly', async () => {
|
|
5
|
-
const findWrench = async ({}) => {
|
|
6
|
-
// ...
|
|
7
|
-
};
|
|
8
|
-
// you can find by metric
|
|
9
|
-
await findWrench({
|
|
10
|
-
size: {
|
|
11
|
-
metric: { millimeters: 16 },
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
// you can find by imperial
|
|
15
|
-
await findWrench({
|
|
16
|
-
size: {
|
|
17
|
-
imperial: { inches: '5/16' },
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
// you can't find by both
|
|
21
|
-
await findWrench({
|
|
22
|
-
// @ts-expect-error - cant be both
|
|
23
|
-
size: {
|
|
24
|
-
metric: { millimeters: 16 },
|
|
25
|
-
imperial: { inches: '5/16' },
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
// you can't find by neither
|
|
29
|
-
await findWrench({
|
|
30
|
-
// @ts-expect-error - cant be neither
|
|
31
|
-
size: {},
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=PickOne.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PickOne.test.js","sourceRoot":"","sources":["../../src/types/PickOne.test.ts"],"names":[],"mappings":";;AAEA,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,UAAU,GAAG,KAAK,EAAE,EAezB,EAAE,EAAE;YACH,MAAM;QACR,CAAC,CAAC;QAEF,yBAAyB;QACzB,MAAM,UAAU,CAAC;YACf,IAAI,EAAE;gBACJ,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;aAC5B;SACF,CAAC,CAAC;QAEH,2BAA2B;QAC3B,MAAM,UAAU,CAAC;YACf,IAAI,EAAE;gBACJ,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;aAC7B;SACF,CAAC,CAAC;QAEH,yBAAyB;QACzB,MAAM,UAAU,CAAC;YACf,kCAAkC;YAClC,IAAI,EAAE;gBACJ,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;gBAC3B,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;aAC7B;SACF,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,UAAU,CAAC;YACf,qCAAqC;YACrC,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const test_fns_1 = require("test-fns");
|
|
4
|
-
const withAssure_1 = require("./withAssure");
|
|
5
|
-
describe('asAssure', () => {
|
|
6
|
-
it('should be able to assure for a specific check', () => {
|
|
7
|
-
const isAString = (input) => typeof input === 'string';
|
|
8
|
-
const assure = (0, withAssure_1.asAssure)(isAString);
|
|
9
|
-
const shouldBeString = assure('hi');
|
|
10
|
-
const error = (0, test_fns_1.getError)(() => {
|
|
11
|
-
const shouldThrowBeforeHere = assure(7);
|
|
12
|
-
});
|
|
13
|
-
expect(error.message).toContain(`input does not satisfy type.check 'isAString'`);
|
|
14
|
-
});
|
|
15
|
-
it('should be able to assure for a generic check', () => {
|
|
16
|
-
const isNotNull = (input) => input !== null;
|
|
17
|
-
const assure = (0, withAssure_1.asAssure)(isNotNull);
|
|
18
|
-
const shouldBeString = assure('hi');
|
|
19
|
-
const shouldBeNumber = assure(7);
|
|
20
|
-
const error = (0, test_fns_1.getError)(() => {
|
|
21
|
-
const shouldThrowBeforeHere = assure(null);
|
|
22
|
-
});
|
|
23
|
-
expect(error.message).toContain(`input does not satisfy type.check 'isNotNull'`);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('withAssure', () => {
|
|
27
|
-
it('should be able to add assure to a specific check', () => {
|
|
28
|
-
const isAString = (0, withAssure_1.withAssure)((input) => typeof input === 'string', { name: 'isAString' });
|
|
29
|
-
const shouldBeString = isAString.assure('hi');
|
|
30
|
-
const error = (0, test_fns_1.getError)(() => {
|
|
31
|
-
const shouldThrowBeforeHere = isAString.assure(7);
|
|
32
|
-
});
|
|
33
|
-
expect(error.message).toContain(`input does not satisfy type.check 'isAString'`);
|
|
34
|
-
});
|
|
35
|
-
it.skip('should be able to assure for a generic check', () => {
|
|
36
|
-
const isNotNullOrig = (input) => input !== null;
|
|
37
|
-
const isNotNull = (0, withAssure_1.withAssure)(isNotNullOrig);
|
|
38
|
-
// @ts-expect-error // todo: fix this once typescript enables passing through generic types. (today for generic, ReturnType<AssureMethod> works but ReturnType<{ assure: AssureMethod }> does not, leading this to fail)
|
|
39
|
-
const shouldBeString = isNotNull.assure('hi');
|
|
40
|
-
// @ts-expect-error // todo: fix this once typescript enables passing through generic types. (today for generic, ReturnType<AssureMethod> works but ReturnType<{ assure: AssureMethod }> does not, leading this to fail)
|
|
41
|
-
const shouldBeNumber = isNotNull.assure(7);
|
|
42
|
-
const error = (0, test_fns_1.getError)(() => {
|
|
43
|
-
// @ts-expect-error // todo: fix this once typescript enables passing through generic types. (today for generic, ReturnType<AssureMethod> works but ReturnType<{ assure: AssureMethod }> does not, leading this to fail)
|
|
44
|
-
const shouldThrowBeforeHere = isNotNull.assure(null);
|
|
45
|
-
});
|
|
46
|
-
expect(error.message).toContain(`input does not satisfy type.check 'isNotNull'`);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=withAssure.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withAssure.test.js","sourceRoot":"","sources":["../../src/wrappers/with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"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hasId_1 = require("../checks/hasId");
|
|
4
|
-
const withNot_1 = require("./withNot");
|
|
5
|
-
describe('withNot', () => {
|
|
6
|
-
it('should return false if an object has an id after wrapping hasId', () => {
|
|
7
|
-
const obj = { id: 821, name: 'bob' };
|
|
8
|
-
const itDoesNotHaveId = (0, withNot_1.withNot)(hasId_1.hasId)(obj);
|
|
9
|
-
expect(itDoesNotHaveId).toEqual(false);
|
|
10
|
-
});
|
|
11
|
-
it('should return false if an object does not have an id', () => {
|
|
12
|
-
const obj = { name: 'bob' };
|
|
13
|
-
const itDoesNotHaveId = (0, withNot_1.withNot)(hasId_1.hasId)(obj);
|
|
14
|
-
expect(itDoesNotHaveId).toEqual(true);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=withNot.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withNot.test.js","sourceRoot":"","sources":["../../src/wrappers/withNot.test.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,uCAAoC;AAEpC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,GAAG,GAAkC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACpE,MAAM,eAAe,GAAG,IAAA,iBAAO,EAAC,aAAK,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,GAAG,GAAkC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC3D,MAAM,eAAe,GAAG,IAAA,iBAAO,EAAC,aAAK,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|