file-type 22.0.0 → 22.0.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/package.json +2 -1
- package/source/index.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-type",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.1",
|
|
4
4
|
"description": "Detect the file type of a file, stream, or data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/file-type",
|
|
@@ -241,6 +241,7 @@
|
|
|
241
241
|
"@types/node": "^25.5.0",
|
|
242
242
|
"ava": "^7.0.0",
|
|
243
243
|
"commonmark": "^0.31.2",
|
|
244
|
+
"esbuild": "^0.28.0",
|
|
244
245
|
"get-stream": "^9.0.1",
|
|
245
246
|
"tsd": "^0.33.0",
|
|
246
247
|
"xo": "^2.0.2"
|
package/source/index.js
CHANGED
|
@@ -62,6 +62,11 @@ function getKnownFileSizeOrMaximum(fileSize) {
|
|
|
62
62
|
return Math.max(0, fileSize);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// Keep the specifier non-literal at the call site so browser bundlers do not try to resolve Node-only imports.
|
|
66
|
+
function importAtRuntime(specifier) {
|
|
67
|
+
return import(specifier);
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
// Wrap stream in an identity TransformStream to avoid BYOB readers.
|
|
66
71
|
// Node.js has a bug where calling controller.close() inside a BYOB stream's
|
|
67
72
|
// pull() callback does not resolve pending reader.read() calls, causing
|
|
@@ -258,8 +263,8 @@ export class FileTypeParser {
|
|
|
258
263
|
this.options.signal?.throwIfAborted();
|
|
259
264
|
// TODO: Remove this when `strtok3.fromFile()` safely rejects non-regular filesystem objects without a pathname race.
|
|
260
265
|
const [{default: fsPromises}, {FileTokenizer}] = await Promise.all([
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
importAtRuntime('node:fs/promises'),
|
|
267
|
+
importAtRuntime('strtok3'),
|
|
263
268
|
]);
|
|
264
269
|
const fileHandle = await fsPromises.open(path, fsPromises.constants.O_RDONLY | fsPromises.constants.O_NONBLOCK);
|
|
265
270
|
const fileStat = await fileHandle.stat();
|