Skip to content

Commit 35c2753

Browse files
committed
ESM 2
1 parent c12f50b commit 35c2753

File tree

4 files changed

+339
-780
lines changed

4 files changed

+339
-780
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export default tseslint.config(
5656
'unicorn/prefer-modern-math-apis': 'off',
5757
'unicorn/prefer-node-protocol': 'off',
5858
'unicorn/no-unreadable-array-destructuring': 'off',
59+
'unicorn/text-encoding-identifier-case': 'off',
5960
'unicorn/no-abusive-eslint-disable': 'off',
6061
'unicorn/no-array-callback-reference': 'off',
6162
'unicorn/number-literal-case': 'off',

package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "generic-filehandle2",
33
"description": "uniform interface for accessing binary data from local files, remote HTTP resources, and browser Blob data",
44
"version": "2.0.5",
5-
"main": "dist/index.js",
6-
"module": "esm/index.js",
5+
"type": "module",
6+
"module": "./esm/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
"import": {
10+
"import": "./esm/index.js"
11+
},
12+
"require": {
13+
"require": "./dist/index.js"
14+
}
15+
},
716
"repository": "GMOD/generic-filehandle2",
817
"license": "MIT",
918
"author": {
@@ -12,7 +21,7 @@
1221
"url": "https://github.com/cmdcolin"
1322
},
1423
"engines": {
15-
"node": ">=12"
24+
"node": ">=14"
1625
},
1726
"files": [
1827
"dist",
@@ -45,10 +54,11 @@
4554
"eslint": "^9.16.0",
4655
"eslint-plugin-import": "^2.31.0",
4756
"eslint-plugin-unicorn": "^59.0.0",
57+
"node-fetch": "^2.0.0",
4858
"prettier": "^3.4.1",
4959
"range-parser": "^1.2.1",
5060
"rimraf": "^6.0.0",
51-
"standard-changelog": "^6.0.0",
61+
"standard-changelog": "^7.0.1",
5262
"typescript": "^5.7.0",
5363
"typescript-eslint": "^8.18.0",
5464
"vitest": "^3.0.1"
@@ -58,6 +68,8 @@
5868
},
5969
"browser": {
6070
"./dist/localFile.js": false,
61-
"./esm/localFile.js": false
71+
"./esm/localFile.js": false,
72+
"fs": false,
73+
"fs/promises": false
6274
}
6375
}

src/index.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
1-
import LocalFile from './localFile.ts'
2-
import RemoteFile from './remoteFile.ts'
3-
4-
import type { FilehandleOptions, GenericFilehandle } from './filehandle.ts'
5-
61
export * from './filehandle.ts'
72

8-
function fromUrl(
9-
source: string,
10-
opts: FilehandleOptions = {},
11-
): GenericFilehandle {
12-
return new RemoteFile(source, opts)
13-
}
14-
function open(
15-
maybeUrl?: string,
16-
maybePath?: string,
17-
maybeFilehandle?: GenericFilehandle,
18-
opts: FilehandleOptions = {},
19-
): GenericFilehandle {
20-
if (maybeFilehandle !== undefined) {
21-
return maybeFilehandle
22-
}
23-
if (maybeUrl !== undefined) {
24-
return fromUrl(maybeUrl, opts)
25-
}
26-
if (maybePath !== undefined) {
27-
return new LocalFile(maybePath, opts)
28-
}
29-
throw new Error('no url, path, or filehandle provided, cannot open')
30-
}
31-
32-
export { fromUrl, open }
333
export { default as BlobFile } from './blobFile.ts'
344
export { default as RemoteFile } from './remoteFile.ts'
355
export { default as LocalFile } from './localFile.ts'

0 commit comments

Comments
 (0)