mirror of
https://github.com/tenrok/axios.git
synced 2026-06-11 18:02:32 +03:00
Adding support for web workers, and react-native
closes #70, closes #98
This commit is contained in:
@@ -140,6 +140,27 @@ function isArguments(val) {
|
||||
return toString.call(val) === '[object Arguments]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
*
|
||||
* This allows axios to run in a web worker, and react-native.
|
||||
* Both environments support XMLHttpRequest, but not fully standard globals.
|
||||
*
|
||||
* web workers:
|
||||
* typeof window -> undefined
|
||||
* typeof document -> undefined
|
||||
*
|
||||
* react-native:
|
||||
* typeof document.createelement -> undefined
|
||||
*/
|
||||
function isStandardBrowserEnv() {
|
||||
return (
|
||||
typeof window !== 'undefined' &&
|
||||
typeof document !== 'undefined' &&
|
||||
typeof document.createElement === 'function'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
@@ -221,6 +242,7 @@ module.exports = {
|
||||
isDate: isDate,
|
||||
isFile: isFile,
|
||||
isBlob: isBlob,
|
||||
isStandardBrowserEnv: isStandardBrowserEnv,
|
||||
forEach: forEach,
|
||||
merge: merge,
|
||||
trim: trim
|
||||
|
||||
Reference in New Issue
Block a user