{"id":17151,"library":"amp-has","title":"amp-has utility (re-export of lodash.has)","description":"The `amp-has` package provides a simple utility function, `has`, designed to check for the existence of nested properties within an object. It is part of the `ampersand.js` ecosystem, which was a collection of loosely coupled JavaScript modules for client-side applications. The package, currently at version 1.0.1, was last updated in April 2016 and is essentially a direct re-export of the `lodash.has` function. Given the minimal activity on the `ampersand.js` project and this specific utility's unmaintained status for many years, its release cadence is effectively ceased. Its key differentiator was its inclusion in the `ampersand.js` modular approach; however, modern applications are strongly advised to use `lodash.has` directly, which is actively maintained and supports contemporary JavaScript module systems.","status":"deprecated","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/ampersandjs/amp","tags":["javascript","amp","util","objects"],"install":[{"cmd":"npm install amp-has","lang":"bash","label":"npm"},{"cmd":"yarn add amp-has","lang":"bash","label":"yarn"},{"cmd":"pnpm add amp-has","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a direct re-export of lodash.has. Users should install and use lodash.has directly.","package":"lodash.has","optional":false}],"imports":[{"note":"amp-has is a CommonJS module. It does not provide native ES Module exports. Attempting to use `import` syntax will result in errors.","wrong":"import { has } from 'amp-has';\nimport has from 'amp-has';","symbol":"has","correct":"const has = require('amp-has');"}],"quickstart":{"code":"const has = require('amp-has');\n\nconst user = {\n  id: 1,\n  name: 'Alice',\n  address: {\n    street: '123 Main St',\n    city: 'Anytown',\n    zip: '12345'\n  },\n  contact: null\n};\n\nconsole.log('User has address.city:', has(user, 'address.city'));\n// Expected: true\n\nconsole.log('User has address.country:', has(user, 'address.country'));\n// Expected: false\n\nconsole.log('User has id:', has(user, 'id'));\n// Expected: true\n\nconsole.log('User has contact.email:', has(user, 'contact.email'));\n// Expected: false (handles null paths gracefully)\n\n// For modern usage, it's recommended to use lodash.has directly:\n// const lodashHas = require('lodash.has');\n// console.log('Using lodash.has directly:', lodashHas(user, 'address.zip'));","lang":"javascript","description":"Demonstrates importing and using the `has` function to safely check for the existence of nested properties within an object, including null or undefined paths."},"warnings":[{"fix":"Uninstall `amp-has` and install `lodash.has`. Replace `require('amp-has')` with `require('lodash.has')` or `import { has } from 'lodash';` if using a full Lodash build or ESM-compatible Lodash package.","message":"`amp-has` is unmaintained since 2016 and is merely a re-export of `lodash.has`. It is strongly recommended to switch directly to `lodash.has` to ensure you are using a current, maintained dependency and avoid potential compatibility issues.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure your project is configured for CommonJS, or use dynamic `import()` if you must use it in an ESM context, though switching to `lodash.has` (which supports ESM) is the better long-term solution. Example: `const has = await import('amp-has');` (note: this imports the module object, not the function directly).","message":"This package is a CommonJS (CJS) module and does not natively support ES Module (ESM) `import` syntax. Attempting to use `import` statements will lead to runtime errors in pure ESM environments.","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":"If staying with `amp-has`, use `const has = require('amp-has');`. Otherwise, migrate to `lodash.has` which offers better ESM support with modern tooling.","cause":"Attempting to use `import { has } from 'amp-has'` in a Node.js project that is configured as a CommonJS module or does not have `\"type\": \"module\"` in its `package.json`.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"The correct CommonJS import is `const has = require('amp-has');`.","cause":"This error can occur if you attempt to destructure `require('amp-has')` (e.g., `const { has } = require('amp-has')`) or use an incorrect `import` statement in a CJS context, as `amp-has` exports the `has` function directly as its `module.exports`.","error":"TypeError: has is not a function"}],"ecosystem":"npm","meta_description":null}