cleanup and notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-06-29 22:14:09 +03:00
parent c5e7e1fbaa
commit c9d0948aa6

View File

@ -267,6 +267,8 @@ function(base, obj, non_strict){
// like Object.create(..) but also handles callable objects correctly... // like Object.create(..) but also handles callable objects correctly...
//
// XXX revise .toString(..) creation...
var create = var create =
module.create = module.create =
function(obj){ function(obj){
@ -284,9 +286,10 @@ function(obj){
func.__call__(this, ...arguments) func.__call__(this, ...arguments)
: 'call' in obj ? : 'call' in obj ?
obj.call(func, ...arguments) obj.call(func, ...arguments)
// NOTE: if obj does not inherit from Function .call // NOTE: if obj does not inherit from Function .call(..)
// might not be available... // might not be available directly...
: Function.prototype.call.call(obj, func, ...arguments) } : Function.prototype.call.call(obj, func, ...arguments) }
// rename...
func.name = name func.name = name
func.name != name func.name != name
&& (func = eval('('+ && (func = eval('('+
@ -294,7 +297,6 @@ function(obj){
.toString() .toString()
.replace(/function\(/, `function ${name}(`) +')')) .replace(/function\(/, `function ${name}(`) +')'))
func.__proto__ = obj func.__proto__ = obj
// XXX not sure about this yet...
Object.defineProperty(func, 'toString', { Object.defineProperty(func, 'toString', {
value: function(){ value: function(){
return Object.hasOwnProperty.call(func, '__call__') ? return Object.hasOwnProperty.call(func, '__call__') ?
@ -303,6 +305,7 @@ function(obj){
enumerable: false, enumerable: false,
}) })
return func } return func }
// normal objects...
return Object.create(obj) } return Object.create(obj) }