bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-06-29 20:21:14 +03:00
parent 5817270787
commit a304b7d91f
2 changed files with 12 additions and 3 deletions

View File

@ -268,19 +268,28 @@ function(base, obj, non_strict){
// like Object.create(..) but also handles callable objects correctly... // like Object.create(..) but also handles callable objects correctly...
// //
// XXX add ability to name the resulting function...
var create = var create =
module.create = module.create =
function(obj){ function(obj){
// name given...
if(typeof(obj) == 'string' && arguments.length > 1){
var name
;[name, obj] = arguments }
// calable... // calable...
if(typeof(obj) == 'function'){ if(typeof(obj) == 'function'){
var func = function(){ var func = function(){
return Object.hasOwnProperty.call(func, '__call__') ? return '__call__' in func ?
func.__call__.call(func, ...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...
: Function.prototype.call.call(obj, func, ...arguments) } : Function.prototype.call.call(obj, func, ...arguments) }
// XXX set the name....
// XXX
func.__proto__ = obj func.__proto__ = obj
// XXX not sure about this yet... // XXX not sure about this yet...
Object.defineProperty(func, 'toString', { Object.defineProperty(func, 'toString', {

View File

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