0.3.0 • Published 2 years ago
proxy-assign v0.3.0
proxy-assign
Creates proxies of all existing properties of source object(s) onto a target object, without actually assigning anything onto the target.
In contrast to Object.assign:
The
Object.assign()
method copies properties from a source object to a target object. It uses[[Get]]
on the source and[[Set]]
on the target.
This doesn't copy and uses both [[Get]]
and [[Set]]
on the source (for properties that exist on it).
Modifying exiting properties (even primitives) alters them on the source object. Any new properties are still set on the target.
Install
npm i proxy-assign
Usage
API
const target = ProxyAssign(target, ...sources)
Example
const ProxyAssign = require('proxy-assign')
const source = { a: 'a' }
const target = {}
const proxy = ProxyAssign(target, source)
proxy.a = 0
proxy.b = 'b'
source: { a: 0 }
target: { b: 'b' }
proxy: Proxy { b: 'b' } // Proxy of target