@ganuz/is-accessor-descriptor
v0.1.1
Published
Is Accessor Descriptor is package from Ganuz library
Downloads
22
Maintainers
Readme
@ganuz/is-accessor-descriptor
Is Accessor Descriptor is package from Ganuz library
Install
$ yarn add @ganuz/is-accessor-descriptor
Or
$ npm install --save @ganuz/is-accessor-descriptor
Use
Module
import {
default as isAccessorDescriptor
} from '@ganuz/is-accessor-descriptor';
Browser
<script src="https://unpkg.com/@ganuz/is-accessor-descriptor/bundle.umd.min.js"></script>
let {
isAccessorDescriptor
} = G;
Examples
isAccessorDescriptor(); // => false
isAccessorDescriptor({}); // => false
isAccessorDescriptor({color: 'red'}); // => false
isAccessorDescriptor({get: undefined}); // => true
isAccessorDescriptor({get: undefined, enumerable: NaN}); // => true
isAccessorDescriptor({get: []}); // => true
isAccessorDescriptor({set: 78, value: {}}); // => true
isAccessorDescriptor({get(){}, writable: true}); // => true
isAccessorDescriptor({get: undefined, value: 88, writable: true}); // => true
Note: This function does not validate that it is a valid descriptor, it only checks if the properties of data descriptor exist, for description validation use {@link isPropertyDescriptor}.
@ganuz/is-accessor-descriptor/assert
Module
import {
default as assertAccessorDescriptor
} from '@ganuz/is-accessor-descriptor/assert';
Browser
<script src="https://unpkg.com/@ganuz/is-accessor-descriptor/assert/bundle.umd.min.js"></script>
let {
assertAccessorDescriptor
} = G;
Examples
assertAccessorDescriptor(null); // throw
assertAccessorDescriptor('foo'); // throw
assertAccessorDescriptor({}); // throw
assertAccessorDescriptor({get: undefined}); // => {get: undefined}
assertAccessorDescriptor({set(v) {}, value: 35}); // => {set(v) {}, value: 35}
License
Copyright © Yisrael Eliev, Licensed under the MIT license.