From c9d0948aa6532f40f0e477ee7f2ec54081ed9845 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 29 Jun 2021 22:14:09 +0300 Subject: [PATCH] cleanup and notes... Signed-off-by: Alex A. Naanou --- object.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/object.js b/object.js index e770ba9..086f23c 100755 --- a/object.js +++ b/object.js @@ -267,6 +267,8 @@ function(base, obj, non_strict){ // like Object.create(..) but also handles callable objects correctly... +// +// XXX revise .toString(..) creation... var create = module.create = function(obj){ @@ -284,9 +286,10 @@ function(obj){ func.__call__(this, ...arguments) : 'call' in obj ? obj.call(func, ...arguments) - // NOTE: if obj does not inherit from Function .call - // might not be available... + // NOTE: if obj does not inherit from Function .call(..) + // might not be available directly... : Function.prototype.call.call(obj, func, ...arguments) } + // rename... func.name = name func.name != name && (func = eval('('+ @@ -294,7 +297,6 @@ function(obj){ .toString() .replace(/function\(/, `function ${name}(`) +')')) func.__proto__ = obj - // XXX not sure about this yet... Object.defineProperty(func, 'toString', { value: function(){ return Object.hasOwnProperty.call(func, '__call__') ? @@ -303,6 +305,7 @@ function(obj){ enumerable: false, }) return func } + // normal objects... return Object.create(obj) }