@zenfs/core 1.6.15 → 1.6.17

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.
@@ -926,9 +926,10 @@ export async function realpath(path, options) {
926
926
  }
927
927
  realpath;
928
928
  export function watch(filename, options = {}) {
929
+ const context = this;
929
930
  return {
930
931
  [Symbol.asyncIterator]() {
931
- const watcher = new FSWatcher(this, filename.toString(), typeof options !== 'string' ? options : { encoding: options });
932
+ const watcher = new FSWatcher(context, filename.toString(), typeof options !== 'string' ? options : { encoding: options });
932
933
  // A queue to hold change events, since we need to resolve them in the async iterator
933
934
  const eventQueue = [];
934
935
  watcher.on('change', (eventType, filename) => {
@@ -252,7 +252,8 @@ export function Async(FS) {
252
252
  (_b = (_a = this._sync) === null || _a === void 0 ? void 0 : _a[`${key}Sync`]) === null || _b === void 0 ? void 0 : _b.call(_a, ...args);
253
253
  }
254
254
  catch (e) {
255
- throw new ErrnoError(e.errno, 'Out of sync! (' + e.message + ')', args[0], key);
255
+ if (e.code != 'ENOENT')
256
+ throw new ErrnoError(e.errno, 'Out of sync! (' + e.message + ')', args[0], key);
256
257
  }
257
258
  return result;
258
259
  };
package/dist/utils.js CHANGED
@@ -136,11 +136,5 @@ export function normalizeOptions(options, encoding = 'utf8', flag, mode = 0) {
136
136
  * @internal
137
137
  */
138
138
  export function randomBigInt() {
139
- try {
140
- return crypto.getRandomValues(new BigUint64Array(1))[0];
141
- }
142
- catch {
143
- // fallback
144
- return BigInt('0x' + randomHex(16 /* 4 bits per char */));
145
- }
139
+ return BigInt('0x' + randomHex(8));
146
140
  }
package/eslint.shared.js CHANGED
@@ -40,9 +40,9 @@ export default [
40
40
  '@typescript-eslint/no-unsafe-member-access': 'off',
41
41
  '@typescript-eslint/no-unsafe-argument': 'off',
42
42
  '@typescript-eslint/no-unsafe-assignment': 'off',
43
- '@typescript-eslint/no-unsafe-return': 'warn',
43
+ '@typescript-eslint/no-unsafe-return': 'off',
44
44
  '@typescript-eslint/no-redundant-type-constituents': 'warn',
45
- '@typescript-eslint/no-unsafe-call': 'warn',
45
+ '@typescript-eslint/no-unsafe-call': 'off',
46
46
  '@typescript-eslint/restrict-plus-operands': 'off',
47
47
  '@typescript-eslint/no-base-to-string': 'off',
48
48
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.6.15",
3
+ "version": "1.6.17",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -48,6 +48,10 @@
48
48
  "./eslint": "./eslint.shared.js",
49
49
  "./tests/*": "./tests/*"
50
50
  },
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "provenance": true
54
+ },
51
55
  "scripts": {
52
56
  "format": "prettier --write .",
53
57
  "format:check": "prettier --check .",
@@ -16,4 +16,21 @@ suite('Context', () => {
16
16
  test('break-out fails', () => {
17
17
  assert.deepEqual(c_fs.readdirSync('/../../'), ['example.txt']);
18
18
  });
19
+
20
+ test('watch should consider context', async () => {
21
+ let lastFile: string,
22
+ events = 0;
23
+ const watcher = c_fs.promises.watch('/', { recursive: true });
24
+
25
+ (async () => {
26
+ for await (const event of watcher) {
27
+ lastFile = event.filename!;
28
+ if (++events == 2) return;
29
+ }
30
+ })();
31
+ await c_fs.promises.writeFile('/xpto.txt', 'in real root');
32
+ assert.strictEqual(lastFile!, 'xpto.txt');
33
+ await c_fs.promises.unlink('/xpto.txt');
34
+ assert.strictEqual(lastFile, 'xpto.txt');
35
+ });
19
36
  });