├── .eslintrc ├── .github └── workflows │ ├── node-aught.yml │ ├── node-pretest.yml │ ├── node-tens.yml │ ├── rebase.yml │ └── require-allow-edits.yml ├── .gitignore ├── .npmrc ├── .nycrc ├── .testem.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── index.js ├── package.json └── test └── index.js /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | 4 | "extends": "@ljharb", 5 | } 6 | -------------------------------------------------------------------------------- /.github/workflows/node-aught.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js < 10' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/node.yml@main 8 | with: 9 | range: '< 10' 10 | type: minors 11 | command: npm run tests-only 12 | 13 | node: 14 | name: 'node < 10' 15 | needs: [tests] 16 | runs-on: ubuntu-latest 17 | steps: 18 | - run: 'echo tests completed' 19 | -------------------------------------------------------------------------------- /.github/workflows/node-pretest.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: pretest/posttest' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/pretest.yml@main 8 | -------------------------------------------------------------------------------- /.github/workflows/node-tens.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js >= 10' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/node.yml@main 8 | with: 9 | range: '>= 10' 10 | type: minors 11 | command: npm run tests-only 12 | 13 | node: 14 | name: 'node >= 10' 15 | needs: [tests] 16 | runs-on: ubuntu-latest 17 | steps: 18 | - run: 'echo tests completed' 19 | -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | uses: ljharb/actions/.github/workflows/rebase.yml@main 8 | secrets: 9 | token: ${{ secrets.GITHUB_TOKEN }} 10 | -------------------------------------------------------------------------------- /.github/workflows/require-allow-edits.yml: -------------------------------------------------------------------------------- 1 | name: Require “Allow Edits” 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | name: "Require “Allow Edits”" 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: ljharb/require-allow-edits@main 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .monitor 3 | .*.swp 4 | .nodemonignore 5 | releases 6 | *.log 7 | *.err 8 | fleet.json 9 | public/browserify 10 | bin/*.json 11 | .bin 12 | build 13 | compile 14 | .lock-wscript 15 | node_modules 16 | 17 | # Only apps should have lockfiles 18 | npm-shrinkwrap.json 19 | package-lock.json 20 | yarn.lock 21 | 22 | coverage/ 23 | .nyc_output/ 24 | 25 | .npmignore 26 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | allow-same-version=true 3 | message=v%s 4 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "all": true, 3 | "check-coverage": false, 4 | "reporter": ["text-summary", "text", "html", "json"], 5 | "exclude": [ 6 | "coverage", 7 | "test" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.testem.json: -------------------------------------------------------------------------------- 1 | { 2 | "launchers": { 3 | "node": { 4 | "command": "node ./test" 5 | } 6 | }, 7 | "src_files": [ 8 | "./**/*.js" 9 | ], 10 | "before_tests": "npm run build", 11 | "on_exit": "rm test/static/bundle.js", 12 | "test_page": "test/static/index.html", 13 | "launch_in_dev": ["node", "phantomjs"] 14 | } 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [v1.0.2](https://github.com/inspect-js/is-object/compare/v1.0.1...v1.0.2) - 2020-12-02 9 | 10 | ### Merged 11 | 12 | - Expanded tests to check for undefined, boolean values, and functions. [`#2`](https://github.com/inspect-js/is-object/pull/2) 13 | 14 | ### Commits 15 | 16 | - [Tests] migrate tests to Github Actions [`1503b2b`](https://github.com/inspect-js/is-object/commit/1503b2beabea6408504e5ed95aa0c6a69683313f) 17 | - [Dev Deps] add `eslint`, drop `jscs` [`0b33130`](https://github.com/inspect-js/is-object/commit/0b33130d6d1b77a4c6f184e760a5dd28e65ef105) 18 | - [meta] add `auto-changelog` [`4c1af71`](https://github.com/inspect-js/is-object/commit/4c1af7108d1498119d8be4014b26f92a6823ae36) 19 | - Use my standard jscs.json. [`8e02200`](https://github.com/inspect-js/is-object/commit/8e0220046caee3243be8312e563646758f842486) 20 | - [Tests] use shared travis-ci configs [`ffaa4b7`](https://github.com/inspect-js/is-object/commit/ffaa4b7503e0df857338ce2359de9845af83cd98) 21 | - Update `tape`, `covert`, `jscs` [`23ae901`](https://github.com/inspect-js/is-object/commit/23ae9016a087da5d433b27228e7d4d066b5f7223) 22 | - [readme] fix repo URLs, remove testling [`f48732a`](https://github.com/inspect-js/is-object/commit/f48732a6839f9cf70443759d02e4a58cb7d90e53) 23 | - [meta] avoid publishing github workflows [`b3a84ee`](https://github.com/inspect-js/is-object/commit/b3a84ee7895e212b626b174be6b248d39b591fca) 24 | - [Tests] run `nyc` on all tests [`a03b699`](https://github.com/inspect-js/is-object/commit/a03b699fdb3b7a78832cfa8005c803f6c455ea11) 25 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`db89fc0`](https://github.com/inspect-js/is-object/commit/db89fc0fc9b8366130b7e605990f653ae53cf8ff) 26 | - Update `tape`, `jscs` [`bcb3ac9`](https://github.com/inspect-js/is-object/commit/bcb3ac9f9eedd0bfcc6988f0a0001d4162c7cba3) 27 | - Expanded tests to check for undefined, boolean values and functions. [`a12751e`](https://github.com/inspect-js/is-object/commit/a12751e6a7050331970e7a82cd961ad18473a6c9) 28 | - Test up to `io.js` `v2.0` [`74d46d7`](https://github.com/inspect-js/is-object/commit/74d46d7f52c9e227068dbef454c97d9c5a7b2442) 29 | - [actions] add automatic rebasing / merge commit blocking [`b5505c3`](https://github.com/inspect-js/is-object/commit/b5505c34800a197724ea2bfb4445a13fce5cd934) 30 | - [actions] add "Allow Edits" workflow [`c79aee4`](https://github.com/inspect-js/is-object/commit/c79aee4d0ecc1aba4be0a1a23d8e19ddf87ca5e4) 31 | - Naming deps/devDeps URLs in README [`1095633`](https://github.com/inspect-js/is-object/commit/1095633d062deea6300c6e35be6e7142a3dc018d) 32 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`5db6e17`](https://github.com/inspect-js/is-object/commit/5db6e1783d638c05a539621ae652d32fbc34c6e1) 33 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`; add `safe-publish-latest` [`ceaf8ab`](https://github.com/inspect-js/is-object/commit/ceaf8ab48b0b8d7e300dce5ad40a5eafbe60df3a) 34 | - Test up to `io.js` `v2.2` [`cf9f70e`](https://github.com/inspect-js/is-object/commit/cf9f70e623a7e0e78c34d056bdfb99d8d5133b69) 35 | - Naming contributor URLs in README [`41b759b`](https://github.com/inspect-js/is-object/commit/41b759befa23b1c67bc573699188d8c930fa96f1) 36 | - Test up to `io.js` `v3.0` [`29cd85b`](https://github.com/inspect-js/is-object/commit/29cd85ba942a33112af94c994c23e27e33f9d4ad) 37 | - Only apps should have lockfiles [`5510e47`](https://github.com/inspect-js/is-object/commit/5510e47639ccb51f64ab82bd14f75d4b4ee7c625) 38 | - All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. [`849b718`](https://github.com/inspect-js/is-object/commit/849b718ed57979757af84e637a3cd24871e61a5d) 39 | - Run `travis-ci` tests on `iojs` and `0.12`; allow `0.8` failures; speed up builds. [`655c5f7`](https://github.com/inspect-js/is-object/commit/655c5f7cdcb7f925fee00a44905ff018002049b4) 40 | - Naming npm package URL in README [`af52357`](https://github.com/inspect-js/is-object/commit/af5235703e31bdecf39f663fe647e4ba1132191e) 41 | - Naming testling-ci URLs in README [`70ab476`](https://github.com/inspect-js/is-object/commit/70ab476401e4122fefc45612ac549b8b791fbb7f) 42 | - Naming travis-ci URLs in README [`08175df`](https://github.com/inspect-js/is-object/commit/08175dffa933ce93e686ee3e48e05af33e13349a) 43 | - [Dev Deps] update `auto-changelog`, `tape` [`0f0dde7`](https://github.com/inspect-js/is-object/commit/0f0dde7501e280cc262d4bfe375a98965c21bbd6) 44 | - [Dev Deps] update `covert`, `tape` [`6148d0e`](https://github.com/inspect-js/is-object/commit/6148d0e857aa4e4f167a5c8892f748b0701caf8b) 45 | - Update `tape`, `jscs` [`dff288a`](https://github.com/inspect-js/is-object/commit/dff288a20b1382836d100d3caf9df3c80fe6290a) 46 | - Update `tape`, `jscs` [`ff04f70`](https://github.com/inspect-js/is-object/commit/ff04f70e14a4844f6446df3ed5cc4b44aaa64dc2) 47 | - Update `jscs` [`75e8791`](https://github.com/inspect-js/is-object/commit/75e879153be96fd7429c1a933b6caffd4d4f3316) 48 | - Update `jscs`, `tape` [`cc7e221`](https://github.com/inspect-js/is-object/commit/cc7e221724339942d13ba52d6541c633e1a160ca) 49 | - Update `tape`, `jscs` [`be32959`](https://github.com/inspect-js/is-object/commit/be3295953a66d6f305be9d5c1f003ae0df0d8c95) 50 | - Use consistent quotes. [`0dedc4b`](https://github.com/inspect-js/is-object/commit/0dedc4b8656063e99b2780b3b989fa404b9242be) 51 | - Naming npm badge PNG in README [`0376b83`](https://github.com/inspect-js/is-object/commit/0376b835c57c93a4e10d99beb7b5be382266faa7) 52 | - Naming npm version badge SVG in README [`fe00aab`](https://github.com/inspect-js/is-object/commit/fe00aab6bdc2ff718749f4ab4327d97f4616a382) 53 | - [readme] remove travis badge [`028ff10`](https://github.com/inspect-js/is-object/commit/028ff106f6862a89adbcf6a0b4acd894f90acdc2) 54 | - [Tests] add missing `lint` script [`f431139`](https://github.com/inspect-js/is-object/commit/f431139c39b7b3b7cd525994e8ae5402db78792b) 55 | - [Dev Deps] update `auto-changelog`; add `aud` [`ad0b964`](https://github.com/inspect-js/is-object/commit/ad0b9648c626edfc9bf66f2ec0322b4821940a56) 56 | - [meta] add `funding` field [`ab362a6`](https://github.com/inspect-js/is-object/commit/ab362a630fd1baef26a990cea3f9873723117e74) 57 | - [actions] update rebase action to use checkout v2 [`592539d`](https://github.com/inspect-js/is-object/commit/592539d9b5a047d1fb4161a0b0dea091ddee057e) 58 | - [actions] switch Automatic Rebase workflow to `pull_request_target` event [`f26329d`](https://github.com/inspect-js/is-object/commit/f26329daab3387e947a642d73850e56570b32741) 59 | - [Tests] only audit prod deps [`58efaae`](https://github.com/inspect-js/is-object/commit/58efaaeecd35df9903df3649e4235f2514a31cd3) 60 | - Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`120491a`](https://github.com/inspect-js/is-object/commit/120491aefe3c96e235d9da96cd00c6e77fb23819) 61 | - Update `tape` [`99ccffe`](https://github.com/inspect-js/is-object/commit/99ccffe074de63562c007ebc35e9ed808ce3ec11) 62 | - Lock covert to v1.0.0. [`9d03921`](https://github.com/inspect-js/is-object/commit/9d039218b89667363910689661fde7c3934e4055) 63 | - Updating jscs [`a72781e`](https://github.com/inspect-js/is-object/commit/a72781e070f35be6a184418f9d649146bad82035) 64 | - Updating tape [`31aabd0`](https://github.com/inspect-js/is-object/commit/31aabd0451663cd9495ea06d7aa26a8e51ba0532) 65 | - Fixing indentation. [`4c3e061`](https://github.com/inspect-js/is-object/commit/4c3e0619d94937a5d9507ced13f97436962a3c8e) 66 | - Updating jscs [`368053e`](https://github.com/inspect-js/is-object/commit/368053e0f2d8179d9538e91339f7c43d270ec4a0) 67 | 68 | ## [v1.0.1](https://github.com/inspect-js/is-object/compare/v1.0.0...v1.0.1) - 2014-09-02 69 | 70 | ### Commits 71 | 72 | - Add license and download badges [`be23442`](https://github.com/inspect-js/is-object/commit/be23442865506ac6c93f42c2b6ab9ac64939901c) 73 | - Updating jscs [`9924028`](https://github.com/inspect-js/is-object/commit/992402874cf123393243f6561b5a27cfdc6de88a) 74 | - Adding a singular license key to package.json [`3f2bd51`](https://github.com/inspect-js/is-object/commit/3f2bd51596a586b222b2571ad3fb18fde9056ba9) 75 | - Rename LICENSE file to proper spelling. [`a7cfdbf`](https://github.com/inspect-js/is-object/commit/a7cfdbf8d35835745bcfb5ea84b3a0bcf82a9315) 76 | 77 | ## [v1.0.0](https://github.com/inspect-js/is-object/compare/v0.1.2...v1.0.0) - 2014-08-18 78 | 79 | ### Merged 80 | 81 | - Updating tape. [`#3`](https://github.com/inspect-js/is-object/pull/3) 82 | - update dependencies [`#2`](https://github.com/inspect-js/is-object/pull/2) 83 | - Update tape, test more browsers [`#1`](https://github.com/inspect-js/is-object/pull/1) 84 | 85 | ### Commits 86 | 87 | - Making indentation consistent. [`aed32ae`](https://github.com/inspect-js/is-object/commit/aed32ae56e9400497f2833fe3cb1e12dde68144e) 88 | - Removing unused example/build code. [`b894fe1`](https://github.com/inspect-js/is-object/commit/b894fe16e0f95203dab0baf7aacde6210f7528ba) 89 | - Adding `npm run lint` [`676f803`](https://github.com/inspect-js/is-object/commit/676f8036f4d492b4fffdb26209f038ee7f6fc416) 90 | - Using single quotes, semicolons, etc. [`96e7760`](https://github.com/inspect-js/is-object/commit/96e7760bc7f40715f43b1217a92cecbf08c68a9a) 91 | - Updating contributors and repo location. [`836e536`](https://github.com/inspect-js/is-object/commit/836e536d11e1715364bccbf4dc1b60c467363a2b) 92 | - Updating travis.yml [`7287d63`](https://github.com/inspect-js/is-object/commit/7287d63d359f916bf01fe1a2351d05bbc6f21872) 93 | - Adding more testling browsers. [`8d1447b`](https://github.com/inspect-js/is-object/commit/8d1447bb2ece7a316a49df911d4345df6056dfa7) 94 | - Updating Travis so it tests on node 0.10, not node 0.1. Also adding node 0.6 and removing unstable 0.9. [`0d773cd`](https://github.com/inspect-js/is-object/commit/0d773cd0d4592122e6d56b40ac7b2378a2cada24) 95 | - Updating README examples [`57a796b`](https://github.com/inspect-js/is-object/commit/57a796b7dd23e02e03efcf14e2eefb5ec92de48b) 96 | - Adding `npm run coverage` and `npm run coverage-quiet` [`228bb1b`](https://github.com/inspect-js/is-object/commit/228bb1ba10df7d560d8f1a37156708856c780acb) 97 | - Use SVG instead of PNG for badges. [`c9c35fa`](https://github.com/inspect-js/is-object/commit/c9c35fac9a235762fe13408f0d4cd5637d4c4317) 98 | - Add dev dependency badge. [`ef78c97`](https://github.com/inspect-js/is-object/commit/ef78c97ee90a1ddffcf197705dcae15f792478ac) 99 | - Adding the npm module version. [`48ddbd5`](https://github.com/inspect-js/is-object/commit/48ddbd54d24b8d8ff8e073a0b890a76905f100a1) 100 | - Updating tape and testem [`adb2d36`](https://github.com/inspect-js/is-object/commit/adb2d369a97953b4570fc2cd9ec4f5cdebd049da) 101 | - Adding npm badge. [`35d55a8`](https://github.com/inspect-js/is-object/commit/35d55a8b2377a640734a0895eaa7d1502f4a48a7) 102 | - Run linter as part of tests [`d9a416b`](https://github.com/inspect-js/is-object/commit/d9a416bef698bf2767c821e9891624194f6d2d86) 103 | - Americanize spellings. [`c644aca`](https://github.com/inspect-js/is-object/commit/c644aca26f525b5d84431b447bf03132a014b7a0) 104 | - Run code coverage as part of tests. [`8fa74b3`](https://github.com/inspect-js/is-object/commit/8fa74b32c5ba2c350858d81403968445701ab56e) 105 | - Updating covert [`2c59d40`](https://github.com/inspect-js/is-object/commit/2c59d401a85493cdd6e1a3b34e7bd8f583664021) 106 | - Updating `tape` [`e65b0d3`](https://github.com/inspect-js/is-object/commit/e65b0d35f7ff9bbaba32a9ce06b69782101a3477) 107 | - `npm test` should be simple :-) [`df503c0`](https://github.com/inspect-js/is-object/commit/df503c0271665204cb4c42d573c2e5f7dfa78012) 108 | - make travis run 0.10 [`3a198b9`](https://github.com/inspect-js/is-object/commit/3a198b92b9a169a385a6350db21e62b3a6b9f99f) 109 | - travis should run node ./test [`33abb28`](https://github.com/inspect-js/is-object/commit/33abb286b229f2eb9576e2d2d64330ff2b337b7f) 110 | 111 | ## [v0.1.2](https://github.com/inspect-js/is-object/compare/v0.1.1...v0.1.2) - 2013-03-12 112 | 113 | ### Commits 114 | 115 | - not private -.- [`b1ef3b8`](https://github.com/inspect-js/is-object/commit/b1ef3b83dc8cf4ad64484f5f6faa59897633ff9d) 116 | 117 | ## v0.1.1 - 2013-03-12 118 | 119 | ### Commits 120 | 121 | - initial [`e62f915`](https://github.com/inspect-js/is-object/commit/e62f91558d2dabf271a100e91eae6c6204cd4641) 122 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Colingo. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # is-object [![Version Badge][npm-version-svg]][npm-url] 2 | 3 | [![github actions][actions-image]][actions-url] 4 | [![coverage][codecov-image]][codecov-url] 5 | [![dependency status][deps-svg]][deps-url] 6 | [![dev dependency status][dev-deps-svg]][dev-deps-url] 7 | [![License][license-image]][license-url] 8 | [![Downloads][downloads-image]][downloads-url] 9 | 10 | [![npm badge][npm-badge-png]][npm-url] 11 | 12 | Checks whether a value is an object 13 | 14 | Because `typeof null` is a troll. 15 | 16 | ## Example 17 | 18 | ```js 19 | var isObject = require('is-object'); 20 | var assert = require('assert'); 21 | 22 | assert.equal(isObject(null), false); 23 | assert.equal(isObject({}), true); 24 | ``` 25 | 26 | ## Installation 27 | 28 | `npm install is-object` 29 | 30 | ## Contributors 31 | 32 | - [Raynos][raynos-github] 33 | - [Jordan Harband][ljharb-github] 34 | 35 | ## MIT Licensed 36 | 37 | [deps-svg]: https://david-dm.org/inspect-js/is-object/status.svg 38 | [deps-url]: https://david-dm.org/inspect-js/is-object 39 | [raynos-github]: https://github.com/Raynos 40 | [ljharb-github]: https://github.com/ljharb 41 | [dev-deps-svg]: https://david-dm.org/inspect-js/is-object/dev-status.svg 42 | [dev-deps-url]: https://david-dm.org/inspect-js/is-object#info=devDependencies 43 | [npm-url]: https://npmjs.org/package/is-object 44 | [npm-version-svg]: https://versionbadg.es/inspect-js/is-object.svg 45 | [npm-badge-png]: https://nodei.co/npm/is-object.png?downloads=true&stars=true 46 | [license-image]: https://img.shields.io/npm/l/is-object.svg 47 | [license-url]: LICENSE 48 | [downloads-image]: https://img.shields.io/npm/dm/is-object.svg 49 | [downloads-url]: https://npm-stat.com/charts.html?package=is-object 50 | [codecov-image]: https://codecov.io/gh/inspect-js/is-object/branch/main/graphs/badge.svg 51 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-object/ 52 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-object 53 | [actions-url]: https://github.com/inspect-js/is-object/actions 54 | 55 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function isObject(x) { 4 | return typeof x === 'object' && x !== null; 5 | }; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "is-object", 3 | "version": "1.0.2", 4 | "description": "Checks whether a value is an object", 5 | "keywords": [], 6 | "author": "Raynos ", 7 | "funding": { 8 | "url": "https://github.com/sponsors/ljharb" 9 | }, 10 | "repository": "git://github.com/inspect-js/is-object.git", 11 | "main": "index", 12 | "homepage": "https://github.com/inspect-js/is-object", 13 | "contributors": [ 14 | { 15 | "name": "Raynos" 16 | }, 17 | { 18 | "name": "Jordan Harband", 19 | "url": "https://github.com/ljharb" 20 | } 21 | ], 22 | "bugs": { 23 | "url": "https://github.com/inspect-js/is-object/issues", 24 | "email": "ljharb@gmail.com" 25 | }, 26 | "devDependencies": { 27 | "@ljharb/eslint-config": "^21.0.0", 28 | "aud": "^2.0.1", 29 | "auto-changelog": "^2.4.0", 30 | "eslint": "=8.8.0", 31 | "in-publish": "^2.0.1", 32 | "npmignore": "^0.3.0", 33 | "nyc": "^10.3.2", 34 | "safe-publish-latest": "^2.0.0", 35 | "tape": "^5.6.1" 36 | }, 37 | "license": "MIT", 38 | "licenses": [ 39 | { 40 | "type": "MIT", 41 | "url": "https://github.com/inspect-js/is-object/raw/HEAD/LICENSE" 42 | } 43 | ], 44 | "scripts": { 45 | "prepack": "npmignore --auto --commentLines=autogenerated", 46 | "prepublishOnly": "safe-publish-latest", 47 | "prepublish": "not-in-publish || npm run prepubishOnly", 48 | "pretest": "npm run lint", 49 | "lint": "eslint --ext=.js,.mjs .", 50 | "tests-only": "nyc tape 'test/**/*.js'", 51 | "test": "npm run tests-only", 52 | "posttest": "aud --production", 53 | "version": "auto-changelog && git add CHANGELOG.md", 54 | "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" 55 | }, 56 | "testling": { 57 | "files": "test/index.js", 58 | "browsers": [ 59 | "ie/6..latest", 60 | "firefox/3..6", 61 | "firefox/16..latest", 62 | "firefox/nightly", 63 | "chrome/22..latest", 64 | "chrome/canary", 65 | "opera/10.0", 66 | "opera/11..latest", 67 | "opera/next", 68 | "safari/4..latest", 69 | "ipad/6.0..latest", 70 | "iphone/6.0..latest" 71 | ] 72 | }, 73 | "auto-changelog": { 74 | "output": "CHANGELOG.md", 75 | "template": "keepachangelog", 76 | "unreleased": false, 77 | "commitLimit": false, 78 | "backfillLimit": false, 79 | "hideCredit": true 80 | }, 81 | "publishConfig": { 82 | "ignore": [ 83 | ".github/workflows" 84 | ] 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var test = require('tape'); 4 | 5 | var isObject = require('../index'); 6 | 7 | test('returns true for objects', function (assert) { 8 | assert.equal(isObject({}), true); 9 | assert.equal(isObject([]), true); 10 | 11 | assert.end(); 12 | }); 13 | 14 | test('returns false for null', function (assert) { 15 | assert.equal(isObject(null), false); 16 | 17 | assert.end(); 18 | }); 19 | 20 | test('returns false for undefined', function (assert) { 21 | assert.equal(isObject(undefined), false); 22 | 23 | assert.end(); 24 | }); 25 | 26 | test('returns false for booleans', function (assert) { 27 | assert.equal(isObject(true), false); 28 | assert.equal(isObject(false), false); 29 | 30 | assert.end(); 31 | }); 32 | 33 | test('returns false for primitives', function (assert) { 34 | assert.equal(isObject(42), false); 35 | assert.equal(isObject('foo'), false); 36 | 37 | assert.end(); 38 | }); 39 | 40 | test('returns false for functions', function (assert) { 41 | assert.equal(isObject(function () {}), false); 42 | 43 | assert.end(); 44 | }); 45 | --------------------------------------------------------------------------------