{"id":13356,"library":"isobj","title":"isobj","description":"The `isobj` package provides a highly focused utility function designed to determine if a given JavaScript value is an 'object literal', specifically designed to exclude arrays (`[]`) and `null`. Released as version `1.0.0` in April 2014, the package has seen no subsequent updates or maintenance, indicating it is an abandoned project. Its functionality, based on its usage examples and common patterns for such utilities, likely checks if the `typeof` operator returns 'object' while also ensuring the value is not `null` and not an array (`Array.isArray`). Notably, it *does* return `true` for instances like `new Date()` or `new RegExp()`, which are JavaScript objects but not strictly 'plain' object literals (i.e., created by `{}`). Due to its age and lack of modern JavaScript module support (it's CommonJS-only), developers are generally advised to implement this check directly using native JavaScript constructs or opt for more actively maintained utility libraries that offer broader compatibility and features.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/watson/isobj","tags":["javascript","test","object","literal","validate","check"],"install":[{"cmd":"npm install isobj","lang":"bash","label":"npm"},{"cmd":"yarn add isobj","lang":"bash","label":"yarn"},{"cmd":"pnpm add isobj","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The only export is a default function accessible via CommonJS `require()`.","symbol":"isObj","correct":"const isObj = require('isobj');"},{"note":"This package is CommonJS-only (v1.0.0 from 2014) and does not provide ESM default exports. Attempting to use this will likely result in runtime errors such as `TypeError: isObj is not a function` or `isobj is not defined` in modern environments.","wrong":"import isObj from 'isobj';","symbol":"isObj"},{"note":"This package does not expose named ESM exports. Native Node.js ESM environments will typically fail with `ERR_PACKAGE_PATH_NOT_EXPORTED` or similar errors when trying to import a CJS-only module this way.","wrong":"import { isObj } from 'isobj';","symbol":"isObj"}],"quickstart":{"code":"const isObj = require('isobj');\n\nconsole.log('--- Testing various values with isobj ---');\n\n// Expected True cases: Object literals and some object instances\nconsole.log('{} (empty object literal):', isObj({}));\nconsole.log('{ a: 1 } (object literal):', isObj({ a: 1 }));\nconsole.log('new Object() (object instance):', isObj(new Object()));\nconsole.log('new Date() (Date object):', isObj(new Date())); // Important: isobj considers this true\nconsole.log('new RegExp(\"a\") (RegExp object):', isObj(new RegExp('a'))); // Important: isobj considers this true\n\n// Expected False cases: Non-objects, null, and arrays\nconsole.log('[] (array literal):', isObj([]));\nconsole.log('new Array() (array instance):', isObj(new Array()));\nconsole.log('null:', isObj(null));\nconsole.log('undefined:', isObj(undefined));\nconsole.log('123 (number):', isObj(123));\nconsole.log('\"hello\" (string):', isObj(\"hello\"));\nconsole.log('true (boolean):', isObj(true));\nconsole.log('Symbol(\"foo\") (symbol):', isObj(Symbol(\"foo\")));\nconsole.log('function() {} (function):', isObj(function() {}));\n\nconsole.log('\\n--- Understanding isobj\\'s definition of \"object\" ---');\nconst exampleValue = new Date();\nconsole.log(`For 'new Date()':`);\nconsole.log(`  - isObj(exampleValue): ${isObj(exampleValue)}`);\nconsole.log(`  - typeof exampleValue === 'object': ${typeof exampleValue === 'object'}`);\nconsole.log(`  - exampleValue !== null: ${exampleValue !== null}`);\nconsole.log(`  - !Array.isArray(exampleValue): ${!Array.isArray(exampleValue)}`);","lang":"javascript","description":"Demonstrates `isobj` usage with various data types, highlighting its interpretation of 'object literal' which includes `Date` and `RegExp` objects, but excludes `null` and arrays."},"warnings":[{"fix":"Prefer native JavaScript checks (`typeof value === 'object' && value !== null && !Array.isArray(value)`) or consider using actively maintained alternatives like `is-plain-object` if strictly plain objects are required, or a modern utility library like Lodash (`_.isObjectLike`) or Ramda for broader object checking needs.","message":"The `isobj` package is effectively abandoned. It was last published in 2014 (v1.0.0) and has received no updates or maintenance since. Using abandoned packages can introduce security vulnerabilities or compatibility issues with newer JavaScript features and environments.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always use `const isObj = require('isobj');` to import this package. If you are in an ESM-only project, consider wrapping it in a CJS loader or replacing it with a modern ESM-compatible utility.","message":"This package is CommonJS-only. It does not provide ECMAScript Module (ESM) exports. Attempting to `import` it in a native ESM environment will lead to runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For strictly plain objects, use `is-plain-object` or implement a custom check like `typeof value === 'object' && value !== null && value.constructor === Object && Object.prototype.toString.call(value) === '[object Object]'`.","message":"The package's definition of 'object literal' includes instances of built-in objects like `new Date()` or `new RegExp()`, which are `typeof object` but not strictly `{}`-style plain objects. If you require a check for strictly plain objects created by the `Object` constructor or `{}` syntax, this package will yield unexpected `true` results for other object types.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually declare types in a `.d.ts` file (e.g., `declare module 'isobj' { function isObj(value: unknown): boolean; export = isObj; }`) or migrate to a modern utility with built-in TypeScript support.","message":"There are no official TypeScript type definitions available for this specific `isobj` package (from `watson`). Developers using TypeScript will need to either declare their own types or accept implicit `any` for the import.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change the import statement to `const isObj = require('isobj');`.","cause":"Attempting to import `isobj` using an ESM `import` statement in a Node.js environment where the package is treated as a CommonJS module without a default export shim.","error":"TypeError: isObj is not a function"},{"fix":"Ensure your environment supports CommonJS `require()`. In browser contexts, use a bundler. In modern Node.js ESM files (`.mjs` or `type: 'module'` in `package.json`), you cannot directly use `require()`. Consider rewriting the check with native JavaScript or using an ESM-compatible utility.","cause":"Attempting to use `require()` in a browser environment without a CommonJS bundler (like Webpack or Browserify) or in a pure ECMAScript Module context in Node.js.","error":"ReferenceError: require is not defined"},{"fix":"If you need to check for strictly 'plain' objects (e.g., `{}`), use a dedicated utility like `is-plain-object` or implement a more specific native JavaScript check.","cause":"Misunderstanding the package's definition of 'object literal'. `isobj` checks if `typeof value === 'object'`, `value !== null`, and `!Array.isArray(value)`, which includes built-in object instances.","error":"isObj returns true for `new Date()` or `new RegExp()` but I expected false (only plain objects)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}