@tb-dev/utils 1.0.7 → 1.0.9
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 +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +13 -1
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,18 @@ function isEmpty(value) {
|
|
|
11
11
|
}
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
|
+
function repeat(amount, fn) {
|
|
15
|
+
let n = Math.trunc(amount);
|
|
16
|
+
if (n < 1) {
|
|
17
|
+
n = 0;
|
|
18
|
+
}
|
|
19
|
+
else if (n > Number.MAX_SAFE_INTEGER) {
|
|
20
|
+
n = Number.MAX_SAFE_INTEGER;
|
|
21
|
+
}
|
|
22
|
+
for (let i = 0; i < n; i++) {
|
|
23
|
+
fn(i);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
14
26
|
function toArray(item) {
|
|
15
27
|
const array = item ?? [];
|
|
16
28
|
return Array.isArray(array) ? array : [array];
|
|
@@ -22,5 +34,6 @@ function toPixel(value) {
|
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
exports.isEmpty = isEmpty;
|
|
37
|
+
exports.repeat = repeat;
|
|
25
38
|
exports.toArray = toArray;
|
|
26
39
|
exports.toPixel = toPixel;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare function isEmpty<K>(value?: Nullish<Set<K>>): boolean;
|
|
|
9
9
|
|
|
10
10
|
export declare function isEmpty<K, V>(value?: Nullish<Map<K, V>>): boolean;
|
|
11
11
|
|
|
12
|
+
export declare function repeat(amount: number, fn: (current?: number) => void): void;
|
|
13
|
+
|
|
12
14
|
export declare function toArray<T>(item?: Nullish<MaybeArray<T>>): T[];
|
|
13
15
|
|
|
14
16
|
export declare function toPixel(value: string | number): string;
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,18 @@ function isEmpty(value) {
|
|
|
7
7
|
}
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
|
+
function repeat(amount, fn) {
|
|
11
|
+
let n = Math.trunc(amount);
|
|
12
|
+
if (n < 1) {
|
|
13
|
+
n = 0;
|
|
14
|
+
}
|
|
15
|
+
else if (n > Number.MAX_SAFE_INTEGER) {
|
|
16
|
+
n = Number.MAX_SAFE_INTEGER;
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < n; i++) {
|
|
19
|
+
fn(i);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
10
22
|
function toArray(item) {
|
|
11
23
|
const array = item ?? [];
|
|
12
24
|
return Array.isArray(array) ? array : [array];
|
|
@@ -17,4 +29,4 @@ function toPixel(value) {
|
|
|
17
29
|
return `${value}px`;
|
|
18
30
|
}
|
|
19
31
|
|
|
20
|
-
export { isEmpty, toArray, toPixel };
|
|
32
|
+
export { isEmpty, repeat, 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.9",
|
|
4
4
|
"description": "TypeScript utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"*.{?(c|m)@(j|t)s,vue}": "pnpm lint"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@tb-dev/utility-types": "^1.0.
|
|
31
|
+
"@tb-dev/utility-types": "^1.0.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rollup/plugin-typescript": "^11.1.5",
|
|
35
|
-
"@tb-dev/eslint-config": "^1.5.
|
|
35
|
+
"@tb-dev/eslint-config": "^1.5.12",
|
|
36
36
|
"@types/node": "^20.10.6",
|
|
37
37
|
"eslint": "^8.56.0",
|
|
38
38
|
"husky": "^8.0.3",
|
|
@@ -45,8 +45,7 @@
|
|
|
45
45
|
"typedoc-plugin-mdn-links": "^3.1.10",
|
|
46
46
|
"typescript": "5.3.3",
|
|
47
47
|
"vite": "^5.0.11",
|
|
48
|
-
"vite-plugin-dts": "^3.7.0"
|
|
49
|
-
"vue": "^3.4.5"
|
|
48
|
+
"vite-plugin-dts": "^3.7.0"
|
|
50
49
|
},
|
|
51
50
|
"files": [
|
|
52
51
|
"dist"
|