diff options
Diffstat (limited to 'lib/utils.js')
-rw-r--r-- | lib/utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
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, +}; |