aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.js
diff options
context:
space:
mode:
authorBen Burwell <ben.burwell@trifecta.com>2016-07-29 11:35:17 -0400
committerBen Burwell <ben.burwell@trifecta.com>2016-07-29 11:35:17 -0400
commitc7ef1919d9898c829c5fb36e2eb612bdf0bde69f (patch)
tree882b794f6e2164fa9ffb940a74d4252ca6454517 /lib/utils.js
Initial commit
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js20
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,
+};