Comparing version 0.2.0 to 0.3.0
@@ -55,11 +55,14 @@ "use strict"; | ||
var rootLookup = root || detectRoot(); | ||
var webCrypto = (rootLookup && (rootLookup.crypto || rootLookup.msCrypto)) || | ||
var globalCrypto = (rootLookup && (rootLookup.crypto || rootLookup.msCrypto)) || | ||
(typeof crypto !== "undefined" ? crypto : null); | ||
if (webCrypto) { | ||
if (typeof (globalCrypto === null || globalCrypto === void 0 ? void 0 : globalCrypto.getRandomValues) === "function") { | ||
return function () { | ||
var buffer = new Uint8Array(1); | ||
webCrypto.getRandomValues(buffer); | ||
globalCrypto.getRandomValues(buffer); | ||
return buffer[0] / 0xff; | ||
}; | ||
} | ||
else if (typeof (globalCrypto === null || globalCrypto === void 0 ? void 0 : globalCrypto.randomBytes) === "function") { | ||
return function () { return globalCrypto.randomBytes(1).readUInt8() / 0xff; }; | ||
} | ||
else { | ||
@@ -83,2 +86,5 @@ try { | ||
} | ||
if (typeof global !== "undefined") { | ||
return global; | ||
} | ||
return null; | ||
@@ -85,0 +91,0 @@ } |
{ | ||
"name": "ulidx", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "ULID generator for NodeJS and the browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# ulidx | ||
> ULID generator for NodeJS and the browser | ||
[](https://www.npmjs.com/package/ulidx) | ||
[](https://www.npmjs.com/package/ulidx)  | ||
@@ -78,5 +78,8 @@ ULID generator library, based off of the original [ulid](https://github.com/ulid/javascript) for NodeJS and the browser. ULIDs are Universally Unique Lexicographically Sortable Identifiers. This library adheres to [this specification](https://github.com/ulid/spec). | ||
* NodeJS 10 and up | ||
* Node REPL | ||
* Browsers with working `crypto` / `msCrypto` libraries | ||
* Web workers | ||
`ulidx` is _not_ compatible with Cloudflare Workers due to their [problematic stance on getting the current time](https://developers.cloudflare.com/workers/learning/security-model#step-1-disallow-timers-and-multi-threading). | ||
### Web | ||
@@ -83,0 +86,0 @@ |
14935
227
91
9