Skip to content

Commit 85105af

Browse files
committed
import from fs/promise instead
1 parent f8660f4 commit 85105af

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

from.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import {statSync, createReadStream, promises as fs} from 'fs';
1+
import {statSync, createReadStream} from 'fs';
2+
import {stat} from 'fs/promises';
23
import DOMException from 'domexception';
34
import Blob from './index.js';
45

5-
const {stat} = fs;
6-
76
/**
87
* @param {string} path filepath on the disk
98
* @returns {Blob}
@@ -19,7 +18,7 @@ const blobFromSync = path => from(statSync(path), path);
1918
const from = (stat, path) => new Blob([new BlobDataItem({
2019
path,
2120
size: stat.size,
22-
lastModified: Number(stat.mtime),
21+
lastModified: stat.mtimeMs,
2322
start: 0
2423
})]);
2524

@@ -55,8 +54,8 @@ class BlobDataItem {
5554
}
5655

5756
async * stream() {
58-
const metadata = await stat(this.#path)
59-
if (metadata.mtime > this.lastModified) {
57+
const {mtimeMs} = await stat(this.#path)
58+
if (mtimeMs > this.lastModified) {
6059
throw new DOMException('The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.', 'NotReadableError');
6160
}
6261
if (this.size) {

0 commit comments

Comments
 (0)