reworked mixin(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-07-05 20:14:28 +03:00
parent 5d1584339a
commit b00433a902
2 changed files with 8 additions and 3 deletions

View File

@ -70,7 +70,7 @@ function(method, name, that){
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// Create an object and mix in sets of methods... // Create an object and mix in sets of methods/props/attrs...
// //
// mixin(root, object, ...) // mixin(root, object, ...)
// -> object // -> object
@ -87,7 +87,12 @@ module.mixin =
function(root, ...objects){ function(root, ...objects){
return objects return objects
.reduce(function(res, cur){ .reduce(function(res, cur){
return Object.assign(Object.create(res), cur) }, root) } var o = Object.create(res)
Object.keys(cur)
.map(function(k){
Object.defineProperty(o, k,
Object.getOwnPropertyDescriptor(cur, k)) })
return o }, root) }

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-object", "name": "ig-object",
"version": "1.2.0", "version": "1.3.0",
"description": "", "description": "",
"main": "object.js", "main": "object.js",
"scripts": { "scripts": {