obj-props: JavaScript Object Property Lists

2.0.0 · active · verified Sun Apr 19

obj-props is a utility package that provides a structured JSON file containing lists of properties for various built-in JavaScript objects. It offers a static dataset, mapping JavaScript constructor names (e.g., "Array", "Boolean", "Object") to an array of their respective property names. The current stable version is 2.0.0. Due to its nature as a static data provider, the package follows an infrequent release cadence, with new versions primarily released when new ECMAScript features introduce new built-in properties or when the underlying data source is updated. It differentiates itself by being a pre-generated, easily consumable JSON resource, forked from Sindre Sorhus's `proto-props`, making it suitable for environments where runtime reflection or dynamic property enumeration might be undesirable or overkill. This makes it valuable for static analysis, documentation, or environments with restricted execution contexts.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing the obj-props object and accessing properties for various built-in JavaScript constructors, including safe iteration.

import objProps from 'obj-props';

// objProps contains a mapping of JavaScript intrinsic object names to their properties.
// For example, to see properties of the Array constructor:
console.log('Array Constructor Properties:', objProps.Array);

// To access properties of the Object constructor:
console.log('Object Constructor Properties:', objProps.Object);

// The entire data structure can be iterated or accessed directly.
// For instance, to list all known intrinsic objects and their property counts:
console.log('\n--- All Intrinsic Objects and Property Counts ---');
for (const constructorName in objProps) {
  if (Object.prototype.hasOwnProperty.call(objProps, constructorName)) {
    const properties = objProps[constructorName];
    console.log(`${constructorName}: ${properties.length} properties`);
  }
}

// Example: Check if 'Promise' properties are listed and access them safely
const promiseProps = objProps.Promise;
if (promiseProps) {
  console.log('\nPromise Constructor Properties (first 3):', promiseProps.slice(0, 3));
} else {
  console.log('\nPromise properties not explicitly listed or available in this version.');
}

view raw JSON →