@tb-dev/utils 4.0.0 → 4.0.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.
- package/dist/function/index.d.ts +1 -0
- package/dist/function/noop.d.ts +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/nil/is-nil.d.ts +2 -1
- package/dist/types.d.ts +3 -1
- package/package.json +11 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './noop';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noop: () => void;
|
package/dist/index.cjs
CHANGED
|
@@ -12,7 +12,7 @@ function isNil(value) {
|
|
|
12
12
|
}
|
|
13
13
|
const isNullish = isNil;
|
|
14
14
|
function upsert(array, item, predicate) {
|
|
15
|
-
const index = array.findIndex(predicate ?? ((
|
|
15
|
+
const index = array.findIndex(predicate ?? ((value) => value === item));
|
|
16
16
|
if (index === -1) {
|
|
17
17
|
array.push(item);
|
|
18
18
|
} else {
|
|
@@ -85,6 +85,8 @@ class PromiseSet {
|
|
|
85
85
|
return set;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
const noop = () => {
|
|
89
|
+
};
|
|
88
90
|
function isEmpty(value) {
|
|
89
91
|
if (isNullish(value)) {
|
|
90
92
|
return true;
|
|
@@ -97,8 +99,6 @@ function isEmpty(value) {
|
|
|
97
99
|
}
|
|
98
100
|
return false;
|
|
99
101
|
}
|
|
100
|
-
const noop = () => {
|
|
101
|
-
};
|
|
102
102
|
function toPixel(value) {
|
|
103
103
|
if (typeof value === "number" || typeof value === "string" && regex.float.test(value)) {
|
|
104
104
|
return `${value}px`;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './regex';
|
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './string';
|
|
7
7
|
export * from './promise';
|
|
8
|
+
export * from './function';
|
|
8
9
|
/**
|
|
9
10
|
* Checks if a value is empty.
|
|
10
11
|
*
|
|
@@ -15,6 +16,5 @@ export * from './promise';
|
|
|
15
16
|
* Any other value is considered empty only if it is nullish.
|
|
16
17
|
*/
|
|
17
18
|
export declare function isEmpty(value?: unknown): boolean;
|
|
18
|
-
export declare const noop: () => void;
|
|
19
19
|
/** Adds the pixel unit to a value. */
|
|
20
20
|
export declare function toPixel(value: string | number): string;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ function isNil(value) {
|
|
|
10
10
|
}
|
|
11
11
|
const isNullish = isNil;
|
|
12
12
|
function upsert(array, item, predicate) {
|
|
13
|
-
const index = array.findIndex(predicate ?? ((
|
|
13
|
+
const index = array.findIndex(predicate ?? ((value) => value === item));
|
|
14
14
|
if (index === -1) {
|
|
15
15
|
array.push(item);
|
|
16
16
|
} else {
|
|
@@ -83,6 +83,8 @@ class PromiseSet {
|
|
|
83
83
|
return set;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
const noop = () => {
|
|
87
|
+
};
|
|
86
88
|
function isEmpty(value) {
|
|
87
89
|
if (isNullish(value)) {
|
|
88
90
|
return true;
|
|
@@ -95,8 +97,6 @@ function isEmpty(value) {
|
|
|
95
97
|
}
|
|
96
98
|
return false;
|
|
97
99
|
}
|
|
98
|
-
const noop = () => {
|
|
99
|
-
};
|
|
100
100
|
function toPixel(value) {
|
|
101
101
|
if (typeof value === "number" || typeof value === "string" && regex.float.test(value)) {
|
|
102
102
|
return `${value}px`;
|
package/dist/nil/is-nil.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ export type MaybeArrayOrSet<T> = MaybeArray<T> | MaybeSet<T>;
|
|
|
9
9
|
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
10
10
|
/** Something may be a Set. */
|
|
11
11
|
export type MaybeSet<T> = T | Set<T>;
|
|
12
|
+
/** Null or undefined. */
|
|
13
|
+
export type Nil = null | undefined;
|
|
12
14
|
/** Something may be nullish. */
|
|
13
|
-
export type Nullish<T> = T |
|
|
15
|
+
export type Nullish<T> = T | Nil;
|
|
14
16
|
/** Constructs a type where all properties of `T` may be null. */
|
|
15
17
|
export type PartialNull<T> = {
|
|
16
18
|
[P in keyof T]: T[P] | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "TypeScript utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,24 +22,19 @@
|
|
|
22
22
|
"utils",
|
|
23
23
|
"typescript"
|
|
24
24
|
],
|
|
25
|
-
"lint-staged": {
|
|
26
|
-
"*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write"
|
|
27
|
-
},
|
|
28
25
|
"devDependencies": {
|
|
29
|
-
"@tb-dev/eslint-config": "^5.
|
|
30
|
-
"@types/node": "^22.7.
|
|
31
|
-
"@vitest/ui": "^2.1.
|
|
32
|
-
"eslint": "^9.
|
|
33
|
-
"husky": "^9.1.6",
|
|
34
|
-
"lint-staged": "^15.2.10",
|
|
26
|
+
"@tb-dev/eslint-config": "^5.4.2",
|
|
27
|
+
"@types/node": "^22.7.5",
|
|
28
|
+
"@vitest/ui": "^2.1.2",
|
|
29
|
+
"eslint": "^9.12.0",
|
|
35
30
|
"prettier": "^3.3.3",
|
|
36
31
|
"tslib": "^2.7.0",
|
|
37
|
-
"typedoc": "^0.26.
|
|
38
|
-
"typedoc-plugin-mdn-links": "^3.3.
|
|
39
|
-
"typescript": "^5.6.
|
|
32
|
+
"typedoc": "^0.26.9",
|
|
33
|
+
"typedoc-plugin-mdn-links": "^3.3.3",
|
|
34
|
+
"typescript": "^5.6.3",
|
|
40
35
|
"vite": "^5.4.8",
|
|
41
|
-
"vite-plugin-dts": "^4.2.
|
|
42
|
-
"vitest": "^2.1.
|
|
36
|
+
"vite-plugin-dts": "^4.2.4",
|
|
37
|
+
"vitest": "^2.1.2"
|
|
43
38
|
},
|
|
44
39
|
"files": [
|
|
45
40
|
"dist"
|
|
@@ -61,7 +56,7 @@
|
|
|
61
56
|
"format-check": "prettier . --check",
|
|
62
57
|
"lint": "eslint . --config eslint.config.js --cache",
|
|
63
58
|
"lint-fix": "eslint . --config eslint.config.js --fix",
|
|
64
|
-
"release": "pnpm run build && pnpm publish",
|
|
59
|
+
"release": "pnpm run test && pnpm run build && pnpm publish",
|
|
65
60
|
"test": "vitest",
|
|
66
61
|
"test:ui": "vitest --ui --watch",
|
|
67
62
|
"type-check": "tsc --noEmit",
|