github-pages-deploy-action/node_modules/object.getownpropertydescriptors
2020-03-06 22:45:40 -05:00
..
node_modules Dependencies 2020-03-06 22:45:40 -05:00
test Dependencies 2020-01-28 00:08:03 -05:00
.editorconfig Dependencies Required 2020-01-28 00:07:56 -05:00
.eslintrc Dependencies Required 2020-01-28 00:07:56 -05:00
.jscs.json Dependencies Required 2020-01-28 00:07:56 -05:00
.npmignore Dependencies Required 2020-01-28 00:07:56 -05:00
.travis.yml Dependencies Required 2020-01-28 00:07:56 -05:00
CHANGELOG.md Dependencies Required 2020-01-28 00:07:56 -05:00
implementation.js Dependencies Required 2020-01-28 00:07:56 -05:00
index.js Dependencies Required 2020-01-28 00:07:56 -05:00
LICENSE Dependencies Required 2020-01-28 00:07:56 -05:00
Makefile Dependencies Required 2020-01-28 00:07:56 -05:00
package.json Dependencies Required 2020-01-28 00:07:56 -05:00
polyfill.js Dependencies Required 2020-01-28 00:07:56 -05:00
README.md Dependencies Required 2020-01-28 00:07:56 -05:00
shim.js Dependencies Required 2020-01-28 00:07:56 -05:00

#object.getownpropertydescriptors Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

An ES2017 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