0.1.1 • Published 6 years ago
@ganuz/copy-properties v0.1.1
@ganuz/copy-properties
Copy Properties is package from Ganuz library
Install
$ yarn add @ganuz/copy-properties
Or
$ npm install --save @ganuz/copy-properties
Use
Module
import {
default as copyProperties
} from '@ganuz/copy-properties';
Browser
<script src="https://unpkg.com/@ganuz/copy-properties/bundle.umd.min.js"></script>
let {
copyProperties
} = G;
Examples
copyProperties(null, {}); // throw TypeError;
copyProperties({}, 'foo'); // throw TypeError;
copyProperties({foo: 'bar', name: 'bob'}, {num: 5, name: 'alice'}); // => {foo: 'bar', name: 'alice', num: 5}
copyProperties(Object.create(null, {color: {value: 'red'}}), {color: 'blue', num: -1}); // => {color: 'red', num: -1}
copyProperties({tv: false}, Object.create({foo: 'bar'}, {car: true})); // => {tv: false, car: true}
copyProperties(Object.freeze({tea: false}), {tea: true}); // => {tea: false}
copyProperties(Object.seal({coffee: true}), {coffee: false}); // => {coffee: true}
copyProperties({num: 5, str: undefined}, {num: undefined, str: 'some'}); // => {num: undefined, str: 'some'}
copyProperties({get color(){ return this._c; }, set color(c) { this._c = c;}},{color: 'red'}); // => {color: 'red'}
copyProperties({}, {[Symbol.toStringTag]: 'Some'}); // => Some{}
copyProperties(copyProperties({color: 'blue'}, Object.create(null, {color: {value: 'red'}})), {color: 'pink'}); // => {color: 'red'}
License
Copyright © Yisrael Eliev, Licensed under the MIT license.