@nyaomaru/divider 2.0.19 → 2.0.21
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 +8 -10
- package/dist/index.js +8 -10
- package/package.json +32 -28
package/dist/index.cjs
CHANGED
|
@@ -277,12 +277,6 @@ function isValidInput(value) {
|
|
|
277
277
|
function ensureStringArray(input) {
|
|
278
278
|
return isString(input) ? [input] : input;
|
|
279
279
|
}
|
|
280
|
-
function getFirstElement(array, fallback) {
|
|
281
|
-
return array[0] ?? fallback;
|
|
282
|
-
}
|
|
283
|
-
function getLastElement(array, fallback) {
|
|
284
|
-
return array.at(-1) ?? fallback;
|
|
285
|
-
}
|
|
286
280
|
|
|
287
281
|
// src/utils/exclude-predicate.ts
|
|
288
282
|
var excludePredicateMap = {
|
|
@@ -427,16 +421,20 @@ function divider(input, ...args) {
|
|
|
427
421
|
return transformDividerInput(input, applyDivision, options);
|
|
428
422
|
}
|
|
429
423
|
|
|
424
|
+
// src/core/divider-segment.ts
|
|
425
|
+
function selectDividerSegment(input, args, select) {
|
|
426
|
+
const result = divider(input, ...args, { flatten: true });
|
|
427
|
+
return select(result) ?? "";
|
|
428
|
+
}
|
|
429
|
+
|
|
430
430
|
// src/core/divider-first.ts
|
|
431
431
|
function dividerFirst(input, ...args) {
|
|
432
|
-
|
|
433
|
-
return getFirstElement(result, "");
|
|
432
|
+
return selectDividerSegment(input, args, (segments) => segments[0]);
|
|
434
433
|
}
|
|
435
434
|
|
|
436
435
|
// src/core/divider-last.ts
|
|
437
436
|
function dividerLast(input, ...args) {
|
|
438
|
-
|
|
439
|
-
return getLastElement(result, "");
|
|
437
|
+
return selectDividerSegment(input, args, (segments) => segments.at(-1));
|
|
440
438
|
}
|
|
441
439
|
|
|
442
440
|
// src/utils/generate-indexes.ts
|
package/dist/index.js
CHANGED
|
@@ -243,12 +243,6 @@ function isValidInput(value) {
|
|
|
243
243
|
function ensureStringArray(input) {
|
|
244
244
|
return isString(input) ? [input] : input;
|
|
245
245
|
}
|
|
246
|
-
function getFirstElement(array, fallback) {
|
|
247
|
-
return array[0] ?? fallback;
|
|
248
|
-
}
|
|
249
|
-
function getLastElement(array, fallback) {
|
|
250
|
-
return array.at(-1) ?? fallback;
|
|
251
|
-
}
|
|
252
246
|
|
|
253
247
|
// src/utils/exclude-predicate.ts
|
|
254
248
|
var excludePredicateMap = {
|
|
@@ -393,16 +387,20 @@ function divider(input, ...args) {
|
|
|
393
387
|
return transformDividerInput(input, applyDivision, options);
|
|
394
388
|
}
|
|
395
389
|
|
|
390
|
+
// src/core/divider-segment.ts
|
|
391
|
+
function selectDividerSegment(input, args, select) {
|
|
392
|
+
const result = divider(input, ...args, { flatten: true });
|
|
393
|
+
return select(result) ?? "";
|
|
394
|
+
}
|
|
395
|
+
|
|
396
396
|
// src/core/divider-first.ts
|
|
397
397
|
function dividerFirst(input, ...args) {
|
|
398
|
-
|
|
399
|
-
return getFirstElement(result, "");
|
|
398
|
+
return selectDividerSegment(input, args, (segments) => segments[0]);
|
|
400
399
|
}
|
|
401
400
|
|
|
402
401
|
// src/core/divider-last.ts
|
|
403
402
|
function dividerLast(input, ...args) {
|
|
404
|
-
|
|
405
|
-
return getLastElement(result, "");
|
|
403
|
+
return selectDividerSegment(input, args, (segments) => segments.at(-1));
|
|
406
404
|
}
|
|
407
405
|
|
|
408
406
|
// src/utils/generate-indexes.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nyaomaru/divider",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.21",
|
|
5
5
|
"description": "To divide string or string[] with a given separator",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -15,6 +15,19 @@
|
|
|
15
15
|
"default": "./dist/index.cjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"test:integration": "tsx tests/integration/usage.test.ts",
|
|
21
|
+
"test:types": "tsc -p tests/tsconfig.json",
|
|
22
|
+
"test:performance": "jest --config jest.performance.config.cjs",
|
|
23
|
+
"test:unit": "jest",
|
|
24
|
+
"lint": "eslint .",
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"prepack": "pnpm run build",
|
|
27
|
+
"typedoc": "typedoc",
|
|
28
|
+
"prepare": "lefthook install",
|
|
29
|
+
"knip": "knip"
|
|
30
|
+
},
|
|
18
31
|
"keywords": [
|
|
19
32
|
"divider",
|
|
20
33
|
"divide",
|
|
@@ -35,25 +48,25 @@
|
|
|
35
48
|
"author": "nyaomaru",
|
|
36
49
|
"license": "MIT",
|
|
37
50
|
"devDependencies": {
|
|
38
|
-
"@eslint/js": "^
|
|
39
|
-
"@swc/core": "^1.15.
|
|
51
|
+
"@eslint/js": "^10.0.1",
|
|
52
|
+
"@swc/core": "^1.15.41",
|
|
40
53
|
"@swc/jest": "^0.2.39",
|
|
41
54
|
"@types/jest": "^30.0.0",
|
|
42
|
-
"@types/node": "^22.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
44
|
-
"@typescript-eslint/parser": "^8.
|
|
45
|
-
"bun-types": "^1.
|
|
46
|
-
"eslint": "^
|
|
55
|
+
"@types/node": "^22.19.21",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
|
57
|
+
"@typescript-eslint/parser": "^8.61.1",
|
|
58
|
+
"bun-types": "^1.3.14",
|
|
59
|
+
"eslint": "^10.5.0",
|
|
47
60
|
"eslint-config-prettier": "^10.1.8",
|
|
48
|
-
"eslint-plugin-prettier": "^5.5.
|
|
49
|
-
"jest": "^30.2
|
|
50
|
-
"knip": "^
|
|
51
|
-
"lefthook": "^2.
|
|
52
|
-
"prettier": "^3.
|
|
53
|
-
"tsup": "^8.
|
|
54
|
-
"tsx": "^4.
|
|
55
|
-
"typedoc": "^0.28.
|
|
56
|
-
"typescript": "^
|
|
61
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
62
|
+
"jest": "^30.4.2",
|
|
63
|
+
"knip": "^6.17.1",
|
|
64
|
+
"lefthook": "^2.1.9",
|
|
65
|
+
"prettier": "^3.8.4",
|
|
66
|
+
"tsup": "^8.5.1",
|
|
67
|
+
"tsx": "^4.22.4",
|
|
68
|
+
"typedoc": "^0.28.19",
|
|
69
|
+
"typescript": "^6.0.3"
|
|
57
70
|
},
|
|
58
71
|
"engines": {
|
|
59
72
|
"node": ">=20"
|
|
@@ -62,14 +75,5 @@
|
|
|
62
75
|
"bugs": {
|
|
63
76
|
"url": "https://github.com/nyaomaru/divider/issues"
|
|
64
77
|
},
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
"test:types": "tsc -p tests/tsconfig.json",
|
|
68
|
-
"test:performance": "jest --config jest.performance.config.cjs",
|
|
69
|
-
"test:unit": "jest --testPathIgnorePatterns=performance",
|
|
70
|
-
"lint": "eslint .",
|
|
71
|
-
"build": "tsup",
|
|
72
|
-
"typedoc": "typedoc",
|
|
73
|
-
"knip": "knip"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
78
|
+
"packageManager": "pnpm@11.2.2"
|
|
79
|
+
}
|