mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 10:30:08 +00:00
reworked mixin(..)
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5d1584339a
commit
b00433a902
@ -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) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user