/** * Splits a string by a given character (see {@link defaultJoinChar}). A backslash escapes * the split character's first character or another backslash; escaped characters don't * apply to the split, and the escaping backslash is removed. Other backslashes are preserved * (e.g. `C:\path`). Inverse of {@link joinWith} for non-empty split characters. * * When the split character starts with a backslash, the escape character is `/` instead. * * With an empty split character, the string is split into individual characters. Since * {@link joinWith} concatenates elements in that case, original boundaries can't be recovered. * * @example * splitBy('this\\,\\,that,,the other,,,\\,') * // or * splitBy('this\\,\\,that,,the other,,,\\,', ',') * // would return * ['this,,that', '', 'the other', '', '', ','] */ export declare const splitBy: (str?: string, splitChar?: string) => string[]; /** * Joins an array of strings using the given character (see {@link defaultJoinChar}). When * the given character appears in an array element, a backslash will be added just before it * to distinguish it from the join character. Effectively the inverse of {@link splitBy}. * * TIP: The join character can actually be a string of any length. Only the first character * will be searched for in the array elements and preceded by a backslash (or `/` when the * join character starts with a backslash). * * @example * joinWith(['this,,that', '', 'the other', '', '', ','], ', ') * // would return * 'this\\,\\,that, , the other, , , \\,' */ export declare const joinWith: (strArr: unknown[], joinChar?: string) => string; type IsUnknown = unknown extends T ? true : false; type Trimmed = IsUnknown extends true ? string : T; /** * Trims the value if it is a string. Otherwise returns the value as is. */ export declare const trimIfString: (val: T) => Trimmed; type ToArrayResult = IsUnknown extends true ? string[] : T extends readonly (infer U)[] ? Trimmed[] : T extends string ? string[] : T extends number ? number[] : never[]; /** * Splits a string by comma (or `splitChar`) then trims each element. Arrays are returned * as is except any string elements are trimmed. */ export declare const toArray: (a: T, { retainEmptyStrings, splitChar }?: { retainEmptyStrings?: boolean; splitChar?: string; }) => ToArrayResult; /** * Determines if an array is free of `null`/`undefined`. */ export declare const nullFreeArray: (arr: T[]) => arr is Exclude[]; export {};