@ganuz/is-writable
Is Writable is package from Ganuz library
Install
$ yarn add @ganuz/is-writable
Or
$ npm install --save @ganuz/is-writable
Use
Module
import {
default as isWritable
} from '@ganuz/is-writable';
Browser
<script src="https://unpkg.com/@ganuz/is-writable/bundle.umd.min.js"></script>
let {
isWritable
} = G;
Examples
isWritable('foo', null); // throw TypeError
isWritable(null, 'key'); // => throw TypeError
isWritable({}, 'foo'); // => true
isWritable({foo: 'bar'}, 'foo'); // => true
isWritable([0, 1, 2]], 1); // => true
isWritable(Object.freeze({color: 'red'}), 'foo') => false
isWritable(Object.create(null, {a: {value: 1}}), 'a'); // => false
isWritable(Object.create(Object.create(null, {a: {value: 1}})), 'a'); // => true
@ganuz/is-writable/assert
Module
import {
default as assertWritable
} from '@ganuz/is-writable/assert';
Browser
<script src="https://unpkg.com/@ganuz/is-writable/assert/bundle.umd.min.js"></script>
let {
assertWritable
} = G;
Examples
assertWritable({}, 'foo'); // => {}
assertWritable({foo: 'bar'}, 'foo'); // => {foo: 'bar'}
assertWritable(Object.create({}, {foo: {value: 'bar'}}), 'foo'); // throw TypeError
assertWritable(Object.freeze({foo: 'bar'}), 'foo'); // throw TypeError
License
Copyright © Yisrael Eliev, Licensed under the MIT license.