{"id":11478,"library":"obj-props","title":"obj-props: JavaScript Object Property Lists","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/dustinspecker/obj-props","tags":["javascript","js","ecmascript","builtin","types","type","data","props"],"install":[{"cmd":"npm install obj-props","lang":"bash","label":"npm"},{"cmd":"yarn add obj-props","lang":"bash","label":"yarn"},{"cmd":"pnpm add obj-props","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is the primary and recommended way to import the package, utilizing its default ES Module export. It imports the entire properties object.","symbol":"objProps","correct":"import objProps from 'obj-props';"},{"note":"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.","wrong":"const objProps = require('obj-props');","symbol":"objProps"},{"note":"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.","wrong":"import { Array, Object } from 'obj-props';","symbol":"Array, Object (example named exports)"}],"quickstart":{"code":"import objProps from 'obj-props';\n\n// objProps contains a mapping of JavaScript intrinsic object names to their properties.\n// For example, to see properties of the Array constructor:\nconsole.log('Array Constructor Properties:', objProps.Array);\n\n// To access properties of the Object constructor:\nconsole.log('Object Constructor Properties:', objProps.Object);\n\n// The entire data structure can be iterated or accessed directly.\n// For instance, to list all known intrinsic objects and their property counts:\nconsole.log('\\n--- All Intrinsic Objects and Property Counts ---');\nfor (const constructorName in objProps) {\n  if (Object.prototype.hasOwnProperty.call(objProps, constructorName)) {\n    const properties = objProps[constructorName];\n    console.log(`${constructorName}: ${properties.length} properties`);\n  }\n}\n\n// Example: Check if 'Promise' properties are listed and access them safely\nconst promiseProps = objProps.Promise;\nif (promiseProps) {\n  console.log('\\nPromise Constructor Properties (first 3):', promiseProps.slice(0, 3));\n} else {\n  console.log('\\nPromise properties not explicitly listed or available in this version.');\n}","lang":"typescript","description":"Demonstrates importing the obj-props object and accessing properties for various built-in JavaScript constructors, including safe iteration."},"warnings":[{"fix":"Upgrade your Node.js environment to version 18.0.0 or later to ensure compatibility.","message":"The 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.","severity":"breaking","affected_versions":"<18.0.0"},{"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.","message":"This 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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.","message":"As 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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()`.","message":"The `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.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use the ES module `import` syntax: `import objProps from 'obj-props';`","cause":"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.","error":"ERR_REQUIRE_ESM"},{"fix":"Access `objProps` directly as an object, for example, `objProps.Array` or `Object.keys(objProps)`.","cause":"Mistakenly treating the `objProps` export as a callable function or class constructor instead of a plain JavaScript object that serves as a data map.","error":"TypeError: objProps is not a function"},{"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.","cause":"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.","error":"Property 'X' does not exist on type 'Record<string, string[]>' (TypeScript error)"}],"ecosystem":"npm"}