{"id":17153,"library":"amp-keys","title":"amp-keys: Object Keys Utility","description":"amp-keys is a minimalist JavaScript utility module, currently at version 1.0.1. It provides a single `keys` function designed to mimic the functionality of `Object.keys`. This package originates from the Ampersand.js project, an older, modular client-side framework that emphasized loosely coupled components. Given that `amp-keys` was last published many years ago (approximately nine years ago, with its parent Ampersand.js last seeing activity around December 2022) and the broader Ampersand.js ecosystem appears to be largely unmaintained, this module can be considered stable but effectively abandoned. Its primary utility was likely for older JavaScript environments that lacked native `Object.keys` support or to provide API consistency within the Ampersand.js application architecture. For modern JavaScript development, relying on the native `Object.keys` is universally preferred, rendering this package largely redundant. Its release cadence was minimal, likely only seeing updates to align with the Ampersand.js framework's initial stable releases.","status":"abandoned","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-keys","lang":"bash","label":"npm"},{"cmd":"yarn add amp-keys","lang":"bash","label":"yarn"},{"cmd":"pnpm add amp-keys","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and exports the function directly as the module.exports. Attempting to use named ESM imports will likely result in an undefined value or an error in Node.js environments unless transpiled.","wrong":"import { keys } from 'amp-keys';","symbol":"keys","correct":"const keys = require('amp-keys');"},{"note":"The package likely exports the function as the module's default export (module.exports = function), not as a named export. Destructuring will fail as 'keys' would be undefined on the module object.","wrong":"const { keys } = require('amp-keys');","symbol":"keys (via destructuring)","correct":"const getObjectKeys = require('amp-keys');\nconst keys = getObjectKeys; // The function is the default export"}],"quickstart":{"code":"const getKeys = require('amp-keys');\n\nconst myObject = {\n  name: 'Alice',\n  age: 30,\n  city: 'New York'\n};\n\n// Get own enumerable property names\nconst objectKeys = getKeys(myObject);\nconsole.log('Keys of myObject:', objectKeys); // Expected: ['name', 'age', 'city']\n\nconst emptyObject = {};\nconst emptyKeys = getKeys(emptyObject);\nconsole.log('Keys of emptyObject:', emptyKeys); // Expected: []\n\n// Demonstrates Object.keys-like behavior (does not include prototype properties)\nfunction ProtoExample() {\n  this.ownProperty = 'foo';\n}\nProtoExample.prototype.protoProperty = 'bar';\n\nconst instance = new ProtoExample();\nconst instanceKeys = getKeys(instance);\nconsole.log('Keys of instance (own properties only):', instanceKeys); // Expected: ['ownProperty']","lang":"javascript","description":"Demonstrates how to import the `keys` function using CommonJS `require` and use it to retrieve the enumerable own property names of various objects."},"warnings":[{"fix":"Migrate to native `Object.keys()` for all modern JavaScript environments. For extremely old environments, consider a modern polyfill or bundler configuration.","message":"This package is effectively abandoned. There will be no further updates, bug fixes, or security patches. It is not compatible with modern JavaScript module systems (ESM) without specific CommonJS interop mechanisms or transpilation.","severity":"breaking","affected_versions":">=1.0.1"},{"fix":"Replace `require('amp-keys')(obj)` with `Object.keys(obj)` directly.","message":"The functionality provided by `amp-keys` is natively available in all modern JavaScript environments (ES5 and above) via `Object.keys()`. Using this package introduces unnecessary overhead and a dependency for already available functionality.","severity":"gotcha","affected_versions":">=1.0.1"},{"fix":"If absolutely necessary to use in an ESM context, wrap it in a compatibility layer or use dynamic `import()` for CJS modules (e.g., `const getKeys = await import('amp-keys'); const keys = getKeys.default;`), but migrating to `Object.keys()` is strongly advised.","message":"This package is a CommonJS module. Direct ES module `import` statements will not work as expected in a native ESM context (e.g., Node.js with type: 'module') unless transpiled or explicit CommonJS interop is used, which is not recommended for an abandoned package.","severity":"gotcha","affected_versions":">=1.0.1"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Use CommonJS `require` to import the default export: `const keys = require('amp-keys');`","cause":"Attempting to use ES module named import syntax (`import { keys } from 'amp-keys';`) when the package is a CommonJS module exporting a single function as its default.","error":"TypeError: (0 , amp_keys_1.keys) is not a function"},{"fix":"The module exports the function directly. Import it as a single variable: `const ampKeys = require('amp-keys');`","cause":"Incorrectly destructuring the CommonJS module import, assuming a named export when the module exports a single function as its default (e.g., `const { ampKeys } = require('amp-keys');`).","error":"TypeError: ampKeys is not a function"}],"ecosystem":"npm","meta_description":null}