Registry / x-is-object

x-is-object

JSON →
library0.1.0jsnpmunverified

The `x-is-object` package provides a minimalist utility function designed to determine if a given JavaScript value is a 'proper object'. This specifically means it checks if the value inherits from `Object` while explicitly excluding `null`, which the standard `typeof value === 'object'` incorrectly classifies as an object. It correctly identifies plain objects, arrays, regular expressions, functions, dates, and wrapped primitives as objects. Currently at version 0.1.0, this package appears to be an older, largely unmaintained project. Its release cadence is effectively non-existent, and there's no indication of active development or planned updates. Key differentiators include its extreme simplicity and its clear, specific definition of what constitutes an object by explicitly excluding `null`, making it a focused alternative to more comprehensive type-checking libraries. It primarily targets CommonJS environments.

npm install x-is-object
INSTALL
IMPORT
SIG · X-IS-OBJECT
X
x-is-object
javascriptv0.1.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.

isObject
const isObject = require('x-is-object');
import isObject from 'x-is-object';
Package is primarily designed for CommonJS environments.
isObject
import isObject from 'x-is-object';
const isObject = require('x-is-object');
For ESM, treat as a default export, though official ESM support might be lacking.
isObject (named default)
import { default as isObject } from 'x-is-object';
import { isObject } from 'x-is-object';
Explicitly importing the default export as a named variable in ESM.

Demonstrates how to import and use the `isObject` function to test various values, highlighting its core behavior of returning true for true objects and false for primitives or null.

const isObject = require('x-is-object'); console.log('{} is object:', isObject({})); // -> true console.log('[] is object:', isObject([])); // -> true console.log('/.*/ is object:', isObject(/.*/)); // -> true console.log('function() {} is object:', isObject(function () {})); // -> true console.log('"hello" is object:', isObject('hello')); // -> false console.log('null is object:', isObject(null)); // -> false console.log('undefined is object:', isObject(undefined)); // -> false
Debug
Known issues
breakingThis package is at version 0.1.0 and appears to be unmaintained. It may not receive security updates, bug fixes, or compatibility updates for newer JavaScript environments or Node.js versions.
fix
Consider using a more actively maintained and robust type-checking library, such as `lodash.isobject` or a custom utility for critical applications. If used, pin the exact version to avoid unexpected changes.
affects: >=0.1.0
gotchaThe package provides only CommonJS exports. While it might work with some ESM bundlers via interop, there is no explicit ESM support or official TypeScript type definitions.
fix
For CommonJS, use `require('x-is-object')`. For ESM, `import isObject from 'x-is-object';` might work but is not officially supported. Manual type declarations (`declare module 'x-is-object'`) would be needed for TypeScript projects.
affects: >=0.1.0
gotchaThe definition of 'object' by `x-is-object` specifically excludes `null` but includes arrays, functions, and regular expressions. This might differ from other libraries or expectations that distinguish between 'plain objects' or specific built-in types.
fix
Be aware of `x-is-object`'s specific definition. If you need to check for plain objects only (e.g., `{}`), you'll need a different utility or a more specific check like `typeof value === 'object' && value !== null && value.constructor === Object`.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: isObject is not a function
Attempting to use `isObject` after an incorrect import or require statement, or trying to access it as a named export in ESM.
fix
For CommonJS, use `const isObject = require('x-is-object');`. For ESM, use `import isObject from 'x-is-object';`.
ReferenceError: require is not defined (when using 'require' in an ESM module)
Using CommonJS `require` syntax within a JavaScript module that is treated as an ES Module (e.g., in a 'type: module' package or an `.mjs` file).
fix
Change the import statement to `import isObject from 'x-is-object';` to align with ES Module syntax. Ensure your build pipeline or Node.js environment correctly handles ES Modules.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources