Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nanoid

Package Overview
Dependencies
Maintainers
1
Versions
103
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 5.0.8 to 5.0.9

8

index.browser.js

@@ -11,6 +11,6 @@ import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'

let bytes = getRandom(step)
let j = step
let j = step | 0
while (j--) {
id += alphabet[bytes[j] & mask] || ''
if (id.length === size) return id
if (id.length >= size) return id
}

@@ -21,6 +21,6 @@ }

export let customAlphabet = (alphabet, size = 21) =>
customRandom(alphabet, size, random)
customRandom(alphabet, size | 0, random)
export let nanoid = (size = 21) => {
let id = ''
let bytes = crypto.getRandomValues(new Uint8Array(size))
let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
while (size--) {

@@ -27,0 +27,0 @@ id += scopedUrlAlphabet[bytes[size] & 63]

@@ -18,3 +18,3 @@ import { webcrypto as crypto } from 'node:crypto'

export function random(bytes) {
fillPool((bytes -= 0))
fillPool((bytes |= 0))
return pool.subarray(poolOffset - bytes, poolOffset)

@@ -32,3 +32,3 @@ }

id += alphabet[bytes[i] & mask] || ''
if (id.length === size) return id
if (id.length >= size) return id
}

@@ -42,3 +42,3 @@ }

export function nanoid(size = 21) {
fillPool((size -= 0))
fillPool((size |= 0))
let id = ''

@@ -45,0 +45,0 @@ for (let i = poolOffset - size; i < poolOffset; i++) {

@@ -6,3 +6,3 @@ let urlAlphabet =

let id = ''
let i = size
let i = size | 0
while (i--) {

@@ -16,3 +16,3 @@ id += alphabet[(Math.random() * alphabet.length) | 0]

let id = ''
let i = size
let i = size | 0
while (i--) {

@@ -19,0 +19,0 @@ id += urlAlphabet[(Math.random() * 64) | 0]

{
"name": "nanoid",
"version": "5.0.8",
"description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
"version": "5.0.9",
"description": "A tiny (118 bytes), secure URL-friendly unique string ID generator",
"keywords": [

@@ -6,0 +6,0 @@ "uuid",

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

* **Small.** 116 bytes (minified and brotlied). No dependencies.
* **Small.** 118 bytes (minified and brotlied). No dependencies.
[Size Limit] controls the size.

@@ -16,0 +16,0 @@ * **Safe.** It uses hardware random generator. Can be used in clusters.

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