Registry / serialization / isobj
library1.0.0jsnpmunverified

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.

npm install isobj
INSTALL
IMPORT
SIG · ISOBJ
I
isobj
serializationjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isObj
const isObj = require('isobj');
The only export is a default function accessible via CommonJS `require()`.
isObj
import isObj from 'isobj';
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.
isObj
import { isObj } from 'isobj';
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.

Demonstrates `isobj` usage with various data types, highlighting its interpretation of 'object literal' which includes `Date` and `RegExp` objects, but excludes `null` and arrays.

const isObj = require('isobj'); console.log('--- Testing various values with isobj ---'); // Expected True cases: Object literals and some object instances console.log('{} (empty object literal):', isObj({})); console.log('{ a: 1 } (object literal):', isObj({ a: 1 })); console.log('new Object() (object instance):', isObj(new Object())); console.log('new Date() (Date object):', isObj(new Date())); // Important: isobj considers this true console.log('new RegExp("a") (RegExp object):', isObj(new RegExp('a'))); // Important: isobj considers this true // Expected False cases: Non-objects, null, and arrays console.log('[] (array literal):', isObj([])); console.log('new Array() (array instance):', isObj(new Array())); console.log('null:', isObj(null)); console.log('undefined:', isObj(undefined)); console.log('123 (number):', isObj(123)); console.log('"hello" (string):', isObj("hello")); console.log('true (boolean):', isObj(true)); console.log('Symbol("foo") (symbol):', isObj(Symbol("foo"))); console.log('function() {} (function):', isObj(function() {})); console.log('\n--- Understanding isobj\'s definition of "object" ---'); const exampleValue = new Date(); console.log(`For 'new Date()':`); console.log(` - isObj(exampleValue): ${isObj(exampleValue)}`); console.log(` - typeof exampleValue === 'object': ${typeof exampleValue === 'object'}`); console.log(` - exampleValue !== null: ${exampleValue !== null}`); console.log(` - !Array.isArray(exampleValue): ${!Array.isArray(exampleValue)}`);
Debug
Known issues
breakingThe `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.
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.
affects: >=1.0.0
gotchaThis 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.
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.
affects: >=1.0.0
gotchaThe 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.
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]'`.
affects: >=1.0.0
gotchaThere 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.
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.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: isObj is not a function
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.
fix
Change the import statement to `const isObj = require('isobj');`.
ReferenceError: require is not defined
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.
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.
isObj returns true for `new Date()` or `new RegExp()` but I expected false (only plain objects)
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.
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.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
isobj — npm install isobj · libregistry