@nyaomaru/divider 1.8.0 → 1.8.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/index.cjs +3 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -108,6 +108,9 @@ function divideString(input, numSeparators, strSeparators) {
|
|
|
108
108
|
if (isEmptyArray(numSeparators) && isEmptyArray(strSeparators)) {
|
|
109
109
|
return [input];
|
|
110
110
|
}
|
|
111
|
+
if (!Array.isArray(numSeparators) || !numSeparators.every(isNumber)) {
|
|
112
|
+
throw new Error("Invalid numeric separators");
|
|
113
|
+
}
|
|
111
114
|
const regex = getRegex(strSeparators);
|
|
112
115
|
const sortedNumSeparators = sortAscending(numSeparators);
|
|
113
116
|
const parts = sliceByIndexes(input, sortedNumSeparators);
|
package/dist/index.js
CHANGED
|
@@ -78,6 +78,9 @@ function divideString(input, numSeparators, strSeparators) {
|
|
|
78
78
|
if (isEmptyArray(numSeparators) && isEmptyArray(strSeparators)) {
|
|
79
79
|
return [input];
|
|
80
80
|
}
|
|
81
|
+
if (!Array.isArray(numSeparators) || !numSeparators.every(isNumber)) {
|
|
82
|
+
throw new Error("Invalid numeric separators");
|
|
83
|
+
}
|
|
81
84
|
const regex = getRegex(strSeparators);
|
|
82
85
|
const sortedNumSeparators = sortAscending(numSeparators);
|
|
83
86
|
const parts = sliceByIndexes(input, sortedNumSeparators);
|