@tb-dev/utils 1.8.5 → 2.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/array.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/string.d.ts +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.js +1 -0
- package/package.json +12 -10
package/dist/array.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybeArray, Nullish } from '
|
|
1
|
+
import { MaybeArray, Nullish } from './types';
|
|
2
2
|
|
|
3
3
|
/** Pushes an item to the array if it doesn't exist, otherwise updates it. */
|
|
4
4
|
export declare function upsert<T>(array: T[], item: T, predicate: (value: T) => boolean): void;
|
package/dist/index.d.ts
CHANGED
package/dist/string.d.ts
CHANGED
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type ExtractPartial<T, K extends keyof T> = Partial<T>[K];
|
|
2
|
+
export type ExtractRequired<T, K extends keyof T> = Required<T>[K];
|
|
3
|
+
export type Fn = () => void;
|
|
4
|
+
/** Something may be an array. */
|
|
5
|
+
export type MaybeArray<T> = T | T[];
|
|
6
|
+
/** Something may be an array or a Set. */
|
|
7
|
+
export type MaybeArrayOrSet<T> = MaybeArray<T> | MaybeSet<T>;
|
|
8
|
+
/** Something may be a promise. */
|
|
9
|
+
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
10
|
+
/** Something may be a Set. */
|
|
11
|
+
export type MaybeSet<T> = T | Set<T>;
|
|
12
|
+
/** Something may be nullish. */
|
|
13
|
+
export type Nullish<T> = T | null | undefined;
|
|
14
|
+
/** Constructs a type where all properties of `T` may be nullish. */
|
|
15
|
+
export type PartialNullish<T> = {
|
|
16
|
+
[P in keyof T]?: Nullish<T[P]>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Like `Pick`, but constructs the type based on the values.
|
|
20
|
+
*/
|
|
21
|
+
export type PickByValue<T, V> = {
|
|
22
|
+
[P in keyof T as T[P] extends V ? P : never]: T[P];
|
|
23
|
+
};
|
|
24
|
+
/** Constructs a type by picking the set of properties `K` from a partial version of `T`. */
|
|
25
|
+
export type PickPartial<T, K extends keyof T> = Pick<Partial<T>, K>;
|
|
26
|
+
/** Constructs a type by picking the set of properties `K` from a required version of `T`. */
|
|
27
|
+
export type PickRequired<T, K extends keyof T> = Pick<Required<T>, K>;
|
|
28
|
+
export type StringifyObject<T> = {
|
|
29
|
+
[P in keyof T]: string;
|
|
30
|
+
};
|
|
31
|
+
/** Constructs a type consisting of some properties of T set to partial. */
|
|
32
|
+
export type WithPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
33
|
+
/** Constructs a type consisting of some properties of T set to partial. */
|
|
34
|
+
export type WithRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "TypeScript utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,21 +26,18 @@
|
|
|
26
26
|
"*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write",
|
|
27
27
|
"*.{?(c|m)@(j|t)s,vue}": "pnpm run lint"
|
|
28
28
|
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@tb-dev/utility-types": "^1.4.1"
|
|
31
|
-
},
|
|
32
29
|
"devDependencies": {
|
|
33
|
-
"@tb-dev/eslint-config": "^3.8.
|
|
34
|
-
"@types/node": "^20.14.
|
|
30
|
+
"@tb-dev/eslint-config": "^3.8.8",
|
|
31
|
+
"@types/node": "^20.14.10",
|
|
35
32
|
"eslint": "^8.57.0",
|
|
36
33
|
"husky": "^9.0.11",
|
|
37
34
|
"lint-staged": "^15.2.7",
|
|
38
35
|
"prettier": "^3.3.2",
|
|
39
36
|
"tslib": "^2.6.3",
|
|
40
|
-
"typedoc": "^0.26.
|
|
41
|
-
"typedoc-plugin-mdn-links": "^3.2.
|
|
42
|
-
"typescript": "^5.5.
|
|
43
|
-
"vite": "^5.3.
|
|
37
|
+
"typedoc": "^0.26.4",
|
|
38
|
+
"typedoc-plugin-mdn-links": "^3.2.3",
|
|
39
|
+
"typescript": "^5.5.3",
|
|
40
|
+
"vite": "^5.3.3",
|
|
44
41
|
"vite-plugin-dts": "^3.9.1"
|
|
45
42
|
},
|
|
46
43
|
"files": [
|
|
@@ -79,6 +76,11 @@
|
|
|
79
76
|
"types": "./dist/string.d.ts",
|
|
80
77
|
"import": "./dist/string.js",
|
|
81
78
|
"require": "./dist/string.cjs"
|
|
79
|
+
},
|
|
80
|
+
"./types": {
|
|
81
|
+
"types": "./dist/types.d.ts",
|
|
82
|
+
"import": "./dist/types.js",
|
|
83
|
+
"require": "./dist/types.cjs"
|
|
82
84
|
}
|
|
83
85
|
},
|
|
84
86
|
"scripts": {
|