@takeshape/util 10.52.5 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +18 -0
- package/es/types.js +18 -0
- package/package.json +3 -3
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,27 @@ export type PickByValue<T, ValueType> = Pick<T, {
|
|
|
14
14
|
export type StringProps<Obj> = {
|
|
15
15
|
[K in keyof Required<Obj>]: Obj[K] extends string ? K : never;
|
|
16
16
|
}[keyof Obj];
|
|
17
|
+
/**
|
|
18
|
+
* Remove index from a type
|
|
19
|
+
* Adapted from https://stackoverflow.com/a/51955852
|
|
20
|
+
* @example
|
|
21
|
+
* // Given:
|
|
22
|
+
* type Foo = {
|
|
23
|
+
* a: string;
|
|
24
|
+
* b: number:
|
|
25
|
+
* [k: string]: unknown
|
|
26
|
+
* };
|
|
27
|
+
* type Bar = RemoveIndex<Foo>;
|
|
28
|
+
* // Is equivalent to:
|
|
29
|
+
* type Bar = {
|
|
30
|
+
* a: string;
|
|
31
|
+
* b: number:
|
|
32
|
+
* };
|
|
33
|
+
*/
|
|
34
|
+
export type RemoveIndex<T> = {
|
|
35
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
36
|
+
};
|
|
37
|
+
export type KnownKeys<T> = keyof RemoveIndex<T>;
|
|
17
38
|
/**
|
|
18
39
|
* A guard for objects that ensures they are plain objects, and thus, can
|
|
19
40
|
* reasonably be typed as a Record.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAIzC;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,SAAS,IAAI,IAAI,CAA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CAEpD"}
|
package/dist/types.js
CHANGED
|
@@ -23,6 +23,24 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
23
23
|
* type Bar = keyof PickByValue<Foo, string>;
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Remove index from a type
|
|
28
|
+
* Adapted from https://stackoverflow.com/a/51955852
|
|
29
|
+
* @example
|
|
30
|
+
* // Given:
|
|
31
|
+
* type Foo = {
|
|
32
|
+
* a: string;
|
|
33
|
+
* b: number:
|
|
34
|
+
* [k: string]: unknown
|
|
35
|
+
* };
|
|
36
|
+
* type Bar = RemoveIndex<Foo>;
|
|
37
|
+
* // Is equivalent to:
|
|
38
|
+
* type Bar = {
|
|
39
|
+
* a: string;
|
|
40
|
+
* b: number:
|
|
41
|
+
* };
|
|
42
|
+
*/
|
|
43
|
+
|
|
26
44
|
/**
|
|
27
45
|
* A guard for objects that ensures they are plain objects, and thus, can
|
|
28
46
|
* reasonably be typed as a Record.
|
package/es/types.js
CHANGED
|
@@ -11,6 +11,24 @@ import isPlainObject from 'lodash/isPlainObject';
|
|
|
11
11
|
* type Bar = keyof PickByValue<Foo, string>;
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Remove index from a type
|
|
16
|
+
* Adapted from https://stackoverflow.com/a/51955852
|
|
17
|
+
* @example
|
|
18
|
+
* // Given:
|
|
19
|
+
* type Foo = {
|
|
20
|
+
* a: string;
|
|
21
|
+
* b: number:
|
|
22
|
+
* [k: string]: unknown
|
|
23
|
+
* };
|
|
24
|
+
* type Bar = RemoveIndex<Foo>;
|
|
25
|
+
* // Is equivalent to:
|
|
26
|
+
* type Bar = {
|
|
27
|
+
* a: string;
|
|
28
|
+
* b: number:
|
|
29
|
+
* };
|
|
30
|
+
*/
|
|
31
|
+
|
|
14
32
|
/**
|
|
15
33
|
* A guard for objects that ensures they are plain objects, and thus, can
|
|
16
34
|
* reasonably be typed as a Record.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/util",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Shared utilities",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"shortid": "^2.2.16",
|
|
33
33
|
"tiny-invariant": "^1.2.0",
|
|
34
34
|
"url-parse": "^1.5.3",
|
|
35
|
-
"@takeshape/routing": "
|
|
35
|
+
"@takeshape/routing": "11.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/classnames": "^2.2.9",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"stripe": "13.8.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=20"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "pnpm build:js && pnpm build:es && pnpm build:types && pnpm build:copy",
|