From 51f8335f0ccf98e577847f40868befd0cddd1273 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 2 Jul 2021 20:49:40 +0300 Subject: [PATCH] cleanup... Signed-off-by: Alex A. Naanou --- object.js | 39 ++++++++++----------------------------- package.json | 2 +- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/object.js b/object.js index 73b1ea8..7eac49a 100755 --- a/object.js +++ b/object.js @@ -312,18 +312,7 @@ function(obj){ .toString() .replace(/function\(/, `function ${name}(`) +')')) func.__proto__ = obj - //* XXX DOC - __mirror_doc(func) - /*/ - Object.defineProperty(func, 'toString', { - value: function(){ - //return Object.hasOwnProperty.call(func, '__call__') ? - return Object.hasOwnProperty.call(this, '__call__') ? - this.__call__.toString() - : this.__proto__.toString() }, - enumerable: false, - }) - //*/ + __toStringProxy(func) return func } // normal object... return Object.create(obj) } @@ -703,14 +692,15 @@ function(a, b){ //--------------------------------------------------------------------- // Constructor... -// helper... -// create a .toString(..) proxy... -var __mirror_doc = -//module.__mirror_doc = -function(func, constructor=null){ +// Create a .toString(..) proxy +// +// This is needed to show the user code instead of the library code that +// callas it... +var __toStringProxy = +//module.__toStringProxy = +function(func){ Object.defineProperty(func, 'toString', { value: function(...args){ - //* XXX DOC var f = ( // explicitly defined .toString(..) this.__proto__.toString !== Function.prototype.toString @@ -720,14 +710,6 @@ function(func, constructor=null){ : '__call__' in this ? this.__call__ : this.__proto__) - /*/ - // user-defined .toString... - if(constructor.prototype.toString !== Function.prototype.toString){ - return constructor.prototype.toString.call(this, ...args) } - var f = typeof(constructor.prototype) == 'function' ? - constructor.prototype - : constructor.prototype.__call__ - //*/ return typeof(f) == 'function' ? module.normalizeIndent(f.toString(...args)) : undefined }, @@ -795,7 +777,7 @@ function(context, constructor, ...args){ // XXX autogenerate/set .name ... : (typeof(constructor.prototype) == 'function' || constructor.prototype.__call__ instanceof Function) ? - __mirror_doc( + __toStringProxy( function(){ return ( // .prototype is a function... @@ -809,8 +791,7 @@ function(context, constructor, ...args){ constructor.prototype, obj, [this, ...arguments]) // .__call__(..) or fail semi-gracefully... : constructor.prototype.__call__ - .call(obj, this, ...arguments)) }, - constructor) + .call(obj, this, ...arguments)) }) // recursively call .__rawinstance__(..) : constructor.__proto__.__rawinstance__ ? constructor.__proto__.__rawinstance__(context, ...args) diff --git a/package.json b/package.json index 3758bea..fca2b9f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "5.5.4", + "version": "5.5.5", "description": "", "main": "object.js", "scripts": {