@nyaomaru/divider 2.0.13 → 2.0.14
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 +38 -28
- package/dist/index.js +38 -28
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -293,17 +293,15 @@ var excludePredicateMap = {
|
|
|
293
293
|
whitespace: (s) => !isWhitespaceOnly(s)
|
|
294
294
|
};
|
|
295
295
|
|
|
296
|
-
// src/utils/option.ts
|
|
297
|
-
function
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return {
|
|
303
|
-
cleanedArgs,
|
|
304
|
-
options
|
|
305
|
-
};
|
|
296
|
+
// src/utils/option-exclude.ts
|
|
297
|
+
function resolveExcludePredicate(exclude) {
|
|
298
|
+
if (exclude == null || isNoneMode(exclude) || typeof exclude !== "string") {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
return Object.hasOwn(excludePredicateMap, exclude) ? excludePredicateMap[exclude] : null;
|
|
306
302
|
}
|
|
303
|
+
|
|
304
|
+
// src/utils/option-output.ts
|
|
307
305
|
function mapDividerOutput(output, transform) {
|
|
308
306
|
return isNestedStringArray(output) ? output.map(transform) : transform(output);
|
|
309
307
|
}
|
|
@@ -314,16 +312,40 @@ function filterDividerOutput(output, shouldKeep, preserveEmpty) {
|
|
|
314
312
|
const filteredRows = output.map((row) => row.filter(shouldKeep));
|
|
315
313
|
return preserveEmpty ? filteredRows : filteredRows.filter((row) => row.length > 0);
|
|
316
314
|
}
|
|
317
|
-
function resolveExcludePredicate(exclude) {
|
|
318
|
-
if (exclude == null || isNoneMode(exclude) || typeof exclude !== "string") {
|
|
319
|
-
return null;
|
|
320
|
-
}
|
|
321
|
-
return Object.hasOwn(excludePredicateMap, exclude) ? excludePredicateMap[exclude] : null;
|
|
322
|
-
}
|
|
323
315
|
function trimSegments(segments, preserveEmpty) {
|
|
324
316
|
const trimmed = segments.map((segment) => segment.trim());
|
|
325
317
|
return preserveEmpty ? trimmed : trimmed.filter((segment) => !isEmptyString(segment));
|
|
326
318
|
}
|
|
319
|
+
|
|
320
|
+
// src/utils/option-transformers.ts
|
|
321
|
+
function applyTrimOption(output, options, shouldPreserveEmpty) {
|
|
322
|
+
if (!options.trim) return output;
|
|
323
|
+
return mapDividerOutput(
|
|
324
|
+
output,
|
|
325
|
+
(segments) => trimSegments(segments, shouldPreserveEmpty)
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
function applyFlattenOption(output, options) {
|
|
329
|
+
return options.flatten && isNestedStringArray(output) ? output.flat() : output;
|
|
330
|
+
}
|
|
331
|
+
function applyExcludeOption(output, options, shouldPreserveEmpty) {
|
|
332
|
+
const shouldKeep = resolveExcludePredicate(options.exclude);
|
|
333
|
+
return shouldKeep == null ? output : filterDividerOutput(output, shouldKeep, shouldPreserveEmpty);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// src/utils/option-arguments.ts
|
|
337
|
+
function extractOptions(args) {
|
|
338
|
+
const clonedArgs = [...args];
|
|
339
|
+
const lastArg = clonedArgs.at(-1);
|
|
340
|
+
const options = isOptions(lastArg) ? (clonedArgs.pop(), lastArg) : {};
|
|
341
|
+
const cleanedArgs = clonedArgs.filter(isStringOrNumber);
|
|
342
|
+
return {
|
|
343
|
+
cleanedArgs,
|
|
344
|
+
options
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/utils/option.ts
|
|
327
349
|
function applyDividerOptions(result, options) {
|
|
328
350
|
const shouldPreserveEmpty = options.preserveEmpty === true;
|
|
329
351
|
let output = result;
|
|
@@ -332,18 +354,6 @@ function applyDividerOptions(result, options) {
|
|
|
332
354
|
output = applyExcludeOption(output, options, shouldPreserveEmpty);
|
|
333
355
|
return output;
|
|
334
356
|
}
|
|
335
|
-
var applyTrimOption = (output, options, shouldPreserveEmpty) => {
|
|
336
|
-
if (!options.trim) return output;
|
|
337
|
-
return mapDividerOutput(
|
|
338
|
-
output,
|
|
339
|
-
(segments) => trimSegments(segments, shouldPreserveEmpty)
|
|
340
|
-
);
|
|
341
|
-
};
|
|
342
|
-
var applyFlattenOption = (output, options) => options.flatten && isNestedStringArray(output) ? output.flat() : output;
|
|
343
|
-
var applyExcludeOption = (output, options, shouldPreserveEmpty) => {
|
|
344
|
-
const shouldKeep = resolveExcludePredicate(options.exclude);
|
|
345
|
-
return shouldKeep == null ? output : filterDividerOutput(output, shouldKeep, shouldPreserveEmpty);
|
|
346
|
-
};
|
|
347
357
|
|
|
348
358
|
// src/utils/separator.ts
|
|
349
359
|
function classifySeparators(args) {
|
package/dist/index.js
CHANGED
|
@@ -259,17 +259,15 @@ var excludePredicateMap = {
|
|
|
259
259
|
whitespace: (s) => !isWhitespaceOnly(s)
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
// src/utils/option.ts
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return {
|
|
269
|
-
cleanedArgs,
|
|
270
|
-
options
|
|
271
|
-
};
|
|
262
|
+
// src/utils/option-exclude.ts
|
|
263
|
+
function resolveExcludePredicate(exclude) {
|
|
264
|
+
if (exclude == null || isNoneMode(exclude) || typeof exclude !== "string") {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return Object.hasOwn(excludePredicateMap, exclude) ? excludePredicateMap[exclude] : null;
|
|
272
268
|
}
|
|
269
|
+
|
|
270
|
+
// src/utils/option-output.ts
|
|
273
271
|
function mapDividerOutput(output, transform) {
|
|
274
272
|
return isNestedStringArray(output) ? output.map(transform) : transform(output);
|
|
275
273
|
}
|
|
@@ -280,16 +278,40 @@ function filterDividerOutput(output, shouldKeep, preserveEmpty) {
|
|
|
280
278
|
const filteredRows = output.map((row) => row.filter(shouldKeep));
|
|
281
279
|
return preserveEmpty ? filteredRows : filteredRows.filter((row) => row.length > 0);
|
|
282
280
|
}
|
|
283
|
-
function resolveExcludePredicate(exclude) {
|
|
284
|
-
if (exclude == null || isNoneMode(exclude) || typeof exclude !== "string") {
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
return Object.hasOwn(excludePredicateMap, exclude) ? excludePredicateMap[exclude] : null;
|
|
288
|
-
}
|
|
289
281
|
function trimSegments(segments, preserveEmpty) {
|
|
290
282
|
const trimmed = segments.map((segment) => segment.trim());
|
|
291
283
|
return preserveEmpty ? trimmed : trimmed.filter((segment) => !isEmptyString(segment));
|
|
292
284
|
}
|
|
285
|
+
|
|
286
|
+
// src/utils/option-transformers.ts
|
|
287
|
+
function applyTrimOption(output, options, shouldPreserveEmpty) {
|
|
288
|
+
if (!options.trim) return output;
|
|
289
|
+
return mapDividerOutput(
|
|
290
|
+
output,
|
|
291
|
+
(segments) => trimSegments(segments, shouldPreserveEmpty)
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
function applyFlattenOption(output, options) {
|
|
295
|
+
return options.flatten && isNestedStringArray(output) ? output.flat() : output;
|
|
296
|
+
}
|
|
297
|
+
function applyExcludeOption(output, options, shouldPreserveEmpty) {
|
|
298
|
+
const shouldKeep = resolveExcludePredicate(options.exclude);
|
|
299
|
+
return shouldKeep == null ? output : filterDividerOutput(output, shouldKeep, shouldPreserveEmpty);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/utils/option-arguments.ts
|
|
303
|
+
function extractOptions(args) {
|
|
304
|
+
const clonedArgs = [...args];
|
|
305
|
+
const lastArg = clonedArgs.at(-1);
|
|
306
|
+
const options = isOptions(lastArg) ? (clonedArgs.pop(), lastArg) : {};
|
|
307
|
+
const cleanedArgs = clonedArgs.filter(isStringOrNumber);
|
|
308
|
+
return {
|
|
309
|
+
cleanedArgs,
|
|
310
|
+
options
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/utils/option.ts
|
|
293
315
|
function applyDividerOptions(result, options) {
|
|
294
316
|
const shouldPreserveEmpty = options.preserveEmpty === true;
|
|
295
317
|
let output = result;
|
|
@@ -298,18 +320,6 @@ function applyDividerOptions(result, options) {
|
|
|
298
320
|
output = applyExcludeOption(output, options, shouldPreserveEmpty);
|
|
299
321
|
return output;
|
|
300
322
|
}
|
|
301
|
-
var applyTrimOption = (output, options, shouldPreserveEmpty) => {
|
|
302
|
-
if (!options.trim) return output;
|
|
303
|
-
return mapDividerOutput(
|
|
304
|
-
output,
|
|
305
|
-
(segments) => trimSegments(segments, shouldPreserveEmpty)
|
|
306
|
-
);
|
|
307
|
-
};
|
|
308
|
-
var applyFlattenOption = (output, options) => options.flatten && isNestedStringArray(output) ? output.flat() : output;
|
|
309
|
-
var applyExcludeOption = (output, options, shouldPreserveEmpty) => {
|
|
310
|
-
const shouldKeep = resolveExcludePredicate(options.exclude);
|
|
311
|
-
return shouldKeep == null ? output : filterDividerOutput(output, shouldKeep, shouldPreserveEmpty);
|
|
312
|
-
};
|
|
313
323
|
|
|
314
324
|
// src/utils/separator.ts
|
|
315
325
|
function classifySeparators(args) {
|