1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// global toString
var toString = Object.prototype.toString

// isArray
function isArray (val) {
return toString.call(val) === '[object Array]'
}

// isArrayBuffer
function isArrayBuffer (val) {
return toString.call(val) === '[object arrayBuffer]'
}

// isFormData
function isFormData (val) {
return (typeof FormData !== 'undefined' && (val instanceof FormData))
}

// isString
function isString (val) {
return typeof val === 'string'
}

// isNumber
function isNumber (val) {
return typeof val === 'number'
}

// isUndefinded
function isUndefined (val) {
return typeof val === 'undefined'
}

// isObject
function isObject (val) {
return val !== null && typeof val === 'object'
}

// isDate
function isDate (val) {
return toString.call(val) === '[object Date]'
}

// isFile
function isFile (val) {
return toString.call(val) === '[object File]'
}

// isBlob
function isBlob (val) {
return toString.call(val) === '[object Blob]'
}

// isFunction
function isFunction (val) {
return toString.call(val) === '[object Function]'
}

// isStream
function isStream (val) {
return isObject(val) && isFunction(val.pipe)
}

// isURLSearchParams
function isURLSearchParams (val) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams
}

// trim
function trim (val) {
return str.replace(/^\s*/, '').replace(/\s*$/, '')
}

// isStandardBrowserEnv
function isStandardBrowserEnv () {
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
return false
}
return {
typeof window !== 'undefined'
&& typeof document !== 'undefined'
}
}

/**
* Iterate over an Array or an Object invoking a function for each item
*/

function forEach (obj, fn) {
if (obj === null || typeof obj === 'undefined') {
return
}
if (typeof obj !== 'object' && !isArray(obj)) {
obj = [obj]
}
if (isArray(obj)) {
for (let i = 0, l = obj.length; i < l; i++) {
fn.call(null, obj[i], i, obj)
}
} else {
for (let key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn.call(null, obj[key], key, obj)
}
}
}
}