Registry / type-stubs / obj-props

obj-props

JSON →
library2.0.0jsnpmunverified

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.

npm install obj-props
INSTALL
IMPORT
SIG · OBJ-PROPS
O
obj-props
type-stubsjavascriptv2.0.0
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.

objProps
import objProps from 'obj-props';
This is the primary and recommended way to import the package, utilizing its default ES Module export. It imports the entire properties object.
objProps
const objProps = require('obj-props');
Attempting to use CommonJS `require()` will result in an `ERR_REQUIRE_ESM` error if the consuming project is set up as an ES module or if `obj-props` itself declares `"type": "module"` in its `package.json`. Node.js 18+ environments, especially with modern package configurations, heavily favor ES Modules.
Array, Object (example named exports)
import { Array, Object } from 'obj-props';
The `obj-props` package provides a single default export which is the entire object containing all properties. It does not export individual intrinsic object property lists as named exports. Trying to destructure named exports from it will fail, as 'Array' or 'Object' are keys within the default-exported object, not top-level exports of the module itself.

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.'); }
Debug
Known issues
breakingThe package explicitly requires Node.js version 18.0.0 or higher. Installation or execution in older Node.js environments will fail due to engine restrictions.
fix
Upgrade your Node.js environment to version 18.0.0 or later to ensure compatibility.
affects: <18.0.0
breakingThis package is a fork of Sindre Sorhus's `proto-props`. While it offers similar functionality, there may be divergences in the data structure, the set of covered properties, or future maintenance. Users migrating from `proto-props` should carefully review the contents and changelog for `obj-props` to understand any behavioral or data differences.
fix
Review the `obj-props.json` file and the package's changelog, especially when migrating from `proto-props`, to identify any breaking changes in data or behavior.
affects: >=2.0.0
breakingAs a major version (`2.0.0`), there may be breaking changes in the structure or content of the `objProps` data object compared to previous major versions. Always consult the release notes when upgrading between major versions.
fix
Consult the `obj-props` release notes or directly inspect the `obj-props.json` file when upgrading from a previous major version to understand any data structure changes.
affects: >=2.0.0
gotchaThe `obj-props` package provides a static snapshot of JavaScript object properties. Its data is generated at build time (via `npm run generate`) and does not dynamically reflect runtime changes to object prototypes or properties in your specific JavaScript environment. New ECMAScript features or host object properties will only be included in new package versions.
fix
Understand that the data is fixed for the installed package version. If you require dynamic reflection of an object's current properties at runtime, use `Object.getOwnPropertyNames()`, `Object.keys()`, or `Reflect.ownKeys()`.
affects: >=2.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to import `obj-props` using `require()` in an ES module context or when the package is primarily designed as an ES module, which prevents synchronous `require` calls.
fix
Use the ES module `import` syntax: `import objProps from 'obj-props';`
TypeError: objProps is not a function
Mistakenly treating the `objProps` export as a callable function or class constructor instead of a plain JavaScript object that serves as a data map.
fix
Access `objProps` directly as an object, for example, `objProps.Array` or `Object.keys(objProps)`.
Property 'X' does not exist on type 'Record<string, string[]>' (TypeScript error)
Attempting to access a property (e.g., `objProps.MyCustomObject`) that is not explicitly part of the `objProps` object's inferred type or included in the static JSON data, which primarily covers built-in JavaScript intrinsics.
fix
Access the property with optional chaining (`objProps.MyCustomObject?.propertyName`) or use a type assertion (`(objProps as Record<string, string[]>).MyCustomObject`) if you are confident it exists, or check `Object.keys(objProps)` for available properties. Remember it only contains built-in objects.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
obj-props — npm install obj-props · libregistry