@zenfs/core 1.4.3 → 1.5.1

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/context.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- import { type ExtractProperties } from 'utilium';
2
1
  import { type CredentialInit, type Credentials } from './credentials.js';
3
2
  import * as fs from './emulation/index.js';
4
- type Fn_FS = Omit<ExtractProperties<typeof fs, (...args: any[]) => any>, 'mountObject'>;
5
- type Fn_Promises = ExtractProperties<typeof fs.promises, (...args: any[]) => any>;
6
3
  /**
7
4
  * Represents some context used for FS operations
8
5
  * @experimental
@@ -20,8 +17,8 @@ export type V_Context = void | (Partial<FSContext> & object);
20
17
  * Allows you to restrict operations to a specific root path and set of credentials.
21
18
  * @experimental
22
19
  */
23
- export interface BoundContext extends Fn_FS, FSContext {
24
- promises: Fn_Promises;
20
+ export interface BoundContext extends FSContext {
21
+ fs: typeof fs;
25
22
  }
26
23
  /**
27
24
  * Allows you to restrict operations to a specific root path and set of credentials.
@@ -29,4 +26,3 @@ export interface BoundContext extends Fn_FS, FSContext {
29
26
  * @experimental
30
27
  */
31
28
  export declare function bindContext(root: string, credentials?: CredentialInit): BoundContext;
32
- export {};
package/dist/context.js CHANGED
@@ -19,5 +19,5 @@ export function bindContext(root, credentials = structuredClone(defaultCredentia
19
19
  };
20
20
  const fn_fs = _bindFunctions(fs, ctx);
21
21
  const fn_promises = _bindFunctions(fs.promises, ctx);
22
- return { ...ctx, ...fn_fs, promises: fn_promises };
22
+ return { ...ctx, fs: { ...fs, ...fn_fs, promises: { ...fs.promises, ...fn_promises } } };
23
23
  }
@@ -19,7 +19,7 @@ export declare class Dirent implements _Dirent {
19
19
  /**
20
20
  * A class representing a directory stream.
21
21
  */
22
- export declare class Dir implements _Dir {
22
+ export declare class Dir implements _Dir, AsyncIterator<Dirent> {
23
23
  readonly path: string;
24
24
  protected readonly context: V_Context;
25
25
  protected closed: boolean;
@@ -55,5 +55,6 @@ export declare class Dir implements _Dir {
55
55
  /**
56
56
  * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
57
57
  */
58
- [Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
58
+ [Symbol.asyncIterator](): this;
59
+ [Symbol.asyncDispose](): Promise<void>;
59
60
  }
@@ -102,4 +102,7 @@ export class Dir {
102
102
  [Symbol.asyncIterator]() {
103
103
  return this;
104
104
  }
105
+ [Symbol.asyncDispose]() {
106
+ return Promise.resolve();
107
+ }
105
108
  }
@@ -3,6 +3,7 @@ import { Readable, Writable } from 'readable-stream';
3
3
  import type { Callback } from '../utils.js';
4
4
  export declare class ReadStream extends Readable implements Node.ReadStream {
5
5
  close(callback?: Callback): void;
6
+ wrap(oldStream: NodeJS.ReadableStream): this;
6
7
  bytesRead: number;
7
8
  path: string | Buffer;
8
9
  pending: boolean;
@@ -11,6 +11,10 @@ export class ReadStream extends Readable {
11
11
  callback(new ErrnoError(Errno.EIO, err.toString()));
12
12
  }
13
13
  }
14
+ wrap(oldStream) {
15
+ super.wrap(oldStream);
16
+ return this;
17
+ }
14
18
  }
15
19
  export class WriteStream extends Writable {
16
20
  close(callback = () => null) {
package/dist/file.d.ts CHANGED
@@ -21,14 +21,14 @@ export declare abstract class File<FS extends FileSystem = FileSystem> {
21
21
  * @internal
22
22
  * The file system that created the file
23
23
  */
24
- fs: FileSystem;
24
+ fs: FS;
25
25
  readonly path: string;
26
26
  constructor(
27
27
  /**
28
28
  * @internal
29
29
  * The file system that created the file
30
30
  */
31
- fs: FileSystem, path: string);
31
+ fs: FS, path: string);
32
32
  /**
33
33
  * Get the current file position.
34
34
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.4.3",
3
+ "version": "1.5.1",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -21,7 +21,6 @@
21
21
  "dist",
22
22
  "tests",
23
23
  "license.md",
24
- "tsconfig.json",
25
24
  "eslint.shared.js"
26
25
  ],
27
26
  "type": "module",
@@ -87,7 +86,6 @@
87
86
  "prettier": "^3.2.5",
88
87
  "tsx": "^4.19.1",
89
88
  "typedoc": "^0.27.1",
90
- "typedoc-plugin-remove-references": "^0.0.6",
91
89
  "typescript": "^5.7.2",
92
90
  "typescript-eslint": "^8.16.0"
93
91
  }
package/readme.md CHANGED
@@ -162,7 +162,7 @@ await configure({
162
162
 
163
163
  fs.writeFileSync('/dev/null', 'Some data to be discarded');
164
164
 
165
- const randomData = new Unit8Array(100);
165
+ const randomData = new Uint8Array(100);
166
166
 
167
167
  const random = fs.openSync('/dev/random', 'r');
168
168
  fs.readSync(random, randomData);
@@ -4,7 +4,7 @@ import { bindContext } from '../../dist/context.js';
4
4
  import * as fs from '../../dist/emulation/index.js';
5
5
 
6
6
  fs.mkdirSync('/new_root');
7
- const c_fs = bindContext('/new_root');
7
+ const { fs: c_fs } = bindContext('/new_root');
8
8
 
9
9
  suite('Context', () => {
10
10
  test('create a file', () => {
@@ -4,6 +4,6 @@ import { copy, data } from '../setup.js';
4
4
 
5
5
  _fs.mkdirSync('/new_root');
6
6
 
7
- export const fs = bindContext('/new_root');
7
+ export const { fs } = bindContext('/new_root');
8
8
 
9
9
  copy(data, fs);
package/tests/setup.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { join, relative } from 'node:path';
2
2
  import { statSync, readFileSync, readdirSync, existsSync, mkdirSync } from 'node:fs';
3
3
  import { fs as _fs } from '../dist/index.js';
4
- import type { BoundContext } from '../dist/context.js';
5
4
 
6
5
  export const data = join(import.meta.dirname, 'data');
7
6
 
@@ -11,7 +10,7 @@ if (!existsSync(tmp)) {
11
10
  mkdirSync(tmp);
12
11
  }
13
12
 
14
- export function copy(_path: string, fs: typeof _fs | BoundContext = _fs) {
13
+ export function copy(_path: string, fs: typeof _fs = _fs) {
15
14
  const path = relative(data, _path) || '/';
16
15
  const stats = statSync(_path);
17
16
 
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "NodeNext",
4
- "target": "ES2020",
5
- "outDir": "dist",
6
- "lib": ["ESNext", "ESNext.Disposable"],
7
- "moduleResolution": "NodeNext",
8
- "declaration": true,
9
- "strict": true
10
- },
11
- "include": ["src/**/*.ts"],
12
- "exclude": ["node_modules"],
13
- "typedocOptions": {
14
- "entryPoints": ["./src/index.ts"],
15
- "out": "docs",
16
- "name": "ZenFS",
17
- "plugin": ["typedoc-plugin-remove-references"]
18
- }
19
- }