Socket
Socket
Sign inDemoInstall

nanoid

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanoid - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

5

async.js

@@ -27,4 +27,5 @@ var crypto = require('crypto')

size = size || 21
var buffer = Buffer.allocUnsafe(size)
if (callback) {
crypto.randomBytes(size, function (err, bytes) {
crypto.randomFill(buffer, 0, size, function (err, bytes) {
if (err) {

@@ -42,3 +43,3 @@ callback(err)

return new Promise(function (resolve, reject) {
crypto.randomBytes(size, function (err, bytes) {
crypto.randomFill(buffer, 0, size, function (err, bytes) {
if (err) {

@@ -45,0 +46,0 @@ reject(err)

3

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 1.2.4
* Speed up Node.js secure generators (by Dmitriy Tsvettsikh).
## 1.2.3

@@ -5,0 +8,0 @@ * Fix JSDoc (by Hendry Sadrak).

{
"name": "nanoid",
"version": "1.2.3",
"version": "1.2.4",
"description": "A tiny (145 bytes), secure URL-friendly unique string ID generator",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,1 +0,8 @@

module.exports = require('crypto').randomBytes
var crypto = require('crypto')
module.exports = function (bytes) {
var buffer = Buffer.allocUnsafe(bytes)
crypto.randomFillSync(buffer)
return buffer
}

@@ -24,3 +24,3 @@ # Nano ID

[all browsers]: http://caniuse.com/#feat=getrandomvalues
[all browsers]: http://caniuse.com/#feat=getrandomvalues
[Size Limit]: https://github.com/ai/size-limit

@@ -84,15 +84,15 @@

$ ./test/benchmark
nanoid 354,201 ops/sec
nanoid/generate 348,467 ops/sec
uid.sync 325,347 ops/sec
uuid/v4 322,328 ops/sec
shortid 33,277 ops/sec
nanoid 400,771 ops/sec
nanoid/generate 401,995 ops/sec
uid.sync 357,449 ops/sec
uuid/v4 353,771 ops/sec
shortid 33,758 ops/sec
Async:
uid 71,998 ops/sec
nanoid/async 72,836 ops/sec
nanoid/async 85,251 ops/sec
uid 76,991 ops/sec
Non-secure:
rndm 2,495,324 ops/sec
nanoid/non-secure 2,746,033 ops/sec
nanoid/non-secure 2,807,009 ops/sec
rndm 2,629,172 ops/sec
```

@@ -154,5 +154,6 @@

const nanoid = require('nanoid/async')
nanoid.then(id => {
model.id = id
})
async function createUser () {
user.id = await nanoid()
}
```

@@ -159,0 +160,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc