added mixin(..) and parent(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-24 21:20:38 +03:00
parent a7f42d1e8c
commit c646b938df
2 changed files with 38 additions and 1 deletions

View File

@ -257,6 +257,43 @@ function superMethod(cls, meth){
}
//---------------------------------------------------------------------
// super replacement...
//
// parent(meth, this)
// parent(meth, name, this)
// -> meth
//
//
// XXX move this to object.js
var parent =
module.parent =
function(meth, name, that){
if(arguments.length == 2){
that = name
name = meth.name
}
while(!that.hasOwnProperty(name) || that[name] !== meth){
that = that.__proto__
}
return that.__proto__[name]
}
//---------------------------------------------------------------------
// XXX move this to object.js
var mixin =
module.mixin =
function(root, ...objects){
return objects
.reduce(function(res, cur){
return Object.assign(Object.create(res), cur) }, root) }
/**********************************************************************
* vim:set ts=4 sw=4 : */ return module })

View File

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