Comparing version 1.0.0 to 1.1.0
28
index.js
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | ||
var length = chars.length | ||
var assert = require('assert') | ||
module.exports = function rndm(len) { | ||
var salt = '' | ||
for (var i = 0; i < len; i++) | ||
salt += chars[Math.floor(length * Math.random())] | ||
return salt | ||
var base62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | ||
var base36 = 'abcdefghijklmnopqrstuvwxyz0123456789' | ||
var base10 = '0123456789' | ||
exports = module.exports = create(base62) | ||
exports.base62 = exports | ||
exports.base36 = create(base36) | ||
exports.base10 = create(base10) | ||
exports.create = create | ||
function create(chars) { | ||
assert(typeof chars === 'string') | ||
var length = Buffer.byteLength(chars) | ||
return function rndm(len) { | ||
assert(typeof len === 'number' && len >= 0) | ||
var salt = '' | ||
for (var i = 0; i < len; i++) salt += chars[Math.floor(length * Math.random())] | ||
return salt | ||
} | ||
} |
{ | ||
"name": "rndm", | ||
"description": "random string generator", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -12,3 +12,22 @@ "name": "Jonathan Ong", | ||
"license": "MIT", | ||
"repository": "jonathanong/rndm" | ||
"devDependencies": { | ||
"mocha": "2", | ||
"istanbul": "0" | ||
}, | ||
"repository": "crypto-utils/rndm", | ||
"scripts": { | ||
"test": "mocha", | ||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", | ||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" | ||
}, | ||
"keywords": [ | ||
"random", | ||
"number", | ||
"generator", | ||
"uid", | ||
"id" | ||
], | ||
"files": [ | ||
"index.js" | ||
] | ||
} |
@@ -12,5 +12,17 @@ | ||
```js | ||
import rndm from 'rndm@1' | ||
// base62 by default | ||
var rndm = require('rndm') | ||
var salt = rndm(16) | ||
``` | ||
### var salt = rndm(length) | ||
### var salt = rndm.base62(length) | ||
### var salt = rndm.base36(length) | ||
### var salt = rndm.base10(length) | ||
### var random = rndm.create(characters) | ||
Create a new random generator with custom characters. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3003
19
28
0
2
4