@nyaomaru/divider 1.2.2 → 1.2.3
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/cjs/core/divider.js +3 -3
- package/dist/cjs/core/parser.js +3 -2
- package/dist/cjs/{core/validator.js → utils/is.js} +1 -1
- package/dist/cjs/utils/regex.js +2 -1
- package/dist/cjs/utils/slice.js +2 -1
- package/dist/esm/core/divider.js +1 -1
- package/dist/esm/core/parser.js +3 -2
- package/dist/esm/{core/validator.js → utils/is.js} +1 -1
- package/dist/esm/utils/regex.js +2 -1
- package/dist/esm/utils/slice.js +2 -1
- package/package.json +1 -1
- /package/dist/types/{core/validator.d.ts → utils/is.d.ts} +0 -0
package/dist/cjs/core/divider.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.divider = divider;
|
|
4
4
|
const parser_1 = require("@/core/parser");
|
|
5
|
-
const
|
|
5
|
+
const is_1 = require("@/utils/is");
|
|
6
6
|
function divider(input, ...args) {
|
|
7
7
|
if (typeof input !== 'string' && !Array.isArray(input)) {
|
|
8
8
|
console.warn("divider: 'input' must be a string or an array of strings. So returning an empty array.");
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
11
|
-
if ((0,
|
|
11
|
+
if ((0, is_1.isEmptyArray)(args)) {
|
|
12
12
|
return (typeof input === 'string' ? [input] : input);
|
|
13
13
|
}
|
|
14
14
|
// Extract the options from the input
|
|
15
15
|
const lastArg = args[args.length - 1];
|
|
16
|
-
const options = (0,
|
|
16
|
+
const options = (0, is_1.isOptions)(lastArg) ? (args.pop(), lastArg) : {};
|
|
17
17
|
// Filter out only numbers and strings
|
|
18
18
|
const { numSeparators, strSeparators } = args.reduce((acc, arg) => {
|
|
19
19
|
if (typeof arg === 'number') {
|
package/dist/cjs/core/parser.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.divideString = divideString;
|
|
4
|
-
const
|
|
4
|
+
const is_1 = require("@/utils/is");
|
|
5
5
|
const regex_1 = require("@/utils/regex");
|
|
6
|
+
const slice_1 = require("@/utils/slice");
|
|
6
7
|
function divideString(input, numSeparators, strSeparators) {
|
|
7
|
-
if (numSeparators
|
|
8
|
+
if ((0, is_1.isEmptyArray)(numSeparators) && (0, is_1.isEmptyArray)(strSeparators)) {
|
|
8
9
|
return [input];
|
|
9
10
|
}
|
|
10
11
|
// Precompile regex for string separators
|
package/dist/cjs/utils/regex.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRegex = getRegex;
|
|
4
|
+
const is_1 = require("@/utils/is");
|
|
4
5
|
const regexCache = new Map();
|
|
5
6
|
function getRegex(separators) {
|
|
6
|
-
if (
|
|
7
|
+
if ((0, is_1.isEmptyArray)(separators))
|
|
7
8
|
return null;
|
|
8
9
|
const key = JSON.stringify(separators);
|
|
9
10
|
if (!regexCache.has(key)) {
|
package/dist/cjs/utils/slice.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sliceByIndexes = sliceByIndexes;
|
|
4
|
+
const is_1 = require("@/utils/is");
|
|
4
5
|
function sliceByIndexes(input, indexes) {
|
|
5
|
-
if (
|
|
6
|
+
if ((0, is_1.isEmptyArray)(indexes))
|
|
6
7
|
return [input];
|
|
7
8
|
const parts = [];
|
|
8
9
|
let start = 0;
|
package/dist/esm/core/divider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { divideString } from '@/core/parser';
|
|
2
|
-
import { isOptions, isEmptyArray } from '@/
|
|
2
|
+
import { isOptions, isEmptyArray } from '@/utils/is';
|
|
3
3
|
export function divider(input, ...args) {
|
|
4
4
|
if (typeof input !== 'string' && !Array.isArray(input)) {
|
|
5
5
|
console.warn("divider: 'input' must be a string or an array of strings. So returning an empty array.");
|
package/dist/esm/core/parser.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isEmptyArray } from '@/utils/is';
|
|
2
2
|
import { getRegex } from '@/utils/regex';
|
|
3
|
+
import { sliceByIndexes } from '@/utils/slice';
|
|
3
4
|
export function divideString(input, numSeparators, strSeparators) {
|
|
4
|
-
if (numSeparators
|
|
5
|
+
if (isEmptyArray(numSeparators) && isEmptyArray(strSeparators)) {
|
|
5
6
|
return [input];
|
|
6
7
|
}
|
|
7
8
|
// Precompile regex for string separators
|
package/dist/esm/utils/regex.js
CHANGED
package/dist/esm/utils/slice.js
CHANGED
package/package.json
CHANGED
|
File without changes
|