@nyaomaru/divider 1.9.8 → 1.9.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 +24 -23
- package/dist/index.js +24 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -57,43 +57,46 @@ var PATH_SEPARATORS = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/utils/is.ts
|
|
60
|
-
function isString(
|
|
61
|
-
return typeof
|
|
60
|
+
function isString(value) {
|
|
61
|
+
return typeof value === "string";
|
|
62
62
|
}
|
|
63
|
-
function isNumber(
|
|
64
|
-
return typeof
|
|
63
|
+
function isNumber(value) {
|
|
64
|
+
return typeof value === "number";
|
|
65
65
|
}
|
|
66
|
-
function isObject(
|
|
67
|
-
return typeof
|
|
66
|
+
function isObject(value) {
|
|
67
|
+
return typeof value === "object" && value !== null;
|
|
68
68
|
}
|
|
69
69
|
function isOptions(value) {
|
|
70
70
|
if (!isObject(value)) return false;
|
|
71
71
|
const options = value;
|
|
72
72
|
return DIVIDER_OPTION_KEYS.some((key) => Object.hasOwn(options, key));
|
|
73
73
|
}
|
|
74
|
-
function isEmptyArray(
|
|
75
|
-
return Array.isArray(
|
|
74
|
+
function isEmptyArray(value) {
|
|
75
|
+
return Array.isArray(value) && value.length === 0;
|
|
76
76
|
}
|
|
77
77
|
function isPositiveInteger(value) {
|
|
78
78
|
return Number.isInteger(value) && value > 0;
|
|
79
79
|
}
|
|
80
|
-
function isValidInput(
|
|
81
|
-
return isString(
|
|
80
|
+
function isValidInput(value) {
|
|
81
|
+
return isString(value) || Array.isArray(value) && value.every(isString);
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
83
|
+
function isStringOrNumber(value) {
|
|
84
|
+
return isString(value) || isNumber(value);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
return Array.isArray(
|
|
86
|
+
function isStringArray(value) {
|
|
87
|
+
return Array.isArray(value) && value.every(isString);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
return
|
|
89
|
+
function isNestedStringArray(value) {
|
|
90
|
+
return Array.isArray(value) && value.length > 0 && Array.isArray(value[0]) && value[0].length > 0 && isStringArray(value[0]);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return
|
|
92
|
+
function isWhitespaceOnly(value) {
|
|
93
|
+
return value.trim() === "";
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
return
|
|
95
|
+
function isEmptyString(value) {
|
|
96
|
+
return value === "";
|
|
97
|
+
}
|
|
98
|
+
function isNoneMode(value) {
|
|
99
|
+
return value === DIVIDER_EXCLUDE_MODES.NONE;
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
// src/utils/regex.ts
|
|
@@ -245,9 +248,7 @@ function extractOptions(args) {
|
|
|
245
248
|
const clonedArgs = [...args];
|
|
246
249
|
const lastArg = clonedArgs.at(-1);
|
|
247
250
|
const options = isOptions(lastArg) ? (clonedArgs.pop(), lastArg) : {};
|
|
248
|
-
const cleanedArgs = clonedArgs.filter(
|
|
249
|
-
(arg) => isString(arg) || isNumber(arg)
|
|
250
|
-
);
|
|
251
|
+
const cleanedArgs = clonedArgs.filter(isStringOrNumber);
|
|
251
252
|
return {
|
|
252
253
|
cleanedArgs,
|
|
253
254
|
options
|
package/dist/index.js
CHANGED
|
@@ -24,43 +24,46 @@ var PATH_SEPARATORS = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// src/utils/is.ts
|
|
27
|
-
function isString(
|
|
28
|
-
return typeof
|
|
27
|
+
function isString(value) {
|
|
28
|
+
return typeof value === "string";
|
|
29
29
|
}
|
|
30
|
-
function isNumber(
|
|
31
|
-
return typeof
|
|
30
|
+
function isNumber(value) {
|
|
31
|
+
return typeof value === "number";
|
|
32
32
|
}
|
|
33
|
-
function isObject(
|
|
34
|
-
return typeof
|
|
33
|
+
function isObject(value) {
|
|
34
|
+
return typeof value === "object" && value !== null;
|
|
35
35
|
}
|
|
36
36
|
function isOptions(value) {
|
|
37
37
|
if (!isObject(value)) return false;
|
|
38
38
|
const options = value;
|
|
39
39
|
return DIVIDER_OPTION_KEYS.some((key) => Object.hasOwn(options, key));
|
|
40
40
|
}
|
|
41
|
-
function isEmptyArray(
|
|
42
|
-
return Array.isArray(
|
|
41
|
+
function isEmptyArray(value) {
|
|
42
|
+
return Array.isArray(value) && value.length === 0;
|
|
43
43
|
}
|
|
44
44
|
function isPositiveInteger(value) {
|
|
45
45
|
return Number.isInteger(value) && value > 0;
|
|
46
46
|
}
|
|
47
|
-
function isValidInput(
|
|
48
|
-
return isString(
|
|
47
|
+
function isValidInput(value) {
|
|
48
|
+
return isString(value) || Array.isArray(value) && value.every(isString);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
50
|
+
function isStringOrNumber(value) {
|
|
51
|
+
return isString(value) || isNumber(value);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return Array.isArray(
|
|
53
|
+
function isStringArray(value) {
|
|
54
|
+
return Array.isArray(value) && value.every(isString);
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function isNestedStringArray(value) {
|
|
57
|
+
return Array.isArray(value) && value.length > 0 && Array.isArray(value[0]) && value[0].length > 0 && isStringArray(value[0]);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
59
|
+
function isWhitespaceOnly(value) {
|
|
60
|
+
return value.trim() === "";
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
62
|
+
function isEmptyString(value) {
|
|
63
|
+
return value === "";
|
|
64
|
+
}
|
|
65
|
+
function isNoneMode(value) {
|
|
66
|
+
return value === DIVIDER_EXCLUDE_MODES.NONE;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
// src/utils/regex.ts
|
|
@@ -212,9 +215,7 @@ function extractOptions(args) {
|
|
|
212
215
|
const clonedArgs = [...args];
|
|
213
216
|
const lastArg = clonedArgs.at(-1);
|
|
214
217
|
const options = isOptions(lastArg) ? (clonedArgs.pop(), lastArg) : {};
|
|
215
|
-
const cleanedArgs = clonedArgs.filter(
|
|
216
|
-
(arg) => isString(arg) || isNumber(arg)
|
|
217
|
-
);
|
|
218
|
+
const cleanedArgs = clonedArgs.filter(isStringOrNumber);
|
|
218
219
|
return {
|
|
219
220
|
cleanedArgs,
|
|
220
221
|
options
|