{"id":21325552,"url":"https://github.com/hifizz/type-tool","last_synced_at":"2025-03-15T23:43:20.418Z","repository":{"id":99694023,"uuid":"166625063","full_name":"hifizz/type-tool","owner":"hifizz","description":"Safe type checker tool for JavaScript.","archived":false,"fork":false,"pushed_at":"2019-01-20T07:55:17.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T12:29:19.173Z","etag":null,"topics":["js-type","type"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/hifizz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","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":"2019-01-20T05:02:39.000Z","updated_at":"2019-01-20T07:55:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbd2d385-a691-452e-8fef-2e4afcf51ddd","html_url":"https://github.com/hifizz/type-tool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hifizz%2Ftype-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hifizz%2Ftype-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hifizz%2Ftype-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hifizz%2Ftype-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hifizz","download_url":"https://codeload.github.com/hifizz/type-tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806038,"owners_count":20350773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["js-type","type"],"created_at":"2024-11-21T21:06:36.055Z","updated_at":"2025-03-15T23:43:20.406Z","avatar_url":"https://github.com/hifizz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# type-tool\n\n[![Build Status](https://travis-ci.com/hifizz/type-tool.svg?branch=master)](https://travis-ci.com/hifizz/type-tool)\n[![codecov](https://codecov.io/gh/hifizz/type-tool/branch/master/graph/badge.svg)](https://codecov.io/gh/hifizz/type-tool)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n一个安全的变量类型检查工具。\n\n## Install\n\nUse yarn:\n\n```bash\nyarn add type-tool\n```\n\nUse npm:\n\n```bash\nnpm i type-tool\n```\n\n## Usage\n\n```js\nimport { isArray } from 'type-tool'\n\nconst targetVariable = []\nconst isVariableArray = isArray(targetVariable)\n\nconsole.log(isVariableArray) // true\n```\n\n```js\nimport * as type from 'type-tool'\n\nconst targetVariable = []\nconst isVariableArray = type.isArray(targetVariable)\n\nconsole.log(isVariableArray) // true\n```\n\n## Documentation\n\n借助 `Object.prototype.toString` 来返回真实的变量类型。\n\n```js\n// 看下面的例子\n\nconsole.log(typeof []) // \"object\"\nconsole.log(Object.prototype.toString.call([])) // \"[Object Array]\"\n\nconsole.log(typeof null) // \"object\"\nconsole.log(Object.prototype.toString.call(null)) // \"[Object Null]\"\n```\n\n### API\n\n**getTypeString**\n`getTypeString(o: any): string` Alias `Object.prototype.toString.call` Return string like \"[Object Null]\" \"[Object Array]\".\n\n**isString** `isString(o: any): boolean`\n\n**isNumber** `isNumber(o: any): boolean`\n\n**isBoolean** `isBoolean(o: any): boolean`\n\n**isSymbol** `isSymbol(o: any): boolean`\n\n**isArray** `isArray(o: any): boolean`\n\n**isObject** `isObject(o: any): boolean`\n\n**isFunction** `isFunction(o: any): boolean`\n\n**isError** `isError(o: any): boolean`\n\n**isNull** `isNull(o: any): boolean`\n\n**isUndefined** `isUndefined(o: any): boolean`\n\n**isDate** `isDate(o: any): boolean`\n\n**isMath** `isMath(o: any): boolean`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhifizz%2Ftype-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhifizz%2Ftype-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhifizz%2Ftype-tool/lists"}