tools.js 556 B

12345678910111213141516171819202122232425
  1. function isString(value){
  2. return 'string' == typeof value
  3. }
  4. function isObject(value){
  5. return 'object' == typeof value
  6. }
  7. function isArray(value){
  8. return 'array' == typeof value
  9. }
  10. //是否合法类型
  11. function isLawfulType(type,value){
  12. let valye_type = typeof value
  13. if(isString(type)){
  14. type = type.toLowerCase()
  15. return type == valye_type
  16. }
  17. if(isArray(type)){
  18. return type.indexOf(valye_type)?true:false;
  19. }
  20. return false
  21. }
  22. function isFunction(value){
  23. return 'function' == typeof value
  24. }
  25. export {isObject,isString,isArray,isLawfulType,isFunction}