@tb-dev/utils 1.1.4 → 1.1.6

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @tb-dev/utils
2
2
 
3
3
  ```bash
4
- pnpm add -D @tb-dev/utils
5
- ```
4
+ pnpm add @tb-dev/utils
5
+ ```
package/dist/index.cjs CHANGED
@@ -1,52 +1,47 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
3
  function splitWhitespace(value) {
6
- if (!value)
7
- return [];
8
- if (Array.isArray(value)) {
9
- const array = value.map((i) => splitWhitespace(i));
10
- return array.flat(Number.POSITIVE_INFINITY);
11
- }
12
- value = value.trim().split(/\s/);
13
- return trimArray(value);
4
+ if (!value)
5
+ return [];
6
+ if (Array.isArray(value)) {
7
+ const array = value.map((i) => splitWhitespace(i));
8
+ return array.flat(Number.POSITIVE_INFINITY);
9
+ }
10
+ value = value.trim().split(/\s/);
11
+ return trimArray(value);
14
12
  }
15
13
  function toArray(item) {
16
- const array = item ?? [];
17
- return Array.isArray(array) ? array : [array];
14
+ const array = item ?? [];
15
+ return Array.isArray(array) ? array : [array];
18
16
  }
19
17
  function trimArray(array) {
20
- return array.map((i) => i.trim()).filter(Boolean);
18
+ return array.map((i) => i.trim()).filter(Boolean);
21
19
  }
22
-
23
20
  function isEmpty(value) {
24
- if (Array.isArray(value) || typeof value === 'string') {
25
- return value.length === 0;
26
- }
27
- if (value instanceof Map || value instanceof Set) {
28
- return value.size === 0;
29
- }
30
- return true;
21
+ if (Array.isArray(value) || typeof value === "string") {
22
+ return value.length === 0;
23
+ }
24
+ if (value instanceof Map || value instanceof Set) {
25
+ return value.size === 0;
26
+ }
27
+ return true;
31
28
  }
32
29
  function repeat(amount, fn) {
33
- let n = Math.trunc(amount);
34
- if (n < 1) {
35
- n = 0;
36
- }
37
- else if (n > Number.MAX_SAFE_INTEGER) {
38
- n = Number.MAX_SAFE_INTEGER;
39
- }
40
- for (let i = 0; i < n; i++) {
41
- fn(i);
42
- }
30
+ let n = Math.trunc(amount);
31
+ if (n < 1) {
32
+ n = 0;
33
+ } else if (n > Number.MAX_SAFE_INTEGER) {
34
+ n = Number.MAX_SAFE_INTEGER;
35
+ }
36
+ for (let i = 0; i < n; i++) {
37
+ fn(i);
38
+ }
43
39
  }
44
40
  function toPixel(value) {
45
- if (typeof value === 'string')
46
- return value;
47
- return `${value}px`;
41
+ if (typeof value === "string")
42
+ return value;
43
+ return `${value}px`;
48
44
  }
49
-
50
45
  exports.isEmpty = isEmpty;
51
46
  exports.repeat = repeat;
52
47
  exports.splitWhitespace = splitWhitespace;
package/dist/index.d.ts CHANGED
@@ -5,10 +5,16 @@ export declare function isEmpty(value?: Nullish<string>): boolean;
5
5
 
6
6
  export declare function isEmpty<T>(value?: Nullish<T[]>): boolean;
7
7
 
8
+ export declare function isEmpty<T>(value?: Nullish<readonly T[]>): boolean;
9
+
8
10
  export declare function isEmpty<K>(value?: Nullish<Set<K>>): boolean;
9
11
 
12
+ export declare function isEmpty<K>(value?: Nullish<ReadonlySet<K>>): boolean;
13
+
10
14
  export declare function isEmpty<K, V>(value?: Nullish<Map<K, V>>): boolean;
11
15
 
16
+ export declare function isEmpty<K, V>(value?: Nullish<ReadonlyMap<K, V>>): boolean;
17
+
12
18
  export declare function repeat(amount: number, fn: (current: number) => void): void;
13
19
 
14
20
  export declare function splitWhitespace(value: Nullish<string | string[]>): string[];
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ function splitWhitespace(value) {
2
+ if (!value)
3
+ return [];
4
+ if (Array.isArray(value)) {
5
+ const array = value.map((i) => splitWhitespace(i));
6
+ return array.flat(Number.POSITIVE_INFINITY);
7
+ }
8
+ value = value.trim().split(/\s/);
9
+ return trimArray(value);
10
+ }
11
+ function toArray(item) {
12
+ const array = item ?? [];
13
+ return Array.isArray(array) ? array : [array];
14
+ }
15
+ function trimArray(array) {
16
+ return array.map((i) => i.trim()).filter(Boolean);
17
+ }
18
+ function isEmpty(value) {
19
+ if (Array.isArray(value) || typeof value === "string") {
20
+ return value.length === 0;
21
+ }
22
+ if (value instanceof Map || value instanceof Set) {
23
+ return value.size === 0;
24
+ }
25
+ return true;
26
+ }
27
+ function repeat(amount, fn) {
28
+ let n = Math.trunc(amount);
29
+ if (n < 1) {
30
+ n = 0;
31
+ } else if (n > Number.MAX_SAFE_INTEGER) {
32
+ n = Number.MAX_SAFE_INTEGER;
33
+ }
34
+ for (let i = 0; i < n; i++) {
35
+ fn(i);
36
+ }
37
+ }
38
+ function toPixel(value) {
39
+ if (typeof value === "string")
40
+ return value;
41
+ return `${value}px`;
42
+ }
43
+ export {
44
+ isEmpty,
45
+ repeat,
46
+ splitWhitespace,
47
+ toArray,
48
+ toPixel,
49
+ trimArray
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/utils",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "TypeScript utils",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,49 +25,47 @@
25
25
  ],
26
26
  "lint-staged": {
27
27
  "*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write",
28
- "*.{?(c|m)@(j|t)s,vue}": "pnpm lint"
28
+ "*.{?(c|m)@(j|t)s,vue}": "pnpm run lint"
29
29
  },
30
30
  "dependencies": {
31
- "@tb-dev/utility-types": "^1.0.9"
31
+ "@tb-dev/utility-types": "^1.0.11"
32
32
  },
33
33
  "devDependencies": {
34
- "@rollup/plugin-typescript": "^11.1.6",
35
- "@tb-dev/eslint-config": "^1.5.15",
36
- "@types/node": "^20.11.0",
34
+ "@tb-dev/eslint-config": "^1.6.5",
35
+ "@types/node": "^20.11.5",
37
36
  "eslint": "^8.56.0",
38
37
  "husky": "^8.0.3",
39
38
  "lint-staged": "^15.2.0",
40
- "prettier": "^3.2.1",
41
- "rollup": "^4.9.5",
39
+ "prettier": "^3.2.4",
42
40
  "taze": "^0.13.1",
43
41
  "tslib": "^2.6.2",
44
42
  "typedoc": "^0.25.7",
45
- "typedoc-plugin-mdn-links": "^3.1.11",
43
+ "typedoc-plugin-mdn-links": "^3.1.12",
46
44
  "typescript": "5.3.3",
47
- "vite": "^5.0.11",
48
- "vite-plugin-dts": "^3.7.0"
45
+ "vite": "^5.0.12",
46
+ "vite-plugin-dts": "^3.7.1"
49
47
  },
50
48
  "files": [
51
49
  "dist"
52
50
  ],
53
51
  "main": "./dist/index.cjs",
54
- "module": "./dist/index.mjs",
52
+ "module": "./dist/index.js",
55
53
  "types": "./dist/index.d.ts",
56
54
  "exports": {
57
55
  ".": {
58
56
  "types": "./dist/index.d.ts",
59
- "import": "./dist/index.mjs",
57
+ "import": "./dist/index.js",
60
58
  "require": "./dist/index.cjs"
61
59
  }
62
60
  },
63
61
  "scripts": {
64
- "build": "rollup --config rollup.config.js",
62
+ "build": "vite build",
65
63
  "bump": "miho bump -k -a .",
66
64
  "docs": "typedoc --plugin typedoc-plugin-mdn-links",
67
65
  "format": "prettier . --write",
68
66
  "format-check": "prettier . --check",
69
67
  "lint": "eslint . --config eslint.config.js --cache",
70
- "release": "nr build && nr bump && pnpm publish",
68
+ "release": "pnpm run build && pnpm run bump && pnpm publish",
71
69
  "type-check": "tsc --noEmit"
72
70
  }
73
71
  }
package/dist/index.mjs DELETED
@@ -1,46 +0,0 @@
1
- function splitWhitespace(value) {
2
- if (!value)
3
- return [];
4
- if (Array.isArray(value)) {
5
- const array = value.map((i) => splitWhitespace(i));
6
- return array.flat(Number.POSITIVE_INFINITY);
7
- }
8
- value = value.trim().split(/\s/);
9
- return trimArray(value);
10
- }
11
- function toArray(item) {
12
- const array = item ?? [];
13
- return Array.isArray(array) ? array : [array];
14
- }
15
- function trimArray(array) {
16
- return array.map((i) => i.trim()).filter(Boolean);
17
- }
18
-
19
- function isEmpty(value) {
20
- if (Array.isArray(value) || typeof value === 'string') {
21
- return value.length === 0;
22
- }
23
- if (value instanceof Map || value instanceof Set) {
24
- return value.size === 0;
25
- }
26
- return true;
27
- }
28
- function repeat(amount, fn) {
29
- let n = Math.trunc(amount);
30
- if (n < 1) {
31
- n = 0;
32
- }
33
- else if (n > Number.MAX_SAFE_INTEGER) {
34
- n = Number.MAX_SAFE_INTEGER;
35
- }
36
- for (let i = 0; i < n; i++) {
37
- fn(i);
38
- }
39
- }
40
- function toPixel(value) {
41
- if (typeof value === 'string')
42
- return value;
43
- return `${value}px`;
44
- }
45
-
46
- export { isEmpty, repeat, splitWhitespace, toArray, toPixel, trimArray };