From c7ef1919d9898c829c5fb36e2eb612bdf0bde69f Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Fri, 29 Jul 2016 11:35:17 -0400 Subject: Initial commit --- lib/utils.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/utils.js (limited to 'lib/utils.js') diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 0000000..2c3ce8b --- /dev/null +++ b/lib/utils.js @@ -0,0 +1,20 @@ +function atoi(str) { + return parseInt(str, 10); +}; + +function chunkify(str) { + var parts = []; + var offset = 0; + var length = str.length % 3 || 3; + while (offset < str.length) { + parts.push(str.substring(offset, offset + length)); + offset += length; + length = 3; + } + return parts; +} + +module.exports = { + atoi: atoi, + chunkify: chunkify, +}; -- cgit v1.2.3