New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-nuid

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-nuid

Nuid for javascript

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
49
decreased by-64.49%
Maintainers
1
Weekly downloads
 
Created
Source

JS NUID

license Travis branch Coveralls github branch npm npm

A highly performant unique identifier generator.

Installation

Use the npm command:

$ npm install js-nuid

Basic Usage

<script src="../index.js"></script>

<script>
    n = new nuid.Nuid();
    for (let i = 0; i < 10; i++) {
        let pre = document.createElement("pre");
        let t = document.createTextNode(n.next());
        pre.appendChild(t);
        document.body.appendChild(pre);
    }
</script>

Performance

NUID needs to be very fast to generate and be truly unique, all while being entropy pool friendly. NUID uses 12 bytes of crypto generated data (entropy draining), and 10 bytes of pseudo-random sequential data that increments with a pseudo-random increment.

Total length of a NUID string is 22 bytes of base 36 ascii text, so 36^22 or 17324272922341479351919144385642496 possibilities.

Supported Browsers

The library uses crypto to generate random numbers. Current support for crypto can be found here: https://caniuse.com/#search=crypto.

If you want to target other browsers, you can shim an implementation of crypto.getRandomValues() such as the one below. However your performance and entropy will vary.

window.crypto.getRandomValues = function(array) {
    for(let i=0; i < array.length; i++) {
        array[i] = Math.floor(Math.random() * (255));
    }
};

Supported Node Versions

Our support policy for Nodejs versions follows Nodejs release support. We will support and build node-nats on even-numbered Nodejs versions that are current or in LTS.

License

Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.

Keywords

FAQs

Package last updated on 18 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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