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 2.1.4 to 2.1.5

14

async/format.js

@@ -32,13 +32,13 @@ /**

module.exports = function (random, alphabet, size) {
var mask = (2 << 31 - Math.clz32((alphabet.length - 1) | 1)) - 1
var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1
var step = Math.ceil(1.6 * mask * size / alphabet.length)
size = +size
function tick (id) {
return random(step).then(function (bytes) {
for (var i = step; i--;) {
var byte = bytes[i] & mask
if (alphabet[byte]) {
id += alphabet[byte]
if (id.length === size) return id
var i = step
while (i--) {
var alpha = alphabet[bytes[i] & mask]
if (alpha) {
id += alpha
if (id.length === +size) return id
}

@@ -45,0 +45,0 @@ }

# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.1.5
* Reduce size (by Max Graey).
* Fix IE support.
## 2.1.4

@@ -5,0 +9,0 @@ * Reduce `generate` size (by Vsevolod Rodionov).

@@ -30,15 +30,14 @@ /**

module.exports = function (random, alphabet, size) {
var mask = (2 << 31 - Math.clz32((alphabet.length - 1) | 1)) - 1
var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1
var step = Math.ceil(1.6 * mask * size / alphabet.length)
var id = ''
size = +size
while (true) {
var bytes = random(step)
for (var i = step; i--;) {
var byte = bytes[i] & mask
var alpha = alphabet[byte]
var i = step
var bytes = random(i)
while (i--) {
var alpha = alphabet[bytes[i] & mask]
if (alpha) {
id += alpha
if (id.length === size) return id
if (id.length === +size) return id
}

@@ -45,0 +44,0 @@ }

{
"name": "nanoid",
"version": "2.1.4",
"version": "2.1.5",
"description": "A tiny (139 bytes), secure URL-friendly unique string ID generator",

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

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

```js
var nanoid = require('nanoid')
const nanoid = require('nanoid')
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"

@@ -165,2 +165,5 @@ ```

You can also use [custom alphabet](#custom-alphabet-or-length)
or [random generator](#custom-random-bytes-generator).
[ID collision probability]: https://zelark.github.io/nano-id-cc/

@@ -253,3 +256,3 @@

const nanoid = require('nanoid/non-secure')
model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
```

@@ -256,0 +259,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