{"id":26608091,"url":"https://github.com/yaohaixiao/types.js","last_synced_at":"2026-02-23T15:32:55.300Z","repository":{"id":164369203,"uuid":"624317307","full_name":"yaohaixiao/types.js","owner":"yaohaixiao","description":"types.js - 专注于检测 JavaScript 数据类型的工具库。","archived":false,"fork":false,"pushed_at":"2025-02-15T12:29:11.000Z","size":3322,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T01:31:56.607Z","etag":null,"topics":["detect","javascript","typeof","types"],"latest_commit_sha":null,"homepage":"https://yaohaixiao.github.io/types.js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaohaixiao.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-06T07:50:09.000Z","updated_at":"2025-02-15T12:29:15.000Z","dependencies_parsed_at":"2023-12-04T13:29:47.513Z","dependency_job_id":"2ba50c30-9106-4952-83e9-3865bc7aeffe","html_url":"https://github.com/yaohaixiao/types.js","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/yaohaixiao/types.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaohaixiao%2Ftypes.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaohaixiao%2Ftypes.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaohaixiao%2Ftypes.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaohaixiao%2Ftypes.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaohaixiao","download_url":"https://codeload.github.com/yaohaixiao/types.js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaohaixiao%2Ftypes.js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29746569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["detect","javascript","typeof","types"],"created_at":"2025-03-23T23:32:07.329Z","updated_at":"2026-02-23T15:32:55.244Z","avatar_url":"https://github.com/yaohaixiao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# types.js\n\n[![npm version](https://img.shields.io/npm/v/@yaohaixiao/types.js)](https://www.npmjs.com/package/@yaohaixiao/types.js)\n![Gzip size](http://img.badgesize.io/https://cdn.jsdelivr.net/gh/yaohaixiao/types.js/lib/types.js?compression=gzip\u0026label=gzip%20size)\n[![prettier code style](https://img.shields.io/badge/code_style-prettier-07b759.svg)](https://prettier.io)\n[![Coverage](https://codecov.io/gh/yaohaixiao/types.js/branch/main/graph/badge.svg)](https://codecov.io/gh/yaohaixiao/types.js)\n[![npm downloads](https://img.shields.io/npm/dt/@yaohaixiao/types.js)](https://npmcharts.com/compare/@yaohaixiao/types.js?minimal=true)\n[![MIT License](https://img.shields.io/github/license/yaohaixiao/types.js.svg)](https://github.com/yaohaixiao/types.js/blob/master/LICENSE)\n\ntypes.js - A library of tools focused on detecting JavaScript data types.\n\n## 特点\n\n- 原生 JavaScript 编写，无任何依赖；\n- 支持 UMD 规范；\n- 支持 ES6 模块；\n- 支持 TypeScript；\n- 支持按需加载；\n- 丰富的数据类型检测方法（80+），且调用方面简单；\n- 文件体积小(Gzip：4.2KB)，加载速度快；\n\n## Browsers support\n\n| [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png\" alt=\"IE / Edge\" width=\"24px\" height=\"24px\" /\u003e](https://github.com/yaohaixiao/types.js/)\u003c/br\u003eIE / Edge | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png\" alt=\"Firefox\" width=\"24px\" height=\"24px\" /\u003e](https://github.com/yaohaixiao/types.js/)\u003c/br\u003eFirefox | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png\" alt=\"Chrome\" width=\"24px\" height=\"24px\" /\u003e](https://github.com/yaohaixiao/types.js/)\u003c/br\u003eChrome | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png\" alt=\"Safari\" width=\"24px\" height=\"24px\" /\u003e](https://github.com/yaohaixiao/types.js/)\u003c/br\u003eSafari | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png\" alt=\"Opera\" width=\"24px\" height=\"24px\" /\u003e](https://github.com/yaohaixiao/types.js/)\u003c/br\u003eOpera |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| IE11, Edge                                                                                                                                                                                             | last 10 versions                                                                                                                                                                                         | last 10 versions                                                                                                                                                                                     | last 10 versions                                                                                                                                                                                     | last 10 versions                                                                                                                                                                                 |\n\n## Installation\n\ntypes.js 支持 UMD 规范和 ES6 的模块调用方式，既可以在 Node.js 环境中使用 npm 安装，也可以在浏览器中使用 script 标签引入到页面。\n\n### npm install\n\n```sh\n# install from npmjs.com\nnpm i -S @yaohaixiao/types.js\n\n# install from github.com\nnpm i -S @yaohaixiao/types.js --registry=https://npm.pkg.github.com\n```\n\n### In a browser\n\n在浏览器中调用 types.js，可以选择调用 jsdelivr 提供的 CDN 服务中的文件，也可以使用本地的 types.js 文件。\n\n#### CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/yaohaixiao/types.js/lib/types.js\"\u003e\u003c/script\u003e\n```\n\n#### Local file\n\n```html\n\u003cscript src=\"/path/to/types.js\"\u003e\u003c/script\u003e\n```\n\n### Node.js 中调用\n\n```js\n// 加载完整模块（包含所有方法）\nconst Types = require('@yaohaixiao/types.js/lib/types')\n\nTypes.is([]) // -\u003e array\n```\n\n```js\n// 调用特定方法\nconst isArray = '@yaohaixiao/types.js/lib/isArray'\n```\n\n### ES6 模块中调用\n\n```js\n// 调用 Types 对象\nimport Types from '@yaohaixiao/types.js'\n\nTypes.is([]) // -\u003e array\nTypes.isArray([]) // -\u003e true\n\n// 2.0.0 开始也支持这样调用\nconst types = Types([])\n\ntypes.is() // -\u003e array\ntypes.isArray() // -\u003e true\n\n// 或者直接\nTypes('2.0.0 开始也支持这样调用').is() // -\u003e string\nTypes('2.0.0 开始也支持这样调用').isHTML() // -\u003e false\n```\n\n```js\n// 调用特定方法\nimport isArray from '@yaohaixiao/types.js/isArray'\n\nisArray([]) // -\u003e true\n```\n\n## [API Documentation](https://yaohaixiao.github.io/types.js/)\n\ntypes.js 提供了很多实用的数据类型判断的方法，以下是一些常用的 API 示例，完整 API 文档请查阅：[https://yaohaixiao.github.io/types.js/](https://yaohaixiao.github.io/types.js/)。\n\n### [Base](https://yaohaixiao.github.io/types.js/#heading-0)\n\ntypes.js 提供以下基础的数据类型检测方法。\n\n### [is(val)](https://yaohaixiao.github.io/types.js/#method-is)\n\nis(val) 方法返回检测数据的数据类型字符串：\n\n* 'number' - 数字\n  * integer - 整数\n  * float - 浮点数\n  * infinite - 正负无穷大\n* 'string' - 字符串\n  * blank - 空格\n  * base64 - Base64 编码字符\n  * chinese - 中文字符\n  * email - 电子邮箱地址\n  * empty - 空字符串\n  * guid - guid 字符串\n  * hex - 十六进制编码字符\n  * html - html 字符串\n  * svg - svg 字符串\n  * IP address - IP 地址\n  * ID number - （中国）身份证号码\n  * json - json 字符串\n  * time - 表示时间的字符串（时间和日期）\n* 'boolean' - 布尔值\n* 'null' - 空值\n* 'undefined' - 未定义\n* 'symbol' - 符号\n* 'bigint' - 任意大的整数\n* 'set' - Set\n* 'weakset' - WeakSet\n* 'map' - Map\n* 'weakmap' - WeakMap\n* 'array' - 数组\n* 'arraybuffer' - 固定长度的二进制数据缓冲区\n* 'int8array' - int8array 数组\n* 'uint8array' - uint8array 数组\n* 'uint8clampedarray' - uint8clampedarray 数组\n* 'int16array' - int16array 数组\n* 'uint16array' - uint16array 数组\n* 'int32array' - int32array 数组\n* 'uint32array' - uint32array 数组\n* 'float32array' - float32array 数组\n* 'float64array' - float64array 数组\n* 'bigint64array' - bigint64array 数组\n* 'biguint64array' - biguint64array 数组\n* 'object' - 对象\n  * prototype - 原型对象（prototype 和 \\_\\_proto\\_\\_）\n  * vnode - vue 中地 VNode 对象\n  * xml - XML DOM 对象\n* 'arguments' - （函数的）参数对象\n* 'dataview' - DataView 视图\n* 'date' - 日期\n* 'error' - 错误\n* 'function' - 函数\n* 'regexp' - 正则表达式对象\n* 'element' - HTML 元素节点\n* 'collection' - HTML NodeList 对象\n* 'text' - HTML 文本节点\n* 'fragment' - DocumentFragment 文档碎片\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，待检测的数据。\n\n#### Returns\n\nType: `String`\n\n返回确切的数据类型名称。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 is() 方法\n// import is from '@yaohaixiao/types.js/is'\nimport { DOMParser } from 'xmldom'\n\nlet Example\nlet args\nconst buffer = new ArrayBuffer(8)\nconst dv = new DataView(buffer)\nconst XML = new DOMParser().parseFromString(\n        '\u003cxml xmlns=\"a\" xmlns:c=\"./lite\"\u003e\\n' +\n        '\\t\u003cchild\u003etest\u003c/child\u003e\\n' +\n        '\\t\u003cchild\u003e\u003c/child\u003e\\n' +\n        '\\t\u003cchild/\u003e\\n' +\n        '\u003c/xml\u003e',\n        'text/xml'\n)\n\nfunction test(age){\n  args = arguments\n  return age\n}\n\ntest(40)\n\n// 基础值类型\nTypes.is('types.js') // -\u003e string\nTypes.is(' ') // -\u003e blank\nTypes.is('Z29vZA==') // -\u003e base64\nTypes.is('中国梦') // -\u003e chinese\nTypes.is('type.js@gmail.com') // -\u003e email\nTypes.is('') // -\u003e empty\nTypes.is('3C8021B0-423D-475D-BECF-63ED5ED34563') // -\u003e guid\nTypes.is('3C8021B0423D475DBECF63ED5ED34563') // -\u003e guid\nTypes.is('#ffffff') // -\u003e hex\nTypes.is('\u003ch2\u003e中国梦\u003c/h2\u003e') // -\u003e html\nTypes.is('126.11.15.255') // -\u003e IP address\nTypes.is('110105491231002') // -\u003e ID number\nTypes.is('11010519491231002X') // -\u003e ID number\nTypes.is('{\"prop\":\"JSON\"}') // -\u003e json\nTypes.is('11:23 am') // -\u003e time\nTypes.is('Jul 08 2023') // -\u003e time\nTypes.is(2023) // -\u003e integer\nTypes.is(3.0) // -\u003e integer\nTypes.is(3.01) // -\u003e float\nTypes.is(Infinity) // -\u003e infinite\nTypes.is(true) // -\u003e boolean\nTypes.is(null) // -\u003e null\nTypes.is(Example) // -\u003e undefined\nTypes.is(Symbol()) // -\u003e symbol\nTypes.is(BigInt(42)) // -\u003e bigint\n\n// Set/WeakSet/Map/WeakMap\nTypes.is(new Set()) // -\u003e set\nTypes.is(new WeakSet()) // -\u003e weakset\nTypes.is(new Map()) // -\u003e map\nTypes.is(new WeakMap()) // -\u003e weakmap\n\n// Object 对象相关\nTypes.is({}) // -\u003e object\nTypes.is(new Object()) // -\u003e object\nTypes.is(Object.prototype) // -\u003e prototype\nTypes.is(XML) // -\u003e xml\nTypes.is(Object.create(null)) // -\u003e object\nTypes.is(new String()) // -\u003e object\nTypes.is(new Number()) // -\u003e object\nTypes.is(new Boolean()) // -\u003e object\nTypes.is(new Error()) // -\u003e error\nTypes.is(new Date()) // -\u003e data\nTypes.is(new RegExp('/s/')) // -\u003e regexp\nTypes.is(/\\s+/ig) // -\u003e regexp\nTypes.is(() =\u003e {}) // -\u003e function\nTypes.is(args) // -\u003e arguments\nTypes.is(dv) // -\u003e dataview\nTypes.is(document.querySelector('#list')) // -\u003e element\nTypes.is(document.querySelectorAll('.item')) // -\u003e coolection\nTypes.is(document.createTextNode('text')) // -\u003e text\nTypes.is(document.createDocumentFragment()) // -\u003e fragment\n\n// Array 相关\nTypes.is([]) // -\u003e array\nTypes.is(new ArrayBuffer(8)) // -\u003e arraybubber\nTypes.is(new Int8Array([])) // -\u003e int8array\nTypes.is(new Int16Array([])) // -\u003e int16array\nTypes.is(new Int32Array([])) // -\u003e int32array\nTypes.is(new Uint8Array([])) // -\u003e uint8array\nTypes.is(new Uint8ClampedArray([])) // -\u003e uint8clampedarray\nTypes.is(new Uint16Array([])) // -\u003e uint16array\nTypes.is(new Uint32Array([])) // -\u003e uint32array\nTypes.is(new Float32Array([])) // -\u003e float32array\nTypes.is(new Float64Array([])) // -\u003e float64array\nTypes.is(new BigInt64Array(64)) // -\u003e bigint64array\nTypes.is(new BigUint64Array(64)) // -\u003e biguint64array\n```\n\n### [isEmpty(val)](https://yaohaixiao.github.io/types.js/#method-isEmpty)\n\nisEmpty(val) 方法用来检测测试数据是否为空字符串。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是空值（空字符串、空对象、空数组等），返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isEmpty() 方法\n// import isEmpty from '@yaohaixiao/types.js/isEmpty'\n\nTypes.isEmpty('') // -\u003e true\nTypes.isEmpty(String()) // -\u003e true\n\nTypes.isEmpty(new String()) // -\u003e false\nTypes.isEmpty(' ') // -\u003e false\n```\n\n### [isFalsy(val)](https://yaohaixiao.github.io/types.js/#method-isFalsy)\n\nisFalsy(val) 方法用来检测测试数据是否为在布尔上下文中被视为 false 的值\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 在布尔上下文中被视为 true 的值，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isFalsy() 方法\n// import isFalsy from '@yaohaixiao/types.js/isFalsy'\n\nTypes.isFalsy(false) // true\nTypes.isFalsy(0) // true\nTypes.isFalsy('') // true\nTypes.isFalsy(null) // true\nTypes.isFalsy(undefined) // true\nTypes.isFalsy(NaN) // true\n\nTypes.isFalsy(true) // false\nTypes.isFalsy(1) // false\nTypes.isFalsy('hello') // false\nTypes.isFalsy({}) // false\nTypes.isFalsy([]) // false\n```\n\n### [isNil(val)](https://yaohaixiao.github.io/types.js/#method-isNil)\n\nisNil(val) 方法用来检测测试数据是否为 Null 或者 undefined。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Null 或者 undefined，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isNil() 方法\n// import isNil from '@yaohaixiao/types.js/isNil'\n\nTypes.isNil(null) // =\u003e true\n\nTypes.isNil(void 0) // =\u003e true\n\nTypes.isNil(undefined) // =\u003e true\n\nTypes.isNil(NaN) // =\u003e false\n\nTypes.isNil('') // =\u003e false\n```\n\n### [isPrimitive(val)](https://yaohaixiao.github.io/types.js/#method-isPrimitive)\n\nisPrimitive(val) 方法用来检测测试数据是否为原始值类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是原始值类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPrimitive() 方法\n// import isPrimitive from '@yaohaixiao/types.js/isPrimitive'\n\nlet num\nconst MAX_SAFE_INTEGER = 9007199254740991\nconst bigint = BigInt(MAX_SAFE_INTEGER + 1)\n\n// True\nTypes.isPrimitive(1) // -\u003e true\nTypes.isPrimitive('num') // -\u003e true\nTypes.isPrimitive(false) // -\u003e true\nTypes.isPrimitive(null) // -\u003e true\nTypes.isPrimitive(num) // -\u003e true\nTypes.isPrimitive(Symbol('foo')) // -\u003e true\nTypes.isPrimitive(bigint) // -\u003e true\n\n// False\nTypes.isPrimitive([]) // -\u003e false\nTypes.isPrimitive({}) // -\u003e false\nTypes.isPrimitive(()=\u003e{}) // -\u003e false\n```\n\n### [isTruly(val)](https://yaohaixiao.github.io/types.js/#method-isTruly)\n\nisTruly(val) 方法用来检测测试数据是否为在布尔上下文中被视为 true 的值。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 在布尔上下文中被视为 true 的值，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isTruly() 方法\n// import isTruly from '@yaohaixiao/types.js/isTruly'\n\nTypes.isTruly(true); // -\u003e true\nTypes.isTruly(1); // -\u003e true\nTypes.isTruly(\"hello\"); // -\u003e true\nTypes.isTruly({}); // -\u003e true\nTypes.isTruly([]); // -\u003e true\n\nTypes.isTruly(false); // -\u003e false\nTypes.isTruly(0); // -\u003e false\nTypes.isTruly(''); // -\u003e false\nTypes.isTruly(null); // -\u003e false\nTypes.isTruly(undefined); // -\u003e false\nTypes.isTruly(NaN); // -\u003e false\n```\n\n### [isValue(val)](https://yaohaixiao.github.io/types.js/#method-isValue)\n\nisValue(val) 方法用来检测测试数据是否为有效的数据。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是有效的数据（非null、undefined或者正负无穷数值），返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isValue() 方法\n// import isValue from '@yaohaixiao/types.js/isValue'\n\nlet projects\n\n// 非有效数据\nTypes.isValue(projects) // -\u003e false\nTypes.isValue(NaN) // -\u003e false\nTypes.isValue(null) // -\u003e false\nTypes.isValue(Infinity) // -\u003e false\nTypes.isValue(-Infinity) // -\u003e false\n\n// 有效数据\nTypes.isValue(0) // -\u003e true\nTypes.isValue('') // -\u003e true\nTypes.isValue(false) // -\u003e true\nTypes.isValue([]) // -\u003e true\nTypes.isValue({}) // -\u003e true\nTypes.isValue(/\\s+/ig) // -\u003e true\nTypes.isValue(new Date()) // -\u003e true\nTypes.isValue(empty) // -\u003e true\nTypes.isValue(fn) // -\u003e true\n```\n\n\n### [Primitive Values](https://yaohaixiao.github.io/types.js/#heading-5)\n\ntypes.js 提供以下方法来检测 Primitive Values（基础值类型） 相关的数据类型。\n\n### [isBigInt(val)](https://yaohaixiao.github.io/types.js/#method-isBigInt)\n\nisBigInt(obj) 方法用来检测测试数据是否为 BigInt 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 BigInt 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBigInt() 方法\n// import isBigInt from '@yaohaixiao/types.js/isBigInt'\n\nconst MAX_SAFE_INTEGER = 9007199254740991\nconst bigint = BigInt(MAX_SAFE_INTEGER + 1)\n\nType.is(bigint) // -\u003e 'bigint'\n\nTypes.isBigInt(MAX_SAFE_INTEGER) // -\u003e false\nTypes.isBigInt(bigint) // -\u003e true\n```\n\n### [isBoolean(val)](https://yaohaixiao.github.io/types.js/#method-isBoolean)\n\nisBoolean(obj) 方法用来检测测试数据是否为 Boolean 类型\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Boolean 类型则返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBoolean() 方法\n// import isBoolean from '@yaohaixiao/types.js/isBoolean'\n\nlet project\n\n// False\nTypes.isBoolean(1) // -\u003e false\nTypes.isBoolean('') // -\u003e false\nTypes.isBoolean(null) // -\u003e false\nTypes.isBoolean(NaN) // -\u003e false\nTypes.isBoolean(project) // -\u003e false\n\n// True\nTypes.isBoolean(!!0) // -\u003e true\nTypes.isBoolean(false) // -\u003e true\nTypes.isBoolean(true) // -\u003e true\nTypes.isBoolean(Boolean('1')) // -\u003e true\nTypes.isBoolean(new Boolean('')) // -\u003e false\nTypes.isBoolean(!!project) // -\u003e true\n```\n\n### [isNull(val)](https://yaohaixiao.github.io/types.js/#method-isNull)\n\nisNull(val) 方法用来检测测试数据是否为 null。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 为 null 返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isNull() 方法\n// import isNull from '@yaohaixiao/types.js/isNull'\n\nlet project\n\nTypes.isNull('') // -\u003e false\nTypes.isNull({}) // -\u003e false\nTypes.isNull(project) // -\u003e false\nTypes.isNull(0) // -\u003e false\nTypes.isNull(false) // -\u003e false\nTypes.isNull(Object.create(null)) // -\u003e false\n\nTypes.isNull(null) // -\u003e true\n\n```\n\n### [isNumber(val)](https://yaohaixiao.github.io/types.js/#method-isNumber)\n\nisNumber(obj) 方法用来检测测试数据是否为 Number 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\nDefault: ``\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Number 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isNumber() 方法\n// import isNumber from '@yaohaixiao/types.js/isNumber'\n\nTypes.isNumber(0) // -\u003e true\nTypes.isNumber(.4) // -\u003e true\nTypes.isNumber(3.4E2) // -\u003e true\nTypes.isNumber(0xffffff) // -\u003e true\nTypes.isNumber(NaN) // -\u003e true\nTypes.isNumber(Infinity) // -\u003e true\nTypes.isNumber(-Infinity) // -\u003e true\n\nTypes.isNumber('2') // -\u003e false\nTypes.isNumber(2 + '1') // -\u003e false\nTypes.isNumber(new Number()) // -\u003e false\n```\n\n### [isPrime(val)](https://yaohaixiao.github.io/types.js/#method-isPrime)\n\nisPrime(val) 方法用来检测测试数据是否为质(素)数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是质数，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPrime() 方法\n// import isPrime from '@yaohaixiao/types.js/isPrime'\n\nTypes.isPrime(3) // -\u003e true\nTypes.isPrime(7) // -\u003e true\nTypes.isPrime(11) // -\u003e true\n\nTypes.isPrime(0) // -\u003e false\nTypes.isPrime(1) // -\u003e false\nTypes.isPrime(2) // -\u003e false\nTypes.isPrime(9) // -\u003e false\n```\n\n### [isString(val)](https://yaohaixiao.github.io/types.js/#method-isString)\n\nisString(val) 方法用来检测测试数据是否为字符串。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是字符串返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isString() 方法\n// import isString from '@yaohaixiao/types.js/isString'\n\nconst text = document.createTextNode('text')\n\nTypes.isString('') // -\u003e true\nTypes.isString(String(2)) // -\u003e true\nTypes.isString(2 + '0') // -\u003e true\n\nTypes.isString(2) // -\u003e false\nTypes.isString(new String()) // -\u003e false\nTypes.isString(text) // -\u003e false\n```\n\n### [isSymbol(val)](https://yaohaixiao.github.io/types.js/#method-isSymbol)\n\nisSymbol(val) 方法用来检测测试数据是否为 Symbol 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Symbol 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isSymbol() 方法\n// import isSymbol from '@yaohaixiao/types.js/isSymbol'\n\nconst sym = Symbol('foo')\nconst symObj = Object(sym)\n\nTypes.is(sym) // -\u003e 'symbol'\nTypes.isSymbol(sym) // -\u003e true\n\nTypes.is(symObj) // -\u003e 'object'\nTypes.isSymbol(symObj) // -\u003e false\n```\n\n### [isUndefined(val)](https://yaohaixiao.github.io/types.js/#method-isUndefined)\n\nisUndefined(val) 方法用来检测测试数据是否 undefined（未定义）。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 undefined（未定义）返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUndefined() 方法\n// import isUndefined from '@yaohaixiao/types.js/isUndefined'\n\nlet project\n\nTypes.isUndefined(project) // -\u003e true\n\nTypes.isUndefined([]) // -\u003e false\nTypes.isUndefined('') // -\u003e false\nTypes.isUndefined(0) // -\u003e false\nTypes.isUndefined(NaN) // -\u003e false\nTypes.isUndefined({}) // -\u003e false\nTypes.isUndefined(false) // -\u003e false\n```\n\n### [Arguments](https://yaohaixiao.github.io/types.js/#heading-19)\n\ntypes.js 提供以下 Arguments 对象相关的类型检测方法。\n\n### [isArguments(val)](https://yaohaixiao.github.io/types.js/#method-isArguments)\n\nisArguments(val) 方法用来检测测试数据是否为 arguments 对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 arguments 对象返回 true，否则返回 false\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isArguments() 方法\n// import isArguments from '@yaohaixiao/types.js/isArguments'\n\nconst argsLike = { '0': 3, '1': 4, length: 2 }\nconst $items = document.querySelectorAll('.item')\nlet args\n\nfunction sum(a, b){\n  args = arguments\n\n  return a + b\n}\n\nsum(3, 5)\n\nTypes.isArguments(argsLike) // -\u003e false\nTypes.isArguments([]) // -\u003e false\nTypes.isArguments(items) // -\u003e false\n\nTypes.is(args) // -\u003e 'arguments'\nTypes.isArguments(args) // -\u003e true\n\n```\n\n### [isEmptyArguments(val)](https://yaohaixiao.github.io/types.js/#method-isEmptyArguments)\n\nisEmptyArguments(val) 方法用来检测测试 arguments 对象长度为 0。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是长度为 0 的 arguments 对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isEmptyArguments() 方法\n// import isEmptyArguments from '@yaohaixiao/types.js/isEmptyArguments'\n\nlet args\nconst fn = function () {arg = arguments}\n\nfn()\n\nTypes.isEmptyArguments(args) // -\u003e true\n\nfn(1)\n\nTypes.isEmptyArguments(args) // -\u003e false\n```\n\n\n### [Array](https://yaohaixiao.github.io/types.js/#heading-19)\n\ntypes.js 提供以下方法来检测 Array 相关的数据类型。\n\n### [isArray(val)](https://yaohaixiao.github.io/types.js/#method-isArray)\n\nisArray(val) 方法用来检测测试数据的数据类型是否为 Array （数组）类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Array 类型返回 true，否则返回 false\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isArray() 方法\n// import isArray from '@yaohaixiao/types.js/isArray'\n\nconst LooksLike = { '0':1, '1':2, length: 2 }\nlet args\n\nfunction sum (a, b){\n  args = arguments\n  return a + b\n}\n\n// True\nTypes.isArray([]) // -\u003e true\nTypes.isArray(new Array()) // -\u003e true\nTypes.isArray('type.js'.split('')) // -\u003e true\n\n// False\n// 虽然  arguments 对象看起来也像数组，但是它也不是数组\nTypes.isArray(args) // -\u003e false\n// 虽然 HTMLNodeList 的看起来像数组，但它并不是数组\nTypes.isArray(document.getElementsByTagName('li')) // -\u003e false\nTypes.isArray(LooksLike) // -\u003e false\nTypes.isArray(new Int8Array()) // -\u003e false\n```\n\n### [isArrayLike(val)](https://yaohaixiao.github.io/types.js/#method-isArrayLike)\n\nisArrayLike(val) 方法用来检测测试数据的数据类型是否为类似数组（array、arguments 对象或者 HTMLNodeList 对象）类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 array、arguments 或者 HTMLNodeList 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isArrayLike() 方法\n// import isArrayLike from '@yaohaixiao/types.js/isArrayLike'\n\nlet args\n\nfunction sum(a, b){\n  args = arguments // -\u003e true\n  return a + b\n}\n\nsum(5, 6)\n\nTypes.isArrayLike([1, 2, 3, 4, 5]) // -\u003e true\n\n// arguments 对象是类似数组类型的数据\nTypes.isArrayLike(args) // -\u003e true\n\n// HTMLNodeList 是类似数组类型的数据\nTypes.isArrayLike(document.getElementsByTagName('li')) // -\u003e true\n\nTypes.isArrayLike({ '0': 1, '1': 2, length: 2 }) // -\u003e false\nTypes.isArrayLike( new Int8Array([]) ) // -\u003e false\n```\n\n### [isArrayLikeObject(val)](https://yaohaixiao.github.io/types.js/#method-isArrayLikeObject)\n\nisArrayLikeObject(val) 方法用来检测测试数据是否为 ArrayLike 的对象数据。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 ArrayLike 的对象数据，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isArrayLikeObject() 方法\n// import isArrayLikeObject from '@yaohaixiao/types.js/isArrayLikeObject'\n\nconst $items = document.querySelectorAll('.item')\nconst obj = { '0': 1, '1': 2, length: 2 }\nlet args\nfunction getAge(age) {\n  args = arguments\n  return age + 18\n}\n\ngetAge(30)\n\nTypes.isArrayLikeObject([]) // -\u003e true\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isArrayLikeObject($items) // -\u003e true\n\nTypes.isArrayLikeObject(args) // -\u003e true\n\nTypes.isArrayLikeObject(obj) // -\u003e false\nTypes.isArrayLikeObject({}) // -\u003e false\n```\n\n### [isEmptyArray(val)](https://yaohaixiao.github.io/types.js/#method-isEmptyArray)\n\nisEmptyArray(val) 方法用来检测测试数据是否为空字符串。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是数据空数组，返回 true，否则 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isEmptyArray() 方法\n// import isEmptyArray from '@yaohaixiao/types.js/isEmptyArray'\n\nTypes.isEmptyArray([]) // -\u003e true\nTypes.isEmptyArray(['']) // -\u003e true\nTypes.isEmptyArray(new Array()) // -\u003e true\n\nTypes.isEmptyArray(new Array(8)) // -\u003e false\n```\n\n\n### [Typed Arrays](https://yaohaixiao.github.io/types.js/#heading-24)\n\ntypes.js 提供以下方法来检测 Typed Arrays 相关的数据类型。\n\n### [isArrayBuffer(val)](https://yaohaixiao.github.io/types.js/#method-isArrayBuffer)\n\nisArrayBuffer(val) 方法用来检测测试数据是否为 ArrayBuffer 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 ArrayBuffer 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isArrayBuffer() 方法\n// import isArrayBuffer from '@yaohaixiao/types.js/isArrayBuffer'\n\nTypes.isArrayBuffer([]) // -\u003e false\nTypes.isArrayBuffer(new ArrayBuffer(8)) // -\u003e true\n```\n\n### [isBigInt64Array(val)](https://yaohaixiao.github.io/types.js/#method-isBigInt64Array)\n\nisBigInt64Array(val) 方法用来检测测试数据是否为 BigInt64Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 BigInt64Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBigInt64Array() 方法\n// import isBigInt64Array from '@yaohaixiao/types.js/isBigInt64Array'\n\nconst arr = [9007199254740992]\ncong bigint64 = new BigInt64Array(42)\n\nType.is(bigint) // -\u003e 'bigint64array'\n\nTypes.isBigInt64Array(arr) // -\u003e false\nTypes.isBigInt64Array(bigint64) // -\u003e true\n```\n\n### [isBigUint64Array(val)](https://yaohaixiao.github.io/types.js/#method-isBigUint64Array)\n\nisBigUint64Array(val) 方法用来检测测试数据是否为 BigUint64Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 BigUint64Array 类型，返回 true，否则返回 false\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBigUint64Array() 方法\n// import isBigUint64Array from '@yaohaixiao/types.js/isBigUint64Array'\n\nconst arr = [9007199254740992]\ncong bigint64 = new BigInt64Array(42)\n\nType.is(bigint) // -\u003e 'bigint64array'\n\nTypes.isBigUint64Array(arr) // -\u003e false\nTypes.isBigUint64Array(bigint64) // -\u003e true\n```\n\n### [isDataView(val)](https://yaohaixiao.github.io/types.js/#method-isDataView)\n\nisDataView(val) 方法用来检测测试数据是否为 DataView 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 isDataView 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isDataView() 方法\n// import isDataView from '@yaohaixiao/types.js/isDataView'\n\nconst buffer = new ArrayBuffer(8)\nconst dv = new DataView(buffer)\n\nTypes.isDataView(buffer) // -\u003e false\nTypes.isDataView(dv) // -\u003e true\n```\n\n### [isFloat32Array(val)](https://yaohaixiao.github.io/types.js/#method-isFloat32Array)\n\nisFloat32Array(val) 方法用来检测测试数据是否为 Float32Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Float32Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isFloat32Array() 方法\n// import isFloat32Array from '@yaohaixiao/types.js/isFloat32Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isFloat32Array(numbers) // -\u003e false\nTypes.isFloat32Array(new Array(32)) // -\u003e false\nTypes.isFloat32Array(args) // -\u003e false\nTypes.isFloat32Array(new Float32Array()) // -\u003e true\n```\n\n### [isFloat64Array(val)](https://yaohaixiao.github.io/types.js/#method-isFloat64Array)\n\nisFloat64Array(val) 方法用来检测测试数据是否为 Float64Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Float64Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isFloat64Array() 方法\n// import isFloat64Array from '@yaohaixiao/types.js/isFloat64Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isFloat64Array(numbers) // -\u003e false\nTypes.isFloat64Array(new Array(32)) // -\u003e false\nTypes.isFloat64Array(args) // -\u003e false\nTypes.isFloat64Array(new Float64Array()) // -\u003e true\n```\n\n### [isInt8Array(val)](https://yaohaixiao.github.io/types.js/#method-isInt8Array)\n\nisInt8Array(val) 方法用来检测测试数据是否为 Int8Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Int8Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isInt8Array() 方法\n// import isInt8Array from '@yaohaixiao/types.js/isInt8Array'\n\nTypes.isInt8Array([]) // -\u003e false\nTypes.isInt8Array(new Array(8)) // -\u003e false\nTypes.isInt8Array(new Int8Array([])) // -\u003e true\n```\n\n### [isInt16Array(val)](https://yaohaixiao.github.io/types.js/#method-isInt16Array)\n\nisInt16Array(val) 方法用来检测测试数据是否为 Int16Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Int16Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isInt16Array() 方法\n// import isInt16Array from '@yaohaixiao/types.js/isInt16Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isInt16Array(numbers) // -\u003e false\nTypes.isInt16Array(new Array(16)) // -\u003e false\nTypes.isInt16Array(args) // -\u003e false\nTypes.isInt16Array(new Int16Array()) // -\u003e true\n```\n\n### [isInt32Array(val)](https://yaohaixiao.github.io/types.js/#method-isInt32Array)\n\nisInt32Array(val) 方法用来检测测试数据是否为 Int32Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\ntrue - 表示检测数据是 Int32Array 类型，false 则表示不是。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isInt32Array() 方法\n// import isInt32Array from '@yaohaixiao/types.js/isInt32Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isInt32Array(numbers) // -\u003e false\nTypes.isInt32Array(new Array(32)) // -\u003e false\nTypes.isInt32Array(args) // -\u003e false\nTypes.isInt32Array(new Int32Array()) // -\u003e true\n```\n\n### [isUint8Array(val)](https://yaohaixiao.github.io/types.js/#method-isUint8Array)\n\nisUint8Array(val) 方法用来检测测试数据是否为 Uint8Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Uint8Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUint8Array() 方法\n// import isUint8Array from '@yaohaixiao/types.js/isUint8Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isUint8Array(numbers) // -\u003e false\nTypes.isUint8Array(new Array(32)) // -\u003e false\nTypes.isUint8Array(args) // -\u003e false\nTypes.isUint8Array(new Uint8Array()) // -\u003e true\n```\n\n### [isUint8ClampedArray(val)](https://yaohaixiao.github.io/types.js/#method-isUint8ClampedArray)\n\nisUint8ClampedArray(val) 方法用来检测测试数据是否为 Uint8ClampedArray 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Uint8ClampedArray 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUint8ClampedArray() 方法\n// import isUint8ClampedArray from '@yaohaixiao/types.js/isUint8ClampedArray'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isUint8ClampedArray(numbers) // -\u003e false\nTypes.isUint8ClampedArray(new Array(32)) // -\u003e false\nTypes.isUint8ClampedArray(args) // -\u003e false\nTypes.isUint8ClampedArray(new Uint8ClampedArray()) // -\u003e true\n```\n\n### [isUint16Array(val)](https://yaohaixiao.github.io/types.js/#method-isUint16Array)\n\nisUint16Array(val) 方法用来检测测试数据是否为 Uint16Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Uint16Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUint16Array() 方法\n// import isUint16Array from '@yaohaixiao/types.js/isUint16Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isUint16Array(numbers) // -\u003e false\nTypes.isUint16Array(new Array(32)) // -\u003e false\nTypes.isUint16Array(args) // -\u003e false\nTypes.isUint16Array(new Uint16Array()) // -\u003e true\n```\n\n### [isUint32Array(val)](https://yaohaixiao.github.io/types.js/#method-isUint32Array)\n\nisUint32Array(val) 方法用来检测测试数据是否为 Uint32Array 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Uint32Array 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUint32Array() 方法\n// import isUint32Array from '@yaohaixiao/types.js/isUint32Array'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(a){\n  args = arguments\n  return a === 'test'\n}\n\ntest()\n\nTypes.isUint32Array(numbers) // -\u003e false\nTypes.isUint32Array(new Array(32)) // -\u003e false\nTypes.isUint32Array(args) // -\u003e false\nTypes.isUint32Array(new Uint32Array()) // -\u003e true\n```\n\n### [isTypedArray(val)](https://yaohaixiao.github.io/types.js/#method-isTypedArray)\n\nisTypedArray(val) 方法用来检测测试数据是否为 TypedArray 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 TypedArray 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isTypedArray() 方法\n// import isTypedArray from '@yaohaixiao/types.js/isTypedArray'\n\nconst numbers = [ 2, 4 ]\nlet args\n\nfunction test(str) {\n  args = arguments\n  return str\n}\n\ntest('str')\n\nTypes.isTypedArray( args ) // -\u003e false\nTypes.isTypedArray( numbers ) // -\u003e false\nTypes.isTypedArray( new Array() ) // -\u003e false\n\nTypes.isTypedArray(new Int8Array([])) // -\u003e true\nTypes.isTypedArray(new Int16Array([])) // -\u003e true\nTypes.isTypedArray(new Int32Array([])) // -\u003e true\n\nTypes.isTypedArray(new Uint8ClampedArray([])) // -\u003e true\nTypes.isTypedArray(new Uint8Array([])) // -\u003e true\nTypes.isTypedArray(new Uint16Array([])) // -\u003e true\nTypes.isTypedArray(new Uint32Array([])) // -\u003e true\n\nTypes.isTypedArray(new Float32Array([])) // -\u003e true\nTypes.isTypedArray(new Float64Array([])) // -\u003e true\n\nTypes.isTypedArray(new BigInt64Array(42)) // -\u003e true\nTypes.isTypedArray(new BigUint64Array(42)) // -\u003e true\n```\n\n### [Element](https://yaohaixiao.github.io/types.js/#heading-88)\n\ntypes.js 提供以下方法来检测 DOM 相关的数据类型。\n\n### [isDOM(val)](https://yaohaixiao.github.io/types.js/#method-isDOM)\n\nisDOM(val) 方法用来检测测试数据是否为 DOM 类型数据：DOM 节点，TextNode，NodeList 和 DocumentFragment）。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 DOM 类型数据，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isDOM() 方法\n// import isDOM from '@yaohaixiao/types.js/isDOM'\n\nconst $list = document.getElementById('list')\nconst $fragment = document.createDocumentFragment()\nconst $items = document.querySelectorAll('.item')\nconst $text = document.createTextNode('text')\n\nTypes.is($list) // -\u003e 'element'\nTypes.isDOM($list) // -\u003e true\n\nTypes.is($fragment) // -\u003e 'fragment'\nTypes.isDOM($fragment) // -\u003e true\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isDOM($items) // -\u003e true\n\nTypes.is($text) // -\u003e 'text'\nTypes.isDOM($text) // -\u003e true\n```\n\n### [isElement(val)](https://yaohaixiao.github.io/types.js/#method-isElement)\n\nisElement(val) 方法用来检测测试数据的数据类型是否为 HTML 元素节点。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 为 HTML 元素节点返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isElement() 方法\n// import isElement from '@yaohaixiao/types.js/isElement'\n\nconst $list = document.getElementById('list')\nconst $div = document.createElement('div')\nconst $text = document.createTextNode('text')\nconst $items = document.querySelectorAll('.item')\nconst $fragment = document.createDocumentFragment()\nconst svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\n\nTypes.isElement(svgElement) // -\u003e true\nTypes.isHTMLElement(svgElement) // -\u003e false\n\nTypes.is($list) // -\u003e 'element'\nTypes.isElement($list) // -\u003e true\n\nTypes.is($div) // -\u003e 'element'\nTypes.isElement($div) // -\u003e true\n\nTypes.is($text) // -\u003e 'text'\nTypes.isElement($text) // -\u003e false\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isElement($items) // -\u003e false\n\nTypes.is($fragment) // -\u003e 'collection'\nTypes.isElement($fragment) // -\u003e false\n```\n\n### [isFragment(val)](https://yaohaixiao.github.io/types.js/#method-isFragment)\n\nisFragment(val) 方法用来检测测试数据是否为 DocumentFragment 文档碎片。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 DocumentFragment 文档碎片，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isFragment() 方法\n// import isFragment from '@yaohaixiao/types.js/isFragment'\n\nconst $list = document.getElementById('list')\nconst $div = document.createElement('div')\nconst $text = document.createTextNode('text')\nconst $items = document.querySelectorAll('.item')\nconst $fragment = document.createDocumentFragment()\n\nTypes.is($list) // -\u003e 'element'\nTypes.isElement($list) // -\u003e true\nTypes.isFragment($list) // -\u003e false\n\nTypes.is($div) // -\u003e 'element'\nTypes.isElement($div) // -\u003e true\nTypes.isFragment($div) // -\u003e false\n\nTypes.is($text) // -\u003e 'text'\nTypes.isElement($text) // -\u003e false\nTypes.isFragment($text) // -\u003e false\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isElement($items) // -\u003e false\nTypes.isFragment($items) // -\u003e false\n\nTypes.is($fragment) // -\u003e 'fragment'\nTypes.isElement($fragment) // -\u003e false\nTypes.isFragment($items) // -\u003e true\n\nTypes.isElement([]) // -\u003e false\n```\n\n### [isHTMLCollection(val)](https://yaohaixiao.github.io/types.js/#method-isHTMLCollection)\n\nisHTMLCollection(val) 方法用来检测数据的是否为 HTMLNodeList 对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 HTMLNodeList 对象返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isHTMLCollection() 方法\n// import isHTMLCollection from '@yaohaixiao/types.js/isHTMLCollection'\n\nconst $list = document.getElementById('list')\nconst $div = document.createElement('div')\nconst $text = document.createTextNode('text')\nconst $items = document.querySelectorAll('.item')\nconst $fragment = document.createDocumentFragment()\n\nTypes.is($list) // -\u003e 'element'\nTypes.isElement($list) // -\u003e true\nTypes.isHTMLCollection($list) // -\u003e false\n\nTypes.is($div) // -\u003e 'element'\nTypes.isElement($div) // -\u003e true\nTypes.isHTMLCollection($div) // -\u003e false\n\nTypes.is($text) // -\u003e 'text'\nTypes.isElement($text) // -\u003e false\nTypes.isHTMLCollection($text) // -\u003e false\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isElement($items) // -\u003e false\nTypes.isHTMLCollection($items) // -\u003e true\n\nTypes.is($fragment) // -\u003e 'fragment'\nTypes.isElement($fragment) // -\u003e false\nTypes.isHTMLCollection($items) // -\u003e false\n```\n\n### [isHTMLElement(val)](https://yaohaixiao.github.io/types.js/#method-isHTMLElement)\n\nisHTMLElement(val) 方法用来检测测试数据的数据类型是否为 HTML 元素节点。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 为 HTML 元素节点，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isHTMLElement() 方法\n// import isHTMLElement from '@yaohaixiao/types.js/isHTMLElement'\n\nconst $list = document.getElementById('list')\nconst $div = document.createElement('div')\nconst $text = document.createTextNode('text')\nconst $items = document.querySelectorAll('.item')\nconst $fragment = document.createDocumentFragment()\n\nTypes.is($list) // -\u003e 'element'\nTypes.isHTMLElement($list) // -\u003e true\n\nTypes.is($div) // -\u003e 'element'\nTypes.isHTMLElement($div) // -\u003e true\n\nTypes.is($text) // -\u003e 'text'\nTypes.isHTMLElement($text) // -\u003e false\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isHTMLElement($items) // -\u003e false\n\nTypes.is($fragment) // -\u003e 'collection'\nTypes.isHTMLElement($fragment) // -\u003e false\n```\n\n### [isNode(val)](https://yaohaixiao.github.io/types.js/#method-isNode)\n\nisNode(val) 方法用来检测测试数据是否为 Node 实例。\n\n注意：在 JavaScript 的 DOM（文档对象模型）中，Node、Element 和 HTMLElement 是非常重要的概念，它们代表了不同层次的抽象，用于描述和操作 HTML 文档中的各种元素和节点。以下是它们之间的区别：\n\n#### 继承关系\n\n它们之间存在着明确的继承层次结构，具体如下：\n\n- Node 是所有节点类型的基类，它处于继承层次的最顶层；\n- Element 继承自 Node，是所有元素节点的基类；\n- HTMLElement 继承自 Element，专门用于表示 HTML 元素；\n\n因此，isNode() 方法可以检测任何类型的 Node 元素。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Node 实例，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isNode() 方法\n// import isNode from '@yaohaixiao/types.js/isNode'\n\nconst div = document.createElement('div')\nTypes.isNode(div) // -\u003e true\nTypes.isElement(div) // -\u003e true\nTypes.isHTMLElement(div) // -\u003e true\n\nconst text = document.createTextNode('text')\nTypes.isNode(text) // -\u003e true\nTypes.isElement(text) // -\u003e false\nTypes.isHTMLElement(text) // -\u003e false\n\nconst fragment = document.createDocumentFragment()\nTypes.isNode(fragment) // -\u003e true\nTypes.isElement(fragment) // -\u003e false\nTypes.isHTMLElement(fragment) // -\u003e false\n\nconst svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\nTypes.isNode(svgElement) // -\u003e true\nTypes.isElement(svgElement) // -\u003e true\nTypes.isHTMLElement(svgElement) // -\u003e false\n\nisNode({}) // -\u003e false\n```\n\n### [isTextNode(val)](https://yaohaixiao.github.io/types.js/#method-isTextNode)\n\nisTextNode(val) 方法用来检测测试数据是否为文本节点。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是文本节点返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isTextNode() 方法\n// import isTextNode from '@yaohaixiao/types.js/isTextNode'\n\nconst $list = document.getElementById('list')\nconst $div = document.createElement('div')\nconst $fragment = document.createDocumentFragment()\nconst $items = document.querySelectorAll('.item')\nconst $text = document.createTextNode('text')\n\nTypes.is($list) // -\u003e 'element'\nTypes.isElement($list) // -\u003e true\nTypes.isTextNode($list) // -\u003e false\n\nTypes.is($div) // -\u003e 'element'\nTypes.isElement($div) // -\u003e true\nTypes.isTextNode($div) // -\u003e false\n\nTypes.is($fragment) // -\u003e 'fragment'\nTypes.isFragment($fragment) // -\u003e true\nTypes.isTextNode($fragment) // -\u003e false\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isHTMLCollection($items) // -\u003e true\nTypes.isTextNode($items) // -\u003e false\n\nTypes.is($text) // -\u003e 'collection'\nTypes.isElement($text) // -\u003e false\nTypes.isTextNode($text) // -\u003e true\n```\n\n### [isShadowRoot(val)](https://yaohaixiao.github.io/types.js/#method-isShadowRoot)\n\nisShadowRoot(val) 方法用来检测测试数据是否为 ShadowRoot 对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 ShadowRoot 对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isShadowRoot() 方法\n// import isShadowRoot from '@yaohaixiao/types.js/isShadowRoot'\n\n// 测试 ShadowRoot 未定义的情况\nconst originalShadowRoot = global.ShadowRoot\n\n// 临时将 ShadowRoot 设置为 undefined\nglobal.ShadowRoot = undefined\nTypes.isShadowRoot({}) // -\u003e false\n\n// 恢复原始的 ShadowRoot\nglobal.ShadowRoot = originalShadowRoot\n\n// 测试传入真正的 ShadowRoot 实例\nconst div = document.createElement('div')\nconst shadowRoot = div.attachShadow({ mode: 'open' })\n\nTypes.isShadowRoot(shadowRoot) // -\u003e true\n\n// 测试传入非 ShadowRoot 实例\nTypes.isShadowRoot({}) // -\u003e false\n```\n\n### [isTextNode(val)](https://yaohaixiao.github.io/types.js/#method-isTextNode)\n\nisTextNode(val) 方法用来检测测试数据是否为 HTMLTextNode (文本节点)类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 HTMLTextNode (文本节点)类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isTextNode() 方法\n// import isTextNode from '@yaohaixiao/types.js/isTextNode'\n\nconst $list = document.getElementById('list')\nconst $div = document.createElement('div')\nconst $fragment = document.createDocumentFragment()\nconst $items = document.querySelectorAll('.item')\nconst $text = document.createTextNode('text')\n\nTypes.is($list) // -\u003e 'element'\nTypes.isElement($list) // -\u003e true\nTypes.isTextNode($list) // -\u003e false\n\nTypes.is($div) // -\u003e 'element'\nTypes.isElement($div) // -\u003e true\nTypes.isTextNode($div) // -\u003e false\n\nTypes.is($fragment) // -\u003e 'fragment'\nTypes.isFragment($fragment) // -\u003e true\nTypes.isTextNode($fragment) // -\u003e false\n\nTypes.is($items) // -\u003e 'collection'\nTypes.isHTMLCollection($items) // -\u003e true\nTypes.isTextNode($items) // -\u003e false\n\nTypes.is($text) // -\u003e 'collection'\nTypes.isElement($text) // -\u003e false\nTypes.isTextNode($text) // -\u003e true\n```\n\n### [isVNode(val)](https://yaohaixiao.github.io/types.js/#method-isVNode)\n\nisVNode(val) 方法用来检测测试数据是否为 VNode (VUE虚拟节点)类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 VNode (VUE虚拟节点)类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\n\u0026lt;template\u0026gt;\n  \u0026lt;dev-header ref=\"header\"\u0026gt;\u0026lt;/dev-header\u0026gt;\n\u0026lt;/template\u0026gt;\n\n\u0026lt;script\u0026gt;\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isVNode() 方法\n// import isVNode from '@yaohaixiao/types.js/isVNode'\n\nexport default {\n  name: 'PageHeader',\n  mounted() {\n    const $header = this.$refs.header\n\n    Types.isVNode($header) // -\u003e true\n  }\n}\n\u0026lt;/script\u0026gt;\n```\n\n### [isWindow(val)](https://yaohaixiao.github.io/types.js/#method-isWindow)\n\nisWindow(val) 方法用来检测测试数据是否为 Window 对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Window 对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isWindow() 方法\n// import isWindow from '@yaohaixiao/types.js/isWindow'\n\nconst $list = document.getElementById('list')\n\nTypes.is($list) // -\u003e 'element'\nTypes.isWindow($list) // -\u003e false\n\nTypes.isWindow(window) // -\u003e true\n\nconst nonWindowObject = {\n  // 模拟部分 Window 对象的属性，但不完整\n  document: {},\n  location: {},\n  // 缺少 alert 和 setInterval 属性\n}\n\nTypes.isWindow(nonWindowObject) // -\u003e false\n\nTypes.isWindow(null) // -\u003e false\n```\n\n\n### [Function](https://yaohaixiao.github.io/types.js/#heading-56)\n\ntypes.js 提供以下方法来检测 Function 相关的数据类型。\n\n### [isConstructor(val)](https://yaohaixiao.github.io/types.js/#method-isConstructor)\n\nisConstructor(val) 方法用来检测测试函数是否为构造函数\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Constructor 构造函数，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isConstructor() 方法\n// import isConstructor from '@yaohaixiao/types.js/isConstructor'\n\nconst fn = function(){}\nconst ff = class {}\n\nTypes.isConstructor(fn) // -\u003e true\nTypes.isConstructor(ff) // -\u003e true\nTypes.isConstructor(console.log) // -\u003e false\n\nTypes.isConstructor(Math) // -\u003e false\nTypes.isConstructor(Boolean) // -\u003e true\nTypes.isConstructor(Array) // -\u003e true\nTypes.isConstructor(Function) // -\u003e true\nTypes.isConstructor(Date) // -\u003e true\nTypes.isConstructor(RegExp) // -\u003e true\nTypes.isConstructor(Object) // -\u003e true\n```\n\n### [isFunction(val)](https://yaohaixiao.github.io/types.js/#method-isFunction)\n\nisFunction(val) 方法用来检测测试数据是否为 Function 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Function 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isFunction() 方法\n// import isFunction from '@yaohaixiao/types.js/isFunction'\n\nconst blank = () =\u003e {}\nconst fn = new Fucntion()\n\nfunction empty(){}\n\nTypes.isFunction(empty) // -\u003e true\nTypes.isFunction(blank) // -\u003e true\nTypes.isFunction(fn) // -\u003e true\nTypes.isFunction(parseInt) // -\u003e true\nTypes.isFunction(Array) // -\u003e true\nTypes.isFunction(Boolean) // -\u003e true\nTypes.isFunction(Date) // -\u003e true\nTypes.isFunction(Number) // -\u003e true\nTypes.isFunction(Object) // -\u003e true\nTypes.isFunction(RegExp) // -\u003e true\nTypes.isFunction(String) // -\u003e true\n\nTypes.isFunction(Math) // -\u003e false\nTypes.isFunction(console) // -\u003e false\n```\n\n### [isNativeFunction(val)](https://yaohaixiao.github.io/types.js/#method-isNativeFunction)\n\nisNativeFunction(val) 方法用来检测测试函数是否为系统内置函数\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要测试的函数。\n\n#### Returns\n\nType: `Boolean`\n\nval 是系统内置函数，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isNativeFunction() 方法\n// import isNativeFunction from '@yaohaixiao/types.js/isNativeFunction'\n\nconst fn = function(){}\nconst ff = class {}\nconst f = () =\u003e console.log('no constructable')\n\nTypes.isNativeFunction(fn) // -\u003e false\nTypes.isNativeFunction(ff) // -\u003e false\nTypes.isNativeFunction(f) // -\u003e false\n\nTypes.isNativeFunction(Math) // -\u003e true\nTypes.isNativeFunction(Boolean) // -\u003e true\nTypes.isNativeFunction(Array) // -\u003e true\nTypes.isNativeFunction(Function) // -\u003e true\nTypes.isNativeFunction(Date) // -\u003e true\nTypes.isNativeFunction(RegExp) // -\u003e true\nTypes.isNativeFunction(Object) // -\u003e true\n```\n\n### [isPrototype(val)](https://yaohaixiao.github.io/types.js/#method-isPrototype)\n\nisPrototype(val) 方法用来检测测试数据是否为构造函数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Prototype 对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPrototype() 方法\n// import isPrototype from '@yaohaixiao/types.js/isPrototype'\n\nconst Yao= {\n  age: 40,\n  career: 'programmer'\n}\n\nconst Programmer = function(name, age) {\n  this.name = name\n  this.age = age\n  this.isDead = false\n\n  return this\n}\n\nProgrammer.prototype.career = 'programmer'\nProgrammer.prototype.getWorkDone = function() {\n  this.isDead = true\n  return this\n}\n\nTypes.isPrototype(null) // =\u003e false\n\nTypes.isPrototype(Object) // =\u003e false\nTypes.isPrototype(Object.prototype) // =\u003e true\n\nTypes.isPrototype(Programmer) // =\u003e false\nTypes.isPrototype(Yao.__proto__) // =\u003e true\n```\n\n\n### [Keyed Collections](https://yaohaixiao.github.io/types.js/#heading-14)\n\ntypes.js 提供以下方法来检测 Keyed Collections 相关的数据类型。\n\n### [isMap(val)](https://yaohaixiao.github.io/types.js/#method-isMap)\n\nisMap(val) 方法用来检测测试数据是否为 Map 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Map 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isMap() 方法\n// import isMap from '@yaohaixiao/types.js/isMap'\n\nconst map = new Map([\n    ['name', 'Robert'],\n    ['Gender', 'Male']\n])\n\nTypes.is(map) // -\u003e 'map'\nTypes.isMap(map) // -\u003e true\n\nTypes.isMap(['name', 'Robert']) // -\u003e false\n```\n\n### [isSet(val)](https://yaohaixiao.github.io/types.js/#method-isSet)\n\nisSet(val) 方法用来检测测试数据是否为 isSet 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 isSet 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isSet() 方法\n// import isSet from '@yaohaixiao/types.js/isSet'\n\nconst set = new Set([1, 2, 3, 4])\nconst arr = [1, 2, 3, 4]\n\nTypes.is(set) // -\u003e 'set'\nTypes.isSet(set) // -\u003e true\n\nTypes.is(arr) // -\u003e 'array'\nTypes.isSet(arr) // -\u003e false\n```\n\n### [isWeakMap(val)](https://yaohaixiao.github.io/types.js/#method-isWeakMap)\n\nisWeakMap(val) 方法用来检测测试数据是否为 WeakMap 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 WeakMap 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isWeakMap() 方法\n// import isWeakMap from '@yaohaixiao/types.js/isWeakMap'\n\nconst map = new Map([\n    ['name', 'Robert'],\n    ['Gender', 'Male']\n])\n\nconst weakmap = new WeakMap()\n\nweakmap.set({}, 37)\n\nTypes.is(weakmap) // -\u003e 'weakmap'\nTypes.isWeakMap(weakmap) // -\u003e true\n\nTypes.is(map) // -\u003e 'map'\nTypes.isWeakMap(map) // -\u003e false\n```\n\n\n### [isWeakSet(val)](https://yaohaixiao.github.io/types.js/#method-isWeakSet)\n\nisWeakSet(val) 方法用来检测测试数据是否为 WeakSet 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 WeakSet 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isWeakSet() 方法\n// import isWeakSet from '@yaohaixiao/types.js/isWeakSet'\n\nconst set = new Set([1, 2, 3, 4])\nconst weakset = new WeakSet()\n\nweakset.add({name: 'Robert'})\n\nTypes.is(set) // -\u003e 'set'\nTypes.isSet(set) // -\u003e true\nTypes.isWeakSet(set) // -\u003e false\n\nTypes.is(weakset) // -\u003e 'weakset'\nTypes.isSet(weakset) // -\u003e false\nTypes.isWeakSet(weakset) // -\u003e true\n```\n\n\n### [Number](https://yaohaixiao.github.io/types.js/#heading-60)\n\ntypes.js 提供以下方法来检测 Number 相关的数据类型。\n\n### [isEven(val)](https://yaohaixiao.github.io/types.js/#method-isEven)\n\nisEven(val) 方法用来检测测试数据的数据类型是否为偶数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是偶数，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isEven() 方法\n// import isEven from '@yaohaixiao/types.js/isEven'\n\nTypes.isEven(2) // -\u003e true\nTypes.isEven(3) // -\u003e false\nTypes.isEven(2.2) // -\u003e false\n```\n\n### [isFloat(val)](https://yaohaixiao.github.io/types.js/#method-isFloat)\n\nisFloat(val) 方法用来检测测试数据是否为浮点数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是浮点数，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isFloat() 方法\n// import isFloat from '@yaohaixiao/types.js/isFloat'\n\nTypes.isFloat(2.4) // -\u003e true\nTypes.isFloat(Number(\"3.4556645445E7\")) // -\u003e true\n\nTypes.isFloat(Number(\"3.4556645445E10\")) // -\u003e false\nTypes.isFloat(2.0) // -\u003e false\nTypes.isFloat(0xffffff) // -\u003e false\nTypes.isFloat(NaN) // -\u003e false\n```\n\n### [isInfinite(val)](https://yaohaixiao.github.io/types.js/#method-isInfinite)\n\nisInfinite(val) 方法用来检测测试数据的数据是正无穷或者负无穷。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是正无穷或者负无穷，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isInfinite() 方法\n// import isInfinite from '@yaohaixiao/types.js/isInfinite'\n\nTypes.isInfinite(2.4) // -\u003e false\n\nTypes.isInfinite(Infinity) // -\u003e true\nTypes.isInfinite(-Infinity) // -\u003e true\n```\n\n### [isInteger(val)](https://yaohaixiao.github.io/types.js/#method-isInteger)\n\nisInteger(val) 方法用来检测测试数据是否为整数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是整数返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isInteger() 方法\n// import isInteger from '@yaohaixiao/types.js/isInteger'\n\nTypes.isInteger(2.4) // -\u003e false\nTypes.isInteger(3.4234E3) // -\u003e false\nTypes.isInteger('1') // -\u003e false\nTypes.isInteger(Number('3.4556645445E7')) // -\u003e false\nTypes.isInteger(NaN) // -\u003e false\nTypes.isInteger(Infinity) // -\u003e false\nTypes.isInteger(-Infinity) // -\u003e false\n\nTypes.isInteger(2) // -\u003e true\nTypes.isInteger(2.0) // -\u003e true\nTypes.isInteger(3.4234E4) // -\u003e true\nTypes.isInteger(0xffffff) // -\u003e true\nTypes.isInteger(Number('1')) // -\u003e true\nTypes.isInteger(parseInt('1.0', 10)) // -\u003e true\nTypes.isInteger(Math.ceil(2.6)) // -\u003e true\n```\n\n### [isLength(val)](https://yaohaixiao.github.io/types.js/#method-isLength)\n\nisLength(val) 方法用来检测测试数据是否为有效 length 值。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是有效 length 值，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isInteger() 方法\n// import isInteger from '@yaohaixiao/types.js/isInteger'\n\nTypes.isInteger(2.4) // -\u003e false\nTypes.isInteger(3.4234E3) // -\u003e false\nTypes.isInteger('1') // -\u003e false\nTypes.isInteger(Number('3.4556645445E7')) // -\u003e false\nTypes.isInteger(NaN) // -\u003e false\nTypes.isInteger(Infinity) // -\u003e false\nTypes.isInteger(-Infinity) // -\u003e false\n\nTypes.isInteger(2) // -\u003e true\nTypes.isInteger(2.0) // -\u003e true\nTypes.isInteger(3.4234E4) // -\u003e true\nTypes.isInteger(0xffffff) // -\u003e true\nTypes.isInteger(Number('1')) // -\u003e true\nTypes.isInteger(parseInt('1.0', 10)) // -\u003e true\nTypes.isInteger(Math.ceil(2.6)) // -\u003e true\n```\n\n### [isNumeric(val)](https://yaohaixiao.github.io/types.js/#method-isNumeric)\n\nisNumeric(val) 方法用来检测测试数据是否是一个数字（只能是 number 类型或者 '123123' 这样的数字字符串）。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是一个数字，返回 true，否则返回false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isNumeric() 方法\n// import isNumeric from '@yaohaixiao/types.js/isNumeric'\n\nTypes.isNumeric(2) // -\u003e true\nTypes.isNumeric(2.4) // -\u003e true\nTypes.isNumeric(0xffffff) // -\u003e true\nTypes.isNumeric(3.1415926E8) // -\u003e true\nTypes.isNumeric('33') // -\u003e true\nTypes.isNumeric('0xffffff') // -\u003e true\n\nTypes.isNumeric(NaN) // -\u003e false\nTypes.isNumeric(Infinity) // -\u003e false\nTypes.isNumeric(-Infinity) // -\u003e false\n```\n\n### [isOdd(val)](https://yaohaixiao.github.io/types.js/#method-isOdd)\n\nisOdd(val) 方法用来检测测试数据的数据类型是否为奇数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是奇数，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isOdd() 方法\n// import isOdd from '@yaohaixiao/types.js/isOdd'\n\nTypes.isOdd(3) // -\u003e true\nTypes.isOdd(3.0) // -\u003e true\nTypes.isOdd(3.01E2) // -\u003e true\nTypes.isOdd(0x000011) // -\u003e true\n\nTypes.isOdd(2.0) // -\u003e false\nTypes.isOdd('2') // -\u003e false\nTypes.isOdd(3.01E3) // -\u003e false\nTypes.isOdd(0x000010) // -\u003e false\nTypes.isOdd(NaN) // -\u003e false\nTypes.isOdd(Infinity) // -\u003e false\n```\n\n### [isSafeInteger(val)](https://yaohaixiao.github.io/types.js/#method-isSafeInteger)\n\nisSafeInteger(val) 方法用来检测测试数据的(数值)是否为整数。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是安全的 Integer 值，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isSafeInteger() 方法\n// import isSafeInteger from '@yaohaixiao/types.js/isSafeInteger'\n\nisSafeInteger(3) // =\u003e true\n\nisSafeInteger(Number.MIN_VALUE) // =\u003e false\n\nisSafeInteger(Infinity) // =\u003e false\n\nisSafeInteger('3') // =\u003e false\n```\n\n### [Object](https://yaohaixiao.github.io/types.js/#heading-39)\n\ntypes.js 提供以下方法来检测 Object 相关的数据类型。\n\n### [isBinary(val)](https://yaohaixiao.github.io/types.js/#method-isBinary)\n\nisBinary(val) 方法用来检测测试数据是二进制（字符串）数据。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是二进制（字符串）数据，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUint16Array() 方法\n// import isBinary from '@yaohaixiao/types.js/isBinary'\n\nconst buffer = Buffer.alloc(15)\n\nTypes.isBinary('Z29vZA==') // -\u003e false\nTypes.isBinary(isArrayBuffer(8)) // -\u003e false\n\nTypes.is(buffer) // -\u003e 'uint8array'\nisBinary(buffer) // -\u003e true\nisBinary(buffer.toString()) // -\u003e true\n```\n\n### [isBuffer(val)](https://yaohaixiao.github.io/types.js/#method-isBuffer)\n\nisBuffer(val) 方法用来检测测试数据是否为 Buffer 类型（运行环境：Node.js）。\n\n注意：Node.js 中实现的 Buffer 对象，实际的数据格式是：Uint8Array 类型的数组。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Buffer 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBuffer() 方法\n// import isBuffer from '@yaohaixiao/types.js/isBuffer'\n\nconst buffer = Buffer.alloc(15)\n\nTypes.isBuffer(new ArrayBuffer(8)) // -\u003e false\nTypes.isBuffer(new Uint8Array(2)) // -\u003e false\n\nTypes.is(buffer) =\u003e 'uint8array'\nTypes.isBuffer(buffer) // -\u003e true\n```\n\n### [isDate(val)](https://yaohaixiao.github.io/types.js/#method-isDate)\n\nisDate(val) 方法用来检测测试数据是否为 Date 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Date 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isDate() 方法\n// import isDate from '@yaohaixiao/types.js/isDate'\n\nconst time = new Date()\n\nTypes.isDate(time) // -\u003e true\nTypes.isDate('2017-07-06') // -\u003e false\nTypes.isDate(time.getFullYear()) // -\u003e false\n```\n\n### [isEmptyObject(val)](https://yaohaixiao.github.io/types.js/#method-isEmptyObject)\n\nisEmptyObject(val) 方法用来检测测试数据是否为空（单体）对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是空（单体）对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isEmptyObject() 方法\n// import isEmptyObject from '@yaohaixiao/types.js/isEmptyObject'\n\nfunction Person(name,age){\n  this.name = name\n  this.age = age\n}\n\nTypes.isEmptyObject({}) // -\u003e true\nTypes.isEmptyObject([]) // true\nTypes.isEmptyObject(Person) // true\nTypes.isEmptyObject(new Object()) // true\nTypes.isEmptyObject(new Boolean()) // true\nTypes.isEmptyObject(new Array()) // true\nTypes.isEmptyObject(new Date('2017-12-11')) // true\nTypes.isEmptyObject(new RegExp('\\s+','ig')) // true\nTypes.isEmptyObject(new String()) // true\n\nTypes.isEmptyObject(new Function()) // false\nTypes.isEmptyObject(['']) // false\nTypes.isEmptyObject(null) // false\nTypes.isEmptyObject({name:'type.js'}) // -\u003e false\nTypes.isEmptyObject(new Person('yaohaixiao',30)) // false\n```\n\n### [isError(val)](https://yaohaixiao.github.io/types.js/#method-isError)\n\nisError(val) 方法用来检测测试数据是否为 Error 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Error 类型返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isError() 方法\n// import isError from '@yaohaixiao/types.js/isError'\n\nconst error = function Error(){}\n\nTypes.isError(new error()) // -\u003e false\nTypes.isError(new Error()) // -\u003e true\n```\n\n### [isHash(val)](https://yaohaixiao.github.io/types.js/#method-isHash)\n\nisHash(val) 方法用来检测测试数据是普通对象（它是方法 [isPlainObject](https://yaohaixiao.github.io/types.js/#isPlainObject) 的别名）。\n\n#### Since\n\n0.4.0\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是普通对象返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isHash() 方法\n// import isHash from '@yaohaixiao/types.js/isHash'\n\nlet udf\n\n// 基础类型\nTypes.isHash(2) // -\u003e false\nTypes.isHash('str') // -\u003e false\nTypes.isHash(false) // -\u003e false\nTypes.isHash(null) // -\u003e false\nTypes.isHash(udf) // -\u003e false\n\n// 引用类型\nTypes.isHash(new Function()) // -\u003e false\nTypes.isHash(function(){}) // -\u003e false\nTypes.isHash(() =\u003e {}) // -\u003e false\nTypes.isHash(class{}) // -\u003e false\n\nTypes.isHash(new class{}) // -\u003e true\nTypes.isHash({}) // -\u003e true\nTypes.isHash(Object.create(null)) // -\u003e true\nTypes.isHash(new Object()) // -\u003e true\nTypes.isHash([]) // -\u003e true\nTypes.isHash(/s+/ig) // -\u003e true\nTypes.isHash(new String()) // -\u003e true\nTypes.isHash(new Number()) // -\u003e true\nTypes.isHash(new Boolean()) // -\u003e true\nTypes.isHash(new Array()) // -\u003e true\nTypes.isHash(new Date()) // -\u003e true\n```\n\n### [isObject(val)](https://yaohaixiao.github.io/types.js/#method-isObject)\n\nisObject(val) 方法用来检测测试数据是否为对象。使用 isObject() 方法测试单体对象和函数都返回值都是 true。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 为对象返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isObject() 方法\n// import isObject from '@yaohaixiao/types.js/isObject'\n\nconst $list = document.getElementById('list')\n\n// True\nTypes.isObject({}) // =\u003e true\nTypes.isObject(Object) // =\u003e true\nTypes.isObject(new Object()) // =\u003e true\nTypes.isObject(Object.create(null)) // =\u003e true\nTypes.isObject([]) // =\u003e true\nTypes.isObject(() =\u003e {}) // =\u003e true\nTypes.isObject(class {}) // =\u003e true\nTypes.isObject($list) // =\u003e true\n\n// False\nTypes.isObject('null') // =\u003e false\nTypes.isObject(1) // =\u003e false\nTypes.isObject(false) // =\u003e false\nTypes.isObject(Symbol('ok')) // =\u003e false\n\n// 针对 null，type.js 认为不是一个有效对象\n// 以避免将 null 作为普通对象操作导致的错误\nTypes.isObject(null) // =\u003e false\n```\n\n### [isObjectLike(val)](https://yaohaixiao.github.io/types.js/#method-isObjectLike)\n\nisObjectLike(val) 方法用来检测测试数据是否为类似 Object 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是普通对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isObjectLike() 方法\n// import isObjectLike from '@yaohaixiao/types.js/isObjectLike'\n\n// True\nTypes.isObjectLike(function empty(){}) // -\u003e true\nTypes.isObjectLike({}) // -\u003e true\nTypes.isObjectLike(Object.create(null)) // -\u003e true\nTypes.isObjectLike(Object.create({})) // -\u003e true\nTypes.isObjectLike(new Function()) // -\u003e true\n\n// False\nTypes.isObjectLike([]) // -\u003e false\nTypes.isObjectLike(null) // -\u003e false\nTypes.isObjectLike(document.getElementById('wrap')) // -\u003e false\n```\n\n### [isPlainObject(val)](https://yaohaixiao.github.io/types.js/#method-isPlainObject)\n\nisPlainObject(val) 方法用来检测测试数据是否为普通对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是普通对象返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPlainObject() 方法\n// import isPlainObject from '@yaohaixiao/types.js/isPlainObject'\n\nlet udf\n\n// 基础类型\nTypes.isPlainObject(2) // -\u003e false\nTypes.isPlainObject('str') // -\u003e false\nTypes.isPlainObject(false) // -\u003e false\nTypes.isPlainObject(null) // -\u003e false\nTypes.isPlainObject(udf) // -\u003e false\n\n// 引用类型\nTypes.isPlainObject(new Function()) // -\u003e false\nTypes.isPlainObject(function(){}) // -\u003e false\nTypes.isPlainObject(() =\u003e {}) // -\u003e false\nTypes.isPlainObject(class{}) // -\u003e false\n\nTypes.isPlainObject(new class{}) // -\u003e true\nTypes.isPlainObject({}) // -\u003e true\nTypes.isPlainObject(Object.create(null)) // -\u003e true\nTypes.isPlainObject(new Object()) // -\u003e true\nTypes.isPlainObject([]) // -\u003e true\nTypes.isPlainObject(/s+/ig) // -\u003e true\nTypes.isPlainObject(new String()) // -\u003e true\nTypes.isPlainObject(new Number()) // -\u003e true\nTypes.isPlainObject(new Boolean()) // -\u003e true\nTypes.isPlainObject(new Array()) // -\u003e true\nTypes.isPlainObject(new Date()) // -\u003e true\n```\n\n### [isPromise(val)](https://yaohaixiao.github.io/types.js/#method-isPromise)\n\nisPromise(val) 方法用来检测测试数据是否为 Promise 对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Promise 对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPromise() 方法\n// import isPromise from '@yaohaixiao/types.js/isPromise'\n\nconst resolve = Promise.resolve\nconst reject = Promise.reject\nconst request = new Promise((resolve, reject) =\u003e {})\nlet val\n\n// 非对象参数\nTypes.isPromise(null) // =\u003e false\nTypes.isPromise(val) // =\u003e false\nTypes.isPromise('') // =\u003e false\nTypes.isPromise(12) // =\u003e false\nTypes.isPromise(false) // =\u003e false\nTypes.isPromise(BigInt(12)) // =\u003e false\nTypes.isPromise(Symbol('prop')) // =\u003e false\n\n\n// 对象参数\nTypes.isPromise([]) // =\u003e false\nTypes.isPromise({}) // =\u003e false\nTypes.isPromise(class {}) // =\u003e false\nTypes.isPromise(() =\u003e {}) // =\u003e false\n\nTypes.isPromise(request) // =\u003e true\nTypes.isPromise(Promise.all([resolve, resolve]) // =\u003e true\nTypes.isPromise(Promise.any([resolve, reject]) // =\u003e true\nTypes.isPromise(resolve) // =\u003e true\n```\n\n### [isPrototype(val)](https://yaohaixiao.github.io/types.js/#method-isPrototype)\n\nisPrototype(val) 方法用来检测测试数据是否为 Prototype 对象。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Prototype 对象，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPrototype() 方法\n// import isPrototype from '@yaohaixiao/types.js/isPrototype'\n\nconst Yao= {\n  age: 40,\n  career: 'programmer'\n}\n\nconst Programmer = function(name, age) {\n  this.name = name\n  this.age = age\n  this.isDead = false\n\n  return this\n}\n\nProgrammer.prototype.career = 'programmer'\nProgrammer.prototype.getWorkDone = function() {\n  this.isDead = true\n  return this\n}\n\nTypes.isPrototype(null) // =\u003e false\n\nTypes.isPrototype(Object) // =\u003e false\nTypes.isPrototype(Object.prototype) // =\u003e true\n\nTypes.isPrototype(Programmer) // =\u003e false\nTypes.isPrototype(Yao.__proto__) // =\u003e true\n```\n\n\n### [isRegExp(val)](https://yaohaixiao.github.io/types.js/#method-isRegExp)\n\nisRegExp(val) 方法用来检测测试数据是否为正则表达式。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是正则表达式，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isRegExp() 方法\n// import isRegExp from '@yaohaixiao/types.js/isRegExp'\n\nconst patternOne = new RegExp('\\\\s+','ig')\nconst patternTwo = /\\s+/ig\nconst patternStr = '/\\\\s+/ig'\n\nTypes.is(patternOne) // -\u003e 'regexp'\nTypes.isRegExp(patternOne) // -\u003e true\n\nTypes.is(patternTwo) // -\u003e 'regexp'\nTypes.isRegExp(patternTwo) // -\u003e true\n\nTypes.is(patternStr) // -\u003e 'string'\nTypes.isRegExp(patternStr) // -\u003e false\n```\n\n### [isStream(val)](https://yaohaixiao.github.io/types.js/#method-isStream)\n\nisStream(val) 方法用来检测测试数据是否为 Stream 类型。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n##### options\n\nType: `Object`\nDefault: `{}`\n\n这是一个解构赋值的参数。它是一个对象，默认值为空对象 {}。 对象中有一个属性 checkOpen，其默认值为 true。checkOpen 用于控制是否检查流的打开状态（即可读或可写状态）。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Stream 类型，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isStream() 方法\n// import isStream from '@yaohaixiao/types.js/isStream'\n\n// 测试流对象\nconst validStream = {\n  writable: true,\n  pipe: () =\u003e {}\n}\n\nTypes.isStream(validStream) // -\u003e true\n\n// 测试非流对象\nconst nonStream = {\n  notAStreamProperty: 'value'\n}\n\nTypes.isStream(nonStream) // -\u003e false\n\n// 测试 null\nTypes.isStream(null) // -\u003e false\n\n// 测试 checkOpen 为 false 的情况\nconst obj = {\n  pipe: () =\u003e {}\n}\n\nTypes.isStream(obj, { checkOpen: false }) // -\u003e true\n```\n\n### [isXML(val)](https://yaohaixiao.github.io/types.js/#method-isXML)\n\nisXML(val) 方法返回检测数据的是否为 XML 格式数据。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 为 XML 返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isXML() 方法\n// import isXML from '@yaohaixiao/types.js/isXML'\n\nconst jsdom = require(\"jsdom\")\nconst { JSDOM } = jsdom\nconst DOMParser = require('xmldom').DOMParser\nconst HTML = new JSDOM('\u003chtml\u003e\u003chead\u003e\u003ctitle\u003eisXML\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\u003cp\u003ep1\u003c/p\u003e\u003cp\u003ep2\u003c/p\u003e\u003cp\u003ep3\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e')\nconst XML = new DOMParser().parseFromString(\n    '\u003cxml xmlns=\"a\" xmlns:c=\"./lite\"\u003e\\n'+\n        '\\t\u003cchild\u003etest\u003c/child\u003e\\n'+\n        '\\t\u003cchild\u003e\u003c/child\u003e\\n'+\n        '\\t\u003cchild/\u003e\\n'+\n    '\u003c/xml\u003e','text/xml')\n\nTypes.isXML(XML) // -\u003e true\nTypes.isXML(HTML) // -\u003e false\n```\n\n\n### [String](https://yaohaixiao.github.io/types.js/#heading-70)\n\ntypes.js 提供以下方法来检测 String 相关的数据类型。\n\n### [isAlpha(val)](https://yaohaixiao.github.io/types.js/#method-isAlpha)\n\nisAlpha(val) 方法用来检测测试数据是否仅包含英文字符。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是仅包含英文字符，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isAlpha() 方法\n// import isAlpha from '@yaohaixiao/types.js/isAlpha'\n\n// String 类型\nTypes.isAlpha('aaa') // -\u003e true\nTypes.isAlpha('good') // -\u003e true\n\nTypes.isAlpha('ok!') // -\u003e false\nTypes.isAlpha('is alpha') // -\u003e false\n\n// 非 String 类型\nTypes.isAlpha([]) // -\u003e false\nTypes.isAlpha(null) // -\u003e false\n```\n\n### [isBase64(val)](https://yaohaixiao.github.io/types.js/#method-isBase64)\n\nisBase64(val) 方法用来检测测试数据是否为一个基于 base64 编码的字符串。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 base64 编码的字符串返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBase64() 方法\n// import isBase64 from '@yaohaixiao/types.js/isBase64'\n\nTypes.isBase64('Z29vZA==') // -\u003e true\nTypes.isBase64('aXNCYXNlNjQ=2') // -\u003e false\n```\n\n### [isBlank(val)](https://yaohaixiao.github.io/types.js/#method-isBlank)\n\nisBlank(val) 方法用来检测测试数据是否只包空格。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 只包含空格返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isBlank() 方法\n// import isBlank from '@yaohaixiao/types.js/isBlank'\n\nTypes.isBlank('  ') // -\u003e true\nTypes.isBlank(new String()) // -\u003e false\nTypes.isBlank('') // -\u003e true\n```\n\n### [isChinese(val, includePunctuation)](https://yaohaixiao.github.io/types.js/#method-isChinese)\n\nisChinese(val, includePunctuation) 方法用来检测测试数据(字符串)是否为中文字符。\n\nWiki 介绍中文字符（Unified Ideographs）包含以下内容：\n\n1. 中文汉字\n2. 象形文字扩展 A-H\n3. 兼容象形文字符\n4. 兼容表意文字增补字符\n5. 中文标点符号\n6. 兼容标点符号\n\n其中：\n\n- 兼容象形文字符：[0xf900, 0xfaff];\n- 兼容表意文字增补字符：[0x2f800, 0x2fa1f];\n- 只是看上去像汉字，因此在 isChinese() 方法中没有纳入到汉字字符。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n##### val\n\nType: `Boolean`\n\n（可选）是否包含标点符号：默认值：true\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 Chinese 中文字符，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isChinese() 方法\n// import isChinese from '@yaohaixiao/types.js/isChinese'\n\nlet chinese\n\n// 非字符串\nTypes.isChinese(null) // -\u003e false\nTypes.isChinese(chinese) // -\u003e false\nTypes.isChinese({}) // -\u003e false\nTypes.isChinese([]) // -\u003e false\nTypes.isChinese(Symbol('symbol')) // -\u003e false\n\n// Ascii 字符\nTypes.isChinese(12) // -\u003e false\nTypes.isChinese('chinese') // -\u003e false\nTypes.isChinese('+=*/') // -\u003e false\n\n// 汉字字符\nTypes.isChinese('汉字字符：尅靈') // -\u003e true\nTypes.isChinese('扩展字符：㐥𠁜𪝹𫞺𫡡𭀔𭍓') // -\u003e true\n\n// 标点符号\nTypes.isChinese('标点符号：。，、；：×·—…（）『』【】《》？！‘’“”～') // -\u003e true\nTypes.isChinese('兼容标点符号：︰︱︲︳︴︵︶︷︸︹︺︻︼︽︾︿﹀﹁﹂﹃﹄﹅﹆﹇﹈﹉﹊﹋﹌﹍﹎﹏') // -\u003e true\n\n// 不包含标点符号，则以下检测无法通过\nTypes.isChinese('标点符号：。，、；：×·—…（）『』【】《》？！‘’“”～', false) // -\u003e false\n```\n\n### [isEmail(val)](https://yaohaixiao.github.io/types.js/#method-isEmail)\n\nisEmail(val) 方法用来检测测试数据是否为合法的 Email 格式。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是正确 Email 格式字符串，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isEmail() 方法\n// import isEmail from '@yaohaixiao/types.js/isEmail'\n\n// True\nTypes.isEmail('yaohaixiao@gmail.com') // =\u003e true\nTypes.isEmail('yaohaixiao@gmail.c') // =\u003e true\nTypes.isEmail('haixiao-yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao_yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao\u0026yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao~yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao+yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao^yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao%yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao$yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao.yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao/yao@gmail.com') // =\u003e true\nTypes.isEmail('haixiao#yao@gmail.com') // =\u003e true\nTypes.isEmail('yao{haixiao@gmail.com') // =\u003e true\nTypes.isEmail('yao|haixiao@gmail.com') // =\u003e true\nTypes.isEmail('yao}haixiao@gmail.com') // =\u003e true\n\n// False\nTypes.isEmail('yaohaixiao#gmail.com') // =\u003e false\nTypes.isEmail('yao\\haixiao@gmail.com') // =\u003e false\nTypes.isEmail('yao[haixiao@gmail.com') // =\u003e false\n```\n\n\n### [isGuid(val)](https://yaohaixiao.github.io/types.js/#method-isGuid)\n\nisGuid(val) 方法用来检测测试数据是否为合法的 UUID 字符串。\n\nAlias: `isUUID`\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必须，待检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的 UUID 字符串，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isGuid() 方法\n// import isGuid from '@yaohaixiao/types.js/isGuid'\n\nTypes.isGuid('749d0000-0194-1005-2e05-08d61613bf2f') // -\u003e true\nTypes.isGuid('d3aa88e2-c754-41e0-8ba6-4198a34aa0a2') // -\u003e true\nTypes.isGuid('00000000-0000-0000-0000-000000000000') // -\u003e true\nTypes.isGuid('{0e40c5ab-1d9b-ee11-983e-e0be0335d021}') // -\u003e true\nTypes.isGuid('08dbe0f11c8641cf8afe6b2824e8f8f5') // -\u003e true\n\nTypes.isGuid('') // -\u003e false\nTypes.isGuid('xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3') // -\u003e false\nTypes.isGuid('934859') // -\u003e false\nTypes.isGuid('A987FBC94BED3078CF079141BA07C9F') // -\u003e false\n```\n\n### [isHex(val)](https://yaohaixiao.github.io/types.js/#method-isHex)\n\nisHex(val) 方法用来检测测试数据是否为 16 进制编码的字符串。\n\n#### Parameters\n\n##### val\n\nType: `String`\nDefault: ``\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 16 进制编码的字符串返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isHex() 方法\n// import isHex from '@yaohaixiao/types.js/isHex'\n\nTypes.isHex('#ffffff') // -\u003e true\nTypes.isHex('f3f3f3') // -\u003e true\nTypes.isHex('#h1f1f1') // -\u003e false\nTypes.isHex('sdadfa') // -\u003e false\n```\n\n### [isHTML(val)](https://yaohaixiao.github.io/types.js/#method-isHTML)\n\nisHTML(val) 方法用来检测测试数据是否为合法的 HTML 代码。\n\n#### Since\n\n0.5.0\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的 HTML 代码，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isHTML() 方法\n// import isHTML from '@yaohaixiao/types.js/isHTML'\n\n// 包含 doctype 标签：\nTypes.isHTML('\u003c!doctype html\u003e') // -\u003e true\nTypes.isHTML('\\n\\n\u003c!doctype html\u003e\u003chtml\u003e') // -\u003e true\n\n// 包含：\u003chtml\u003e，\u003cbody\u003e 或者 \u003cx-*\u003e 标签：\nTypes.isHTML('\u003chtml\u003e') // -\u003e true\nTypes.isHTML('\u003chtml\u003e\u003c/html\u003e') // -\u003e true\nTypes.isHTML('\u003chtml lang=\"en\"\u003e\u003c/html\u003e') // -\u003e true\nTypes.isHTML('\u003chtml\u003e\u003cbody\u003e\u003c/html\u003e') // -\u003e true\nTypes.isHTML('\u003chtml\u003e\u003cbody class=\"no-js\"\u003e\u003c/html\u003e') // -\u003e true\nTypes.isHTML('\u003cx-unicorn\u003e') // -\u003e true\n\n// 包含任何合法的 HTML 标签：\nTypes.isHTML('\u003cp\u003efoo\u003c/p\u003e') // -\u003e true\nTypes.isHTML('\u003ca href=\"#\"\u003efoo\u003c/a\u003e') // -\u003e true\nTypes.isHTML('\u003cbr /\u003e') // -\u003e true\n\n// 无法匹配 XML 标签：\nTypes.isHTML('\u003cattribute\u003eaddress\u003c/attribute\u003e') // -\u003e false\nTypes.isHTML('\u003caddress\u003eWuhan City\u003c/address\u003e') // -\u003e false\nTypes.isHTML('\u003cage\u003e20\u003c/age\u003e') // -\u003e false\nTypes.isHTML('\u003cgender\u003email\u003c/gender\u003e') // -\u003e false\nTypes.isHTML('\u003ccareer\u003eprogrammer\u003c/career\u003e') // -\u003e false\n```\n\n### [isIDNumber(val)](https://yaohaixiao.github.io/types.js/#method-isIDNumber)\n\nisIDNumber(val) 方法用来检测测试数据是否为（中国）身份证号码。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n（必须）val 待检测的数据（身份证号码）。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的（中国）身份证号码（格式），返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isIDNumber() 方法\n// import isIDNumber from '@yaohaixiao/types.js/isIDNumber'\n\n// 有效的 15 位身份证号码\nTypes.isIDNumber('110105491231002'); // -\u003e true\n\n// 无效的 15 位身份证号码\nTypes.isIDNumber('123456789012345'); // -\u003e false\n\n// 有效的 18 位身份证号码（校验码为 X）\nTypes.('11010519491231002X'); // -\u003e true\n\n// 无效的 18 位身份证号码（校验码错误）\nTypes.isIDNumber('110105194912310029'); // -\u003e false\n\n// 无效的 18 位身份证号码（非法字符 Y）\nTypes.isIDNumber('11010519491231002Y'); // -\u003e false\n\n// 无效的 18 位身份证号码\nTypes.isIDNumber('123456789012345678'); // -\u003e false\n\n// 长度不符合\nTypes.isIDNumber('11010519491231002'); // -\u003e false\nTypes.isIDNumber('11010519491231002XX'); // -\u003e false\n\n// 格式错误\nTypes.isIDNumber('A1010519491231002X'); // -\u003e false\nTypes.isIDNumber('11010519491231002x'); // -\u003e false\n\n// 非字符串\nTypes.isIDNumber(110105194912310021); // -\u003e false\n```\n\n### [isIPAddress(val)](https://yaohaixiao.github.io/types.js/#method-isIPAddress)\n\nisIPAddress(val) 方法用来检测测试数据是否为合法的 IP 地址格式。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的 IP 地址格式字符串，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isIPAddress() 方法\n// import isIPAddress from '@yaohaixiao/types.js/isIPAddress'\n\n// IPv4\nTypes.isIPAddress('126.11.15.33') // -\u003e true\nTypes.isIPAddress('255.255.255.255') // -\u003e true\nTypes.isIPAddress('126.11.15.255') // -\u003e false\nTypes.isIPAddress('126.11.15.256') // -\u003e false\nTypes.isIPAddress('126.11.15.a56') // -\u003e false\nTypes.isIPAddress('126.11.15.') // -\u003e false\n\n// IPv6\nTypes.isIPAddress('FC00:0000:130F:0000:0000:09C0:876A:130B') // -\u003e true\nTypes.isIPAddress('FC00:0000:130F:0000:0000:09C0:876A:130') // -\u003e true\nTypes.isIPAddress('FC00:0000:130F:0000:0000:09C0:876A') // -\u003e false\nTypes.isIPAddress('FC00:0000:130F:0000:0000:09C0:876A:X130') // -\u003e false\n```\n\n### [isJSON(val)](https://yaohaixiao.github.io/types.js/#method-isJSON)\n\nisJSON(val) 方法用来检测测试数据是否为 JSON 格式字符串数据。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是 JSON 格式字符串数据返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isJSON() 方法\n// import isJSON from '@yaohaixiao/types.js/isJSON'\n\n// String\nTypes.isJSON('') // -\u003e false\nTypes.isJSON(\"\") // -\u003e false\nTypes.isJSON(\"json\") // -\u003e true\n\n// Number\nTypes.isJSON(3) // -\u003e false\nTypes.isJSON(\"3\") // -\u003e true\n\n// Boolean\nTypes.isJSON(false) // -\u003e false\nTypes.isJSON(\"false\") // -\u003e true\n\n// Object\nTypes.isJSON(null) // -\u003e false\nTypes.isJSON(\"null\") // -\u003e true\n\nTypes.isJSON({ prop: 'JSON' }) // -\u003e false\nTypes.isJSON(\"{\\\"prop\\\":\\\"JSON\\\"}\") // -\u003e true\n\n// Array\nTypes.isJSON([1, 2, 3]) // -\u003e false\nTypes.isJSON(\"[1, 2, 3]\") // -\u003e true\n```\n\n### [isPhoneNumber(val)](https://yaohaixiao.github.io/types.js/#method-isPhoneNumber)\n\nisPhoneNumber(val) 方法用来检测测试数据是否为合法的电话号码格式。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的电话号码格式字符串，返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isPhoneNumber() 方法\n// import isPhoneNumber from '@yaohaixiao/types.js/isPhoneNumber'\n\n// 移动电话号码\nTypes.isPhoneNumber(13901030304) // -\u003e false\nTypes.isPhoneNumber('1390103030a') // =\u003e false\n\nTypes.isPhoneNumber('+86 13901030304') // -\u003e true\nTypes.isPhoneNumber('13901030304') // -\u003e true\nTypes.isPhoneNumber('139-010-30304') // -\u003e true\nTypes.isPhoneNumber('139.010.30304') // -\u003e true\n\n// 固定电话号码\nTypes.isPhoneNumber('+86 84923296') // -\u003e true\nTypes.isPhoneNumber('027 84923296') // -\u003e true\nTypes.isPhoneNumber('(027) 84923296') // -\u003e true\nTypes.isPhoneNumber('(027)84923296') // -\u003e true\nTypes.isPhoneNumber('027-84923296') // -\u003e true\nTypes.isPhoneNumber('027.84923296') // -\u003e true\nTypes.isPhoneNumber('027 849-23296') // -\u003e true\nTypes.isPhoneNumber('027-849-23296') // -\u003e true\n```\n\n### [isSVG(val)](https://yaohaixiao.github.io/types.js/#method-isSVG)\n\nisSVG(val) 方法用来检测测试数据是否为合法的 SVG 代码。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的 SVG 代码（字符串），返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isHTML() 方法\n// import isSVG from '@yaohaixiao/types.js/isSVG'\n\nTypes.isSVG('\u003c!doctype html\u003e') // -\u003e false\n\nconst svg = '\u003csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"200\" viewBox=\"0 0 26 28\"\u003e' +\n  '\u003cpath d=\"M22 15.5v7.5c0\"\u003e\u003c/path\u003e' +\n  '\u003c/svg\u003e'\n\nTypes.isSVG(svg) // -\u003e true\n```\n\n### [isTime(val, type)](https://yaohaixiao.github.io/types.js/#method-isTime)\n\nisTime(val, type) 方法用来检测测试数据是否为有效的时间（字符串）。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n##### type\n\nType: `String`\n\n（可选）测试的时间类型:\n\n- time - 时间；\n- date - 日期；\n- 不传 - 时间或者日期皆可\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是有效的时间（字符串），返回 true，否则返回 false。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isTime() 方法\n// import isTime from '@yaohaixiao/types.js/isTime'\n\nlet chinese\n\n// 非字符串\nTypes.isTime(123) // -\u003e false\nTypes.isTime(false) // -\u003e false\nTypes.isTime(null) // -\u003e false\nTypes.isTime(chinese) // -\u003e false\nTypes.isTime(Symbol('symbol')) // -\u003e false\nTypes.isTime(BigInt(42)) // -\u003e false\nTypes.isTime({}) // -\u003e false\nTypes.isTime([]) // -\u003e false\nTypes.isTime(() =\u003e {}) // -\u003e false\n\n// 字符串\nTypes.isTime('time') // -\u003e false\n\n// 时间\n// 12小时格式时间\nTypes.isTime('1:23', 'time') // -\u003e true\nTypes.isTime('01:23', 'time') // -\u003e true\nTypes.isTime('11:23 am', 'time') // -\u003e true\nTypes.isTime('11:23 AM', 'time') // -\u003e true\nTypes.isTime('11:23 pm', 'time') // -\u003e true\nTypes.isTime('5:23 PM', 'time') // -\u003e true\n\nTypes.isTime('23:01 pm', 'time') // -\u003e false\n\n// 24小时格式时间\nTypes.isTime('3:34', 'time') // -\u003e true\nTypes.isTime('03:45', 'time') // -\u003e true\nTypes.isTime('18:16:01', 'time') // -\u003e true\nTypes.isTime('23:34:59', 'time') // -\u003e true\n\nTypes.isTime('03:60', 'time') // -\u003e false\nTypes.isTime('24:01', 'time') // -\u003e false\n\n// 日期\nTypes.isTime('2001.01.01') // -\u003e true\nTypes.isTime('2001/01/01') // -\u003e true\nTypes.isTime('2001-01-01') // -\u003e true\nTypes.isTime('2001-01-32') // -\u003e false\nTypes.isTime('2001-13-00') // -\u003e false\n\nTypes.isTime('01.01.2001') // -\u003e true\nTypes.isTime('01/11/2001') // -\u003e true\nTypes.isTime('31-12-2001') // -\u003e true\nTypes.isTime('31-13-2001') // -\u003e false\nTypes.isTime('32.12.2001') // -\u003e false\n\nTypes.isTime('Jul 08 2023 11:15:11', 'date') // -\u003e true\nTypes.isTime('Jul 32 2023 11:15:34', 'date') // -\u003e false\n```\n\n### [isURL(val)](https://yaohaixiao.github.io/types.js/#method-isURL)\n\nisURL(val) 方法用来检测测试数据是否为合法的 URL 格式。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的 URL 格式（字符串），返回 true，否则返回。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isURL() 方法\n// import isURL from '@yaohaixiao/types.js/isURL'\n\n// IP 访问\nTypes.isURL('http://127.0.0.1') // -\u003e true\nTypes.isURL('https://127.0.0') // -\u003e false\nTypes.isURL('https://127.0.0.') // -\u003e false\n\nTypes.isURL('http://127.0.0.1:8080') // -\u003e true\nTypes.isURL('http://127.0.0.1:8080#top') // -\u003e true\nTypes.isURL('http://127.0.0.1:8080?id=22') // -\u003e true\nTypes.isURL('http://127.0.0.1/console') // -\u003e true\nTypes.isURL('http://127.0.0.1:8080/workbench/?id=2#projects') // -\u003e true\n\n// 域名访问\nTypes.isURL('http://localhost') -\u003e false\nTypes.isURL('ftp://www.yaohaixiao.com') -\u003e false\n\nTypes.isURL('http://www.yaohaixiao.') -\u003e false\nTypes.isURL('http://www.yaohaixiao.c') -\u003e false\nTypes.isURL('http://www.yaohaixiao.c1') -\u003e false\n\nTypes.isURL('https://www.yaohaixiao.cn') -\u003e true\nTypes.isURL('https://www.yaohaixiao.com') -\u003e true\nTypes.isURL('https://www.yaohaixiao.com:8083') -\u003e true\nTypes.isURL('https://www.yaohaixiao.com/blog#top') -\u003e true\nTypes.isURL('https://www.yaohaixiao.com/blog/?page=2') -\u003e true\nTypes.isURL('https://www.yaohaixiao.com:8083/blog?page=2#top') -\u003e true\n```\n\n### [isUUID(val)](https://yaohaixiao.github.io/types.js/#method-isUUID)\n\nisUUID(val) 方法用来检测测试数据是否为合法的 UUID 字符串。\n\n#### Parameters\n\n##### val\n\nType: `Any`\n\n必选，要检测的数据。\n\n#### Returns\n\nType: `Boolean`\n\n'val' 是合法的 UUID 格式（字符串），返回 true，否则返回。\n\n#### Example\n\n```js\nimport Types from '@yaohaixiao/types.js'\n// 或者单独引用 isUUID() 方法\n// import isUUID from '@yaohaixiao/types.js/isUUID'\n\nTypes.isUUID('749d0000-0194-1005-2e05-08d61613bf2f') // -\u003e true\nTypes.isUUID('d3aa88e2-c754-41e0-8ba6-4198a34aa0a2') // -\u003e true\nTypes.isUUID('00000000-0000-0000-0000-000000000000') // -\u003e true\nTypes.isUUID('{0e40c5ab-1d9b-ee11-983e-e0be0335d021}') // -\u003e true\nTypes.isUUID('08dbe0f11c8641cf8afe6b2824e8f8f5') // -\u003e true\n\nTypes.isUUID('') // -\u003e false\nTypes.isUUID('xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3') // -\u003e false\nTypes.isUUID('934859') // -\u003e false\nTypes.isUUID('A987FBC94BED3078CF079141BA07C9F') // -\u003e false\n```\n\n\n## License\n\nJavaScript Code Licensed under [MIT License](http://opensource.org/licenses/mit-license.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaohaixiao%2Ftypes.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaohaixiao%2Ftypes.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaohaixiao%2Ftypes.js/lists"}