2.1.8 • Published 1 month ago

object.getownpropertydescriptors v2.1.8

Weekly downloads
15,000,982
License
MIT
Repository
github
Last release
1 month ago

object.getownpropertydescriptors Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

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

util.promisifynode-environment-flagssymbol.prototype.descriptionutil-promisifyairbnb-js-shimsarchetype-libraryvuedragdropuploadimageskilli8n-react-native-fast-imagespecify-importsbabel-specify-imports@icanpm/api-master@cashremit/cr-streamline-iconscloud-archive-s3bb-chat@frxf/frxf@fundefund/funde_ckgql_din_modafryxicons@l1nyanm1ng/react-picture-viewercogoportutilsreact-native-slider-kf@infinitebrahmanuniverse/nolb-object_@saaspe/componentssklif-ui-kitsklif-api@everything-registry/sub-chunk-2365p149-tablesklif-ui@anonybit-modules/videoreconstruction@devorso/dcountdowndesign-system-fitbank-450dataormfastlion-picture-viewerfn-lib-exampleflowable-bpmn-modelerfrdrk-js-semaphoreenzyme-adapter-react-helperes7-shim@hazyflame/vue-jitsi-meetimage-stories@hawkingnetwork/react-native-tab-view@hansomware/tools@greminder/bootstrap-material-designhubot-buda@graines-digitales/nice-handsome-buttonhot-zone-vueiex-sdkicons-vue-testjamuskalim@chakra-swap/core@eliteswap/v2-core@ericmcornelius/ease@farvater/open-pedigree@fabwcie/ckeditor5-preview@fate-lovely/wxmp@faizanhaider/iconsaxhexyun.helpersguruwayguruway.jsgenerator-bootstrap-boilerplate-template@innoswap/core@inti-ar/evm-chains@ikon-x/ckeditor5-custom-build-for-irrosoftjesusdemojulien-easy-modal@jarrydark/editorsimplejs@jellywelly/iterare@igniswap/igni-swap-libl2forlerna@kodinghandle/bullswap-lib@knooks/use-title@kommunicate/kommunicate-chatbot-plugin@junto/vuex-class-component@junvary/quasar-ui-qcascader@jretts/modified-sveltejs@kirrosh/pts@kiwanoswap/v2-corenextjs-storieszillow-js-shims@alexshmyrkov/react-ranger@afria/afria-librariesbirken-react-native-community-image-editorcandlelabssdkckeditor5-custom-ksckeditor5-custom-build-for-irrosoftckeditor5-custom-build-megampireckeditor5-custom-symmetre@bastou/jsontotsinterface@batbayar/superset-plugin-chart-hello-worldckeditor5-strapi-msg@beldore/react-otp-inputckeditor5-build-custom-strapickeditor5-build-classic-ticketckeditor5-build-classic-v-editckeditor-5-imi-1ckeditor5-build-yektackeditor5-click-virtual@blkmarketco/components-libraryap-vue-captchawxmp
2.1.8

1 month ago

2.1.7

8 months ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.4

2 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago