Registry / amp-has

amp-has

JSON →
library1.0.1jsnpmunverified

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.

npm install amp-has
INSTALL
IMPORT
SIG · AMP-HAS
A
amp-has
javascriptv1.0.1
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.

has
const has = require('amp-has');
import { has } from 'amp-has'; import has from 'amp-has';
amp-has is a CommonJS module. It does not provide native ES Module exports. Attempting to use `import` syntax will result in errors.

Demonstrates importing and using the `has` function to safely check for the existence of nested properties within an object, including null or undefined paths.

const has = require('amp-has'); const user = { id: 1, name: 'Alice', address: { street: '123 Main St', city: 'Anytown', zip: '12345' }, contact: null }; console.log('User has address.city:', has(user, 'address.city')); // Expected: true console.log('User has address.country:', has(user, 'address.country')); // Expected: false console.log('User has id:', has(user, 'id')); // Expected: true console.log('User has contact.email:', has(user, 'contact.email')); // Expected: false (handles null paths gracefully) // For modern usage, it's recommended to use lodash.has directly: // const lodashHas = require('lodash.has'); // console.log('Using lodash.has directly:', lodashHas(user, 'address.zip'));
Debug
Known issues
deprecated`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.
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.
affects: >=1.0.0
gotchaThis 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.
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).
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
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`.
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.
TypeError: has is not a function
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`.
fix
The correct CommonJS import is `const has = require('amp-has');`.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
lodash.hasrequiredThis package is a direct re-export of lodash.has. Users should install and use lodash.has directly.
Agent activity
4 hits · last 30 days
node
4
Resources
amp-has — npm install amp-has · libregistry