vanillajs-helpers

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS

View the Project on GitHub Tokimon/vanillajs-helpers

vanillajs-helpers > “chunkString”

External module: “chunkString”

Index

Functions


Functions

chunkString

chunkString(str: string, size?: number): string[]

Defined in chunkString.ts:13

Split a String up into smaller strings of a give size (eg. ‘ABCDEF’ -> [AB,CD,EF])

chunkString('abcdefghijkl'); // -> ['ab', 'cd', 'ef', 'gh', 'ij', 'kl']
chunkString('abcdefghijkl', 4); // -> ['abcd', 'efgh', 'ijkl']

Parameters:

Param Type Default value Description
str string - String to split up
size number 2 Size par chunk

Returns: string[]