@nyaomaru/divider 1.2.0 → 1.2.2

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.
@@ -8,7 +8,7 @@ function divider(input, ...args) {
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 (args.length === 0) {
11
+ if ((0, validator_1.isEmptyArray)(args)) {
12
12
  return (typeof input === 'string' ? [input] : input);
13
13
  }
14
14
  // Extract the options from the input
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isOptions = isOptions;
4
+ exports.isEmptyArray = isEmptyArray;
4
5
  function isOptions(arg) {
5
6
  return typeof arg === 'object' && arg !== null && 'flatten' in arg;
6
7
  }
8
+ function isEmptyArray(input) {
9
+ return input.length === 0;
10
+ }
@@ -1,11 +1,11 @@
1
1
  import { divideString } from '@/core/parser';
2
- import { isOptions } from '@/core/validator';
2
+ import { isOptions, isEmptyArray } from '@/core/validator';
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.");
6
6
  return [];
7
7
  }
8
- if (args.length === 0) {
8
+ if (isEmptyArray(args)) {
9
9
  return (typeof input === 'string' ? [input] : input);
10
10
  }
11
11
  // Extract the options from the input
@@ -1,3 +1,6 @@
1
1
  export function isOptions(arg) {
2
2
  return typeof arg === 'object' && arg !== null && 'flatten' in arg;
3
3
  }
4
+ export function isEmptyArray(input) {
5
+ return input.length === 0;
6
+ }
@@ -1,2 +1,2 @@
1
1
  import type { DividerArgs } from '@/core/types';
2
- export declare function dividerLast<T extends string | string[], F extends boolean>(input: T, ...args: DividerArgs<F>): string;
2
+ export declare function dividerLast<T extends string | string[], F extends boolean = false>(input: T, ...args: DividerArgs<F>): string;
@@ -1,3 +1,4 @@
1
1
  export declare function isOptions(arg: unknown): arg is {
2
2
  flatten?: boolean;
3
3
  };
4
+ export declare function isEmptyArray<T>(input: T[]): boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nyaomaru/divider",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "description": "To divide string or string[] with a given separator",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.js",