@stryke/string-format 0.14.7 → 0.16.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/CHANGELOG.md +50 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +4 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/dist/list.cjs +25 -0
- package/dist/list.d.cts +17 -0
- package/dist/list.d.cts.map +1 -0
- package/dist/list.d.mts +17 -0
- package/dist/list.d.mts.map +1 -0
- package/dist/list.mjs +25 -0
- package/dist/list.mjs.map +1 -0
- package/dist/path/src/correct-path.cjs +120 -0
- package/dist/path/src/correct-path.mjs +120 -0
- package/dist/path/src/correct-path.mjs.map +1 -0
- package/dist/path/src/cwd.cjs +17 -0
- package/dist/path/src/cwd.mjs +17 -0
- package/dist/path/src/cwd.mjs.map +1 -0
- package/dist/path/src/is-type.cjs +29 -0
- package/dist/path/src/is-type.mjs +29 -0
- package/dist/path/src/is-type.mjs.map +1 -0
- package/dist/path/src/join-paths.cjs +122 -0
- package/dist/path/src/join-paths.mjs +123 -0
- package/dist/path/src/join-paths.mjs.map +1 -0
- package/dist/path/src/regex.cjs +12 -0
- package/dist/path/src/regex.mjs +9 -0
- package/dist/path/src/regex.mjs.map +1 -0
- package/dist/path/src/slash.cjs +15 -0
- package/dist/path/src/slash.mjs +15 -0
- package/dist/path/src/slash.mjs.map +1 -0
- package/dist/pretty-path.cjs +17 -0
- package/dist/pretty-path.d.cts +27 -0
- package/dist/pretty-path.d.cts.map +1 -0
- package/dist/pretty-path.d.mts +27 -0
- package/dist/pretty-path.d.mts.map +1 -0
- package/dist/pretty-path.mjs +18 -0
- package/dist/pretty-path.mjs.map +1 -0
- package/dist/title-case.cjs +2 -1
- package/dist/title-case.d.cts +13 -3
- package/dist/title-case.d.cts.map +1 -1
- package/dist/title-case.d.mts +13 -3
- package/dist/title-case.d.mts.map +1 -1
- package/dist/title-case.mjs +2 -1
- package/dist/title-case.mjs.map +1 -1
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - String Format
|
|
4
4
|
|
|
5
|
+
## [0.16.0](https://github.com/storm-software/stryke/releases/tag/string-format%400.16.0) (03/06/2026)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **string-format:** Added the `expandAcronyms` option to `titleCase` helper ([e2fef657](https://github.com/storm-software/stryke/commit/e2fef657))
|
|
10
|
+
|
|
11
|
+
### Updated Dependencies
|
|
12
|
+
|
|
13
|
+
- Updated **helpers** to **v0.9.51**
|
|
14
|
+
- Updated **types** to **v0.10.48**
|
|
15
|
+
- Updated **path** to **v0.26.15**
|
|
16
|
+
|
|
17
|
+
## [0.15.1](https://github.com/storm-software/stryke/releases/tag/string-format%400.15.1) (03/06/2026)
|
|
18
|
+
|
|
19
|
+
### Updated Dependencies
|
|
20
|
+
|
|
21
|
+
- Updated **helpers** to **v0.9.50**
|
|
22
|
+
- Updated **types** to **v0.10.47**
|
|
23
|
+
- Updated **path** to **v0.26.14**
|
|
24
|
+
|
|
25
|
+
## [0.15.0](https://github.com/storm-software/stryke/releases/tag/string-format%400.15.0) (03/06/2026)
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
- **string-format:** Added misssing `exports` to package ([8972efdc](https://github.com/storm-software/stryke/commit/8972efdc))
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- **string-format:** Added `list` and `prettyPath` helper functions ([c9071abc](https://github.com/storm-software/stryke/commit/c9071abc))
|
|
34
|
+
|
|
35
|
+
### Updated Dependencies
|
|
36
|
+
|
|
37
|
+
- Updated **helpers** to **v0.9.49**
|
|
38
|
+
- Updated **types** to **v0.10.46**
|
|
39
|
+
- Updated **path** to **v0.26.13**
|
|
40
|
+
|
|
41
|
+
## [0.14.8](https://github.com/storm-software/stryke/releases/tag/string-format%400.14.8) (03/03/2026)
|
|
42
|
+
|
|
43
|
+
### Updated Dependencies
|
|
44
|
+
|
|
45
|
+
- Updated **helpers** to **v0.9.48**
|
|
46
|
+
- Updated **types** to **v0.10.45**
|
|
47
|
+
|
|
48
|
+
## [0.14.7](https://github.com/storm-software/stryke/releases/tag/string-format%400.14.7) (03/03/2026)
|
|
49
|
+
|
|
50
|
+
### Updated Dependencies
|
|
51
|
+
|
|
52
|
+
- Updated **helpers** to **v0.9.47**
|
|
53
|
+
- Updated **types** to **v0.10.44**
|
|
54
|
+
|
|
5
55
|
## [0.14.6](https://github.com/storm-software/stryke/releases/tag/string-format%400.14.6) (03/03/2026)
|
|
6
56
|
|
|
7
57
|
### Updated Dependencies
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,7 @@ const require_prepositions = require('./prepositions.cjs');
|
|
|
14
14
|
const require_special_cases = require('./special-cases.cjs');
|
|
15
15
|
const require_format_special_cases = require('./format-special-cases.cjs');
|
|
16
16
|
const require_kebab_case = require('./kebab-case.cjs');
|
|
17
|
+
const require_list = require('./list.cjs');
|
|
17
18
|
const require_lower_case_first = require('./lower-case-first.cjs');
|
|
18
19
|
const require_normalize_email = require('./normalize-email.cjs');
|
|
19
20
|
const require_ordinals = require('./ordinals.cjs');
|
|
@@ -22,6 +23,7 @@ const require_pad = require('./pad.cjs');
|
|
|
22
23
|
const require_pascal_case = require('./pascal-case.cjs');
|
|
23
24
|
const require_period_split = require('./period-split.cjs');
|
|
24
25
|
const require_pretty_bytes = require('./pretty-bytes.cjs');
|
|
26
|
+
const require_pretty_path = require('./pretty-path.cjs');
|
|
25
27
|
const require_start_case = require('./start-case.cjs');
|
|
26
28
|
const require_strip_indents = require('./strip-indents.cjs');
|
|
27
29
|
const require_title_case = require('./title-case.cjs');
|
|
@@ -60,12 +62,14 @@ exports.isSnakeCase = require_snake_case.isSnakeCase;
|
|
|
60
62
|
exports.isStartCase = require_start_case.isStartCase;
|
|
61
63
|
exports.isVowel = require_vowels.isVowel;
|
|
62
64
|
exports.kebabCase = require_kebab_case.kebabCase;
|
|
65
|
+
exports.list = require_list.list;
|
|
63
66
|
exports.lowerCaseFirst = require_lower_case_first.lowerCaseFirst;
|
|
64
67
|
exports.normalizeEmail = require_normalize_email.normalizeEmail;
|
|
65
68
|
exports.pad = require_pad.pad;
|
|
66
69
|
exports.pascalCase = require_pascal_case.pascalCase;
|
|
67
70
|
exports.periodSplit = require_period_split.periodSplit;
|
|
68
71
|
exports.prettyBytes = require_pretty_bytes.prettyBytes;
|
|
72
|
+
exports.prettyPath = require_pretty_path.prettyPath;
|
|
69
73
|
exports.removePackageVersion = require_package.removePackageVersion;
|
|
70
74
|
exports.snakeCase = require_snake_case.snakeCase;
|
|
71
75
|
exports.startCase = require_start_case.startCase;
|
package/dist/index.d.cts
CHANGED
|
@@ -10,6 +10,7 @@ import { escapeHtml, escapeRegExp } from "./escape.cjs";
|
|
|
10
10
|
import { FormatSpecialCasesOptions, formatSpecialCases } from "./format-special-cases.cjs";
|
|
11
11
|
import { CASE_SPLIT_PATTERN, GetWordsOptions, RELAXED_SPLIT_PATTERN, getWords } from "./get-words.cjs";
|
|
12
12
|
import { isKebabCase, kebabCase } from "./kebab-case.cjs";
|
|
13
|
+
import { list } from "./list.cjs";
|
|
13
14
|
import { lowerCaseFirst } from "./lower-case-first.cjs";
|
|
14
15
|
import { normalizeEmail } from "./normalize-email.cjs";
|
|
15
16
|
import { toOrdinal } from "./ordinals.cjs";
|
|
@@ -19,12 +20,13 @@ import { isPascalCase, pascalCase } from "./pascal-case.cjs";
|
|
|
19
20
|
import { isPeriodSplit, periodSplit } from "./period-split.cjs";
|
|
20
21
|
import { PREPOSITIONS } from "./prepositions.cjs";
|
|
21
22
|
import { Options, prettyBytes, toLocaleString } from "./pretty-bytes.cjs";
|
|
23
|
+
import { PrettyPathOptions, prettyPath } from "./pretty-path.cjs";
|
|
22
24
|
import { SnakeCaseOptions, isSnakeCase, snakeCase } from "./snake-case.cjs";
|
|
23
25
|
import { SPECIAL_CASES } from "./special-cases.cjs";
|
|
24
26
|
import { isStartCase, startCase } from "./start-case.cjs";
|
|
25
27
|
import { stripIndents } from "./strip-indents.cjs";
|
|
26
|
-
import { titleCase } from "./title-case.cjs";
|
|
28
|
+
import { TitleCaseOptions, titleCase } from "./title-case.cjs";
|
|
27
29
|
import { unescape } from "./unescape.cjs";
|
|
28
30
|
import { upperCaseFirst } from "./upper-case-first.cjs";
|
|
29
31
|
import { getIndefiniteArticle, isVowel } from "./vowels.cjs";
|
|
30
|
-
export { ACRONYMS, ACRONYM_DESCRIPTION, ACRONYM_DISPLAY, ACRONYM_LIST, ARTICLES, CASE_SPLIT_PATTERN, CONJUNCTIONS, FormatSpecialCasesOptions, GetWordsOptions, Options, PREPOSITIONS, RELAXED_SPLIT_PATTERN, SPECIAL_CASES, SnakeCaseOptions, camelCase, combine, constantCase, deburr, decamelize, escapeHtml, escapeRegExp, formatSpecialCases, getIndefiniteArticle, getPackageName, getPackageVersion, getWords, hasPackageVersion, isCamelCase, isConstantCase, isKebabCase, isPascalCase, isPeriodSplit, isSnakeCase, isStartCase, isVowel, kebabCase, lowerCaseFirst, normalizeEmail, pad, pascalCase, periodSplit, prettyBytes, removePackageVersion, snakeCase, startCase, stripIndents, titleCase, toLocaleString, toOrdinal, unescape, upperCaseFirst };
|
|
32
|
+
export { ACRONYMS, ACRONYM_DESCRIPTION, ACRONYM_DISPLAY, ACRONYM_LIST, ARTICLES, CASE_SPLIT_PATTERN, CONJUNCTIONS, FormatSpecialCasesOptions, GetWordsOptions, Options, PREPOSITIONS, PrettyPathOptions, RELAXED_SPLIT_PATTERN, SPECIAL_CASES, SnakeCaseOptions, TitleCaseOptions, camelCase, combine, constantCase, deburr, decamelize, escapeHtml, escapeRegExp, formatSpecialCases, getIndefiniteArticle, getPackageName, getPackageVersion, getWords, hasPackageVersion, isCamelCase, isConstantCase, isKebabCase, isPascalCase, isPeriodSplit, isSnakeCase, isStartCase, isVowel, kebabCase, list, lowerCaseFirst, normalizeEmail, pad, pascalCase, periodSplit, prettyBytes, prettyPath, removePackageVersion, snakeCase, startCase, stripIndents, titleCase, toLocaleString, toOrdinal, unescape, upperCaseFirst };
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ import { escapeHtml, escapeRegExp } from "./escape.mjs";
|
|
|
10
10
|
import { FormatSpecialCasesOptions, formatSpecialCases } from "./format-special-cases.mjs";
|
|
11
11
|
import { CASE_SPLIT_PATTERN, GetWordsOptions, RELAXED_SPLIT_PATTERN, getWords } from "./get-words.mjs";
|
|
12
12
|
import { isKebabCase, kebabCase } from "./kebab-case.mjs";
|
|
13
|
+
import { list } from "./list.mjs";
|
|
13
14
|
import { lowerCaseFirst } from "./lower-case-first.mjs";
|
|
14
15
|
import { normalizeEmail } from "./normalize-email.mjs";
|
|
15
16
|
import { toOrdinal } from "./ordinals.mjs";
|
|
@@ -19,12 +20,13 @@ import { isPascalCase, pascalCase } from "./pascal-case.mjs";
|
|
|
19
20
|
import { isPeriodSplit, periodSplit } from "./period-split.mjs";
|
|
20
21
|
import { PREPOSITIONS } from "./prepositions.mjs";
|
|
21
22
|
import { Options, prettyBytes, toLocaleString } from "./pretty-bytes.mjs";
|
|
23
|
+
import { PrettyPathOptions, prettyPath } from "./pretty-path.mjs";
|
|
22
24
|
import { SnakeCaseOptions, isSnakeCase, snakeCase } from "./snake-case.mjs";
|
|
23
25
|
import { SPECIAL_CASES } from "./special-cases.mjs";
|
|
24
26
|
import { isStartCase, startCase } from "./start-case.mjs";
|
|
25
27
|
import { stripIndents } from "./strip-indents.mjs";
|
|
26
|
-
import { titleCase } from "./title-case.mjs";
|
|
28
|
+
import { TitleCaseOptions, titleCase } from "./title-case.mjs";
|
|
27
29
|
import { unescape } from "./unescape.mjs";
|
|
28
30
|
import { upperCaseFirst } from "./upper-case-first.mjs";
|
|
29
31
|
import { getIndefiniteArticle, isVowel } from "./vowels.mjs";
|
|
30
|
-
export { ACRONYMS, ACRONYM_DESCRIPTION, ACRONYM_DISPLAY, ACRONYM_LIST, ARTICLES, CASE_SPLIT_PATTERN, CONJUNCTIONS, FormatSpecialCasesOptions, GetWordsOptions, Options, PREPOSITIONS, RELAXED_SPLIT_PATTERN, SPECIAL_CASES, SnakeCaseOptions, camelCase, combine, constantCase, deburr, decamelize, escapeHtml, escapeRegExp, formatSpecialCases, getIndefiniteArticle, getPackageName, getPackageVersion, getWords, hasPackageVersion, isCamelCase, isConstantCase, isKebabCase, isPascalCase, isPeriodSplit, isSnakeCase, isStartCase, isVowel, kebabCase, lowerCaseFirst, normalizeEmail, pad, pascalCase, periodSplit, prettyBytes, removePackageVersion, snakeCase, startCase, stripIndents, titleCase, toLocaleString, toOrdinal, unescape, upperCaseFirst };
|
|
32
|
+
export { ACRONYMS, ACRONYM_DESCRIPTION, ACRONYM_DISPLAY, ACRONYM_LIST, ARTICLES, CASE_SPLIT_PATTERN, CONJUNCTIONS, FormatSpecialCasesOptions, GetWordsOptions, Options, PREPOSITIONS, PrettyPathOptions, RELAXED_SPLIT_PATTERN, SPECIAL_CASES, SnakeCaseOptions, TitleCaseOptions, camelCase, combine, constantCase, deburr, decamelize, escapeHtml, escapeRegExp, formatSpecialCases, getIndefiniteArticle, getPackageName, getPackageVersion, getWords, hasPackageVersion, isCamelCase, isConstantCase, isKebabCase, isPascalCase, isPeriodSplit, isSnakeCase, isStartCase, isVowel, kebabCase, list, lowerCaseFirst, normalizeEmail, pad, pascalCase, periodSplit, prettyBytes, prettyPath, removePackageVersion, snakeCase, startCase, stripIndents, titleCase, toLocaleString, toOrdinal, unescape, upperCaseFirst };
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { PREPOSITIONS } from "./prepositions.mjs";
|
|
|
14
14
|
import { SPECIAL_CASES } from "./special-cases.mjs";
|
|
15
15
|
import { formatSpecialCases } from "./format-special-cases.mjs";
|
|
16
16
|
import { isKebabCase, kebabCase } from "./kebab-case.mjs";
|
|
17
|
+
import { list } from "./list.mjs";
|
|
17
18
|
import { lowerCaseFirst } from "./lower-case-first.mjs";
|
|
18
19
|
import { normalizeEmail } from "./normalize-email.mjs";
|
|
19
20
|
import { toOrdinal } from "./ordinals.mjs";
|
|
@@ -22,10 +23,11 @@ import { pad } from "./pad.mjs";
|
|
|
22
23
|
import { isPascalCase, pascalCase } from "./pascal-case.mjs";
|
|
23
24
|
import { isPeriodSplit, periodSplit } from "./period-split.mjs";
|
|
24
25
|
import { prettyBytes, toLocaleString } from "./pretty-bytes.mjs";
|
|
26
|
+
import { prettyPath } from "./pretty-path.mjs";
|
|
25
27
|
import { isStartCase, startCase } from "./start-case.mjs";
|
|
26
28
|
import { stripIndents } from "./strip-indents.mjs";
|
|
27
29
|
import { titleCase } from "./title-case.mjs";
|
|
28
30
|
import { unescape } from "./unescape.mjs";
|
|
29
31
|
import { getIndefiniteArticle, isVowel } from "./vowels.mjs";
|
|
30
32
|
|
|
31
|
-
export { ACRONYMS, ACRONYM_DESCRIPTION, ACRONYM_DISPLAY, ACRONYM_LIST, ARTICLES, CASE_SPLIT_PATTERN, CONJUNCTIONS, PREPOSITIONS, RELAXED_SPLIT_PATTERN, SPECIAL_CASES, camelCase, combine, constantCase, deburr, decamelize, escapeHtml, escapeRegExp, formatSpecialCases, getIndefiniteArticle, getPackageName, getPackageVersion, getWords, hasPackageVersion, isCamelCase, isConstantCase, isKebabCase, isPascalCase, isPeriodSplit, isSnakeCase, isStartCase, isVowel, kebabCase, lowerCaseFirst, normalizeEmail, pad, pascalCase, periodSplit, prettyBytes, removePackageVersion, snakeCase, startCase, stripIndents, titleCase, toLocaleString, toOrdinal, unescape, upperCaseFirst };
|
|
33
|
+
export { ACRONYMS, ACRONYM_DESCRIPTION, ACRONYM_DISPLAY, ACRONYM_LIST, ARTICLES, CASE_SPLIT_PATTERN, CONJUNCTIONS, PREPOSITIONS, RELAXED_SPLIT_PATTERN, SPECIAL_CASES, camelCase, combine, constantCase, deburr, decamelize, escapeHtml, escapeRegExp, formatSpecialCases, getIndefiniteArticle, getPackageName, getPackageVersion, getWords, hasPackageVersion, isCamelCase, isConstantCase, isKebabCase, isPascalCase, isPeriodSplit, isSnakeCase, isStartCase, isVowel, kebabCase, list, lowerCaseFirst, normalizeEmail, pad, pascalCase, periodSplit, prettyBytes, prettyPath, removePackageVersion, snakeCase, startCase, stripIndents, titleCase, toLocaleString, toOrdinal, unescape, upperCaseFirst };
|
package/dist/list.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/list.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert an array of strings into a human-readable list string.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* list(["apple", "banana", "cherry"]) // "apple, banana, and cherry"
|
|
8
|
+
* list(["apple", "banana"]) // "apple and banana"
|
|
9
|
+
* list(["apple"]) // "apple"
|
|
10
|
+
* list("apple") // "apple"
|
|
11
|
+
*
|
|
12
|
+
* @param strings - The array of strings or a single string to convert into a list.
|
|
13
|
+
* @returns The converted list string.
|
|
14
|
+
*/
|
|
15
|
+
function list(strings) {
|
|
16
|
+
if (typeof strings === "string") return strings;
|
|
17
|
+
if (strings.length === 0) return "";
|
|
18
|
+
if (strings.length === 1) return strings[0];
|
|
19
|
+
if (strings.length === 2) return `${strings[0]} and ${strings[1]}`;
|
|
20
|
+
const last = strings.pop();
|
|
21
|
+
return `${strings.join(", ")}, and ${last}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.list = list;
|
package/dist/list.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/list.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert an array of strings into a human-readable list string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* list(["apple", "banana", "cherry"]) // "apple, banana, and cherry"
|
|
7
|
+
* list(["apple", "banana"]) // "apple and banana"
|
|
8
|
+
* list(["apple"]) // "apple"
|
|
9
|
+
* list("apple") // "apple"
|
|
10
|
+
*
|
|
11
|
+
* @param strings - The array of strings or a single string to convert into a list.
|
|
12
|
+
* @returns The converted list string.
|
|
13
|
+
*/
|
|
14
|
+
declare function list(strings: string | string[]): string;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { list };
|
|
17
|
+
//# sourceMappingURL=list.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.cts","names":[],"sources":["../src/list.ts"],"sourcesContent":[],"mappings":";;AA8BA;;;;;;;;;;;iBAAgB,IAAA"}
|
package/dist/list.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/list.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert an array of strings into a human-readable list string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* list(["apple", "banana", "cherry"]) // "apple, banana, and cherry"
|
|
7
|
+
* list(["apple", "banana"]) // "apple and banana"
|
|
8
|
+
* list(["apple"]) // "apple"
|
|
9
|
+
* list("apple") // "apple"
|
|
10
|
+
*
|
|
11
|
+
* @param strings - The array of strings or a single string to convert into a list.
|
|
12
|
+
* @returns The converted list string.
|
|
13
|
+
*/
|
|
14
|
+
declare function list(strings: string | string[]): string;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { list };
|
|
17
|
+
//# sourceMappingURL=list.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.mts","names":[],"sources":["../src/list.ts"],"sourcesContent":[],"mappings":";;AA8BA;;;;;;;;;;;iBAAgB,IAAA"}
|
package/dist/list.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/list.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert an array of strings into a human-readable list string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* list(["apple", "banana", "cherry"]) // "apple, banana, and cherry"
|
|
7
|
+
* list(["apple", "banana"]) // "apple and banana"
|
|
8
|
+
* list(["apple"]) // "apple"
|
|
9
|
+
* list("apple") // "apple"
|
|
10
|
+
*
|
|
11
|
+
* @param strings - The array of strings or a single string to convert into a list.
|
|
12
|
+
* @returns The converted list string.
|
|
13
|
+
*/
|
|
14
|
+
function list(strings) {
|
|
15
|
+
if (typeof strings === "string") return strings;
|
|
16
|
+
if (strings.length === 0) return "";
|
|
17
|
+
if (strings.length === 1) return strings[0];
|
|
18
|
+
if (strings.length === 2) return `${strings[0]} and ${strings[1]}`;
|
|
19
|
+
const last = strings.pop();
|
|
20
|
+
return `${strings.join(", ")}, and ${last}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { list };
|
|
25
|
+
//# sourceMappingURL=list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.mjs","names":[],"sources":["../src/list.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert an array of strings into a human-readable list string.\n *\n * @example\n * list([\"apple\", \"banana\", \"cherry\"]) // \"apple, banana, and cherry\"\n * list([\"apple\", \"banana\"]) // \"apple and banana\"\n * list([\"apple\"]) // \"apple\"\n * list(\"apple\") // \"apple\"\n *\n * @param strings - The array of strings or a single string to convert into a list.\n * @returns The converted list string.\n */\nexport function list(strings: string | string[]): string {\n if (typeof strings === \"string\") {\n return strings;\n }\n\n if (strings.length === 0) {\n return \"\";\n }\n\n if (strings.length === 1) {\n return strings[0]!;\n }\n\n if (strings.length === 2) {\n return `${strings[0]} and ${strings[1]}`;\n }\n\n const last = strings.pop();\n\n return `${strings.join(\", \")}, and ${last}`;\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,KAAK,SAAoC;AACvD,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,KAAI,QAAQ,WAAW,EACrB,QAAO;AAGT,KAAI,QAAQ,WAAW,EACrB,QAAO,QAAQ;AAGjB,KAAI,QAAQ,WAAW,EACrB,QAAO,GAAG,QAAQ,GAAG,OAAO,QAAQ;CAGtC,MAAM,OAAO,QAAQ,KAAK;AAE1B,QAAO,GAAG,QAAQ,KAAK,KAAK,CAAC,QAAQ"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const require_cwd = require('./cwd.cjs');
|
|
2
|
+
const require_regex = require('./regex.cjs');
|
|
3
|
+
const require_is_type = require('./is-type.cjs');
|
|
4
|
+
const require_slash = require('./slash.cjs');
|
|
5
|
+
const require_join_paths = require('./join-paths.cjs');
|
|
6
|
+
|
|
7
|
+
//#region ../path/src/correct-path.ts
|
|
8
|
+
function normalizeWindowsPath(input = "") {
|
|
9
|
+
if (!input) return input;
|
|
10
|
+
return require_slash.slash(input).replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Corrects/normalized a file path.
|
|
14
|
+
*
|
|
15
|
+
* @param path - The path to correct.
|
|
16
|
+
* @returns The corrected path.
|
|
17
|
+
*/
|
|
18
|
+
function correctPath(path) {
|
|
19
|
+
if (!path || path.length === 0) return ".";
|
|
20
|
+
path = normalizeWindowsPath(path);
|
|
21
|
+
const isUNCPath = path.match(require_regex.UNC_REGEX);
|
|
22
|
+
const isPathAbsolute = require_is_type.isAbsolutePath(path);
|
|
23
|
+
const trailingSeparator = path.endsWith("/");
|
|
24
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
25
|
+
if (path.length === 0) {
|
|
26
|
+
if (isPathAbsolute) return "/";
|
|
27
|
+
return trailingSeparator ? "./" : ".";
|
|
28
|
+
}
|
|
29
|
+
if (trailingSeparator) path += "/";
|
|
30
|
+
if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
31
|
+
if (isUNCPath) {
|
|
32
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
33
|
+
return `//${path}`;
|
|
34
|
+
}
|
|
35
|
+
return !path.startsWith("/") && isPathAbsolute && !require_regex.DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
39
|
+
*
|
|
40
|
+
* @param path - The path to normalize.
|
|
41
|
+
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
42
|
+
* @returns the normalize path string.
|
|
43
|
+
*/
|
|
44
|
+
function normalizeString(path, allowAboveRoot) {
|
|
45
|
+
let res = "";
|
|
46
|
+
let lastSegmentLength = 0;
|
|
47
|
+
let lastSlash = -1;
|
|
48
|
+
let dots = 0;
|
|
49
|
+
let char = null;
|
|
50
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
51
|
+
if (index < path.length) char = path[index];
|
|
52
|
+
else if (char === "/") break;
|
|
53
|
+
else char = "/";
|
|
54
|
+
if (char === "/") {
|
|
55
|
+
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
56
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
57
|
+
if (res.length > 2) {
|
|
58
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
59
|
+
if (lastSlashIndex === -1) {
|
|
60
|
+
res = "";
|
|
61
|
+
lastSegmentLength = 0;
|
|
62
|
+
} else {
|
|
63
|
+
res = res.slice(0, lastSlashIndex);
|
|
64
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
65
|
+
}
|
|
66
|
+
lastSlash = index;
|
|
67
|
+
dots = 0;
|
|
68
|
+
continue;
|
|
69
|
+
} else if (res.length > 0) {
|
|
70
|
+
res = "";
|
|
71
|
+
lastSegmentLength = 0;
|
|
72
|
+
lastSlash = index;
|
|
73
|
+
dots = 0;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (allowAboveRoot) {
|
|
78
|
+
res += res.length > 0 ? "/.." : "..";
|
|
79
|
+
lastSegmentLength = 2;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
83
|
+
else res = path.slice(lastSlash + 1, index);
|
|
84
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
85
|
+
}
|
|
86
|
+
lastSlash = index;
|
|
87
|
+
dots = 0;
|
|
88
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
89
|
+
else dots = -1;
|
|
90
|
+
}
|
|
91
|
+
return res;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts a given path to a relative path based on the current working directory.
|
|
95
|
+
*
|
|
96
|
+
* @param path - The path to convert to a relative path.
|
|
97
|
+
* @param cwd - The current working directory to use as the base path if the path is not absolute.
|
|
98
|
+
* @returns The relative path.
|
|
99
|
+
*/
|
|
100
|
+
function toRelativePath(path, cwd$1 = require_cwd.cwd()) {
|
|
101
|
+
if (!path || path.length === 0) return ".";
|
|
102
|
+
if (require_is_type.isAbsolutePath(path)) path = require_slash.slash(normalizeString(path, true));
|
|
103
|
+
else path = require_slash.slash(normalizeString(require_join_paths.joinPaths(cwd$1, path), true));
|
|
104
|
+
if (path.startsWith("./")) return path.slice(2);
|
|
105
|
+
return path;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Removes a trailing slash from a path if it has one.
|
|
109
|
+
*
|
|
110
|
+
* @param path - The path to modify.
|
|
111
|
+
* @returns The modified path without a trailing slash.
|
|
112
|
+
*/
|
|
113
|
+
function withoutTrailingSlash(path) {
|
|
114
|
+
const result = correctPath(path);
|
|
115
|
+
return result.endsWith("/") ? result.slice(0, -1) : result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
exports.toRelativePath = toRelativePath;
|
|
120
|
+
exports.withoutTrailingSlash = withoutTrailingSlash;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { cwd } from "./cwd.mjs";
|
|
2
|
+
import { DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX } from "./regex.mjs";
|
|
3
|
+
import { isAbsolutePath } from "./is-type.mjs";
|
|
4
|
+
import { slash } from "./slash.mjs";
|
|
5
|
+
import { joinPaths } from "./join-paths.mjs";
|
|
6
|
+
|
|
7
|
+
//#region ../path/src/correct-path.ts
|
|
8
|
+
function normalizeWindowsPath(input = "") {
|
|
9
|
+
if (!input) return input;
|
|
10
|
+
return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Corrects/normalized a file path.
|
|
14
|
+
*
|
|
15
|
+
* @param path - The path to correct.
|
|
16
|
+
* @returns The corrected path.
|
|
17
|
+
*/
|
|
18
|
+
function correctPath(path) {
|
|
19
|
+
if (!path || path.length === 0) return ".";
|
|
20
|
+
path = normalizeWindowsPath(path);
|
|
21
|
+
const isUNCPath = path.match(UNC_REGEX);
|
|
22
|
+
const isPathAbsolute = isAbsolutePath(path);
|
|
23
|
+
const trailingSeparator = path.endsWith("/");
|
|
24
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
25
|
+
if (path.length === 0) {
|
|
26
|
+
if (isPathAbsolute) return "/";
|
|
27
|
+
return trailingSeparator ? "./" : ".";
|
|
28
|
+
}
|
|
29
|
+
if (trailingSeparator) path += "/";
|
|
30
|
+
if (DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
31
|
+
if (isUNCPath) {
|
|
32
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
33
|
+
return `//${path}`;
|
|
34
|
+
}
|
|
35
|
+
return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
39
|
+
*
|
|
40
|
+
* @param path - The path to normalize.
|
|
41
|
+
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
42
|
+
* @returns the normalize path string.
|
|
43
|
+
*/
|
|
44
|
+
function normalizeString(path, allowAboveRoot) {
|
|
45
|
+
let res = "";
|
|
46
|
+
let lastSegmentLength = 0;
|
|
47
|
+
let lastSlash = -1;
|
|
48
|
+
let dots = 0;
|
|
49
|
+
let char = null;
|
|
50
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
51
|
+
if (index < path.length) char = path[index];
|
|
52
|
+
else if (char === "/") break;
|
|
53
|
+
else char = "/";
|
|
54
|
+
if (char === "/") {
|
|
55
|
+
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
56
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
57
|
+
if (res.length > 2) {
|
|
58
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
59
|
+
if (lastSlashIndex === -1) {
|
|
60
|
+
res = "";
|
|
61
|
+
lastSegmentLength = 0;
|
|
62
|
+
} else {
|
|
63
|
+
res = res.slice(0, lastSlashIndex);
|
|
64
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
65
|
+
}
|
|
66
|
+
lastSlash = index;
|
|
67
|
+
dots = 0;
|
|
68
|
+
continue;
|
|
69
|
+
} else if (res.length > 0) {
|
|
70
|
+
res = "";
|
|
71
|
+
lastSegmentLength = 0;
|
|
72
|
+
lastSlash = index;
|
|
73
|
+
dots = 0;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (allowAboveRoot) {
|
|
78
|
+
res += res.length > 0 ? "/.." : "..";
|
|
79
|
+
lastSegmentLength = 2;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
83
|
+
else res = path.slice(lastSlash + 1, index);
|
|
84
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
85
|
+
}
|
|
86
|
+
lastSlash = index;
|
|
87
|
+
dots = 0;
|
|
88
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
89
|
+
else dots = -1;
|
|
90
|
+
}
|
|
91
|
+
return res;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts a given path to a relative path based on the current working directory.
|
|
95
|
+
*
|
|
96
|
+
* @param path - The path to convert to a relative path.
|
|
97
|
+
* @param cwd - The current working directory to use as the base path if the path is not absolute.
|
|
98
|
+
* @returns The relative path.
|
|
99
|
+
*/
|
|
100
|
+
function toRelativePath(path, cwd$1 = cwd()) {
|
|
101
|
+
if (!path || path.length === 0) return ".";
|
|
102
|
+
if (isAbsolutePath(path)) path = slash(normalizeString(path, true));
|
|
103
|
+
else path = slash(normalizeString(joinPaths(cwd$1, path), true));
|
|
104
|
+
if (path.startsWith("./")) return path.slice(2);
|
|
105
|
+
return path;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Removes a trailing slash from a path if it has one.
|
|
109
|
+
*
|
|
110
|
+
* @param path - The path to modify.
|
|
111
|
+
* @returns The modified path without a trailing slash.
|
|
112
|
+
*/
|
|
113
|
+
function withoutTrailingSlash(path) {
|
|
114
|
+
const result = correctPath(path);
|
|
115
|
+
return result.endsWith("/") ? result.slice(0, -1) : result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { toRelativePath, withoutTrailingSlash };
|
|
120
|
+
//# sourceMappingURL=correct-path.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correct-path.mjs","names":["char: string | null","currentDir","cwd"],"sources":["../../../../path/src/correct-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { appendPath } from \"./append\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\nimport { slash } from \"./slash\";\n\n// Util to normalize windows paths to posix\nexport function normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n\n return slash(input).replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\n/**\n * Corrects/normalized a file path.\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function correctPath(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolutePath(path);\n const trailingSeparator = path.endsWith(\"/\");\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return !path.startsWith(\"/\") &&\n isPathAbsolute &&\n !DRIVE_LETTER_REGEX.test(path)\n ? `/${path}`\n : path;\n}\n\n/**\n * Remove any star tokens (*) from the end of the file path\n *\n * @example\n * stripStars(\"src/**\") // returns \"src\"\n * stripStars(\"src/*\") // returns \"src\"\n * stripStars(\"src/**\\/*\") // returns \"src\"\n * stripStars(\"src/**\\/*.txt\") // returns \"src\"\n * stripStars(\"src/**\\/file.txt\") // returns \"src\"\n * stripStars(\"src/file.txt\") // returns \"src/file.txt\"\n * stripStars(\"\") // returns \".\"\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function stripStars(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n path = correctPath(path);\n\n let found = false;\n\n return `${path.startsWith(\"/\") ? \"/\" : \"\"}${path\n .split(\"/\")\n .reduce((ret, segment) => {\n if (!segment?.trim()) {\n return ret;\n }\n\n if (found || segment.includes(\"*\")) {\n found = true;\n return ret;\n }\n\n return ret + (ret ? `/${segment}` : segment);\n }, \"\")}`;\n}\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalize path string.\n */\nexport function normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\n/**\n * Converts a given path to an absolute path based on the current working directory.\n *\n * @param path - The path to convert to an absolute path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The absolute path.\n */\nexport function toAbsolutePath(path: string, cwd = currentDir()): string {\n if (isAbsolutePath(path)) {\n return path;\n }\n\n return slash(normalizeString(appendPath(path, cwd), true));\n}\n\n/**\n * Converts a given path to a relative path based on the current working directory.\n *\n * @param path - The path to convert to a relative path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The relative path.\n */\nexport function toRelativePath(path: string, cwd = currentDir()): string {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n if (isAbsolutePath(path)) {\n path = slash(normalizeString(path, true));\n } else {\n path = slash(normalizeString(joinPaths(cwd, path), true));\n }\n\n if (path.startsWith(\"./\")) {\n return path.slice(2);\n }\n\n return path;\n}\n\n/**\n * Adds a trailing slash to a path if it doesn't already have one.\n *\n * @param path - The path to modify.\n * @returns The modified path with a trailing slash.\n */\nexport function withTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result : `${result}/`;\n}\n\n/**\n * Removes a trailing slash from a path if it has one.\n *\n * @param path - The path to modify.\n * @returns The modified path without a trailing slash.\n */\nexport function withoutTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result.slice(0, -1) : result;\n}\n"],"mappings":";;;;;;;AA8BA,SAAgB,qBAAqB,QAAQ,IAAI;AAC/C,KAAI,CAAC,MACH,QAAO;AAGT,QAAO,MAAM,MAAM,CAAC,QAAQ,2BAA0B,MAAK,EAAE,aAAa,CAAC;;;;;;;;AAS7E,SAAgB,YAAY,MAAe;AACzC,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAIT,QAAO,qBAAqB,KAAK;CAEjC,MAAM,YAAY,KAAK,MAAM,UAAU;CACvC,MAAM,iBAAiB,eAAe,KAAK;CAC3C,MAAM,oBAAoB,KAAK,SAAS,IAAI;AAG5C,QAAO,gBAAgB,MAAM,CAAC,eAAe;AAE7C,KAAI,KAAK,WAAW,GAAG;AACrB,MAAI,eACF,QAAO;AAET,SAAO,oBAAoB,OAAO;;AAGpC,KAAI,kBACF,SAAQ;AAEV,KAAI,mBAAmB,KAAK,KAAK,CAC/B,SAAQ;AAGV,KAAI,WAAW;AACb,MAAI,CAAC,eACH,QAAO,OAAO;AAEhB,SAAO,KAAK;;AAGd,QAAO,CAAC,KAAK,WAAW,IAAI,IAC1B,kBACA,CAAC,mBAAmB,KAAK,KAAK,GAC5B,IAAI,SACJ;;;;;;;;;AAkDN,SAAgB,gBAAgB,MAAc,gBAAyB;CACrE,IAAI,MAAM;CACV,IAAI,oBAAoB;CACxB,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAIA,OAAsB;AAC1B,MAAK,IAAI,QAAQ,GAAG,SAAS,KAAK,QAAQ,EAAE,OAAO;AACjD,MAAI,QAAQ,KAAK,OAEf,QAAO,KAAK;WACH,SAAS,IAClB;MAEA,QAAO;AAET,MAAI,SAAS,KAAK;AAChB,OAAI,cAAc,QAAQ,KAAK,SAAS,GAAG,YAEhC,SAAS,GAAG;AACrB,QACE,IAAI,SAAS,KACb,sBAAsB,KACtB,IAAI,IAAI,SAAS,OAAO,OACxB,IAAI,IAAI,SAAS,OAAO,KAExB;SAAI,IAAI,SAAS,GAAG;MAClB,MAAM,iBAAiB,IAAI,YAAY,IAAI;AAC3C,UAAI,mBAAmB,IAAI;AACzB,aAAM;AACN,2BAAoB;aACf;AACL,aAAM,IAAI,MAAM,GAAG,eAAe;AAClC,2BAAoB,IAAI,SAAS,IAAI,IAAI,YAAY,IAAI;;AAE3D,kBAAY;AACZ,aAAO;AACP;gBACS,IAAI,SAAS,GAAG;AACzB,YAAM;AACN,0BAAoB;AACpB,kBAAY;AACZ,aAAO;AACP;;;AAGJ,QAAI,gBAAgB;AAClB,YAAO,IAAI,SAAS,IAAI,QAAQ;AAChC,yBAAoB;;UAEjB;AACL,QAAI,IAAI,SAAS,EACf,QAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM;QAE3C,OAAM,KAAK,MAAM,YAAY,GAAG,MAAM;AAExC,wBAAoB,QAAQ,YAAY;;AAE1C,eAAY;AACZ,UAAO;aACE,SAAS,OAAO,SAAS,GAClC,GAAE;MAEF,QAAO;;AAGX,QAAO;;;;;;;;;AAyBT,SAAgB,eAAe,MAAc,QAAMC,KAAY,EAAU;AACvE,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAGT,KAAI,eAAe,KAAK,CACtB,QAAO,MAAM,gBAAgB,MAAM,KAAK,CAAC;KAEzC,QAAO,MAAM,gBAAgB,UAAUC,OAAK,KAAK,EAAE,KAAK,CAAC;AAG3D,KAAI,KAAK,WAAW,KAAK,CACvB,QAAO,KAAK,MAAM,EAAE;AAGtB,QAAO;;;;;;;;AAqBT,SAAgB,qBAAqB,MAAsB;CACzD,MAAM,SAAS,YAAY,KAAK;AAEhC,QAAO,OAAO,SAAS,IAAI,GAAG,OAAO,MAAM,GAAG,GAAG,GAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../path/src/cwd.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get the current working directory.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This function attempts to retrieve the current working directory using `process.cwd()`.
|
|
8
|
+
*
|
|
9
|
+
* @returns The current working directory or '/' if it cannot be determined
|
|
10
|
+
*/
|
|
11
|
+
function cwd() {
|
|
12
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
13
|
+
return "/";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.cwd = cwd;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../path/src/cwd.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the current working directory.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This function attempts to retrieve the current working directory using `process.cwd()`.
|
|
7
|
+
*
|
|
8
|
+
* @returns The current working directory or '/' if it cannot be determined
|
|
9
|
+
*/
|
|
10
|
+
function cwd() {
|
|
11
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
12
|
+
return "/";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { cwd };
|
|
17
|
+
//# sourceMappingURL=cwd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwd.mjs","names":[],"sources":["../../../../path/src/cwd.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Get the current working directory.\n *\n * @remarks\n * This function attempts to retrieve the current working directory using `process.cwd()`.\n *\n * @returns The current working directory or '/' if it cannot be determined\n */\nexport function cwd() {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n return process.cwd().replace(/\\\\/g, \"/\");\n }\n return \"/\";\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,MAAM;AACpB,KAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,QAAQ,WAC3D,QAAO,QAAQ,KAAK,CAAC,QAAQ,OAAO,IAAI;AAE1C,QAAO"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const require_regex = require('./regex.cjs');
|
|
2
|
+
const require_slash = require('./slash.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../path/src/is-type.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the path is an absolute path.
|
|
7
|
+
*
|
|
8
|
+
* @param path - The path to check
|
|
9
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
10
|
+
*/
|
|
11
|
+
function isAbsolutePath(path) {
|
|
12
|
+
return require_regex.ABSOLUTE_PATH_REGEX.test(require_slash.slash(path));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if the path is an absolute path.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This is an alias for {@link isAbsolutePath}.
|
|
19
|
+
*
|
|
20
|
+
* @param path - The path to check
|
|
21
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
22
|
+
*/
|
|
23
|
+
function isAbsolute(path) {
|
|
24
|
+
return isAbsolutePath(path);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.isAbsolute = isAbsolute;
|
|
29
|
+
exports.isAbsolutePath = isAbsolutePath;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ABSOLUTE_PATH_REGEX } from "./regex.mjs";
|
|
2
|
+
import { slash } from "./slash.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../path/src/is-type.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the path is an absolute path.
|
|
7
|
+
*
|
|
8
|
+
* @param path - The path to check
|
|
9
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
10
|
+
*/
|
|
11
|
+
function isAbsolutePath(path) {
|
|
12
|
+
return ABSOLUTE_PATH_REGEX.test(slash(path));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if the path is an absolute path.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This is an alias for {@link isAbsolutePath}.
|
|
19
|
+
*
|
|
20
|
+
* @param path - The path to check
|
|
21
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
22
|
+
*/
|
|
23
|
+
function isAbsolute(path) {
|
|
24
|
+
return isAbsolutePath(path);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isAbsolute, isAbsolutePath };
|
|
29
|
+
//# sourceMappingURL=is-type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,eAAe,MAAuB;AACpD,QAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;;;;;;;;;;;AAY9C,SAAgB,WAAW,MAAuB;AAChD,QAAO,eAAe,KAAK"}
|