{"id":29022043,"url":"https://github.com/jsweb/truetype","last_synced_at":"2025-06-26T02:37:39.524Z","repository":{"id":33095741,"uuid":"147009661","full_name":"jsweb/truetype","owner":"jsweb","description":"Simple JS module to check types consistently and concisely","archived":false,"fork":false,"pushed_at":"2022-08-18T17:58:14.000Z","size":402,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T21:19:13.924Z","etag":null,"topics":[],"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/jsweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-01T15:22:23.000Z","updated_at":"2022-12-07T10:02:32.000Z","dependencies_parsed_at":"2022-06-28T11:31:56.033Z","dependency_job_id":null,"html_url":"https://github.com/jsweb/truetype","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/jsweb/truetype","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsweb%2Ftruetype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsweb%2Ftruetype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsweb%2Ftruetype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsweb%2Ftruetype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsweb","download_url":"https://codeload.github.com/jsweb/truetype/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsweb%2Ftruetype/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261988015,"owners_count":23240949,"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":[],"created_at":"2025-06-26T02:37:36.159Z","updated_at":"2025-06-26T02:37:39.470Z","avatar_url":"https://github.com/jsweb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @jsweb/truetype\n\nSimple JS module to check types consistently and concisely.\n\nTests coverage at [https://truetype.jsweb.app](https://truetype.jsweb.app)\n\n![package-npm](https://img.shields.io/badge/package-npm-blue.svg?style=for-the-badge)\n![module-es](https://img.shields.io/badge/module-es-blue.svg?style=for-the-badge)\n![tests-ava](https://img.shields.io/badge/tests-ava-blue.svg?style=for-the-badge)\n\n## Why?\n\nChecking types in JavaScript is not so easy...\n\nThe builtin operators `typeof`, `instanceof` and other methods are not precise enough to report the exact type of a value.\n\nSo, this module aims to check types of variables with more useful returns.\n\n## New in v4.0.0\n\nNow, its a full ES module, there is no UMD or CommonJS version.\n\nES modules are the new pattern in modern JS development, already supported in newer versions of Node.js and modern borwsers natively.\n\nBackward compatibility is not a concern here. If you use a module bundler (like Webpack or Rollup) to transpile your code, the result will be compatible according to your setup.\n\n---\n\n## Installation\n\nYou can install with NPM, Yarn or Unpkg CDN:\n\n`npm i -S @jsweb/truetype`\n\n`yarn add @jsweb/truetype`\n\n`pnpm add @jsweb/truetype`\n\n## Usage\n\n### ES6\n\nTree shaking (since v3.0.0):\n\n```javascript\nimport { isInteger, isDate, isNotNull } from '@jsweb/truetype'\n```\n\n### From CDN (installation not required)\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { isNumber } from 'https://unpkg.com/@jsweb/truetype'\n\n  const number = isNumber(1)\n\u003c/script\u003e\n```\n\n## Methods\n\n### isDefined(value: any): boolean\n\nCheck if a value is not undefined.\n\n### isNull(value: any): boolean\n\nCheck if value is null.\n\n### isNotNull(value: any): boolean\n\nCheck if value is not null.\n\n### isValid(value: any): boolean\n\nCheck if value is \"valid\" (is not null or undefined).\n\n### instance(value: any): string\n\nGet the constructor name of the value.\n\nReturns a string with a type name like `Object`, `Array`, `String`, `Number`, ...\n\nCan be a native or custom constructor name.\n\n```javascript\ninstance(1) // returns Number\n\nclass Foo {\n  constructor(x) {\n    this.x = x\n  }\n}\n\nconst bar = new Foo(1)\n\ninstance(bar) // returns Foo\n```\n\n### is(value: any, type: string): boolean\n\nCheck if `value` is of `type`.\n\nCan be a native or custom constructor name.\n\n```javascript\nis({}, 'Object') // returns true\nis([], 'Array') // returns true\nis('foo', 'String') // returns true\nis(false, 'Boolean') // returns true\n// ...\n\nclass Foo {\n  constructor(x) {\n    this.x = x\n  }\n}\n\nconst bar = new Foo(1)\n\nis(bar, 'Foo') // returns true\n```\n\n### isBoolean(value: any): boolean\n\nCheck if value is a boolean.\n\n### isString(value: any): boolean\n\nCheck if value is a string.\n\n### isNumber(value: any): boolean\n\nCheck if value is a number.\n\n### isInteger(value: any): boolean\n\nCheck if value is an integer number.\n\n### isFloat(value: any): boolean\n\nCheck if value is a float point number.\n\n### isObject(value: any): boolean\n\nCheck if value is an object.\n\n### isArray(value: any): boolean\n\nCheck if value is an Array.\n\n### isDate(value: any): boolean\n\nCheck if value is a Date object.\n\n### isRegExp(value: any): boolean\n\nCheck if value is a Regular Expression.\n\n### isFunction(value: any): boolean\n\nCheck if value is a function.\n\n### isEmpty(value: string | array | object): boolean\n\nThis is a bonus utility.\n\nCheck if value is empty.\n\nOnly for string, array and objects. Any other type will return false.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsweb%2Ftruetype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsweb%2Ftruetype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsweb%2Ftruetype/lists"}