-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate browser as target env of exports
Refs #38
- Loading branch information
Showing
3 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-disable no-undef, no-restricted-globals */ | ||
|
||
type Name = "FormData" | "Blob" | "File"; | ||
type Exports = typeof FormData | typeof Blob | typeof File; | ||
type AccessValue = (name: Name) => Exports; | ||
|
||
const accessValue: AccessValue = name => { | ||
// new standardized access to the global object | ||
if (typeof globalThis !== "undefined") { | ||
return globalThis[name] | ||
} | ||
// WebWorker specific access | ||
if (typeof self !== "undefined") { | ||
return self[name] | ||
} | ||
|
||
return window[name] | ||
} | ||
|
||
const formData = accessValue("FormData") | ||
const blob = accessValue("Blob") | ||
const file = accessValue("File") | ||
|
||
export {formData as FormData, blob as Blob, file as File} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters