toastflow-core 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/util.ts +6 -6
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "url": "https://github.com/adrianjanocko/toastflow.git",
9
9
  "directory": "packages/core"
10
10
  },
11
- "version": "1.0.8",
11
+ "version": "1.0.9",
12
12
  "main": "src/index.ts",
13
13
  "module": "src/index.ts",
14
14
  "types": "src/index.ts",
package/src/util.ts CHANGED
@@ -3,21 +3,21 @@
3
3
  * to the classic template with random nibbles (uses `crypto.getRandomValues` when possible).
4
4
  */
5
5
  export function generateUuid(): string {
6
- const cryptoSource: Crypto | undefined =
7
- typeof crypto !== "undefined" ? (crypto as Crypto) : undefined;
6
+ const cryptoSource = typeof crypto !== "undefined" ? crypto : undefined;
8
7
 
9
8
  if (typeof cryptoSource?.randomUUID === "function") {
10
9
  try {
11
10
  return cryptoSource.randomUUID();
12
- } catch {
13
- // ignore and use fallback
14
- }
11
+ } catch {}
15
12
  }
16
13
 
17
14
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
18
15
  let rand: number;
19
16
 
20
- if (cryptoSource?.getRandomValues) {
17
+ if (
18
+ cryptoSource !== undefined &&
19
+ cryptoSource.getRandomValues !== undefined
20
+ ) {
21
21
  const buffer = new Uint8Array(1);
22
22
  cryptoSource.getRandomValues(buffer);
23
23
  rand = buffer[0] & 0xf;