UNPKG

strind

Version:

Partition strings based on character indices

21 lines (20 loc) 634 B
/** * Partitions a string based on character indices. * * @param {string} str - string to partition * @param {[number,number][]} indices - array of tuples to match [start, end] indices * @param {function} callback - callback function called with matching characters */ declare function strind<T = string>(str: string, indices: TupleIndices[] | TupleIndices, callback?: (params: { chars: string; matches: boolean; }) => T): { unmatched: INonmatched[]; matched: string[] | T[]; }; declare type TupleIndices = [number, number]; interface INonmatched { chars: string; index: number; } export default strind;