@zenfs/dom 0.0.3 → 0.0.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/fetch.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  export declare const fetchIsAvailable: boolean;
3
2
  /**
4
3
  * Asynchronously download a file as a buffer or a JSON object.
@@ -7,9 +6,9 @@ export declare const fetchIsAvailable: boolean;
7
6
  * constants.
8
7
  * @hidden
9
8
  */
10
- export declare function fetchFile(p: string, type: 'buffer'): Promise<Buffer>;
9
+ export declare function fetchFile(p: string, type: 'buffer'): Promise<Uint8Array>;
11
10
  export declare function fetchFile(p: string, type: 'json'): Promise<any>;
12
- export declare function fetchFile(p: string, type: string): Promise<any>;
11
+ export declare function fetchFile(p: string, type: 'buffer' | 'json'): Promise<any>;
13
12
  /**
14
13
  * Asynchronously retrieves the size of the given file in bytes.
15
14
  * @hidden
package/dist/fetch.js CHANGED
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  /**
11
11
  * Contains utility methods for network I/O (using fetch)
12
12
  */
13
- import { Buffer } from 'buffer';
14
13
  import { ApiError, ErrorCode } from '@zenfs/core/ApiError.js';
15
14
  export const fetchIsAvailable = typeof fetch !== 'undefined' && fetch !== null;
16
15
  /**
@@ -27,11 +26,10 @@ export function fetchFile(p, type) {
27
26
  }
28
27
  switch (type) {
29
28
  case 'buffer':
30
- const buf = yield response.arrayBuffer().catch(convertError);
31
- return Buffer.from(buf);
29
+ const arrayBuffer = yield response.arrayBuffer().catch(convertError);
30
+ return new Uint8Array(arrayBuffer);
32
31
  case 'json':
33
- const json = yield response.json().catch(convertError);
34
- return json;
32
+ return response.json().catch(convertError);
35
33
  default:
36
34
  throw new ApiError(ErrorCode.EINVAL, 'Invalid download type: ' + type);
37
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/dom",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "DOM backends for ZenFS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist",
@@ -37,31 +37,20 @@
37
37
  "format": "prettier --write src",
38
38
  "format:check": "prettier --check src",
39
39
  "lint": "eslint src",
40
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest",
41
40
  "build": "node scripts/build.mjs",
42
- "build:docs": "typedoc --out docs --name ZenFS src/index.ts",
41
+ "build:docs": "typedoc --out docs --name 'ZenFS DOM' src/index.ts",
43
42
  "prepublishOnly": "npm run build"
44
43
  },
45
44
  "devDependencies": {
46
- "@jest/globals": "^29.5.0",
47
- "@types/jest": "^29.5.1",
48
- "@types/node": "^14.18.62",
49
45
  "@typescript-eslint/eslint-plugin": "^5.55.0",
50
46
  "@typescript-eslint/parser": "^5.55.0",
51
- "archiver": "~2.1.1",
52
- "buffer": "~5.1.0",
53
- "cross-env": "^7.0.3",
54
47
  "esbuild": "^0.17.18",
55
- "esbuild-plugin-polyfill-node": "^0.3.0",
56
48
  "eslint": "^8.36.0",
57
- "jest": "^29.5.0",
58
- "path": "^0.12.7",
59
49
  "prettier": "^2.8.7",
60
- "ts-jest": "^29.1.0",
61
50
  "typedoc": "^0.25.1",
62
51
  "typescript": "5.2.2"
63
52
  },
64
53
  "dependencies": {
65
- "@zenfs/core": "^0.0.8"
54
+ "@zenfs/core": "^0.0.11"
66
55
  }
67
56
  }