Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit daad0fc

Browse files
committed
accept undefined for split
1 parent dc36dbb commit daad0fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/packages/core/utils/string/split-string-to-array.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Splits a string into an array using a specified delimiter,
33
* trims whitespace from each element, and removes empty elements.
44
*
5-
* @param {string} string - The input string to be split and processed.
5+
* @param {string | undefined} string - The input string to be split and processed.
66
* @param {string} [split=','] - The delimiter used for splitting the string (default is comma).
7-
* @returns {string[]} An array of non-empty, trimmed strings.
7+
* @returns {Array<string>} An array of non-empty, trimmed strings.
88
*
99
* @example
1010
* const result = splitStringToArray('one, two, three, ,five');
@@ -14,7 +14,7 @@
1414
* const customDelimiterResult = splitStringToArray('apple | orange | banana', ' | ');
1515
* // customDelimiterResult: ['apple', 'orange', 'banana']
1616
*/
17-
export function splitStringToArray(string: string, split: string = ','): string[] {
17+
export function splitStringToArray(string: string | undefined, split: string = ','): string[] {
1818
if (!string) return [];
1919
return (
2020
string

0 commit comments

Comments
 (0)