@budsbox/lib-es 1.0.0 → 1.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/string.d.ts CHANGED
@@ -7,7 +7,7 @@ export type { ParsedPackageName };
7
7
  *
8
8
  * @param packageName - The full name of the package, potentially including a scope.
9
9
  * @param clean - A flag indicating whether to return a cleaned version (i.e., without a leading `@` and trailing `/`) of the scope. Defaults to false.
10
- * @return An object containing the parsed scope and name of the package. The scope will be `null` if no scope is present.
10
+ * @returns An object containing the parsed scope and name of the package. The scope will be `null` if no scope is present.
11
11
  */
12
12
  export declare function parsePackageName(packageName: string, clean?: boolean): Required<ParsedPackageName>;
13
13
  /**
@@ -22,14 +22,15 @@ export declare function stringifyPackageName(parsedPackageName: Readonly<ParsedP
22
22
  *
23
23
  * @param parsedPackageName - A parsed package name object of type `ParsedPackageName` or a Nil value.
24
24
  * @param allowNil - A boolean flag specifying whether Nil values are allowed for conversion.
25
- * @return The string representation of the package name if valid, or an empty string if `allowNil` is true and the input is Nil.
25
+ * @returns The string representation of the package name if valid, or an empty string if `allowNil` is true and the input is Nil.
26
26
  */
27
27
  export declare function stringifyPackageName(parsedPackageName: Readonly<ParsedPackageName> | Nil, allowNil: true): string;
28
28
  /**
29
- * Returns the string representation of the given value.
30
- * Useful for debugging purposes.
29
+ * Converts the provided value to a string representation suitable for debugging purposes.
31
30
  *
32
- * @param value
31
+ * @param value - The value to be converted to its string representation. Can be of any type.
32
+ * @returns A string representation of the input value.
33
+ * If the value cannot be serialized using JSON.stringify, it falls back to using String conversion.
33
34
  */
34
35
  export declare function debugString(value: unknown): string;
35
36
  /**
@@ -45,7 +46,8 @@ export declare function clampWS(str: string): string;
45
46
  * It ensures that there are no duplicate slashes between the parts
46
47
  * and trims leading/trailing slashes where necessary.
47
48
  *
48
- * @param parts - An array of path parts to join. Each part can be a string, number, boolean, null, or undefined. Non-string values will be stringified, and null/undefined values are ignored.
49
+ * @param parts - An array of path parts to join. Each part can be a string, number, boolean, null, or undefined.
50
+ * Non-string values will be serialized, and null/undefined values are ignored.
49
51
  * @returns The combined path as a single string, with proper slash formatting.
50
52
  */
51
53
  export declare function joinPath(...parts: ReadonlyArray<string | number | boolean | null | undefined>): string;
package/dist/string.js CHANGED
@@ -1,10 +1,10 @@
1
- import { isNil, isNotNil, isString } from '#guards';
1
+ import { isNil, isNotNil } from '#guards';
2
2
  /**
3
3
  * Parses a package name string to extract its scope and name.
4
4
  *
5
5
  * @param packageName - The full name of the package, potentially including a scope.
6
6
  * @param clean - A flag indicating whether to return a cleaned version (i.e., without a leading `@` and trailing `/`) of the scope. Defaults to false.
7
- * @return An object containing the parsed scope and name of the package. The scope will be `null` if no scope is present.
7
+ * @returns An object containing the parsed scope and name of the package. The scope will be `null` if no scope is present.
8
8
  */
9
9
  export function parsePackageName(packageName, clean = false) {
10
10
  const [scope, cleanScope] = /^@([^/]+)\//.exec(packageName) ?? [null, null];
@@ -18,15 +18,14 @@ export function stringifyPackageName(parsedPackageName, allowNil = false) {
18
18
  throw new TypeError('Expected a non-nil value');
19
19
  }
20
20
  const { scope, name } = parsedPackageName ?? { scope: null, name: '' };
21
- return isString(scope) ?
22
- [scope.replace(/^@?([^]+)\/?$/, '@$1'), name].join('/')
23
- : name;
21
+ return joinPath(scope?.replace(/^@?/, '@'), name);
24
22
  }
25
23
  /**
26
- * Returns the string representation of the given value.
27
- * Useful for debugging purposes.
24
+ * Converts the provided value to a string representation suitable for debugging purposes.
28
25
  *
29
- * @param value
26
+ * @param value - The value to be converted to its string representation. Can be of any type.
27
+ * @returns A string representation of the input value.
28
+ * If the value cannot be serialized using JSON.stringify, it falls back to using String conversion.
30
29
  */
31
30
  export function debugString(value) {
32
31
  try {
@@ -51,7 +50,8 @@ export function clampWS(str) {
51
50
  * It ensures that there are no duplicate slashes between the parts
52
51
  * and trims leading/trailing slashes where necessary.
53
52
  *
54
- * @param parts - An array of path parts to join. Each part can be a string, number, boolean, null, or undefined. Non-string values will be stringified, and null/undefined values are ignored.
53
+ * @param parts - An array of path parts to join. Each part can be a string, number, boolean, null, or undefined.
54
+ * Non-string values will be serialized, and null/undefined values are ignored.
55
55
  * @returns The combined path as a single string, with proper slash formatting.
56
56
  */
57
57
  export function joinPath(...parts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budsbox/lib-es",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "homepage": "https://gitlab.com/budsbox/fe/seed",
5
5
  "bugs": {
6
6
  "url": "https://gitlab.com/budsbox/fe/seed/-/issues"
@@ -15,30 +15,50 @@
15
15
  "import": {
16
16
  "default": "./dist/array.js",
17
17
  "types": "./dist/array.d.ts"
18
+ },
19
+ "require": {
20
+ "default": "./dist/array.js",
21
+ "types": "./dist/array.d.ts"
18
22
  }
19
23
  },
20
24
  "#object": {
21
25
  "import": {
22
26
  "default": "./dist/object.js",
23
27
  "types": "./dist/object.d.ts"
28
+ },
29
+ "require": {
30
+ "default": "./dist/object.js",
31
+ "types": "./dist/object.d.ts"
24
32
  }
25
33
  },
26
34
  "#string": {
27
35
  "import": {
28
36
  "default": "./dist/string.js",
29
37
  "types": "./dist/string.d.ts"
38
+ },
39
+ "require": {
40
+ "default": "./dist/string.js",
41
+ "types": "./dist/string.d.ts"
30
42
  }
31
43
  },
32
44
  "#guards": {
33
45
  "import": {
34
46
  "default": "./dist/guards.js",
35
47
  "types": "./dist/guards.d.ts"
48
+ },
49
+ "require": {
50
+ "default": "./dist/guards.js",
51
+ "types": "./dist/guards.d.ts"
36
52
  }
37
53
  },
38
54
  "#logical": {
39
55
  "import": {
40
56
  "default": "./dist/logical.js",
41
57
  "types": "./dist/logical.d.ts"
58
+ },
59
+ "require": {
60
+ "default": "./dist/logical.js",
61
+ "types": "./dist/logical.d.ts"
42
62
  }
43
63
  }
44
64
  },
@@ -47,30 +67,50 @@
47
67
  "import": {
48
68
  "default": "./dist/array.js",
49
69
  "types": "./dist/array.d.ts"
70
+ },
71
+ "require": {
72
+ "default": "./dist/array.js",
73
+ "types": "./dist/array.d.ts"
50
74
  }
51
75
  },
52
76
  "./object": {
53
77
  "import": {
54
78
  "default": "./dist/object.js",
55
79
  "types": "./dist/object.d.ts"
80
+ },
81
+ "require": {
82
+ "default": "./dist/object.js",
83
+ "types": "./dist/object.d.ts"
56
84
  }
57
85
  },
58
86
  "./string": {
59
87
  "import": {
60
88
  "default": "./dist/string.js",
61
89
  "types": "./dist/string.d.ts"
90
+ },
91
+ "require": {
92
+ "default": "./dist/string.js",
93
+ "types": "./dist/string.d.ts"
62
94
  }
63
95
  },
64
96
  "./guards": {
65
97
  "import": {
66
98
  "default": "./dist/guards.js",
67
99
  "types": "./dist/guards.d.ts"
100
+ },
101
+ "require": {
102
+ "default": "./dist/guards.js",
103
+ "types": "./dist/guards.d.ts"
68
104
  }
69
105
  },
70
106
  "./logical": {
71
107
  "import": {
72
108
  "default": "./dist/logical.js",
73
109
  "types": "./dist/logical.d.ts"
110
+ },
111
+ "require": {
112
+ "default": "./dist/logical.js",
113
+ "types": "./dist/logical.d.ts"
74
114
  }
75
115
  },
76
116
  "./package.json": "./package.json"
@@ -89,10 +129,10 @@
89
129
  "type-fest": "^4.32.0"
90
130
  },
91
131
  "devDependencies": {
92
- "@budsbox/eslint": "^1.0.0",
93
- "@budsbox/eslint_presets-lib": "^1.0.0",
94
- "@budsbox/eslint_presets-tools": "^1.0.0",
95
- "@budsbox/tsconfigs": "^4.0.0",
132
+ "@budsbox/eslint": "^1.0.3",
133
+ "@budsbox/eslint_presets-lib": "^1.0.2",
134
+ "@budsbox/eslint_presets-tools": "^1.0.2",
135
+ "@budsbox/tsconfigs": "^4.1.0",
96
136
  "@eslint/js": "^9.26.0",
97
137
  "@types/eslint": "^9.6.1",
98
138
  "@types/node": "^22.15.2",