@nyaomaru/divider 1.8.4 → 1.8.5

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.d.cts CHANGED
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Constants defining the available exclusion modes for divider functions.
3
+ * These modes control how empty or whitespace segments are handled in the output.
4
+ *
5
+ * @constant
6
+ * @enum {string}
7
+ * @property {string} NONE - Keep all segments, including empty and whitespace-only segments
8
+ * @property {string} EMPTY - Exclude empty segments (length = 0)
9
+ * @property {string} WHITESPACE - Exclude segments that contain only whitespace characters
10
+ */
1
11
  declare const DividerExcludeModes: {
2
12
  readonly NONE: "none";
3
13
  readonly EMPTY: "empty";
@@ -46,12 +56,64 @@ type DividerArgs = DividerSeparators | [...DividerSeparators, DividerOptions];
46
56
  */
47
57
  declare function divider<T extends DividerInput>(input: T, ...args: DividerArgs): DividerResult<T>;
48
58
 
59
+ /**
60
+ * Extracts the first segment after dividing the input using specified separators.
61
+ *
62
+ * @param input - A string or array of strings to divide
63
+ * @param args - Array of separators (numbers/strings) to use for division
64
+ * @returns The first segment after division, or an empty string if no segments are found
65
+ * @example
66
+ * dividerFirst("hello-world", "-") // returns "hello"
67
+ * dividerFirst("abc123def", 3) // returns "abc"
68
+ */
49
69
  declare function dividerFirst(input: string | string[], ...args: DividerSeparators): string;
50
70
 
71
+ /**
72
+ * Extracts the last segment after dividing the input using specified separators.
73
+ *
74
+ * @param input - A string or array of strings to divide
75
+ * @param args - Array of separators (numbers/strings) to use for division
76
+ * @returns The last segment after division, or an empty string if no segments are found
77
+ * @example
78
+ * dividerLast("hello-world", "-") // returns "world"
79
+ * dividerLast("abc123def", 3) // returns "def"
80
+ */
51
81
  declare function dividerLast(input: string | string[], ...args: DividerSeparators): string;
52
82
 
83
+ /**
84
+ * Divides input into chunks of specified size with optional configuration.
85
+ *
86
+ * This function provides a way to split input into equal-sized chunks with additional control:
87
+ * - Can specify starting offset for the chunking
88
+ * - Can limit the maximum number of chunks produced
89
+ * - Supports both string and array inputs
90
+ * - When maxChunks is specified, remaining content is merged into the last chunk
91
+ *
92
+ * @param input - String or array of strings to divide into chunks
93
+ * @param size - Size of each chunk
94
+ * @param options - Configuration options for chunking behavior
95
+ * @param options.startOffset - Starting position for the first chunk (default: 0)
96
+ * @param options.maxChunks - Maximum number of chunks to produce (default: 0 = no limit)
97
+ * @returns Array of chunks based on input type and options
98
+ * @example
99
+ * dividerLoop("abcdef", 2) // returns ["ab", "cd", "ef"]
100
+ * dividerLoop("abcdef", 2, { maxChunks: 2 }) // returns ["ab", "cdef"]
101
+ */
53
102
  declare function dividerLoop<T extends string | string[]>(input: T, size: number, options?: DividerLoopOptions): DividerResult<T>;
54
103
 
104
+ /**
105
+ * Divides a string or array of strings by separating numbers from non-numbers.
106
+ *
107
+ * This function splits input by detecting transitions between numeric and non-numeric characters.
108
+ * For example, "abc123def" would be split into ["abc", "123", "def"].
109
+ *
110
+ * @param input - String or array of strings to divide
111
+ * @param options - Optional configuration options for the division process
112
+ * @returns Array of segments where numbers and non-numbers are separated
113
+ * @example
114
+ * dividerNumberString("abc123def") // returns ["abc", "123", "def"]
115
+ * dividerNumberString("test42") // returns ["test", "42"]
116
+ */
55
117
  declare function dividerNumberString<T extends string | string[]>(input: T, options?: DividerOptions): DividerResult<T>;
56
118
 
57
119
  export { type DividerArgs, type DividerArrayResult, type DividerExcludeMode, type DividerInput, type DividerLoopOptions, type DividerOptions, type DividerResult, type DividerSeparator, type DividerSeparators, type DividerStringResult, type NumericSeparator, type StringArrayInput, type StringInput, type StringSeparator, divider, dividerFirst, dividerLast, dividerLoop, dividerNumberString };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Constants defining the available exclusion modes for divider functions.
3
+ * These modes control how empty or whitespace segments are handled in the output.
4
+ *
5
+ * @constant
6
+ * @enum {string}
7
+ * @property {string} NONE - Keep all segments, including empty and whitespace-only segments
8
+ * @property {string} EMPTY - Exclude empty segments (length = 0)
9
+ * @property {string} WHITESPACE - Exclude segments that contain only whitespace characters
10
+ */
1
11
  declare const DividerExcludeModes: {
2
12
  readonly NONE: "none";
3
13
  readonly EMPTY: "empty";
@@ -46,12 +56,64 @@ type DividerArgs = DividerSeparators | [...DividerSeparators, DividerOptions];
46
56
  */
47
57
  declare function divider<T extends DividerInput>(input: T, ...args: DividerArgs): DividerResult<T>;
48
58
 
59
+ /**
60
+ * Extracts the first segment after dividing the input using specified separators.
61
+ *
62
+ * @param input - A string or array of strings to divide
63
+ * @param args - Array of separators (numbers/strings) to use for division
64
+ * @returns The first segment after division, or an empty string if no segments are found
65
+ * @example
66
+ * dividerFirst("hello-world", "-") // returns "hello"
67
+ * dividerFirst("abc123def", 3) // returns "abc"
68
+ */
49
69
  declare function dividerFirst(input: string | string[], ...args: DividerSeparators): string;
50
70
 
71
+ /**
72
+ * Extracts the last segment after dividing the input using specified separators.
73
+ *
74
+ * @param input - A string or array of strings to divide
75
+ * @param args - Array of separators (numbers/strings) to use for division
76
+ * @returns The last segment after division, or an empty string if no segments are found
77
+ * @example
78
+ * dividerLast("hello-world", "-") // returns "world"
79
+ * dividerLast("abc123def", 3) // returns "def"
80
+ */
51
81
  declare function dividerLast(input: string | string[], ...args: DividerSeparators): string;
52
82
 
83
+ /**
84
+ * Divides input into chunks of specified size with optional configuration.
85
+ *
86
+ * This function provides a way to split input into equal-sized chunks with additional control:
87
+ * - Can specify starting offset for the chunking
88
+ * - Can limit the maximum number of chunks produced
89
+ * - Supports both string and array inputs
90
+ * - When maxChunks is specified, remaining content is merged into the last chunk
91
+ *
92
+ * @param input - String or array of strings to divide into chunks
93
+ * @param size - Size of each chunk
94
+ * @param options - Configuration options for chunking behavior
95
+ * @param options.startOffset - Starting position for the first chunk (default: 0)
96
+ * @param options.maxChunks - Maximum number of chunks to produce (default: 0 = no limit)
97
+ * @returns Array of chunks based on input type and options
98
+ * @example
99
+ * dividerLoop("abcdef", 2) // returns ["ab", "cd", "ef"]
100
+ * dividerLoop("abcdef", 2, { maxChunks: 2 }) // returns ["ab", "cdef"]
101
+ */
53
102
  declare function dividerLoop<T extends string | string[]>(input: T, size: number, options?: DividerLoopOptions): DividerResult<T>;
54
103
 
104
+ /**
105
+ * Divides a string or array of strings by separating numbers from non-numbers.
106
+ *
107
+ * This function splits input by detecting transitions between numeric and non-numeric characters.
108
+ * For example, "abc123def" would be split into ["abc", "123", "def"].
109
+ *
110
+ * @param input - String or array of strings to divide
111
+ * @param options - Optional configuration options for the division process
112
+ * @returns Array of segments where numbers and non-numbers are separated
113
+ * @example
114
+ * dividerNumberString("abc123def") // returns ["abc", "123", "def"]
115
+ * dividerNumberString("test42") // returns ["test", "42"]
116
+ */
55
117
  declare function dividerNumberString<T extends string | string[]>(input: T, options?: DividerOptions): DividerResult<T>;
56
118
 
57
119
  export { type DividerArgs, type DividerArrayResult, type DividerExcludeMode, type DividerInput, type DividerLoopOptions, type DividerOptions, type DividerResult, type DividerSeparator, type DividerSeparators, type DividerStringResult, type NumericSeparator, type StringArrayInput, type StringInput, type StringSeparator, divider, dividerFirst, dividerLast, dividerLoop, dividerNumberString };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nyaomaru/divider",
3
3
  "type": "module",
4
- "version": "1.8.4",
4
+ "version": "1.8.5",
5
5
  "description": "To divide string or string[] with a given separator",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",