amp-keys: Object Keys Utility

1.0.1 · abandoned · verified Wed Apr 22

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.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `keys` function using CommonJS `require` and use it to retrieve the enumerable own property names of various objects.

const getKeys = require('amp-keys');

const myObject = {
  name: 'Alice',
  age: 30,
  city: 'New York'
};

// Get own enumerable property names
const objectKeys = getKeys(myObject);
console.log('Keys of myObject:', objectKeys); // Expected: ['name', 'age', 'city']

const emptyObject = {};
const emptyKeys = getKeys(emptyObject);
console.log('Keys of emptyObject:', emptyKeys); // Expected: []

// Demonstrates Object.keys-like behavior (does not include prototype properties)
function ProtoExample() {
  this.ownProperty = 'foo';
}
ProtoExample.prototype.protoProperty = 'bar';

const instance = new ProtoExample();
const instanceKeys = getKeys(instance);
console.log('Keys of instance (own properties only):', instanceKeys); // Expected: ['ownProperty']

view raw JSON →