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

kuuid

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

kuuid - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

20

index.js

@@ -50,2 +50,13 @@ // standard Node.js crypto library

// calculate an 8-digit prefix for the timestamp 't'
// that is base62 encoded and sorts in reverse time order
// but with milliseconds
const prefixReverseMs = function (t) {
// get time stamp for now
const timestamp = maxTS - tsms(t)
// turn timestamp into 8-digit, base-62 encoded string
return base62Encode(timestamp).padStart(8, '0')
}
const rand = function (n) {

@@ -80,2 +91,7 @@ if (!n) {

// generate a kuuid (reverse mode)
const idmsr = function (t) {
return prefixReverseMs(t) + rand()
}
// generate short id

@@ -97,6 +113,8 @@ const ids = function (t) {

idms,
idmsr,
rand,
prefix,
prefixms,
prefixReverse
prefixReverse,
prefixReverseMs
}

2

package.json
{
"name": "kuuid",
"version": "0.6.1",
"version": "0.6.2",
"description": "K-sortable UUID - roughly time-sortable unique id generator",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -83,5 +83,11 @@ # kuuid

kuuid.idms()
// 0RW2yGC21miE8r3oeOun2pGeIp0EoQNu
// 0T6vppV82RX4Nx1ZzGqB0Exjjs4fkuhh
```
```js
// 'now' reverse
kuuid.idmsr()
// zWt4A9Wz3TxK0h4MRkec06xADk3kIemn
```
## Short ids

@@ -128,2 +134,8 @@

or for a millisecond-precision reversed version:
```js
kuuid.prefixReverseMs()
```
## How does it work?

@@ -130,0 +142,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