UNPKG

simple-utils-js

Version:

前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown

26 lines (23 loc) 556 B
/** * @description: 类型判断 * @param {*} * @return {*} */ let typeFn = {} const curring = (fn, arr = []) => { let len = fn.length return (...args) => { arr = arr.concat(args) if (arr.length < len) { return curring(fn, arr) } return fn(...arr) } } function isType(type, content) { return Object.prototype.toString.call(content) === `[object ${type}]` } ;['String', 'Number', 'Boolean', 'Null', 'Array', 'Object', 'Function'].forEach(type => { typeFn['is' + type] = curring(isType)(type) }) module.exports = typeFn