type-fns 0.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Uladzimir Kasacheuski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # type-fns
2
+
3
+ ![ci_on_commit](https://github.com/ehmpathy/type-fns/workflows/ci_on_commit/badge.svg)
4
+ ![deploy_on_tag](https://github.com/ehmpathy/type-fns/workflows/deploy_on_tag/badge.svg)
5
+
6
+ Narrow your codepaths with generic types, type checks, and type guards for simpler, safer, and easier to read code.
7
+
8
+ # Purpose
9
+
10
+ Narrow your codepaths for simpler, safer, and easier to read code.
11
+ - simplify your code paths with type narrowing using type checks (e.g., `isPresent`, `isAPromise`, `isAFunction`, `isOfEnum`, etc)
12
+ - declare your types more readably with powerful extended types (e.g., `PickOne`, `HasMetadata`, etc)
13
+
14
+ This library is a collection of generic types, type guards, and type checks we've found the need to define over and over again across different domains, collected in one spot for reusability.
15
+
16
+
17
+
18
+ # Background
19
+
20
+ Type guards are built from type checks, built on a type predicate.
21
+ - type predicate: `value is 'blue'`
22
+ - type check: `const isBlue(value: any): value is 'blue' = value === 'blue'`
23
+ - type guard: `if (isBlue(color)) throw new Error('should be blue')`
24
+
25
+ Type guards allow us to to inform typescript we've checked the type of a variable at runtime, enabling type narrowing.
26
+
27
+ _For more information about typescripts type guards, type checks, and type predicates, [see this section in the typescript docs on "narrowing"](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)_
28
+
29
+
30
+ # Install
31
+
32
+ ```sh
33
+ npm install --save type-fns
34
+ ```
35
+
36
+ # Examples
37
+
38
+ ## generic types
39
+
40
+ ### `PickOne`
41
+
42
+ The generic type `PickOne` allows you to specify that only one of the keys in the object can be defined, the others must be undefined.
43
+
44
+ This is very useful when working with an interface where you have exclusive settings. For example:
45
+ ```ts
46
+ import { PickOne } from 'type-fns';
47
+
48
+ const findWrench = async ({
49
+ size,
50
+ }: {
51
+ /**
52
+ * specify the size of the wrench in either `imperial` or `metric` units
53
+ *
54
+ * note
55
+ * - we "PickOne" because this is an exclusive option, a size cant be defined in both
56
+ */
57
+ size: PickOne<{
58
+ metric: {
59
+ millimeters: number,
60
+ }
61
+ imperial: {
62
+ inches: string,
63
+ }
64
+ }>
65
+ }) => {
66
+ // ...
67
+ }
68
+
69
+ // you can find by metric
70
+ await findWrench({
71
+ size: {
72
+ metric: { millimeters: 16 }
73
+ }
74
+ })
75
+
76
+ // you can find by imperial
77
+ await findWrench({
78
+ size: {
79
+ imperial: { inches: '5/16' }
80
+ }
81
+ })
82
+
83
+ // you can't find by both
84
+ await findWrench({
85
+ size: {
86
+ metric: { millimeters: 16 } , // 🛑 typescript error: `Type '{ millimeters: number; }' is not assignable to type 'undefined'.ts(2322)`
87
+ imperial: { inches: '5/16' }
88
+ }
89
+ })
90
+ ```
91
+
92
+ ## type guards
93
+
94
+ ### `isPresent`
95
+
96
+ The type predicate of `isPresent` any informs typescript that if a value passes this type check, the value is _not_ `null` or `undefined`:
97
+
98
+ This is most useful for filtering, to inform typescript that we have removed all `null` or `undefined` values from an array. For example:
99
+ ```ts
100
+ import { isPresent } from 'type-fns';
101
+
102
+ // you have an array that contains strings or nulls
103
+ const stringsOrNulls = ['success:1', 'success:2', null, 'success:3', null]; // type = `(string | null)[]`
104
+
105
+ // now you want to get rid of all the nulls and only think about the strings: use `isPresent`
106
+ const strings = stringsOrNulls.filter(isPresent); // type = string[]
107
+
108
+ // the type predicate on the `isPresent` function informs typescript that all of the nulls and undefineds have been removed
109
+ strings.map((string) => string.toUpperCase()); // now you can operate on the strings without typescript complaining!
110
+ ```
111
+
112
+ ### `isOfEnum`
113
+
114
+ The type predicate of `isOfEnum` allows you to check whether a value is a valid member of an enum. For example:
115
+ ```ts
116
+ import { createIsOfEnum } from 'type-fns';
117
+
118
+ // you have an enum
119
+ enum Planet {
120
+ ...
121
+ VENUS = 'VENUS',
122
+ EARTH = 'EARTH',
123
+ MARS = 'MARS',
124
+ ...
125
+ }
126
+
127
+ // define a type check for your enum
128
+ const isPlanet = createIsOfEnum(Planet);
129
+
130
+ // use your new type check for a type guard
131
+ if (!isPlanet(potentialPlanet)) throw new Error('is not a planet');
132
+ ```
133
+
134
+ ### `isAPromise`
135
+
136
+ The type predicate of `isAPromise` allows you to narrow down the type of any variable that may be a promise
137
+
138
+ ```ts
139
+ import { isAPromise } from 'type-fns';
140
+
141
+ // imagine we didn't know whether soonerOrLater is a promise or a string
142
+ const soonerOrLater: Promise<string> | string = Promise.resolve('hello') as any;
143
+
144
+ // typescript wont let you do things not common between the two types, rightly so
145
+ soonerOrLater.toLowerCase(); // 🛑 typescript error: `Property 'toLowerCase' does not exist on type 'string | Promise<string>'.`
146
+
147
+ // use the type-check to narrow down the the type to operate specifically per type
148
+ if (isAPromise(soonerOrLater)) {
149
+ soonerOrLater.then((value) => value.toLowerCase()); // no error since type was narrowed to `Promise<string>`
150
+ } else {
151
+ soonerOrLater.toLowerCase(); // no error since type was narrowed to `string`
152
+ }
153
+ ```
154
+
155
+ ### `isAFunction`
156
+
157
+ The type predicate of `isAFunction` allows you to narrow down the type of any variable that may be a function
158
+
159
+ This is super helpful when writing apis that can take a literal or a function that creates the literal. For example
160
+ ```ts
161
+ const superCoolApi = async ({
162
+ getConfig
163
+ }: {
164
+ getConfig: Config | () => Promise<Config> // this can be the `Config` object or a function which resolves the `Config` object
165
+ }) => {
166
+ const config: Config = isAFunction(getConfig)
167
+ ? await getConfig() // if getConfig is a function, then execut it and await it to grab the config
168
+ : getConfig; // otherwise, it is the config object already
169
+ }
170
+ ```
package/changelog.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## [0.4.0](https://www.github.com/ehmpathy/type-fns/compare/v0.3.0...v0.4.0) (2022-11-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * **checks:** add isAFunction, isAPromise, and PickOne type checks and generic type ([981ae42](https://www.github.com/ehmpathy/type-fns/commit/981ae4275530bdae203b9013bed193f1afda6b8d))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **cicd:** update github actions, test scripts, and swap repo org to ehmpathy ([b6a1458](https://www.github.com/ehmpathy/type-fns/commit/b6a1458b6d2d5423255fc8eaee2e3181d0c14850))
14
+ * **doc:** fix comment describing has metadata in code ([d7d2e55](https://www.github.com/ehmpathy/type-fns/commit/d7d2e556ba03ad5a573f90d6ea75c5696f493058))
15
+ * **name:** rename package to type-fns ([66258d9](https://www.github.com/ehmpathy/type-fns/commit/66258d93e7964c675b92f50061ddcb11a79f2b69))
16
+ * **tests:** remove example of type error from tests ([326123c](https://www.github.com/ehmpathy/type-fns/commit/326123cf845b31e82edb0d3d50cd6034217df2fa))
17
+
18
+ ## [0.3.0](https://www.github.com/ehmpathy/type-fns/compare/v0.2.1...v0.3.0) (2022-01-03)
19
+
20
+
21
+ ### Features
22
+
23
+ * **checks:** add the HasMetadata type modifier ([85f0ca4](https://www.github.com/ehmpathy/type-fns/commit/85f0ca467983ea6f1fc5845990f98dbe9cbe5e8f))
24
+
25
+ ### [0.2.1](https://www.github.com/ehmpathy/type-fns/compare/v0.2.0...v0.2.1) (2021-11-16)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **enum:** forbid giving isOfEnum functions null or undefined as an input ([98ec621](https://www.github.com/ehmpathy/type-fns/commit/98ec6216bc5775cbb2015f400358fe7d5fffc303))
@@ -0,0 +1,12 @@
1
+ /**
2
+ * asserts that an object has an id
3
+ */
4
+ export declare type HasId<T> = T & {
5
+ id: number;
6
+ };
7
+ /**
8
+ * checks whether not an object that may have an id does have the id, at runtime
9
+ */
10
+ export declare const hasId: <T extends {
11
+ id?: undefined | number;
12
+ }>(obj: T) => obj is HasId<T>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasId = void 0;
4
+ /**
5
+ * checks whether not an object that may have an id does have the id, at runtime
6
+ */
7
+ exports.hasId = (obj) => {
8
+ return !!obj.id;
9
+ };
10
+ //# sourceMappingURL=hasId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasId.js","sourceRoot":"","sources":["../../src/checks/hasId.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACU,QAAA,KAAK,GAAG,CAAwC,GAAM,EAAmB,EAAE;IACtF,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * these are the keys most commonly used metadata keys
3
+ */
4
+ declare type TypicalMetadataKeys = 'id' | 'uuid' | 'createdAt' | 'updatedAt' | 'effectiveAt';
5
+ /**
6
+ * asserts that any optional metadata keys of the object will now be required
7
+ *
8
+ * by default, the following keys are considered to be metadata:
9
+ * - `id`
10
+ * - `uuid`
11
+ * - `createdAt`
12
+ * - `updatedAt`
13
+ * - `effectiveAt`
14
+ *
15
+ * note:
16
+ * - this type does not make any other optional, non-metadata keys required
17
+ * - i.e., any optional types on the object that are not specified as metadata keys will not be made required
18
+ * - this type does not _add_ any database-generated properties to the type definition
19
+ * - i.e., if a metadata key was not already present on the object's type - it will not be added
20
+ */
21
+ export declare type HasMetadata<T extends Record<string, any>, MetadataKeys = TypicalMetadataKeys> = T & Required<Pick<T, keyof T & // that are on the object
22
+ MetadataKeys>>;
23
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=hasMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasMetadata.js","sourceRoot":"","sources":["../../src/checks/hasMetadata.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * asserts that an object has a uuid
3
+ */
4
+ export declare type HasUuid<T> = T & {
5
+ uuid: string;
6
+ };
7
+ /**
8
+ * checks whether not an object that may have a uuid does have the uuid, at runtime
9
+ */
10
+ export declare const hasUuid: <T extends {
11
+ uuid?: undefined | string;
12
+ }>(obj: T) => obj is HasUuid<T>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasUuid = void 0;
4
+ /**
5
+ * checks whether not an object that may have a uuid does have the uuid, at runtime
6
+ */
7
+ exports.hasUuid = (obj) => {
8
+ return typeof obj.uuid === 'string';
9
+ };
10
+ //# sourceMappingURL=hasUuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasUuid.js","sourceRoot":"","sources":["../../src/checks/hasUuid.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACU,QAAA,OAAO,GAAG,CAA0C,GAAM,EAAqB,EAAE;IAC5F,OAAO,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const isAFunction: (obj: any) => obj is Function;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAFunction = void 0;
4
+ exports.isAFunction = (obj) => typeof obj === 'function';
5
+ //# sourceMappingURL=isAFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isAFunction.js","sourceRoot":"","sources":["../../src/checks/isAFunction.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,CAAC,GAAQ,EAAmB,EAAE,CAAC,OAAO,GAAG,KAAK,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * checks whether the value is a promise
3
+ */
4
+ export declare const isAPromise: <T extends unknown = any>(obj: any) => obj is Promise<T>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAPromise = void 0;
4
+ /**
5
+ * checks whether the value is a promise
6
+ */
7
+ exports.isAPromise = (obj) => Promise.resolve(obj) === obj;
8
+ //# sourceMappingURL=isAPromise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isAPromise.js","sourceRoot":"","sources":["../../src/checks/isAPromise.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,UAAU,GAAG,CAAsB,GAAQ,EAAqB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `Something` = `any`, with the exclusion of `null` and `undefined`
3
+ */
4
+ declare type Something = {};
5
+ /**
6
+ * a generic fn that allows us to create type checks for enums. for example:
7
+ * ```ts
8
+ * // you have an enum
9
+ * enum Planet {
10
+ * ...
11
+ * VENUS = 'VENUS',
12
+ * EARTH = 'EARTH',
13
+ * MARS = 'MARS',
14
+ * ...
15
+ * }
16
+ *
17
+ * // define a type check for your enum
18
+ * const isPlanet = createIsOfEnum(Planet);
19
+ *
20
+ * // use your new type check for a type guard
21
+ * if (!isPlanet(potentialPlanet)) throw new Error('is not a planet');
22
+ * ```
23
+ *
24
+ * ref: https://stackoverflow.com/a/58278753/3068233
25
+ */
26
+ export declare const createIsOfEnum: <T>(e: T) => (token: Something) => token is T[keyof T];
27
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIsOfEnum = void 0;
4
+ /**
5
+ * a generic fn that allows us to create type checks for enums. for example:
6
+ * ```ts
7
+ * // you have an enum
8
+ * enum Planet {
9
+ * ...
10
+ * VENUS = 'VENUS',
11
+ * EARTH = 'EARTH',
12
+ * MARS = 'MARS',
13
+ * ...
14
+ * }
15
+ *
16
+ * // define a type check for your enum
17
+ * const isPlanet = createIsOfEnum(Planet);
18
+ *
19
+ * // use your new type check for a type guard
20
+ * if (!isPlanet(potentialPlanet)) throw new Error('is not a planet');
21
+ * ```
22
+ *
23
+ * ref: https://stackoverflow.com/a/58278753/3068233
24
+ */
25
+ exports.createIsOfEnum = (e) => (token) => Object.values(e).includes(token);
26
+ //# sourceMappingURL=isOfEnum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isOfEnum.js","sourceRoot":"","sources":["../../src/checks/isOfEnum.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,cAAc,GAAG,CAAI,CAAI,EAAE,EAAE,CAAC,CAAC,KAAgB,EAAuB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAmB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * checks whether the value is defined and is not null
3
+ *
4
+ * https://github.com/microsoft/TypeScript/issues/16069#issuecomment-566222173
5
+ */
6
+ export declare const isPresent: <T>(t: void | T | null | undefined) => t is T;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPresent = void 0;
4
+ /**
5
+ * checks whether the value is defined and is not null
6
+ *
7
+ * https://github.com/microsoft/TypeScript/issues/16069#issuecomment-566222173
8
+ */
9
+ exports.isPresent = (t) => t !== undefined && t !== null;
10
+ //# sourceMappingURL=isPresent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPresent.js","sourceRoot":"","sources":["../../src/checks/isPresent.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,SAAS,GAAG,CAAI,CAA8B,EAAU,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './checks/hasId';
2
+ export * from './checks/hasUuid';
3
+ export * from './checks/hasMetadata';
4
+ export * from './checks/isPresent';
5
+ export * from './checks/isOfEnum';
6
+ export * from './wrappers/withNot';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./checks/hasId"), exports);
14
+ __exportStar(require("./checks/hasUuid"), exports);
15
+ __exportStar(require("./checks/hasMetadata"), exports);
16
+ __exportStar(require("./checks/isPresent"), exports);
17
+ __exportStar(require("./checks/isOfEnum"), exports);
18
+ __exportStar(require("./wrappers/withNot"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,mDAAiC;AACjC,uDAAqC;AACrC,qDAAmC;AACnC,oDAAkC;AAClC,qDAAmC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * creates a type which allows specifying one, and only one, key of an object
3
+ *
4
+ * ref:
5
+ * - https://stackoverflow.com/a/56933182/3068233
6
+ */
7
+ export declare type PickOne<T> = {
8
+ [P in keyof T]: Record<P, T[P]> & Partial<Record<Exclude<keyof T, P>, undefined>>;
9
+ }[keyof T];
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PickOne.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickOne.js","sourceRoot":"","sources":["../../src/types/PickOne.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * a wrapper that enables you to easily negate the result of a type check function
3
+ *
4
+ * for example:
5
+ * ```ts
6
+ * const withoutIds = objects.filter(withNot(hasUuid));
7
+ *
8
+ * const invalidOptions = objects.filter(withNot(isOfStatus));
9
+ * ```
10
+ */
11
+ export declare const withNot: <T>(is: (args: T) => boolean) => (args: T) => boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withNot = void 0;
4
+ /**
5
+ * a wrapper that enables you to easily negate the result of a type check function
6
+ *
7
+ * for example:
8
+ * ```ts
9
+ * const withoutIds = objects.filter(withNot(hasUuid));
10
+ *
11
+ * const invalidOptions = objects.filter(withNot(isOfStatus));
12
+ * ```
13
+ */
14
+ exports.withNot = (is) => (args) => !is(args);
15
+ //# sourceMappingURL=withNot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withNot.js","sourceRoot":"","sources":["../../src/wrappers/withNot.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACU,QAAA,OAAO,GAAG,CAAI,EAAwB,EAA0B,EAAE,CAAC,CAAC,IAAO,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "type-fns",
3
+ "version": "0.4.0",
4
+ "description": "A set of types, type checks, and type guards for simpler, safer, and easier to read code.",
5
+ "author": "UladKasach @uladkasach",
6
+ "license": "MIT",
7
+ "repository": "ehmpathy/type-fns",
8
+ "homepage": "https://github.com/ehmpathy/type-fns",
9
+ "keywords": [
10
+ "types",
11
+ "type guards",
12
+ "guards",
13
+ "type checks",
14
+ "checks",
15
+ "type",
16
+ "checking",
17
+ "typescript"
18
+ ],
19
+ "bugs": "https://github.com/ehmpathy/type-fns/issues",
20
+ "main": "dist/index.js",
21
+ "engines": {
22
+ "node": ">=8.0.0"
23
+ },
24
+ "files": [
25
+ "/dist"
26
+ ],
27
+ "scripts": {
28
+ "build:clean": "rm -rf ./dist",
29
+ "build:ts": "tsc -p ./tsconfig.build.json",
30
+ "build": "npm run build:clean && npm run build:ts",
31
+ "test:types": "tsc --noEmit",
32
+ "test:format": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
33
+ "test:lint": "eslint -c ./.eslintrc.js src/**/*.ts",
34
+ "test:unit": "jest --forceExit --verbose --passWithNoTests",
35
+ "test:integration": "jest -c ./jest.integration.config.js --forceExit --verbose --passWithNoTests",
36
+ "test": "npm run test:types && npm run test:lint && npm run test:unit && npm run test:integration",
37
+ "prepublish": "npm run build",
38
+ "preversion": "npm run prepublish && npm run test",
39
+ "postversion": "git push origin HEAD --tags --no-verify"
40
+ },
41
+ "devDependencies": {
42
+ "@types/jest": "^24.0.18",
43
+ "@types/lodash.pick": "^4.4.6",
44
+ "@types/uuid": "^3.4.5",
45
+ "@typescript-eslint/eslint-plugin": "2.19.0",
46
+ "@typescript-eslint/parser": "2.19.0",
47
+ "dotenv": "^8.1.0",
48
+ "eslint": "6.1.0",
49
+ "eslint-config-airbnb-base": "14.0.0",
50
+ "eslint-config-airbnb-typescript": "7.0.0",
51
+ "eslint-config-prettier": "6.10.0",
52
+ "eslint-plugin-import": "2.20.1",
53
+ "eslint-plugin-prettier": "3.1.2",
54
+ "husky": "^1.3.1",
55
+ "jest": "^25.5.4",
56
+ "joi": "^17.2.1",
57
+ "prettier": "^2.0.4",
58
+ "ts-jest": "^25.4.0",
59
+ "typescript": "^3.8.3",
60
+ "uuid": "^3.3.3",
61
+ "yup": "^0.29.3"
62
+ },
63
+ "dependencies": {}
64
+ }