diff --git a/index.js b/index.js index eb61762..95107ab 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,12 @@ +const mathRandom = require('math-random') + function yid() { - let id = Date.now() + '-' + String(Math.random()).substr(2, 13) - while ( id.length < 27 ) + let id = Date.now() + '-' + String(mathRandom()).substr(2, 13) + + while ( id.length < 27 ) { id += '0' + } + return id } diff --git a/package.json b/package.json index aae701c..97f7c63 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,13 @@ "scripts": { "test": "node test.js" }, + "dependencies": { + "math-random": "^1.0.1" + }, + "homepage": "https://github.com/chilts/yid", + "bugs": { + "url": "https://github.com/chilts/yid/issues" + }, "repository": { "type": "git", "url": "git+https://github.com/chilts/yid.git" @@ -14,9 +21,5 @@ "id" ], "author": "Andrew Chilton", - "license": "ISC", - "bugs": { - "url": "https://github.com/chilts/yid/issues" - }, - "homepage": "https://github.com/chilts/yid#readme" + "license": "ISC" }