react-http-fetch
Version:
An http library for React JS built on top of native JS fetch
51 lines (50 loc) • 1.41 kB
JavaScript
/**
* Safely assert whether the given value is an ArrayBuffer.
*
* In some execution environments ArrayBuffer is not defined.
*/
export function isArrayBuffer(value) {
return typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
}
/**
* Safely assert whether the given value is a Blob.
*
* In some execution environments Blob is not defined.
*/
export function isBlob(value) {
return typeof Blob !== 'undefined' && value instanceof Blob;
}
/**
* Safely assert whether the given value is a FormData instance.
*
* In some execution environments FormData is not defined.
*/
export function isFormData(value) {
return typeof FormData !== 'undefined' && value instanceof FormData;
}
/**
* Safely assert whether the given value is a URLSearchParams instance.
*
* In some execution environments URLSearchParams is not defined.
*/
export function isUrlSearchParams(value) {
return typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams;
}
/**
* Safely assert whether the given value is a number.
*/
export function isNumber(value) {
return typeof value === 'number';
}
/**
* Safely assert whether the given value is a boolean.
*/
export function isBoolean(value) {
return typeof value === 'boolean';
}
/**
* Safely assert whether the given value is an object.
*/
export function isObject(value) {
return typeof value === 'object';
}