Skip to content

Commit 4750aee

Browse files
committed
feat: add detection of Promise support
1 parent 2828f6a commit 4750aee

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/promises.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ export class FileHandle implements IFileHandle {
182182
}
183183
}
184184

185-
export default function createPromisesApi(vol: Volume): IPromisesAPI {
185+
export default function createPromisesApi(vol: Volume): null | IPromisesAPI {
186+
if (typeof Promise === 'undefined') return null;
186187
return {
187188
FileHandle,
188189

src/volume.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ export class Volume {
575575
'ExperimentalWarning',
576576
);
577577
}
578+
if (this.promisesApi === null) throw new Error('Promise is not supported in this environment.');
578579
return this.promisesApi;
579580
}
580581

0 commit comments

Comments
 (0)