Skip to content

Commit

Permalink
Merge pull request #18 from ethstorage/node18
Browse files Browse the repository at this point in the history
Fixed the problem that lower version of nodejs does not support File
  • Loading branch information
iteyelmp authored Aug 13, 2024
2 parents ee6e4e6 + ab700f9 commit 55bc307
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ export function isBuffer(content) {
}

export function isFile(content) {
const isNodeFile = content && typeof content === 'object' &&
typeof content.isNodeJs === 'boolean' &&
content.isNodeJs;
return (content instanceof File) || isNodeFile;
if (isNodejs()) {
return content && typeof content === 'object' &&
typeof content.isNodeJs === 'boolean' &&
content.isNodeJs;
} else {
return content instanceof File;
}
}

export function isNodejs() {
return typeof process !== 'undefined' && !!process.versions && !!process.versions.node;
}

0 comments on commit 55bc307

Please sign in to comment.