Skip to content

Instantly share code, notes, and snippets.

@valentineus
Created April 22, 2020 09:43
Show Gist options
  • Save valentineus/35017bb810a5f7075426524c85d8e7bf to your computer and use it in GitHub Desktop.
Save valentineus/35017bb810a5f7075426524c85d8e7bf to your computer and use it in GitHub Desktop.
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