more cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-04-30 02:10:01 +03:00
parent 9fed68370b
commit aea2355520
3 changed files with 8 additions and 14 deletions

View File

@ -214,8 +214,8 @@ parent(<method>, <this>)
Get parent method and call it Get parent method and call it
``` ```
parentCall(<method>, <this>)
parentCall(<prototype>, <name>, <this>) parentCall(<prototype>, <name>, <this>)
parentCall(<method>, <this>)
-> <result> -> <result>
-> undefined -> undefined
``` ```

View File

@ -132,7 +132,7 @@ function(obj, name, callback){
// the first .method value visible from 'this', i.e. the top most // the first .method value visible from 'this', i.e. the top most
// value and not the value visible from that particular level... // value and not the value visible from that particular level...
// //
// XXX need to add a way to work with props... // XXX need to add a way to work with props... (???)
var parent = var parent =
module.parent = module.parent =
function(proto, name){ function(proto, name){
@ -155,8 +155,8 @@ function(proto, name){
// Find the next parent method and call it... // Find the next parent method and call it...
// //
// parentCall(meth, this, ...)
// parentCall(proto, name, this, ...) // parentCall(proto, name, this, ...)
// parentCall(meth, this, ...)
// -> res // -> res
// -> undefined // -> undefined
// //
@ -170,20 +170,14 @@ function(proto, name){
// or: // or:
// parent(method, this).call(this, ...) // parent(method, this).call(this, ...)
// NOTE: for more docs see parent(..) // NOTE: for more docs see parent(..)
//
// XXX should we rename this to parent.call(..) ???
// ...this does not care about context so there is no reason to keep
// the default call, but this lowers discoverability and might be
// confusing...
var parentCall = var parentCall =
module.parentCall = module.parentCall =
function(proto, name, that, ...args){ function(proto, name, that, ...args){
var [p, c] = typeof(name) == typeof('str') ? var meth = parent(proto, name)
[ [proto, name, that], [...arguments].slice(2)]
: [ [proto, name], [...arguments].slice(1)]
var meth = parent(...p)
return meth instanceof Function ? return meth instanceof Function ?
meth.call(...c) meth.call(...( typeof(name) == typeof('str') ?
[...arguments].slice(2)
: [...arguments].slice(1) ))
: undefined } : undefined }

View File

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