Skip to content

Commit f3bef9b

Browse files
committed
Updates
1 parent 265d245 commit f3bef9b

File tree

4 files changed

+58
-17
lines changed

4 files changed

+58
-17
lines changed

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
"description": "uniform interface for accessing binary data from local files, remote HTTP resources, and browser Blob data",
44
"version": "2.0.3",
55
"type": "module",
6+
"module": "./esm/index.js",
67
"main": "./esm/index.js",
7-
"exports": {
8-
".": {
9-
"import": "./esm/index.js",
10-
"require": "./dist/index.js"
11-
},
12-
"./localFile.js": {
13-
"import": "./esm/localFile.js",
14-
"require": "./dist/localFile.js",
15-
"browser": null
16-
}
17-
},
8+
"exports": "./esm/index.js",
189
"repository": "GMOD/generic-filehandle2",
1910
"license": "MIT",
2011
"author": {
@@ -26,16 +17,20 @@
2617
"node": ">=14"
2718
},
2819
"files": [
20+
"dist",
2921
"esm",
3022
"src"
3123
],
3224
"scripts": {
3325
"test": "vitest",
3426
"coverage": "yarn test --coverage",
3527
"lint": "eslint --report-unused-disable-directives --max-warnings 0 src test",
36-
"clean": "rimraf esm",
28+
"clean": "rimraf dist esm",
3729
"prebuild": "yarn clean",
38-
"build": "tsc --outDir esm",
30+
"build:esm": "tsc --outDir esm",
31+
"build:es5": "tsc --module commonjs --outDir dist",
32+
"build": "yarn build:esm && yarn build:es5",
33+
"postbuild:es5": "echo '{\"type\": \"commonjs\"}' > dist/package.json",
3934
"preversion": "yarn lint && yarn test --run && yarn build",
4035
"postversion": "git push --follow-tags"
4136
},
@@ -63,5 +58,11 @@
6358
},
6459
"publishConfig": {
6560
"access": "public"
61+
},
62+
"browser": {
63+
"./dist/localFile.js": false,
64+
"./esm/localFile.js": false,
65+
"fs": false,
66+
"fs/promises": false
6667
}
6768
}

src/mockLocalFile.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { FilehandleOptions, GenericFilehandle, Stats } from './filehandle'
2+
3+
export default class LocalFile implements GenericFilehandle {
4+
public constructor(_source: string, _opts: FilehandleOptions = {}) {
5+
throw new Error('unimplemented')
6+
}
7+
8+
read(): Promise<Uint8Array<ArrayBuffer>> {
9+
throw new Error('unimplemented')
10+
}
11+
12+
public async readFile(): Promise<Uint8Array<ArrayBuffer>>
13+
public async readFile(options: BufferEncoding): Promise<string>
14+
public async readFile<T extends undefined>(
15+
options:
16+
| Omit<FilehandleOptions, 'encoding'>
17+
| (Omit<FilehandleOptions, 'encoding'> & { encoding: T }),
18+
): Promise<Uint8Array<ArrayBuffer>>
19+
public async readFile<T extends BufferEncoding>(
20+
options: Omit<FilehandleOptions, 'encoding'> & { encoding: T },
21+
): Promise<string>
22+
readFile<T extends BufferEncoding>(
23+
options: Omit<FilehandleOptions, 'encoding'> & { encoding: T },
24+
): T extends BufferEncoding
25+
? Promise<Uint8Array<ArrayBuffer>>
26+
: Promise<Uint8Array<ArrayBuffer> | string>
27+
public async readFile(
28+
_options: FilehandleOptions | BufferEncoding = {},
29+
): Promise<Uint8Array<ArrayBuffer> | string> {
30+
throw new Error('unimplemented')
31+
}
32+
33+
stat(): Promise<Stats> {
34+
throw new Error('unimplemented')
35+
}
36+
37+
close(): Promise<void> {
38+
throw new Error('unimplemented')
39+
}
40+
}

test/remoteFile.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TextDecoder } from 'util'
22

33
import rangeParser from 'range-parser'
4-
import { beforeEach, afterEach, expect, test, vi } from 'vitest'
4+
import { afterEach, beforeEach, expect, test, vi } from 'vitest'
55

66
import { LocalFile, RemoteFile } from '../src/'
77

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,9 +2825,9 @@ tinyexec@^0.3.2:
28252825
integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==
28262826

28272827
tinyglobby@^0.2.13:
2828-
version "0.2.13"
2829-
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.13.tgz#a0e46515ce6cbcd65331537e57484af5a7b2ff7e"
2830-
integrity sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==
2828+
version "0.2.14"
2829+
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.14.tgz#5280b0cf3f972b050e74ae88406c0a6a58f4079d"
2830+
integrity sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==
28312831
dependencies:
28322832
fdir "^6.4.4"
28332833
picomatch "^4.0.2"

0 commit comments

Comments
 (0)