Created
April 22, 2020 09:43
-
-
Save valentineus/35017bb810a5f7075426524c85d8e7bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type SplitString = (value: string, length: number) => string[]; | |
export const splitString: SplitString = (value: string, length: number): string[] => { | |
const chunks: string[] = []; | |
for (let index: number = 0; index < value.length; index += length) { | |
const chunk: string = value.slice(index, index + length); | |
chunks.push(chunk); | |
} | |
return chunks; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment