mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-04 07:02:18 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
70
web/node_modules/redux/src/utils/kindOf.js
generated
vendored
Normal file
70
web/node_modules/redux/src/utils/kindOf.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
||||
function miniKindOf(val) {
|
||||
if (val === void 0) return 'undefined'
|
||||
if (val === null) return 'null'
|
||||
|
||||
const type = typeof val
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'symbol':
|
||||
case 'function': {
|
||||
return type
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) return 'array'
|
||||
if (isDate(val)) return 'date'
|
||||
if (isError(val)) return 'error'
|
||||
|
||||
const constructorName = ctorName(val)
|
||||
switch (constructorName) {
|
||||
case 'Symbol':
|
||||
case 'Promise':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
case 'Map':
|
||||
case 'Set':
|
||||
return constructorName
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
// other
|
||||
return type.slice(8, -1).toLowerCase().replace(/\s/g, '')
|
||||
}
|
||||
|
||||
function ctorName(val) {
|
||||
return typeof val.constructor === 'function' ? val.constructor.name : null
|
||||
}
|
||||
|
||||
function isError(val) {
|
||||
return (
|
||||
val instanceof Error ||
|
||||
(typeof val.message === 'string' &&
|
||||
val.constructor &&
|
||||
typeof val.constructor.stackTraceLimit === 'number')
|
||||
)
|
||||
}
|
||||
|
||||
function isDate(val) {
|
||||
if (val instanceof Date) return true
|
||||
return (
|
||||
typeof val.toDateString === 'function' &&
|
||||
typeof val.getDate === 'function' &&
|
||||
typeof val.setDate === 'function'
|
||||
)
|
||||
}
|
||||
|
||||
export function kindOf(val) {
|
||||
let typeOfVal = typeof val
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
typeOfVal = miniKindOf(val)
|
||||
}
|
||||
|
||||
return typeOfVal
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue