zgg-ui
Version:
2.0.1 正式版本 基于 Vue 3、UniApp 和 TypeScript 开发的多端适配移动端 UI 组件库,旨在提供丰富的组件集合,帮助开发者快速构建多端响应式的移动应用界面
61 lines (53 loc) • 1.7 kB
text/typescript
import { baseGetTag } from './_baseGetTag'
import { toSource } from './_toSource'
/** `Object#toString` result references. */
const mapTag = '[object Map]',
objectTag = '[object Object]',
promiseTag = '[object Promise]',
setTag = '[object Set]',
weakMapTag = '[object WeakMap]'
const dataViewTag = '[object DataView]'
/** Used to detect maps, sets, and weakmaps. */
const dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map),
promiseCtorString = toSource(Promise),
setCtorString = toSource(Set),
weakMapCtorString = toSource(WeakMap)
/**
* Gets the `toStringTag` of `value`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
let getTag = baseGetTag
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
if (
(DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
(Map && getTag(new Map()) != mapTag) ||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
(Set && getTag(new Set()) != setTag) ||
(WeakMap && getTag(new WeakMap()) != weakMapTag)
) {
getTag = function (value: any) {
const result = baseGetTag(value)
const Ctor = result == objectTag ? value.constructor : undefined
const ctorString = Ctor ? toSource(Ctor) : ''
if (ctorString) {
switch (ctorString) {
case dataViewCtorString:
return dataViewTag
case mapCtorString:
return mapTag
case promiseCtorString:
return promiseTag
case setCtorString:
return setTag
case weakMapCtorString:
return weakMapTag
}
}
return result
}
}
export { getTag }