Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1x | const splitByIndex = ( value: string, index: number, format: "space" | "dash" = "space" ): string => { const formatString = format === "space" ? " " : "-"; if (value.length < index) return value; return [value.substring(0, index)] .concat(splitByIndex(value.substring(index), index, format)) .filter((chunk) => chunk) .join(formatString); }; export default splitByIndex; |