@ganuz/define-properties
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@ganuz/define-properties

Source Code Version MIT License Bundle Size TypeScript

Define Properties is package from Ganuz library

Install

$ yarn add @ganuz/define-properties

Or

$ npm install --save @ganuz/define-properties

Use

Module

import {
  default as defineProperties
} from '@ganuz/define-properties';

Browser

<script src="https://unpkg.com/@ganuz/define-properties/bundle.umd.min.js"></script>
let {
  defineProperties
} = G;

Examples

 defineProperties(null, {}); // throw TypeError
 defineProperties({}, {foo: {value: 'bar'}}); // => {foo: 'bar'}
 defineProperties({}, {[Symbol.toStringTag]: {get: () => 'Some'}}); // => Some{}
 defineProperties(Object.freeze({drink: 'tea'}), {color: {value: 'yellow'}}); // => {drink: 'tea'}
 let object = {car: false};

 defineProperties(object, {
     color: {value: 'red'},
     foo: {get: () => 'bar', writable: true},
     jeep: {value: true}
 }); // throw TypeError

 console.log(object); // => {car: false}
 let object = Object.create(null, {
     num: {value: 3, configurable: true},
     color: {value: 'pink', enumerable: true},
     drink: {value: 'tea', writable: true},
     word: {value: 'cool', writable: true},
     name: {value: 'bob', configurable: true, enumerable: true}
 });

 defineProperties(object, {
     num: {value: -1},
     color: {value: 'red'},
     drink: {value: 'coffee', configurable: false},
     word: {value: 'fun', enumerable: true},
    name: {value: 'alice'}
 }) === object; // => true

 getOwnPropertyDescriptors(object);
 // => {
 //    num: {value: -1, configurable: true, enumerable: false, writable: false},
 //    color: {value: 'pink', configurable: false, enumerable: true, writable: false},
 //    drink: {value: 'coffee', configurable: false, enumerable: false, writable: true},
 //    word: {value: 'cool', configurable: false, enumerable: false, writable: true},
 //    name: {value: 'alice', configurable: true, enumerable: true, writable: false}
 // }

License

Copyright © Yisrael Eliev, Licensed under the MIT license.

Package Sidebar

Install

npm i @ganuz/define-properties

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

111 kB

Total Files

15

Last publish

Collaborators

  • yisraelx