npm package: @ganuz/set
Description: Set is package from Ganuz library
Author: Yisrael Eliev
Latest version: 0.1.1

# @ganuz/set
[![Source Code](https://img.shields.io/badge/%3C%2F%3E-source_code-blue.svg)](https://github.com/yisraelx/ganuz/blob/master/modules/set)
[![Version](https://img.shields.io/npm/v/@ganuz/set.svg)](https://www.npmjs.com/package/@ganuz/set)
[![MIT License](https://img.shields.io/npm/l/@ganuz/set.svg?color=yellow)](https://github.com/yisraelx/ganuz/blob/master/LICENSE)
[![Bundle Size](https://img.shields.io/bundlephobia/min/@ganuz/set.svg?color=green)](https://bundlephobia.com/result?p=@ganuz/set)
[![TypeScript](https://img.shields.io/badge/100%25-TypeScript-blue.svg)](https://www.typescriptlang.org)

**Set is package from Ganuz library**

## Install
```sh
$ yarn add @ganuz/set
```
Or
```sh
$ npm install --save @ganuz/set
```

## Use
**Module**
```typescript
import {
  default as set
} from '@ganuz/set';
```

**Browser**
```html
<script src="https://unpkg.com/@ganuz/set/bundle.umd.min.js"></script>
```
```typescript
let {
  set
} = G;
```

**Examples**
```typescript
 set(null, 'foo', 'bar'); // throw TypeError
 set({}, 'foo', 'bar'); // => true
 set({color: 'blue'}, 'color', 'green'); // => true
 set(v => v, Symbol('foo'), 'bar'); // => true
 set({}, 'foo', 'bar', {}); // => true
 set(Object.freeze({}), 'foo', 'bar', {}); // => true
 set(Object.freeze({foo: 'bar'}), 'foo', 'bar'); // => false
 set({}, 'foo', 'bob', {get(){}, set(v){}}); // => false
 set({}, 'foo', 'bar', 69); // => false
 set({get foo(){}}, 'foo', 'bar'); // => false
 set({get foo(){}}, 'foo', 'bar', {}); // => false
 set(Object.preventExtensions({}), 'foo', 'bar'); // => false
 set(Object.preventExtensions({}), 'foo', 'bar', {}); // => false
 set(Object.create(null, {foo: {value: 'bar'}}), 'foo', 'bob'); // => false
 set(Object.create(null, {foo: {value: 'bar'}}), 'foo', 'bob', {}); // => false
 set(Object.create(Object.create(null, {foo: {value: 'bar'}})), 'foo', 'bob'); // => false
 set(Object.freeze({}), 'foo', 'bar', {}); // => true
 set({}, 'foo', 'bob', Object.create(null, {foo: {value: 'bar'}})); // => false
```
```typescript
 let object = {
     set name(name){ this._name = name; },
     _name: 'bob'
 };
 let other = {_name: 'alice'};

 set(object, 'name', 'john', other); // => true
 console.log(object._name); // => 'bob'
 console.log(other._name); // => 'john'
```
```typescript
 let object = {
     set color(color){ this._color = color; },
     _color: 'blue'
  };
 let other = Object.freeze({_color: 'red'});

 set(object, 'color', 'green', other); // => true (in 'use strict' mode it will throw TypeError)
 console.log(object._color); // => 'blue'
 console.log(other._color); // => 'red'
```
```typescript
 let object = {num: 69}
 let anther = {
     get num(){
         return this._num;
     },
     set num(num){
         this._num = num;
     },
     _num: -1
 }

 set(object, 'num', 77, anther); // => false
 console.log(object.num); // => 69
 console.log(other.num); // => -1
```

### @ganuz/set/polyfill
**Module**
```typescript
  import '@ganuz/set/polyfill';
```

**Browser**
```html
<script src="https://unpkg.com/@ganuz/set/polyfill/bundle.umd.min.js"></script>
```

## License
Copyright © [Yisrael Eliev](https://github.com/yisraelx),
Licensed under the [MIT license](https://github.com/yisraelx/ganuz/blob/master/LICENSE).