@budsbox/lib-es 2.0.0 → 2.1.0
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 +16 -1
- package/dist/string.js +9 -1
- package/package.json +3 -3
package/dist/string.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CamelCase, DelimiterCase, KebabCase, PascalCase, SnakeCase } from 'type-fest';
|
|
2
|
-
import type { Nil } from '@budsbox/lib-types';
|
|
2
|
+
import type { Nil, Undef } from '@budsbox/lib-types';
|
|
3
3
|
import type { ParsedPackageName } from './types.js';
|
|
4
4
|
export type { ParsedPackageName };
|
|
5
5
|
/**
|
|
@@ -25,6 +25,21 @@ export declare function serializePackageName(parsedPackageName: Readonly<ParsedP
|
|
|
25
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 serializePackageName(parsedPackageName: Readonly<ParsedPackageName> | Nil, allowNil: true): string;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the package name based on the provided identifier and options.
|
|
30
|
+
* Can return either a string representing the package name or a parsed package name object.
|
|
31
|
+
*
|
|
32
|
+
* @param ident - The package identifier, either as a string or a parsed package name object.
|
|
33
|
+
* @param options - Optional settings to modify the resolution behavior.
|
|
34
|
+
* Includes an optional `baseScope` to use as a default scope and a `parsed` flag
|
|
35
|
+
* to indicate whether the result should be returned as a parsed package name object.
|
|
36
|
+
* @returns The resolved package name as a string if `parsed` is false or not specified,
|
|
37
|
+
* or as a `ParsedPackageName` object if `parsed` is true.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolvePackageName<TParsed extends boolean = false>(ident: string | Readonly<ParsedPackageName>, options?: Readonly<{
|
|
40
|
+
baseScope?: Undef<string>;
|
|
41
|
+
parsed?: TParsed;
|
|
42
|
+
}>): TParsed extends true ? ParsedPackageName : string;
|
|
28
43
|
/**
|
|
29
44
|
* Converts the provided value to a string representation suitable for debugging purposes.
|
|
30
45
|
*
|
package/dist/string.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNil, isNotNil } from './guards.js';
|
|
1
|
+
import { isNil, isNotNil, isString } from './guards.js';
|
|
2
2
|
/**
|
|
3
3
|
* Parses a package name string to extract its scope and name.
|
|
4
4
|
*
|
|
@@ -20,6 +20,14 @@ export function serializePackageName(parsedPackageName, allowNil = false) {
|
|
|
20
20
|
const { scope, name } = parsedPackageName ?? { scope: null, name: '' };
|
|
21
21
|
return joinPath(scope?.replace(/^@?/, '@'), name);
|
|
22
22
|
}
|
|
23
|
+
export function resolvePackageName(ident, { baseScope, parsed = false, } = {}) {
|
|
24
|
+
const { scope, name } = isString(ident) ? parsePackageName(ident) : ident;
|
|
25
|
+
const parsedIdent = {
|
|
26
|
+
scope: scope ?? baseScope ?? null,
|
|
27
|
+
name,
|
|
28
|
+
};
|
|
29
|
+
return parsed ? parsedIdent : serializePackageName(parsedIdent);
|
|
30
|
+
}
|
|
23
31
|
/**
|
|
24
32
|
* Converts the provided value to a string representation suitable for debugging purposes.
|
|
25
33
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budsbox/lib-es",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"homepage": "https://gitlab.com/budsbox/fe/seed",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://gitlab.com/budsbox/fe/seed/-/issues"
|
|
@@ -129,10 +129,10 @@
|
|
|
129
129
|
"type-fest": "^4.32.0"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
|
-
"@budsbox/eslint": "^1.0
|
|
132
|
+
"@budsbox/eslint": "^1.1.0",
|
|
133
133
|
"@budsbox/eslint_presets-lib": "^1.0.2",
|
|
134
134
|
"@budsbox/eslint_presets-tools": "^1.0.2",
|
|
135
|
-
"@budsbox/tsconfigs": "^4.
|
|
135
|
+
"@budsbox/tsconfigs": "^4.2.0",
|
|
136
136
|
"@eslint/js": "^9.26.0",
|
|
137
137
|
"@types/eslint": "^9.6.1",
|
|
138
138
|
"@types/node": "^22.15.2",
|