@ganuz/is-definable
Is Definable is package from Ganuz library
Install
$ yarn add @ganuz/is-definable
Or
$ npm install --save @ganuz/is-definable
Use
Module
import {
default as isDefinable
} from '@ganuz/is-definable';
Browser
<script src="https://unpkg.com/@ganuz/is-definable/bundle.umd.min.js"></script>
let {
isDefinable
} = G;
Examples
isDefinable(null, 'prop'); // throw TypeError
isDefinable({}, 'foo'); // => true
isDefinable({foo: 'bar'}, 'foo'); // => true
isDefinable({get some(){}}, 'some'); // => true
isDefinable(Object.create({}, {color: {value: 'red', writable: false, configurable: true}}), 'foo'); // => true
isDefinable(Object.create({}, {foo: {value: 'bar', writable: true, configurable: false}}), 'foo'); // => false
isDefinable(Object.preventExtensions({num: 88}), 'num'); // => false
isDefinable(Object.seal({}), 'car'); // => false
@ganuz/is-definable/assert
Module
import {
default as assertDefinable
} from '@ganuz/is-definable/assert';
Browser
<script src="https://unpkg.com/@ganuz/is-definable/assert/bundle.umd.min.js"></script>
let {
assertDefinable
} = G;
Examples
assertDefinable({color: 'red'}, 'color'); // => {color: 'red'};
assertDefinable([1], 1); // => [1];
assertDefinable(Object.freeze({foo: 'bar'}), 'foo'); // throw TypeError
assertDefinable(Object.create(null, {foo: {value: 'bar'}}), foo); // throw TypeError
License
Copyright © Yisrael Eliev, Licensed under the MIT license.