@ganuz/is-property-descriptor
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@ganuz/is-property-descriptor

Source Code Version MIT License Bundle Size TypeScript

Is Property Descriptor is package from Ganuz library

Install

$ yarn add @ganuz/is-property-descriptor

Or

$ npm install --save @ganuz/is-property-descriptor

Use

Module

import {
  default as isPropertyDescriptor
} from '@ganuz/is-property-descriptor';

Browser

<script src="https://unpkg.com/@ganuz/is-property-descriptor/bundle.umd.min.js"></script>
let {
  isPropertyDescriptor
} = G;

Examples

 isPropertyDescriptor(); // => false
 isPropertyDescriptor('foo'); // => false
 isPropertyDescriptor({}); // => true
 isPropertyDescriptor({color: 'red'}); // => true
 isPropertyDescriptor(class {}); // => true
 isPropertyDescriptor({value: undefined, foo: 'bar'}); // => true
 isPropertyDescriptor({get: undefined}); // => true
 isPropertyDescriptor({set: Object, enumerable: [0, 1, 2]}); // => true
 isPropertyDescriptor({get(){}, value: 55}); // => false
 isPropertyDescriptor({get: 'foo'}); // => false
 isPropertyDescriptor({get(){}, set: NaN}); // => false
 isPropertyDescriptor({get(){}, writable: undefined}); // => false
 isPropertyDescriptor({set(){}, value: undefined}); // => false

Note: To check the kind of the descriptor use {@link isDataDescriptor} or {@link isAccessorDescriptor}

@ganuz/is-property-descriptor/assert

Module

import {
  default as assertPropertyDescriptor
} from '@ganuz/is-property-descriptor/assert';

Browser

<script src="https://unpkg.com/@ganuz/is-property-descriptor/assert/bundle.umd.min.js"></script>
let {
  assertPropertyDescriptor
} = G;

Examples

 assertPropertyDescriptor(null); // throw TypeError
 assertPropertyDescriptor(false); // throw TypeError
 assertPropertyDescriptor({set: []}); // throw TypeError
 assertPropertyDescriptor({get() {}, writable: false}); // throw TypeError
 assertPropertyDescriptor({set: undefined, value: 'foo'}); // throw TypeError
 assertPropertyDescriptor({}); // => {}
 assertPropertyDescriptor({get: undefined}); // => {get: undefined}
 assertPropertyDescriptor({enumerable: true}); // => {enumerable: true}
 assertPropertyDescriptor({value: NaN}); // => {value: NaN}

License

Copyright © Yisrael Eliev, Licensed under the MIT license.

Package Sidebar

Install

npm i @ganuz/is-property-descriptor

Weekly Downloads

4

Version

0.1.1

License

MIT

Unpacked Size

120 kB

Total Files

27

Last publish

Collaborators

  • yisraelx