An Object.assign like utility that preserve descriptors, as in accessors or value, or configurable, or writable, etc.
importassignPropertiesfrom'assign-properties';constassignProperties=require('assign-properties');// <script src="https://unpkg.com/assign-properties">Same Object.assign API
// the issue with assign is that copies are valuesconstbefore=Object.assign({},{getrandom(){returnMath.random()}});// mixins are broken this waybefore.random===before.random;// true// with assignProperties, everything is fineconstafter=assignProperties({},{getrandom(){returnMath.random()}});// the getter is passed along instead of being lost in the processafter.random===after.random;// falseconstbase={getrandom(){returnMath.random()}};constspread={...base};spread.random===spread.random;// trueSo, if you want to bring accessors to the mix, this module is your stop.