{"id":17155,"library":"amp-is-object","title":"amp-is-object: Object Type Checker","description":"The `amp-is-object` package provides a minimalist utility function to reliably determine if a given JavaScript value is an object. It is part of the `ampersand.js` ecosystem, a loosely coupled, non-frameworky collection of modules for client-side applications, often drawing inspiration from Backbone.js. Crucially, this package is unrelated to Google's Accelerated Mobile Pages (AMP Project), which is a distinct initiative for web content optimization. Currently at version 1.0.1, `amp-is-object` is a stable, simple module with a focused scope. The broader `ampersand.js` project appears to be in a maintenance state with infrequent updates, meaning this utility package is largely static, offering consistent behavior without active feature development or frequent new releases. Its primary differentiation lies in its minimal footprint and specific role within the `ampersand.js` context, providing a core type-checking function.","status":"maintenance","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/ampersandjs/amp","tags":["javascript","amp","util","utils"],"install":[{"cmd":"npm install amp-is-object","lang":"bash","label":"npm"},{"cmd":"yarn add amp-is-object","lang":"bash","label":"yarn"},{"cmd":"pnpm add amp-is-object","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CommonJS module. Use `require()` for compatibility, especially in Node.js environments. Direct ES module `import` syntax will not work without transpilation or specific Node.js loader configurations for CJS interoperability.","wrong":"import isObject from 'amp-is-object';\nimport { isObject } from 'amp-is-object';","symbol":"isObject","correct":"const isObject = require('amp-is-object');"}],"quickstart":{"code":"const isObject = require('amp-is-object');\n\nconsole.log('Is {} an object?', isObject({})); // Expected: true\nconsole.log('Is [] an object?', isObject([])); // Expected: true (arrays are objects in JS)\nconsole.log('Is null an object?', isObject(null)); // Expected: false (common JS gotcha)\nconsole.log('Is \"hello\" an object?', isObject('hello')); // Expected: false\nconsole.log('Is 123 an object?', isObject(123)); // Expected: false\nconsole.log('Is undefined an object?', isObject(undefined)); // Expected: false\nconsole.log('Is new Date() an object?', isObject(new Date())); // Expected: true","lang":"javascript","description":"Demonstrates how to import and use the `isObject` function to check various JavaScript values."},"warnings":[{"fix":"Verify the package origin (`ampersandjs` on GitHub) and context (a client-side JS framework utility) to ensure it aligns with your project's needs, distinct from Google AMP.","message":"This package, `amp-is-object`, is part of the `ampersand.js` project and is NOT related to Google's Accelerated Mobile Pages (AMP Project / amp.dev). The names are coincidental, but the technologies and ecosystems are completely different. Do not confuse them.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"In ES Module contexts, consider using dynamic import (`import('amp-is-object').then(mod => mod)`) or ensure your build tools (e.g., Webpack, Rollup, Babel) are configured to handle CommonJS modules.","message":"The `amp-is-object` package is implemented as a CommonJS module. In modern Node.js environments configured for ES Modules (`\"type\": \"module\"` in `package.json`), a direct `require()` call might lead to errors, or `import` statements might fail to resolve the module correctly without specific interoperability settings or transpilation.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider if a more actively maintained and modern utility for object type checking (e.g., from Lodash, Underscore, or a dedicated modern small utility) would better suit long-term project needs, especially for new projects.","message":"This package, being at version 1.0.1 and part of an older, largely maintenance-mode ecosystem (`ampersand.js`), is unlikely to receive new features, significant bug fixes, or updates to modern JavaScript paradigms (e.g., native ESM support, TypeScript definitions). It is stable but static.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"For basic CJS compatibility in ESM, you can typically use `import { createRequire } from 'module'; const require = createRequire(import.meta.url);` then `const isObject = require('amp-is-object');`. Alternatively, use a build tool that handles CJS-to-ESM conversion.","cause":"Attempting to use `require()` in a JavaScript file that is being interpreted as an ES Module (e.g., due to `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Since `amp-is-object` likely exports a single function directly via `module.exports = function() { ... }`, the correct (though sometimes still problematic in pure ESM) import if you absolutely must use `import` syntax would be `import isObject = require('amp-is-object');` (TypeScript specific) or `import * as isObject from 'amp-is-object';` followed by `isObject.default()` or `isObject()` depending on build/runtime behavior, but `require` is safest.","cause":"This error occurs when an ES Module `import isObject from 'amp-is-object';` attempts to treat the CommonJS module's `module.exports` as a default export, but the export is not structured that way, or the transpiler/runtime incorrectly handles it.","error":"TypeError: (0, _ampIsObject.default) is not a function"}],"ecosystem":"npm","meta_description":null}