type-fns 0.8.1 → 0.9.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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * these are the keys most commonly used metadata keys
3
3
  */
4
- declare const typicalMetadataKeys: readonly ["id", "uuid", "createdAt", "updatedAt", "effectiveAt"];
4
+ declare const typicalMetadataKeys: readonly ["id", "uuid", "createdAt", "updatedAt", "deletedAt", "effectiveAt"];
5
5
  /**
6
6
  * these are the keys most commonly used metadata keys
7
7
  */
@@ -14,6 +14,7 @@ type TypicalMetadataKeys = typeof typicalMetadataKeys[number];
14
14
  * - `uuid`
15
15
  * - `createdAt`
16
16
  * - `updatedAt`
17
+ * - `deletedAt`
17
18
  * - `effectiveAt`
18
19
  *
19
20
  * note:
@@ -32,9 +33,10 @@ MetadataKeys>>;
32
33
  * - `uuid`
33
34
  * - `createdAt`
34
35
  * - `updatedAt`
36
+ * - `deletedAt`
35
37
  * - `effectiveAt`
36
38
  *
37
39
  * see more information about the `HasMetadata` type in its jsdoc on-hover documentation
38
40
  */
39
- export declare const hasMetadata: <MetadataKeys extends string = "id" | "uuid" | "createdAt" | "updatedAt" | "effectiveAt", T extends Record<string, any> = Record<string, any>>(obj: T, keys?: MetadataKeys[]) => obj is HasMetadata<T, MetadataKeys>;
41
+ export declare const hasMetadata: <MetadataKeys extends string = "id" | "uuid" | "createdAt" | "updatedAt" | "deletedAt" | "effectiveAt", T extends Record<string, any> = Record<string, any>>(obj: T, keys?: MetadataKeys[]) => obj is HasMetadata<T, MetadataKeys>;
40
42
  export {};
@@ -9,6 +9,7 @@ const typicalMetadataKeys = [
9
9
  'uuid',
10
10
  'createdAt',
11
11
  'updatedAt',
12
+ 'deletedAt',
12
13
  'effectiveAt',
13
14
  ];
14
15
  /**
@@ -19,6 +20,7 @@ const typicalMetadataKeys = [
19
20
  * - `uuid`
20
21
  * - `createdAt`
21
22
  * - `updatedAt`
23
+ * - `deletedAt`
22
24
  * - `effectiveAt`
23
25
  *
24
26
  * see more information about the `HasMetadata` type in its jsdoc on-hover documentation
@@ -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,aAAa;CACL,CAAC;AAmCX;;;;;;;;;;;GAWG;AACI,MAAM,WAAW,GAAG,CAIzB,GAAM,EACN,OAAuB,mBAA4C,EACvB,EAAE,CAC9C,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;AAPjC,QAAA,WAAW,eAOsB"}
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;AAoCX;;;;;;;;;;;;GAYG;AACI,MAAM,WAAW,GAAG,CAIzB,GAAM,EACN,OAAuB,mBAA4C,EACvB,EAAE,CAC9C,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;AAPjC,QAAA,WAAW,eAOsB"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * a companion to the `Omit` type, returns a new object without the omitted attributes
3
+ */
4
+ export declare const omit: <T extends Record<string, any>>(obj: T, keys: (keyof T)[]) => Omit<T, keyof T>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omit = void 0;
4
+ /**
5
+ * a companion to the `Omit` type, returns a new object without the omitted attributes
6
+ */
7
+ const omit = (obj, keys) => Object.entries(obj).reduce((summary, [key, value]) => {
8
+ // if key is in the specified keys, dont add it to the new object
9
+ if (keys.includes(key))
10
+ return summary;
11
+ // if it is not within specified keys, add it
12
+ return Object.assign(Object.assign({}, summary), { [key]: value });
13
+ }, {});
14
+ exports.omit = omit;
15
+ //# sourceMappingURL=omit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/companions/omit.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,IAAI,GAAG,CAClB,GAAM,EACN,IAAiB,EACa,EAAE,CAChC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IACnD,iEAAiE;IACjE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAEvC,6CAA6C;IAC7C,uCAAY,OAAO,KAAE,CAAC,GAAG,CAAC,EAAE,KAAK,IAAG;AACtC,CAAC,EAAE,EAAyB,CAAQ,CAAC;AAV1B,QAAA,IAAI,QAUsB"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * a companion to the `Pick` type, returns a new object with only the picked attributes
3
+ */
4
+ export declare const pick: <T extends Record<string, any>>(obj: T, keys: (keyof T)[]) => Pick<T, keyof T>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pick = void 0;
4
+ /**
5
+ * a companion to the `Pick` type, returns a new object with only the picked attributes
6
+ */
7
+ const pick = (obj, keys) => Object.entries(obj).reduce((summary, [key, value]) => {
8
+ // if key is not in the specified keys, dont add it to the new object
9
+ if (!keys.includes(key))
10
+ return summary;
11
+ // if it is within specified keys, add it
12
+ return Object.assign(Object.assign({}, summary), { [key]: value });
13
+ }, {});
14
+ exports.pick = pick;
15
+ //# sourceMappingURL=pick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.js","sourceRoot":"","sources":["../../src/companions/pick.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,IAAI,GAAG,CAClB,GAAM,EACN,IAAiB,EACa,EAAE,CAChC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IACnD,qEAAqE;IACrE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAExC,yCAAyC;IACzC,uCAAY,OAAO,KAAE,CAAC,GAAG,CAAC,EAAE,KAAK,IAAG;AACtC,CAAC,EAAE,EAAyB,CAAQ,CAAC;AAV1B,QAAA,IAAI,QAUsB"}
package/dist/index.d.ts CHANGED
@@ -10,3 +10,5 @@ export * from './types/PickOne';
10
10
  export * from './checks/isNotNull';
11
11
  export * from './checks/isNotUndefined';
12
12
  export * from './types/DropFirst';
13
+ export * from './companions/omit';
14
+ export * from './companions/pick';
package/dist/index.js CHANGED
@@ -26,4 +26,6 @@ __exportStar(require("./types/PickOne"), exports);
26
26
  __exportStar(require("./checks/isNotNull"), exports);
27
27
  __exportStar(require("./checks/isNotUndefined"), exports);
28
28
  __exportStar(require("./types/DropFirst"), exports);
29
+ __exportStar(require("./companions/omit"), exports);
30
+ __exportStar(require("./companions/pick"), exports);
29
31
  //# 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,qDAAmC;AACnC,oDAAkC;AAClC,qDAAmC;AACnC,uDAAqC;AACrC,sDAAoC;AACpC,kDAAgC;AAChC,qDAAmC;AACnC,0DAAwC;AACxC,oDAAkC"}
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;AACnC,uDAAqC;AACrC,sDAAoC;AACpC,kDAAgC;AAChC,qDAAmC;AACnC,0DAAwC;AACxC,oDAAkC;AAClC,oDAAkC;AAClC,oDAAkC"}
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": "0.8.1",
5
+ "version": "0.9.1",
6
6
  "repository": "ehmpathy/type-fns",
7
7
  "homepage": "https://github.com/ehmpathy/type-fns",
8
8
  "keywords": [
@@ -25,25 +25,23 @@
25
25
  ],
26
26
  "scripts": {
27
27
  "commit:with-cli": "npx cz",
28
- "fix:format:terraform": "echo 'no terraform'",
29
28
  "fix:format:prettier": "prettier --write '**/*.ts' --config ./prettier.config.js",
30
- "fix:format": "npm run fix:format:prettier && npm run fix:format:terraform",
29
+ "fix:format": "npm run fix:format:prettier",
31
30
  "fix:lint": "eslint -c ./.eslintrc.js src/**/*.ts --fix",
32
31
  "build:artifact": "echo 'no artifact'",
33
32
  "build:clean": "rm dist/ -rf",
34
33
  "build:compile": "tsc -p ./tsconfig.build.json",
35
- "build": "npm run build:clean && npm run build:compile && npm run build:artifact",
34
+ "build": "npm run build:clean && npm run build:compile",
36
35
  "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
36
  "test:types": "tsc -p ./tsconfig.build.json --noEmit",
38
37
  "prepublish": "npm run build",
39
- "test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
40
- "test:format:terraform": "echo 'no terraform'",
41
38
  "test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
42
- "test:format": "npm run test:format:prettier && npm run test:format:terraform",
39
+ "test:format": "npm run test:format:prettier",
40
+ "test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
41
+ "test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
43
42
  "test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
44
43
  "test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests",
45
44
  "test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests",
46
- "test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
47
45
  "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
48
46
  "test": "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",
49
47
  "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
@@ -62,8 +60,8 @@
62
60
  "@typescript-eslint/parser": "5.46.1",
63
61
  "core-js": "3.26.1",
64
62
  "cz-conventional-changelog": "3.3.0",
65
- "declapract": "^0.10.9",
66
- "declapract-typescript-ehmpathy": "^0.20.11",
63
+ "declapract": "0.11.2",
64
+ "declapract-typescript-ehmpathy": "0.23.7",
67
65
  "depcheck": "1.4.3",
68
66
  "eslint": "8.30.0",
69
67
  "eslint-config-airbnb-typescript": "17.0.0",
package/readme.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # type-fns
2
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
3
  Narrow your codepaths with generic types, type checks, and type guards for simpler, safer, and easier to read code.
7
4
 
8
5
  # Purpose