@tb-dev/utils 1.0.3 → 1.0.5
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/index.cjs +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +10 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
+
function isEmpty(value) {
|
|
6
|
+
if (Array.isArray(value) || typeof value === 'string') {
|
|
7
|
+
return value.length === 0;
|
|
8
|
+
}
|
|
9
|
+
if (value instanceof Map || value instanceof Set) {
|
|
10
|
+
return value.size === 0;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
5
14
|
function toArray(item) {
|
|
6
15
|
const array = item ?? [];
|
|
7
16
|
return Array.isArray(array) ? array : [array];
|
|
@@ -12,5 +21,6 @@ function toPixel(value) {
|
|
|
12
21
|
return `${value}px`;
|
|
13
22
|
}
|
|
14
23
|
|
|
24
|
+
exports.isEmpty = isEmpty;
|
|
15
25
|
exports.toArray = toArray;
|
|
16
26
|
exports.toPixel = toPixel;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { MaybeArray } from '@tb-dev/utility-types';
|
|
2
2
|
import type { Nullish } from '@tb-dev/utility-types';
|
|
3
3
|
|
|
4
|
+
export declare function isEmpty(value?: Nullish<string>): boolean;
|
|
5
|
+
|
|
6
|
+
export declare function isEmpty<T>(value?: Nullish<T[]>): boolean;
|
|
7
|
+
|
|
8
|
+
export declare function isEmpty<K>(value?: Nullish<Set<K>>): boolean;
|
|
9
|
+
|
|
10
|
+
export declare function isEmpty<K, V>(value?: Nullish<Map<K, V>>): boolean;
|
|
11
|
+
|
|
4
12
|
export declare function toArray<T>(item?: Nullish<MaybeArray<T>>): T[];
|
|
5
13
|
|
|
6
14
|
export declare function toPixel(value: string | number): string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
function isEmpty(value) {
|
|
2
|
+
if (Array.isArray(value) || typeof value === 'string') {
|
|
3
|
+
return value.length === 0;
|
|
4
|
+
}
|
|
5
|
+
if (value instanceof Map || value instanceof Set) {
|
|
6
|
+
return value.size === 0;
|
|
7
|
+
}
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
1
10
|
function toArray(item) {
|
|
2
11
|
const array = item ?? [];
|
|
3
12
|
return Array.isArray(array) ? array : [array];
|
|
@@ -8,4 +17,4 @@ function toPixel(value) {
|
|
|
8
17
|
return `${value}px`;
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
export { toArray, toPixel };
|
|
20
|
+
export { isEmpty, toArray, toPixel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "TypeScript utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"husky": "^8.0.3",
|
|
39
39
|
"lint-staged": "^15.2.0",
|
|
40
40
|
"prettier": "^3.1.1",
|
|
41
|
-
"rollup": "^4.9.
|
|
41
|
+
"rollup": "^4.9.4",
|
|
42
42
|
"taze": "^0.13.1",
|
|
43
43
|
"tslib": "^2.6.2",
|
|
44
44
|
"typedoc": "^0.25.6",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"format": "prettier . --write",
|
|
69
69
|
"format-check": "prettier . --check",
|
|
70
70
|
"lint": "eslint . --config eslint.config.js --cache",
|
|
71
|
+
"release": "nr bump && nr build && pnpm publish",
|
|
71
72
|
"type-check": "tsc --noEmit"
|
|
72
73
|
}
|
|
73
74
|
}
|