@zenfs/core 1.8.2 → 1.8.4

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.
package/dist/file.js CHANGED
@@ -626,7 +626,7 @@ export class LazyFile extends File {
626
626
  end = position + Math.max(this.stats.size - position, 0);
627
627
  }
628
628
  this._position = end;
629
- return end - position;
629
+ return end;
630
630
  }
631
631
  /**
632
632
  * Read data from the file.
@@ -637,12 +637,12 @@ export class LazyFile extends File {
637
637
  * If position is unset, data will be read from the current file position.
638
638
  */
639
639
  async read(buffer, offset = 0, length = buffer.byteLength - offset, position = this.position) {
640
- const bytesRead = this.prepareRead(length, position);
640
+ const end = this.prepareRead(length, position);
641
641
  const uint8 = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
642
- await this.fs.read(this.path, uint8.subarray(offset, offset + length), position, bytesRead);
642
+ await this.fs.read(this.path, uint8.subarray(offset, offset + length), position, end);
643
643
  if (config.syncImmediately)
644
644
  await this.sync();
645
- return { bytesRead, buffer };
645
+ return { bytesRead: end - position, buffer };
646
646
  }
647
647
  /**
648
648
  * Read data from the file.
@@ -654,12 +654,12 @@ export class LazyFile extends File {
654
654
  * @returns number of bytes written
655
655
  */
656
656
  readSync(buffer, offset = 0, length = buffer.byteLength - offset, position = this.position) {
657
- const bytesRead = this.prepareRead(length, position);
657
+ const end = this.prepareRead(length, position);
658
658
  const uint8 = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
659
- this.fs.readSync(this.path, uint8.subarray(offset, offset + length), position, bytesRead);
659
+ this.fs.readSync(this.path, uint8.subarray(offset, offset + length), position, end);
660
660
  if (config.syncImmediately)
661
661
  this.syncSync();
662
- return bytesRead;
662
+ return end - position;
663
663
  }
664
664
  async chmod(mode) {
665
665
  if (this.closed)
@@ -149,8 +149,8 @@ export declare abstract class FileSystem {
149
149
  existsSync(path: string): boolean;
150
150
  abstract link(target: string, link: string): Promise<void>;
151
151
  abstract linkSync(target: string, link: string): void;
152
- abstract sync(path: string, data?: Uint8Array, stats?: Partial<Readonly<StatsLike>>): Promise<void>;
153
- abstract syncSync(path: string, data?: Uint8Array, stats?: Partial<Readonly<StatsLike>>): void;
152
+ abstract sync(path: string, data?: Uint8Array, stats?: Readonly<Partial<StatsLike>>): Promise<void>;
153
+ abstract syncSync(path: string, data?: Uint8Array, stats?: Readonly<Partial<StatsLike>>): void;
154
154
  /**
155
155
  * Reads into a buffer
156
156
  * @param buffer The buffer to read into. You must set the `byteOffset` and `byteLength` appropriately!
package/dist/utils.d.ts CHANGED
@@ -73,7 +73,7 @@ export declare function normalizeOptions(options: fs.WriteFileOptions | (fs.Enco
73
73
  export type Concrete<T extends ClassLike> = Pick<T, keyof T> & (new (...args: any[]) => InstanceType<T>);
74
74
  /**
75
75
  * Generate a random ino
76
- * @internal
76
+ * @internal @deprecated @hidden
77
77
  */
78
78
  export declare function randomBigInt(): bigint;
79
79
  /**
package/dist/utils.js CHANGED
@@ -135,7 +135,7 @@ export function normalizeOptions(options, encoding = 'utf8', flag, mode = 0) {
135
135
  }
136
136
  /**
137
137
  * Generate a random ino
138
- * @internal
138
+ * @internal @deprecated @hidden
139
139
  */
140
140
  export function randomBigInt() {
141
141
  return BigInt('0x' + randomHex(8));
@@ -172,7 +172,7 @@ export function growBuffer(buffer, newByteLength) {
172
172
  const newBuffer = growBuffer(buffer.buffer, newByteLength);
173
173
  return new buffer.constructor(newBuffer, buffer.byteOffset, newByteLength);
174
174
  }
175
- const isShared = buffer instanceof SharedArrayBuffer;
175
+ const isShared = typeof SharedArrayBuffer !== 'undefined' && buffer instanceof SharedArrayBuffer;
176
176
  // Note: If true, the buffer must be resizable/growable because of the first check.
177
177
  if (buffer.maxByteLength > newByteLength) {
178
178
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",