es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
37 lines • 1.16 kB
text/typescript
//#region src/compat/string/split.d.ts
/**
* Splits the input string by the specified `separator`
* and returns a new array containing the split segments.
*
* @param [string=''] The string to split.
* @param [separator] The separator pattern to split by.
* @param [limit] The length to truncate results to.
* @returns Returns the string segments.
*
* @example
* split('a-b-c', '-');
* // => ['a', 'b', 'c']
*
* split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
declare function split(string: string | null | undefined, separator?: RegExp | string, limit?: number): string[];
/**
* Splits the input string by the specified `separator`
* and returns a new array containing the split segments.
*
* @param [string=''] The string to split.
* @param [separator] The separator pattern to split by.
* @param [limit] The length to truncate results to.
* @returns Returns the string segments.
*
* @example
* split('a-b-c', '-');
* // => ['a', 'b', 'c']
*
* split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
declare function split(string: string | null | undefined, index: string | number, guard: object): string[];
//#endregion
export { split };