{"id":25893051,"url":"https://github.com/t99/typit","last_synced_at":"2026-04-17T08:06:19.916Z","repository":{"id":57384127,"uuid":"190823252","full_name":"T99/typit","owner":"T99","description":"Fully recursive runtime typechecking.","archived":false,"fork":false,"pushed_at":"2022-09-27T00:45:17.000Z","size":129,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-02T06:07:06.229Z","etag":null,"topics":["npm","runtime","typechecking","types"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/T99.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["T99"]}},"created_at":"2019-06-07T23:25:12.000Z","updated_at":"2022-09-27T00:45:22.000Z","dependencies_parsed_at":"2023-01-18T22:45:33.535Z","dependency_job_id":null,"html_url":"https://github.com/T99/typit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/T99/typit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T99%2Ftypit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T99%2Ftypit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T99%2Ftypit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T99%2Ftypit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/T99","download_url":"https://codeload.github.com/T99/typit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T99%2Ftypit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268039932,"owners_count":24185825,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["npm","runtime","typechecking","types"],"created_at":"2025-03-02T21:30:09.169Z","updated_at":"2026-04-17T08:06:19.868Z","avatar_url":"https://github.com/T99.png","language":"TypeScript","funding_links":["https://github.com/sponsors/T99"],"categories":[],"sub_categories":[],"readme":"# typit\n\nTypit provides runtime type-checking abilities which are often useful when interacting with and/or building public APIs in which data could potentially be received in a malformed manner.\n\nBy using a runtime typechecking system such as typit, a programmer can ensure that the data received by their programs is well-formed, well-defined and correctly typed, thus removing the need to worry about or 'check-on-access' the state and type of each key-value pair you attempt to use.\n\n### [Find typit on NPM.](https://www.npmjs.com/package/typit)\n\n## Table of Contents\n\n - [Installation](#installation)\n - [Basic Usage](#basic-usage)\n - [Documentation](#documentation)\n - [License](#license)\n\n## Installation\n\nInstall from NPM with\n```\n$ npm install --save typit\n```\n\n## Basic Usage\n\nLet's get started checking the types of some variables.\n\n```typescript\nimport { StandardType } from \"typit\";\n\nlet myString: string = \"Hello there!\";\n\nconsole.log(StandardType.STRING.checkConformity(myString));   // Prints 'true'.\nconsole.log(StandardType.NUMBER.checkConformity(myString));   // Prints 'false'.\n```\n\nAwesome! We can check if variables conform to any standard primitive types using the `StandardType` class!\n\nBut what about something a little more powerful? Might we be able to check if variables conform to more complex object structures? Let's see...\n\n```typescript\nimport { StandardType, ArrayType, ObjectType, OptionalType, EnumType } from \"typit\";\n\nlet clientType: ObjectType = new ObjectType({\n    clientID: StandardType.STRING,\n    isAdmin: StandardType.BOOLEAN,\n    purchases: new ArrayType(new ObjectType({\n        purchaseID: StandardType.STRING,\n        amount: new OptionalType(StandardType.NUMBER),\n        price: StandardType.NUMBER\n    })),\n    preferences: {\n        theme: new EnumType(\"light\", \"dark\", \"tango\"),\n        autoLogout: StandardType.BOOLEAN\n    }\n});\n```\n\nGreat! We've created our type in order to validate our hypothetical `client` objects! Now let's use it to check some actual objects.\n\n```typescript\nclientType.checkConformity({\n    clientID: \"93nco8a1\",\n    isAdmin: false,\n    purchases: [{\n        purchaseID: \"9c7j10sn\",\n        price: 14.99\n    }, {\n        purchaseID: \"1n8d3nlj\",\n        amount: 3,\n        price: 21.75\n    }],\n    preferences: {\n        theme: \"dark\",\n        autoLogout: false\n    }\n}); // Returns 'true'.\n\nclientType.checkConformity({\n    clientID: 2,\n    isAdmin: \"yep\",\n    purchases: \"a couple\",\n    preferences: {\n        theme: \"solarized\",\n        autoLogout: 5\n    }\n}); // Returns 'false'.\n```\n\n## Documentation\n\nSee the [wiki](https://github.com/T99/typit/wiki) for full documentation.\n\n## License\n\ntypit is made available under the GNU General Public License v3.\n\nCopyright (C) 2022 Trevor Sears\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft99%2Ftypit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft99%2Ftypit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft99%2Ftypit/lists"}