JavaScript Getter/Setter Properties List
The `get-set-props` package provides a comprehensive, machine-readable list of getter and setter properties available on standard JavaScript built-in types. This data is exposed as a simple JSON file, making it highly portable and usable across various JavaScript environments, including Node.js and browsers. Currently at version 0.2.0, its release cadence is likely infrequent, primarily tied to updates in the JavaScript specification or the underlying data source it forks from (Sindre Sorhus' `proto-props`). Its primary differentiator is its simplicity and directness: it's a static data set rather than a runtime utility, making it ideal for tooling, static analysis, or documentation generation that needs to query the reflective properties of JavaScript objects.
Common errors
-
TypeError: getSetProps is not a function
cause Attempting to invoke the imported `getSetProps` as a function. The package exports a data object, not a callable function.fixAccess properties directly from the imported object, e.g., `getSetProps.Array` to get the list for Arrays. -
SyntaxError: Cannot use import statement outside a module
cause Using `import` syntax in a CommonJS-only environment (e.g., an older Node.js project without `"type": "module"` in `package.json` or without proper transpilation).fixTo use ESM `import` statements, ensure your Node.js project's `package.json` includes `"type": "module"` or use a bundler (like Webpack, Rollup, Parcel) to transpile your code for CommonJS compatibility if targeting older environments.
Warnings
- gotcha This package is a static data source (a JSON file) and does not provide any runtime functions or utilities for dynamically reflecting properties. Users expecting a utility library to inspect objects at runtime should look for alternatives.
- breaking As a pre-1.0 package (currently 0.2.0), the exact structure or content of the exported JSON data might change in minor or even patch versions without strictly adhering to semantic versioning guidelines for data structure updates. Always review changes when upgrading.
- gotcha The package requires Node.js version 18 or greater, as specified in its `engines` field. Using it with older Node.js versions may lead to unexpected behavior or errors related to module resolution or syntax.
Install
-
npm install get-set-props -
yarn add get-set-props -
pnpm add get-set-props
Imports
- getSetProps
const getSetProps = require('get-set-props');import getSetProps from 'get-set-props';
- getSetProps.json
import data from 'get-set-props/get-set-props.json';
- Type information
/** @type {import('get-set-props')} */ const getSetProps = require('get-set-props');
Quickstart
import getSetProps from 'get-set-props';
console.log(getSetProps);
/*
// Example partial output:
{
Array: [
'length',
],
ArrayBuffer: [
],
Boolean: [],
DataView: [
'buffer',
'byteLength',
'byteOffset'
],
Date: [
'timezoneOffset'
],
Error: [
'stack'
],
Float32Array: [
'buffer',
'byteLength',
'byteOffset',
'length'
]
}
*/