{"id":21074814,"url":"https://github.com/dawsbot/object-types","last_synced_at":"2025-05-16T06:31:31.396Z","repository":{"id":57312900,"uuid":"51612250","full_name":"dawsbot/object-types","owner":"dawsbot","description":"Get JavaScript object types","archived":false,"fork":false,"pushed_at":"2022-04-06T18:17:14.000Z","size":8,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-02T05:38:04.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dawsbot.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":"2016-02-12T19:49:41.000Z","updated_at":"2023-08-25T11:25:39.000Z","dependencies_parsed_at":"2022-09-20T23:10:34.906Z","dependency_job_id":null,"html_url":"https://github.com/dawsbot/object-types","commit_stats":null,"previous_names":["dawsonbotsford/object-types"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fobject-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fobject-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fobject-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fobject-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawsbot","download_url":"https://codeload.github.com/dawsbot/object-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225411504,"owners_count":17470246,"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":"2024-11-19T19:18:10.348Z","updated_at":"2024-11-19T19:18:10.837Z","avatar_url":"https://github.com/dawsbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deprecated in favor of [to-type](https://github.com/dawsonbotsford/to-type)\n\n# object-types \n\n\u003e Get Javascript Object types\n\n\n\u003cbr\u003e\n\n## Install\n\n```\nnpm install --save object-types\n```\n\n\n\u003cbr\u003e\n\n## Usage\n\n```js\nconst objectTypes = require('object-types');\n\ntypeof [];\n//=\u003e 'object'\nobjectTypes([]);\n//=\u003e 'array'\n\n\ntypeof new Object(true);\n//=\u003e 'object'\nobjectTypes(new Object(true));\n//=\u003e 'boolean'\n\n\ntypeof {};\n//=\u003e 'object'\nobjectTypes({});\n//=\u003e 'object'\n```\n\n\u003cbr\u003e\n\n## The Problem\nJavaScript objects can be of various object types. As an example, a string can be a string or a string can be an object string:\n\n```js\ntypeof 'example string';\n//=\u003e string\n\ntypeof new Object('example string');\n//=\u003e object\n```\n\n\u003cbr\u003e\n\nIt seems like you can treat literal strings the same as object strings:\n\n```js\nconst myArray = ['a string', new Object('my string object')];\n\nmyArray.map(elem =\u003e {\n  return elem.toUpperCase()\n});\n//=\u003e ['A STRING', 'MY STRING OBJECT']\n```\n\n\u003cbr\u003e\n\nBut not always. **Equality operators do not behave the same**.\n\n```js\nconst myArray = ['a string', new Object('my string object')];\n\ntypeof myArray[0] === myArray[1]\n//=\u003e false\n```\n\n\u003cbr\u003e\n\nWith object-types, you can stop getting `object` for all of your `typeof` calls.\n\n```js\nconst myArray = [1,2,3];\nconst obj = new Object([1,2,3]);\n\ntypeof myArray === typeof obj;\n//=\u003e false\n\ntypeof myArray === objectTypes(obj);\n//=\u003e true\n```\n\n\n\n\u003cbr\u003e\n\n## API\n\n### objectTypes(obj)\n\n##### obj\n\nType: `object`\n\nReturns the typeof object as a string:\n* 'object'\n* 'string'\n* 'number'\n* 'boolean'\n* 'array'\n* 'date'\n* 'regexp'\n*  throws `TypeError` if unknown object type is inputted\n\n\u003cbr\u003e\n\n## Related\n\n* [deep-blue-string](https://github.com/dawsonbotsford/deep-blue-string)\n\n\u003cbr\u003e\n\n## License\n\nMIT © [dawsonbotsford](http://dawsonbotsford.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Fobject-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawsbot%2Fobject-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Fobject-types/lists"}