🚀 Socket Launch Week 🚀 Day 3: Socket Acquires Coana.Learn More
Socket
Sign inDemoInstall
Socket

enhance-object-property-names-getters

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enhance-object-property-names-getters

Enhance Object with getAllPropertyNames and getNPropertyNames

0.0.2
latest
Source
npm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

enhance-object-property-names-getters

Enhance Object with getAllPropertyNames and getNPropertyNames

Install

Simply require/import enhance-object-property-names-getters from npm/yarn

Use

After requiring/importing, Object will have new configurable descriptors:

Object.getOwnPropertyNames(document); // ['location'] (length:1)
Object.getNPropertyNames(document, 0); // [] (length:0)
Object.getNPropertyNames(document, 1); // ['location'] (length:1)
Object.getNPropertyNames(document, 2); // ['location', 'constructor'] (length:2)
Object.getNPropertyNames(document, 3); // ['location', 'constructor', ...] (length:235)
Object.getAllPropertyNames(document); // ['location', 'constructor', ...] (length:299)

You can also pass to both a final boolean argument to either use or avoid caching of properties (default:true)

Explanation

Object.getOwnPropertyNames gives you the own props of an object, sometimes you might want more properties that are inherited as part of the prototype chain. You can ask for all properties using getAllPropertyNames by climbing up the chain to the final root, or climb only a fixed amount of levels using getNPropertyNames.

FAQs

Package last updated on 14 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts