Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-05-30 01:17:13 +03:00
parent e4372a785c
commit d80aca31fb
2 changed files with 30 additions and 11 deletions

View File

@ -522,8 +522,7 @@ one of the following:
Special case: get callable implementations Special case: get callable implementations
``` ```
sources(<object>, '__call__') sources(<object>, '__call__', ..)
sources(<object>, '__call__', <callback>)
-> <list> -> <list>
``` ```
@ -563,6 +562,17 @@ callback(<descriptor>, <source>)
-> <value> -> <value>
``` ```
Special case: get callable implementations
```
values(<object>, '__call__', ..)
-> <list>
```
This will return the callable objects themselves or the value of `.__call__`.
See [`sources(..)`](#sources) for docs on `callback(..)` and special cases. See [`sources(..)`](#sources) for docs on `callback(..)` and special cases.
### `parent(..)` ### `parent(..)`

View File

@ -155,6 +155,12 @@ module.STOP =
// -> list // -> list
// -> [] // -> []
// //
// Get callables or objects defining .__call__ (special-case)
// sources(obj, '__call__')
// sources(obj, '__call__', callback)
// -> list
// -> []
//
// callback(obj) // callback(obj)
// -> STOP // -> STOP
// -> .. // -> ..
@ -172,7 +178,7 @@ module.STOP =
// NOTE: an ampty array will effectively omit the // NOTE: an ampty array will effectively omit the
// triggering object from the results. // triggering object from the results.
// - other - return a value instead of the triggering object. // - other - return a value instead of the triggering object.
// //
// //
// NOTE: this gos up the prototype chain, not caring about any role ( // NOTE: this gos up the prototype chain, not caring about any role (
// instance/class or instance/prototype) bounderies and depends // instance/class or instance/prototype) bounderies and depends
@ -181,11 +187,6 @@ module.STOP =
// for any overloading in the instance, though this approach is // for any overloading in the instance, though this approach is
// not very reusable.... // not very reusable....
// NOTE: this will not trigger any props... // NOTE: this will not trigger any props...
//
// XXX document the '__call__' special case...
// - '__call__' gets either the callable prototype or .__call__(..)
// - priority...
// -
var sources = var sources =
module.sources = module.sources =
function(obj, name, callback){ function(obj, name, callback){
@ -229,9 +230,12 @@ function(obj, name, callback){
// -> .. // -> ..
// //
// //
// NOTE: for more docs on the callback(..) see sources(..) // Special case: name is given as '__call__'
// This will return either the value the object if it is callable
// or the value of .__call__ attribute...
// //
// XXX document the '__call__' cpecial case... //
// NOTE: for more docs on the callback(..) see sources(..)
var values = var values =
module.values = module.values =
function(obj, name, callback, props){ function(obj, name, callback, props){
@ -266,6 +270,11 @@ function(obj, name, callback, props){
// -> value // -> value
// -> undefined // -> undefined
// //
// Get parent callable or .__call__ value (special-case)
// parent(proto, '__call__')
// -> value
// -> undefined
//
// Get parent method... // Get parent method...
// parent(method, this) // parent(method, this)
// -> meth // -> meth
@ -633,7 +642,7 @@ function(context, constructor, ...args){
// parent... // parent...
Reflect.apply( Reflect.apply(
constructor.prototype, obj, [this, ...arguments]) constructor.prototype, obj, [this, ...arguments])
// .__call__(..) // .__call__(..) or fail semi-gracefully...
: constructor.prototype.__call__ : constructor.prototype.__call__
.call(obj, this, ...arguments)) }, .call(obj, this, ...arguments)) },
constructor) constructor)