{"id":25255000,"url":"https://github.com/nandovejer/js-subtype","last_synced_at":"2026-02-10T15:39:06.924Z","repository":{"id":259212764,"uuid":"876682165","full_name":"nandovejer/js-subtype","owner":"nandovejer","description":"js-subtype is a lightweight library that allows you to determine JavaScript subtypes, making it easy to identify the exact type of an object (like Array, Date, etc.).","archived":false,"fork":false,"pushed_at":"2025-01-21T15:32:27.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-07T22:56:45.791Z","etag":null,"topics":["javascript","subtypes","type-detection","types","utility"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nandovejer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-10-22T11:40:33.000Z","updated_at":"2025-01-21T15:32:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"444b62b7-d1a5-4863-905c-3156dec10b9d","html_url":"https://github.com/nandovejer/js-subtype","commit_stats":null,"previous_names":["nandovejer/js-subtype"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nandovejer/js-subtype","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandovejer%2Fjs-subtype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandovejer%2Fjs-subtype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandovejer%2Fjs-subtype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandovejer%2Fjs-subtype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nandovejer","download_url":"https://codeload.github.com/nandovejer/js-subtype/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandovejer%2Fjs-subtype/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269338064,"owners_count":24400179,"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-08-07T02:00:09.698Z","response_time":73,"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":["javascript","subtypes","type-detection","types","utility"],"created_at":"2025-02-12T05:51:22.342Z","updated_at":"2026-02-10T15:39:06.224Z","avatar_url":"https://github.com/nandovejer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-subtype\n\n[![npm version](https://badge.fury.io/js/js-subtype.svg)](https://badge.fury.io/js/js-subtype)  \n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n`js-subtype` is a lightweight library that allows you to determine JavaScript subtypes, making it easy to identify the exact type of an object (like `Array`, `Date`, etc.).\n\n## Features\n\n- Supports multiple subtypes (`Array`, `Date`, `Map`, `RegExp`, etc.).\n- Lightweight and easy to use.\n- Zero dependencies.\n- Works in both Node.js and modern browsers.\n\n## Installation\n\nInstall using npm:\n\n```bash\nnpm install js-subtype\n```\n\nOr with yarn:\n\n```bash\nyarn add js-subtype\n```\n\n## Usage\n\nHere’s a quick example of how to use `js-subtype`:\n\n```javascript\nconst { getType } = require(\"js-subtype\");\n\nconsole.log(getType([1, 2, 3])); // Output: \"Array\"\nconsole.log(getType(new Date())); // Output: \"Date\"\nconsole.log(getType(/regex/)); // Output: \"RegExp\"\n```\n\n### API\n\n#### `getType(value)`\n\nReturns a string representing the subtype of the given value.\n\n- **Parameters**:\n  - `value`: Any JavaScript value.\n- **Returns**: The string subtype (`Array`, `Date`, `Map`, etc.).\n\n## Use Cases\n\n### Advanced Type Validation\n\nUse `js-subtype` to validate inputs or types precisely in your applications:\n\n```javascript\nfunction validateInput(input) {\n  if (getType(input) !== \"Array\") {\n    throw new Error(\"Input must be an array.\");\n  }\n  // Additional logic...\n}\n```\n\n\n| Type       | Subtype       | Description                                                                 |\n|------------|---------------|-----------------------------------------------------------------------------|\n| `undefined`| `undefined`   | Undefined value.                                                           |\n| `boolean`  | `boolean`     | Boolean value (`true` or `false`).                                         |\n| `number`   | `integer`     | Integer number.                                                            |\n| `number`   | `float`       | Floating-point number.                                                     |\n| `string`   | `string`      | Text string.                                                               |\n| `object`   | `null`        | Null value.                                                                |\n| `object`   | `array`       | Array (list of elements).                                                  |\n| `object`   | `date`        | `Date` object.                                                             |\n| `object`   | `regexp`      | Regular expression.                                                        |\n| `object`   | `map`         | `Map` object.                                                              |\n| `object`   | `set`         | `Set` object.                                                              |\n| `object`   | `weakmap`     | `WeakMap` object.                                                          |\n| `object`   | `weakset`     | `WeakSet` object.                                                          |\n| `object`   | `error`       | `Error` object.                                                            |\n| `object`   | `promise`     | `Promise` object.                                                          |\n| `object`   | `object`      | Generic object.                                                            |\n| `function` | `function`    | Function.                                                                  |\n| `symbol`   | `symbol`      | Symbol (`Symbol`).                                                         |\n| `bigint`   | `bigint`      | Large integer (`BigInt`).                                                  |\n\n\n\n### Identifying Native JavaScript Objects\n\nDetermine the exact native type of an object, such as `Map` or `Set`:\n\n```javascript\nconsole.log(getType(new Map())); // Output: \"Map\"\nconsole.log(getType(new Set())); // Output: \"Set\"\n```\n\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnandovejer%2Fjs-subtype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnandovejer%2Fjs-subtype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnandovejer%2Fjs-subtype/lists"}