MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / chunkify

Function chunkify

Hashes/SHA1.js:39–45  ·  view source on GitHub ↗

* Separates string into chunks of the same size * * @param {string} str - string to separate into chunks * @param {int} size - number of characters wanted in each chunk * @return {array} - array of original string split into chunks * * @example * chunkify("this is a test", 2)

(str, size)

Source from the content-addressed store, hash-verified

37 * chunkify("this is a test", 2)
38 */
39function chunkify(str, size) {
40 const chunks = []
41 for (let i = 0; i < str.length; i += size) {
42 chunks.push(str.slice(i, i + size))
43 }
44 return chunks
45}
46
47/**
48 * Rotates string representation of bits to the left

Callers 1

SHA1Function · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected