@nyaomaru/divider 2.0.17 → 2.0.18
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 +48 -40
- package/dist/index.js +48 -40
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,38 @@ __export(index_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(index_exports);
|
|
34
34
|
|
|
35
|
+
// src/utils/guards/primitives.ts
|
|
36
|
+
function isString(value) {
|
|
37
|
+
return typeof value === "string";
|
|
38
|
+
}
|
|
39
|
+
function isNumber(value) {
|
|
40
|
+
return typeof value === "number";
|
|
41
|
+
}
|
|
42
|
+
function isObject(value) {
|
|
43
|
+
return typeof value === "object" && value !== null;
|
|
44
|
+
}
|
|
45
|
+
function isPlainObject(value) {
|
|
46
|
+
if (!isObject(value)) return false;
|
|
47
|
+
const proto = Object.getPrototypeOf(value);
|
|
48
|
+
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
49
|
+
}
|
|
50
|
+
function isPositiveInteger(value) {
|
|
51
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
52
|
+
}
|
|
53
|
+
function isStringOrNumber(value) {
|
|
54
|
+
return isString(value) || isNumber(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/utils/guards/array.ts
|
|
58
|
+
function isEmptyArray(value) {
|
|
59
|
+
return Array.isArray(value) && value.length === 0;
|
|
60
|
+
}
|
|
61
|
+
function isNestedStringArray(value) {
|
|
62
|
+
if (!Array.isArray(value) || value.length === 0) return false;
|
|
63
|
+
const firstRow = value[0];
|
|
64
|
+
return Array.isArray(firstRow) && firstRow.every((item) => isString(item));
|
|
65
|
+
}
|
|
66
|
+
|
|
35
67
|
// src/constants/index.ts
|
|
36
68
|
var DIVIDER_EXCLUDE_MODES = {
|
|
37
69
|
NONE: "none",
|
|
@@ -71,43 +103,7 @@ var QUERY_DECODE_MODES = {
|
|
|
71
103
|
RAW: "raw"
|
|
72
104
|
};
|
|
73
105
|
|
|
74
|
-
// src/utils/
|
|
75
|
-
function isString(value) {
|
|
76
|
-
return typeof value === "string";
|
|
77
|
-
}
|
|
78
|
-
function isNumber(value) {
|
|
79
|
-
return typeof value === "number";
|
|
80
|
-
}
|
|
81
|
-
function isObject(value) {
|
|
82
|
-
return typeof value === "object" && value !== null;
|
|
83
|
-
}
|
|
84
|
-
function isPlainObject(value) {
|
|
85
|
-
if (!isObject(value)) return false;
|
|
86
|
-
const proto = Object.getPrototypeOf(value);
|
|
87
|
-
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
88
|
-
}
|
|
89
|
-
function isOptions(value) {
|
|
90
|
-
if (!isPlainObject(value)) return false;
|
|
91
|
-
const options = value;
|
|
92
|
-
return DIVIDER_OPTION_KEYS.some((key) => Object.hasOwn(options, key));
|
|
93
|
-
}
|
|
94
|
-
function isEmptyArray(value) {
|
|
95
|
-
return Array.isArray(value) && value.length === 0;
|
|
96
|
-
}
|
|
97
|
-
function isPositiveInteger(value) {
|
|
98
|
-
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
99
|
-
}
|
|
100
|
-
function isValidInput(value) {
|
|
101
|
-
return isString(value) || Array.isArray(value) && value.every(isString);
|
|
102
|
-
}
|
|
103
|
-
function isStringOrNumber(value) {
|
|
104
|
-
return isString(value) || isNumber(value);
|
|
105
|
-
}
|
|
106
|
-
function isNestedStringArray(value) {
|
|
107
|
-
if (!Array.isArray(value) || value.length === 0) return false;
|
|
108
|
-
const firstRow = value[0];
|
|
109
|
-
return Array.isArray(firstRow) && firstRow.every((item) => isString(item));
|
|
110
|
-
}
|
|
106
|
+
// src/utils/guards/whitespace.ts
|
|
111
107
|
function isSpaceOrTab(value) {
|
|
112
108
|
return value === WHITE_SPACE || value === TAB;
|
|
113
109
|
}
|
|
@@ -117,9 +113,6 @@ function isWhitespaceOnly(value) {
|
|
|
117
113
|
function isEmptyString(value) {
|
|
118
114
|
return value === "";
|
|
119
115
|
}
|
|
120
|
-
function isNoneMode(value) {
|
|
121
|
-
return value === DIVIDER_EXCLUDE_MODES.NONE;
|
|
122
|
-
}
|
|
123
116
|
|
|
124
117
|
// src/utils/regex.ts
|
|
125
118
|
function normalizeSeparators(separators) {
|
|
@@ -275,6 +268,11 @@ var assertValidNumSeparators = (numSeparators) => {
|
|
|
275
268
|
}
|
|
276
269
|
};
|
|
277
270
|
|
|
271
|
+
// src/utils/guards/divider-input.ts
|
|
272
|
+
function isValidInput(value) {
|
|
273
|
+
return isString(value) || Array.isArray(value) && value.every(isString);
|
|
274
|
+
}
|
|
275
|
+
|
|
278
276
|
// src/utils/array.ts
|
|
279
277
|
function ensureStringArray(input) {
|
|
280
278
|
return isString(input) ? [input] : input;
|
|
@@ -293,6 +291,16 @@ var excludePredicateMap = {
|
|
|
293
291
|
whitespace: (s) => !isWhitespaceOnly(s)
|
|
294
292
|
};
|
|
295
293
|
|
|
294
|
+
// src/utils/guards/options.ts
|
|
295
|
+
function isOptions(value) {
|
|
296
|
+
if (!isPlainObject(value)) return false;
|
|
297
|
+
const options = value;
|
|
298
|
+
return DIVIDER_OPTION_KEYS.some((key) => Object.hasOwn(options, key));
|
|
299
|
+
}
|
|
300
|
+
function isNoneMode(value) {
|
|
301
|
+
return value === DIVIDER_EXCLUDE_MODES.NONE;
|
|
302
|
+
}
|
|
303
|
+
|
|
296
304
|
// src/utils/option-exclude.ts
|
|
297
305
|
function resolveExcludePredicate(exclude) {
|
|
298
306
|
if (exclude == null || isNoneMode(exclude) || typeof exclude !== "string") {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
// src/utils/guards/primitives.ts
|
|
2
|
+
function isString(value) {
|
|
3
|
+
return typeof value === "string";
|
|
4
|
+
}
|
|
5
|
+
function isNumber(value) {
|
|
6
|
+
return typeof value === "number";
|
|
7
|
+
}
|
|
8
|
+
function isObject(value) {
|
|
9
|
+
return typeof value === "object" && value !== null;
|
|
10
|
+
}
|
|
11
|
+
function isPlainObject(value) {
|
|
12
|
+
if (!isObject(value)) return false;
|
|
13
|
+
const proto = Object.getPrototypeOf(value);
|
|
14
|
+
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
15
|
+
}
|
|
16
|
+
function isPositiveInteger(value) {
|
|
17
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
18
|
+
}
|
|
19
|
+
function isStringOrNumber(value) {
|
|
20
|
+
return isString(value) || isNumber(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/utils/guards/array.ts
|
|
24
|
+
function isEmptyArray(value) {
|
|
25
|
+
return Array.isArray(value) && value.length === 0;
|
|
26
|
+
}
|
|
27
|
+
function isNestedStringArray(value) {
|
|
28
|
+
if (!Array.isArray(value) || value.length === 0) return false;
|
|
29
|
+
const firstRow = value[0];
|
|
30
|
+
return Array.isArray(firstRow) && firstRow.every((item) => isString(item));
|
|
31
|
+
}
|
|
32
|
+
|
|
1
33
|
// src/constants/index.ts
|
|
2
34
|
var DIVIDER_EXCLUDE_MODES = {
|
|
3
35
|
NONE: "none",
|
|
@@ -37,43 +69,7 @@ var QUERY_DECODE_MODES = {
|
|
|
37
69
|
RAW: "raw"
|
|
38
70
|
};
|
|
39
71
|
|
|
40
|
-
// src/utils/
|
|
41
|
-
function isString(value) {
|
|
42
|
-
return typeof value === "string";
|
|
43
|
-
}
|
|
44
|
-
function isNumber(value) {
|
|
45
|
-
return typeof value === "number";
|
|
46
|
-
}
|
|
47
|
-
function isObject(value) {
|
|
48
|
-
return typeof value === "object" && value !== null;
|
|
49
|
-
}
|
|
50
|
-
function isPlainObject(value) {
|
|
51
|
-
if (!isObject(value)) return false;
|
|
52
|
-
const proto = Object.getPrototypeOf(value);
|
|
53
|
-
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
54
|
-
}
|
|
55
|
-
function isOptions(value) {
|
|
56
|
-
if (!isPlainObject(value)) return false;
|
|
57
|
-
const options = value;
|
|
58
|
-
return DIVIDER_OPTION_KEYS.some((key) => Object.hasOwn(options, key));
|
|
59
|
-
}
|
|
60
|
-
function isEmptyArray(value) {
|
|
61
|
-
return Array.isArray(value) && value.length === 0;
|
|
62
|
-
}
|
|
63
|
-
function isPositiveInteger(value) {
|
|
64
|
-
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
65
|
-
}
|
|
66
|
-
function isValidInput(value) {
|
|
67
|
-
return isString(value) || Array.isArray(value) && value.every(isString);
|
|
68
|
-
}
|
|
69
|
-
function isStringOrNumber(value) {
|
|
70
|
-
return isString(value) || isNumber(value);
|
|
71
|
-
}
|
|
72
|
-
function isNestedStringArray(value) {
|
|
73
|
-
if (!Array.isArray(value) || value.length === 0) return false;
|
|
74
|
-
const firstRow = value[0];
|
|
75
|
-
return Array.isArray(firstRow) && firstRow.every((item) => isString(item));
|
|
76
|
-
}
|
|
72
|
+
// src/utils/guards/whitespace.ts
|
|
77
73
|
function isSpaceOrTab(value) {
|
|
78
74
|
return value === WHITE_SPACE || value === TAB;
|
|
79
75
|
}
|
|
@@ -83,9 +79,6 @@ function isWhitespaceOnly(value) {
|
|
|
83
79
|
function isEmptyString(value) {
|
|
84
80
|
return value === "";
|
|
85
81
|
}
|
|
86
|
-
function isNoneMode(value) {
|
|
87
|
-
return value === DIVIDER_EXCLUDE_MODES.NONE;
|
|
88
|
-
}
|
|
89
82
|
|
|
90
83
|
// src/utils/regex.ts
|
|
91
84
|
function normalizeSeparators(separators) {
|
|
@@ -241,6 +234,11 @@ var assertValidNumSeparators = (numSeparators) => {
|
|
|
241
234
|
}
|
|
242
235
|
};
|
|
243
236
|
|
|
237
|
+
// src/utils/guards/divider-input.ts
|
|
238
|
+
function isValidInput(value) {
|
|
239
|
+
return isString(value) || Array.isArray(value) && value.every(isString);
|
|
240
|
+
}
|
|
241
|
+
|
|
244
242
|
// src/utils/array.ts
|
|
245
243
|
function ensureStringArray(input) {
|
|
246
244
|
return isString(input) ? [input] : input;
|
|
@@ -259,6 +257,16 @@ var excludePredicateMap = {
|
|
|
259
257
|
whitespace: (s) => !isWhitespaceOnly(s)
|
|
260
258
|
};
|
|
261
259
|
|
|
260
|
+
// src/utils/guards/options.ts
|
|
261
|
+
function isOptions(value) {
|
|
262
|
+
if (!isPlainObject(value)) return false;
|
|
263
|
+
const options = value;
|
|
264
|
+
return DIVIDER_OPTION_KEYS.some((key) => Object.hasOwn(options, key));
|
|
265
|
+
}
|
|
266
|
+
function isNoneMode(value) {
|
|
267
|
+
return value === DIVIDER_EXCLUDE_MODES.NONE;
|
|
268
|
+
}
|
|
269
|
+
|
|
262
270
|
// src/utils/option-exclude.ts
|
|
263
271
|
function resolveExcludePredicate(exclude) {
|
|
264
272
|
if (exclude == null || isNoneMode(exclude) || typeof exclude !== "string") {
|