UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

32 lines (31 loc) 1.2 kB
import { type AtLeastTuple } from '@augment-vir/core'; /** * Same as * * [`''.split`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/split) * but includes the split delimiter in the output array. * * @category String * @category Package : @augment-vir/common * @example * * ```ts * import {splitIncludeSplit} from '@augment-vir/common'; * * splitIncludeSplit('1,2,3', ',', {caseSensitive: false}); // outputs `['1', ',', '2', ',', '3']` * ``` * * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function splitIncludeSplit(original: string, splitDelimiter: string | RegExp, { caseSensitive }: { caseSensitive: boolean; }): readonly string[]; /** * Same as * [`''.split`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/split) * but typed better: it always returns an array with at least one string. * * @category String * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function safeSplit(input: string, splitString: string): AtLeastTuple<string, 1>;