{"id":29654475,"url":"https://github.com/jqrony/typeh","last_synced_at":"2025-07-22T07:34:44.322Z","repository":{"id":305015511,"uuid":"1021658787","full_name":"jqrony/typeh","owner":"jqrony","description":"A lightweight JS utility for advanced type detection, validation, and enforcement.","archived":false,"fork":false,"pushed_at":"2025-07-17T19:59:21.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-17T20:56:52.244Z","etag":null,"topics":["datatype","typehint"],"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/jqrony.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-17T18:28:58.000Z","updated_at":"2025-07-17T19:59:24.000Z","dependencies_parsed_at":"2025-07-17T23:36:04.136Z","dependency_job_id":"dede9344-a3e3-4d6c-913b-7b8f0f30d9e5","html_url":"https://github.com/jqrony/typeh","commit_stats":null,"previous_names":["jqrony/typeh"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jqrony/typeh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jqrony%2Ftypeh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jqrony%2Ftypeh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jqrony%2Ftypeh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jqrony%2Ftypeh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jqrony","download_url":"https://codeload.github.com/jqrony/typeh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jqrony%2Ftypeh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266448510,"owners_count":23930226,"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-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["datatype","typehint"],"created_at":"2025-07-22T07:34:43.738Z","updated_at":"2025-07-22T07:34:44.318Z","avatar_url":"https://github.com/jqrony.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typeh - JavaScript Type Helper Library [![npm version](https://img.shields.io/npm/v/typeh?style=flat-square)](https://www.npmjs.com/package/typeh)\n\n\n\u003e A lightweight JS utility for advanced type detection, validation, and enforcement.\n\n\n\u003ca href=\"https://github.com/jqrony/typeh/blob/main/LICENSE\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/jqrony/typeh?style=flat-square\u0026color=blue\" alt=\"License\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/indianmodassir\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Author-Indian%20Modassir-blue?style=flat-square\" alt=\"Author\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/typeh\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dm/typeh?color=blue\u0026style=flat-square\" alt=\"Download\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.jsdelivr.com/package/npm/typeh\"\u003e\n  \u003cimg src=\"https://img.shields.io/jsdelivr/npm/hm/typeh?style=flat-square\" alt=\"jsDelivr Hits\"\u003e\n\u003c/a\u003e\n\n\n## Features\n\n- Determine the detailed type of any value (including distinguishing between integers and floats)\n- Validate values against expected types with detailed error messages\n- Check for common type categories like scalar, numeric, countable, infinite, etc.\n- Supports multiple types (e.g. `int|float`) in validation\n- Works in browser and Node.js environments\n\n---\n\n## Installation\n\nSince TH is a self-contained script, you can include it directly in your project.\n\n```bash\nnpm install typeh --save\n```\n\n### Browser\n\nInclude the script in your HTML:\n\n```html\n\u003cscript src=\"path/to/th.js\"\u003e\u003c/script\u003e\n```\n\nOR\n\n```js\n// Node.js\nrequire(\"typeh\");\n```\n\n**isA Types**\n\n- isCountable()\n- isInteger()\n- isDouble()\n- isNumeric()\n- isLong()\n- isScalar()\n- isInfinite()\n- isString()\n- isBool()\n- isArray()\n- isObject()\n- isCallable()\n- isIterable()\n- isNull()\n- isFalse()\n- isTrue()\n\n**Type List**\n- int\n- float\n- string\n- bool/boolean\n- array\n- object\n- callable\n- iterable\n- mixed\n- null\n- false\n- true\n\nOthers... Like (HTMLElement, regexp, symbol etc.) But support only in `define` method.\n\n### Usage\n\n**Variable**\n\n```js\n// Required\nconst arr = array([]);\nconst str = string('Hello World');\nconst fn = callable(() =\u003e {});\nconst isBool = bool(true);\nconst num = int(12);\nconst float = float(12.22);\nconst values = iterable(new Set([1,2,3,4]));\nconst obj = object({});\nconst data = mixed(\"Foo\"); // Allow all types\n\n/* Optional/Required */\nfunction myFun(username, email, number, isAdult) {\n  username = string(username); // [required]\n  email = _string(email);      // [optional]\n  number = _int(number);       // [optional]\n  isAdult = bool(isAdult);     // [required]\n}\n\nmyFun('Foo', null, null, true);\n```\n\n**How to use custom Type**\n```js\nconst custom = define(\"string|array|bool\", []); // Allow (string, array, boolean) only\n\n// Optional\nconst optval = define(\"?string|array\"); // Allow (string, array, null, undefined)\n```\n\n**Argument typeh**\n\n```js\nfunction select(selector, context, results, isSelf) {\n  setType({\n    string: selector,     // [required]\n    HTMLElement: context, // [required]\n    array: results,       // [required]\n    \"?bool\": isSelf       // [optional]\n  });\n}\n```\n\n**How To Check Primitive Type**\n\n```js\ntoType(/^[a-z]/);      // Output: regexp\ntoType(new Date);      // Output: date\ntoType('Hello');       // Output: string\ntoType(123);           // Output: number\ntoType(true);          // Output: boolean\ntoType(() =\u003e {});      // Output: function\ntoType([]);            // Output: array\ntoType({});            // Output: object\ntoType(new Error());   // Output: error\ntoType(Symbol('Foo')); // Output: symbol\n```\n\n**Check To Object Type**\n```js\ntoType(12.21);         // Output: float\ntoType(123);           // Output: int\ntoType(/^[a-z]/);      // Output: regexp\ntoType('Hello');       // Output: string\n\nconst body = document.body;\ntoType(body); // Output: HTMLBodyElement\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjqrony%2Ftypeh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjqrony%2Ftypeh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjqrony%2Ftypeh/lists"}