2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Add isFunction and isStream helpers

This commit is contained in:
Nick Uraltsev
2016-04-12 19:49:12 -07:00
parent 4de17bca09
commit 9e7b1b5993
2 changed files with 33 additions and 1 deletions
+22
View File
@@ -122,6 +122,26 @@ function isBlob(val) {
return toString.call(val) === '[object Blob]';
}
/**
* Determine if a value is a Function
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Function, otherwise false
*/
function isFunction(val) {
return toString.call(val) === '[object Function]';
}
/**
* Determine if a value is a Stream
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Stream, otherwise false
*/
function isStream(val) {
return isObject(val) && isFunction(val.pipe);
}
/**
* Trim excess whitespace off the beginning and end of a string
*
@@ -237,6 +257,8 @@ module.exports = {
isDate: isDate,
isFile: isFile,
isBlob: isBlob,
isFunction: isFunction,
isStream: isStream,
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,
merge: merge,