@tb-dev/utils 4.1.7 → 5.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/LICENSE +1 -1
- package/dist/array/to-array.d.ts +2 -2
- package/dist/string/split-whitespace.d.ts +2 -2
- package/dist/types.d.ts +4 -9
- package/package.json +7 -7
package/LICENSE
CHANGED
package/dist/array/to-array.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MaybeArray,
|
|
1
|
+
import { MaybeArray, Option } from '../types';
|
|
2
2
|
/** Converts the item to an array if it isn't already. */
|
|
3
|
-
export declare function toArray<T>(item?:
|
|
3
|
+
export declare function toArray<T>(item?: Option<MaybeArray<T>>): T[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Option } from '../types';
|
|
2
2
|
import { TrimArrayOptions } from '../array/trim-array';
|
|
3
3
|
export type SplitWhitespaceOptions = TrimArrayOptions;
|
|
4
4
|
/**
|
|
@@ -11,4 +11,4 @@ export type SplitWhitespaceOptions = TrimArrayOptions;
|
|
|
11
11
|
* splitWhitespace(['a ', ['b', ['c d']]]); // ['a', 'b', 'c', 'd']
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export declare function splitWhitespace(value:
|
|
14
|
+
export declare function splitWhitespace(value: Option<string | string[]>, options?: SplitWhitespaceOptions): string[];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
export type ExtractPartial<T, K extends keyof T> = Partial<T>[K];
|
|
2
2
|
export type ExtractRequired<T, K extends keyof T> = Required<T>[K];
|
|
3
|
+
/** Void function. */
|
|
3
4
|
export type Fn = () => void;
|
|
4
5
|
/** Something may be an array. */
|
|
5
6
|
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
7
|
/** Something may be a promise. */
|
|
9
8
|
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
10
|
-
/** Something may be a Set. */
|
|
11
|
-
export type MaybeSet<T> = T | Set<T>;
|
|
12
9
|
/** Null or undefined. */
|
|
13
10
|
export type Nil = null | undefined;
|
|
14
11
|
/** Something may be nullish. */
|
|
15
|
-
export type
|
|
16
|
-
/** Something may be nullish. */
|
|
17
|
-
export type Option<T> = Nullish<T>;
|
|
12
|
+
export type Option<T> = T | Nil;
|
|
18
13
|
/** Constructs a type where all properties of `T` may be null. */
|
|
19
14
|
export type PartialNull<T> = {
|
|
20
15
|
[P in keyof T]: T[P] | null;
|
|
21
16
|
};
|
|
22
17
|
/** Constructs a type where all properties of `T` may be nullish. */
|
|
23
18
|
export type PartialNullish<T> = {
|
|
24
|
-
[P in keyof T]?:
|
|
19
|
+
[P in keyof T]?: Option<T[P]>;
|
|
25
20
|
};
|
|
26
21
|
/** Like `Pick`, but constructs the type based on the values. */
|
|
27
22
|
export type PickByValue<T, V> = {
|
|
@@ -32,7 +27,7 @@ export type PickPartial<T, K extends keyof T> = Pick<Partial<T>, K>;
|
|
|
32
27
|
/** Constructs a type by picking the set of properties `K` from a required version of `T`. */
|
|
33
28
|
export type PickRequired<T, K extends keyof T> = Pick<Required<T>, K>;
|
|
34
29
|
/** Removes the readonly modifier from all properties of T. */
|
|
35
|
-
export type
|
|
30
|
+
export type Writable<T> = {
|
|
36
31
|
-readonly [P in keyof T]: T[P];
|
|
37
32
|
};
|
|
38
33
|
/** Constructs a type consisting of some properties of T set to partial. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "TypeScript utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"typescript"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@tb-dev/eslint-config": "^6.
|
|
27
|
-
"@types/node": "^22.13.
|
|
26
|
+
"@tb-dev/eslint-config": "^6.5.0",
|
|
27
|
+
"@types/node": "^22.13.9",
|
|
28
28
|
"@vitest/ui": "^3.0.7",
|
|
29
29
|
"eslint": "^9.21.0",
|
|
30
|
-
"prettier": "^3.5.
|
|
30
|
+
"prettier": "^3.5.3",
|
|
31
31
|
"tslib": "^2.8.1",
|
|
32
32
|
"typedoc": "^0.27.9",
|
|
33
|
-
"typedoc-plugin-mdn-links": "^
|
|
34
|
-
"typescript": "^5.
|
|
33
|
+
"typedoc-plugin-mdn-links": "^5.0.1",
|
|
34
|
+
"typescript": "^5.8.2",
|
|
35
35
|
"vite": "^6.2.0",
|
|
36
|
-
"vite-plugin-dts": "^4.5.
|
|
36
|
+
"vite-plugin-dts": "^4.5.3",
|
|
37
37
|
"vitest": "^3.0.7"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|