Skip to content

split() function

Splits string by separator.

Signature:

typescript
declare function split(sep: string, iterable: Iterable<string>): IterableIterator<string>;

Example

ts
const iter = split(',', '1,2,3,4');
iter.next(); // 1
iter.next(); // 2
iter.next(); // 3
iter.next(); // 4
iter.next(); // undefined

// with pipe
pipe(
 "1,2,3,4,5",
 split(','),
 toArray,
); // ["1", "2", "3", "4", "5"]

see pipe, toArray

Open Source Code

Released under the Apache-2.0 License.