Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

Object.getOwnPropertyDescriptors

ES7 spec-compliant shim for `Object.getOwnPropertyDescriptors` that works in ES5.

Subscribe to updates I use Object.getOwnPropertyDescriptors


Statistics on Object.getOwnPropertyDescriptors

Number of watchers on Github 0
Number of open issues 0
Main language HTML
Open pull requests 0+
Closed pull requests 0+
Last commit over 4 years ago
Repo Created over 4 years ago
Repo Last Updated over 4 years ago
Size 33 KB
Organization / Authorwebreflection
Contributors1
Page Updated
Do you use Object.getOwnPropertyDescriptors? Leave a review!
View Object.getOwnPropertyDescriptors activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating Object.getOwnPropertyDescriptors for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

object.getownpropertydescriptors Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

An ECMAScript spec-compliant shim for Object.getOwnPropertyDescriptors that works in ES5. Invoke its shim method to shim Object.getOwnPropertyDescriptors if it is unavailable, and if Object.getOwnPropertyDescriptor is available.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Example

var getDescriptors = require('object.getownpropertydescriptors');
var assert = require('assert');
var obj = { normal: Infinity };
var enumDescriptor = {
    enumerable: false,
    writable: false,
    configurable: true,
    value: true
};
var writableDescriptor = {
    enumerable: true,
    writable: true,
    configurable: true,
    value: 42
};
var symbol = Symbol();
var symDescriptor = {
    enumerable: true,
    writable: true,
    configurable: false,
    value: [symbol]
};

Object.defineProperty(obj, 'enumerable', enumDescriptor);
Object.defineProperty(obj, 'writable', writableDescriptor);
Object.defineProperty(obj, 'symbol', symDescriptor);

var descriptors = getDescriptors(obj);

assert.deepEqual(descriptors, {
    normal: {
        enumerable: true,
        writable: true,
        configurable: true,
        value: Infinity
    },
    enumerable: enumDescriptor,
    writable: writableDescriptor,
    symbol: symDescriptor
});
var getDescriptors = require('object.getownpropertydescriptors');
var assert = require('assert');
/* when Object.getOwnPropertyDescriptors is not present */
delete Object.getOwnPropertyDescriptors;
var shimmedDescriptors = getDescriptors.shim();
assert.equal(shimmedDescriptors, getDescriptors);
assert.deepEqual(shimmedDescriptors(obj), getDescriptors(obj));
var getDescriptors = require('object.getownpropertydescriptors');
var assert = require('assert');
/* when Object.getOwnPropertyDescriptors is present */
var shimmedDescriptors = getDescriptors.shim();
assert.notEqual(shimmedDescriptors, getDescriptors);
assert.deepEqual(shimmedDescriptors(obj), getDescriptors(obj));

Tests

Simply clone the repo, npm install, and run npm test

Object.getOwnPropertyDescriptors list of languages used
Other projects in HTML