@zenfs/core
Advanced tools
Comparing version 1.6.4 to 1.6.5
@@ -114,4 +114,5 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
const newBuffer = new Uint8Array(sz_inode); | ||
const buf = ArrayBuffer.isView(buffer) ? buffer.buffer : buffer; | ||
// Fill the new buffer with current data | ||
newBuffer.set(new Uint8Array(ArrayBuffer.isView(buffer) ? buffer.buffer : buffer)); | ||
newBuffer.set(new Uint8Array(buf)); | ||
/* Add a random ino. | ||
@@ -121,4 +122,3 @@ This will be different from the actual one, | ||
*/ | ||
const randomIno = crypto.getRandomValues(new Uint32Array(2)); | ||
newBuffer.set(randomIno, sz_inode - 2); | ||
new DataView(newBuffer.buffer).setBigUint64(sz_inode - 2, randomBigInt()); | ||
buffer = newBuffer; | ||
@@ -125,0 +125,0 @@ } |
import type * as fs from 'node:fs'; | ||
import type { ClassLike, OptionalTuple } from 'utilium'; | ||
import { type ClassLike, type OptionalTuple } from 'utilium'; | ||
import { type AbsolutePath } from './emulation/path.js'; | ||
@@ -4,0 +4,0 @@ import { ErrnoError } from './error.js'; |
@@ -0,1 +1,2 @@ | ||
import { randomHex } from 'utilium'; | ||
import { dirname, resolve } from './emulation/path.js'; | ||
@@ -221,3 +222,9 @@ import { Errno, ErrnoError } from './error.js'; | ||
export function randomBigInt() { | ||
return crypto.getRandomValues(new BigUint64Array(1))[0]; | ||
try { | ||
return crypto.getRandomValues(new BigUint64Array(1))[0]; | ||
} | ||
catch { | ||
// fallback | ||
return BigInt('0x' + randomHex(16 /* 4 bits per char */)); | ||
} | ||
} |
{ | ||
"name": "@zenfs/core", | ||
"version": "1.6.4", | ||
"version": "1.6.5", | ||
"description": "A filesystem, anywhere", | ||
@@ -5,0 +5,0 @@ "funding": { |
585943
14850