{"id":26315294,"url":"https://github.com/raphaelhaettich/simple-type-check","last_synced_at":"2026-05-18T22:08:22.691Z","repository":{"id":57361062,"uuid":"158711367","full_name":"RaphaelHaettich/simple-type-check","owner":"RaphaelHaettich","description":"Simple and very small JavaScript library to check types and instanceof. ","archived":false,"fork":false,"pushed_at":"2019-03-27T14:28:48.000Z","size":154,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T13:05:00.347Z","etag":null,"topics":["javascript","micro","npm","small","type","type-check","types"],"latest_commit_sha":null,"homepage":"","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/RaphaelHaettich.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-11-22T14:31:41.000Z","updated_at":"2019-03-27T14:28:47.000Z","dependencies_parsed_at":"2022-09-26T16:40:52.368Z","dependency_job_id":null,"html_url":"https://github.com/RaphaelHaettich/simple-type-check","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphaelHaettich%2Fsimple-type-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphaelHaettich%2Fsimple-type-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphaelHaettich%2Fsimple-type-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphaelHaettich%2Fsimple-type-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RaphaelHaettich","download_url":"https://codeload.github.com/RaphaelHaettich/simple-type-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725636,"owners_count":20337671,"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":["javascript","micro","npm","small","type","type-check","types"],"created_at":"2025-03-15T12:18:08.058Z","updated_at":"2026-05-18T22:08:22.644Z","avatar_url":"https://github.com/RaphaelHaettich.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-type-check\n\n[![GitHub license](https://img.shields.io/github/license/RaphaelHaettich/simple-type-check.svg)](https://github.com/RaphaelHaettich/simple-type-check/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/RaphaelHaettich/simple-type-check.svg?branch=master)](https://travis-ci.org/RaphaelHaettich/simple-type-check)\n[![NPM version](https://img.shields.io/npm/v/simple-type-check.svg?style=flat)](https://www.npmjs.com/package/simple-type-check)\n[![NPM downloads](https://img.shields.io/npm/dt/simple-type-check.svg?style=flat)](https://www.npmjs.com/package/simple-type-check)\n[![GitHub issues](https://img.shields.io/github/issues/RaphaelHaettich/simple-type-check.svg)](https://github.com/RaphaelHaettich/simple-type-check/issues)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Code Style](https://badgen.net/badge/code%20style/Airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)\n\n\n# simple-type-check\n\u003e Simple and very small JavaScript library to check types and instanceof. \n  \n## Install\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\nnpm install simple-type-check\n```\n\n## Usage\nInclude module in your file:\n```js\nconst simpleTypeCheck = require('simple-type-check');\n```\nYou need to call the function with the parameters ```value``` and ```type```. Value can be anything and the type needs to be a string for type checking or the function for instanceof checking.\n```js\nconst value = 1234;\nconst type = 'number';\nconst result = simpleTypeCheck(value , type);\n// result is now true.\n```\nIn the default settings the library returns ```true``` if the check was successful and throws an ```Error``` if it fails.\n\n```js\nconst value = 'string';\nconst type = 'number';\nconst result = simpleTypeCheck(value , type);\n// result is undefinied and the error: \"string is not of type number\" is thrown.\n```\nThe third argument is ```throwError```, which is default ```true```.  You can add ```false``` as the third argument. Then the library will not throw an ```Error``` and instead return ```false```.\n\n```js\nconst value = 'string';\nconst type = 'number';\nconst result = simpleTypeCheck(value , type, false);\n// result is false.\n```\nIf you want to test an ```Array```, ```HTMLElement``` or something similar, you can do this too. In this case you need to add the function as ```type```.\n\n```js\nconst value = [];\nconst type = Array;\nconst result = simpleTypeCheck(value , type);\n// result is true.\n```\n```js\nconst value = document.getElementById(\"testId\");\nconst type = window.HTMLElement;\nconst result = simpleTypeCheck(value , type);\n// result is true.\n```\n### Testet types\nThe following types are testet, anything different should work too. You are welcome to add a PR with the test for more types.\n\n| Type | Works |\n|--|--|\n| ```Array``` | ✅ |\n| ```HTMLElement``` | ✅ |\n| ```'number'``` | ✅ |\n| ```'function'``` | ✅ |\n| ```'boolean'``` | ✅ |\n| ```'object'``` | ✅ |\n| ```'string'``` | ✅ |\n| ```'undefined'``` | ✅ |\n\n## Contribute\nIf you want to contribute to this project please commit with the `npm run commit` command, this will secure the automatic semantic versioning. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphaelhaettich%2Fsimple-type-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphaelhaettich%2Fsimple-type-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphaelhaettich%2Fsimple-type-check/lists"}