From d1e443fd8c1242c864b216e6ac306cbc0d165d6c Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 2 Jul 2021 21:50:25 +0300 Subject: [PATCH] minor tweaks... Signed-off-by: Alex A. Naanou --- object.js | 11 +++-------- package.json | 2 +- test.js | 16 +++++++++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/object.js b/object.js index 554e055..70e6cde 100755 --- a/object.js +++ b/object.js @@ -701,7 +701,7 @@ var __toStringProxy = //module.__toStringProxy = function(func){ Object.defineProperty(func, 'toString', { - value: function(...args){ + value: function toString(...args){ var f = ( // explicitly defined .toString(..) this.__proto__.toString !== Function.prototype.toString @@ -712,11 +712,6 @@ function(func){ this.__call__ : this.__proto__) return module.normalizeIndent(f.toString(...args)) }, - /*/ - return typeof(f) == 'function' ? - module.normalizeIndent(f.toString(...args)) - : undefined }, - //*/ enumerable: false, }) return func } @@ -1058,7 +1053,7 @@ function Constructor(name, a, b, c){ ;((constructor_mixin || {}).toString === Function.prototype.toString || (constructor_mixin || {}).toString === Object.prototype.toString) && Object.defineProperty(_constructor, 'toString', { - value: function(){ + value: function toString(){ var args = proto.__init__ ? proto.__init__ .toString() @@ -1076,7 +1071,7 @@ function Constructor(name, a, b, c){ // set generic raw instance constructor... _constructor.__rawinstance__ instanceof Function || Object.defineProperty(_constructor, '__rawinstance__', { - value: function(context, ...args){ + value: function __rawinstance__(context, ...args){ return RawInstance(context, this, ...args) }, enumerable: false, }) diff --git a/package.json b/package.json index 7bf863c..257ac2d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "5.5.6", + "version": "5.5.7", "description": "", "main": "object.js", "scripts": { diff --git a/test.js b/test.js index 11e200d..1f32345 100755 --- a/test.js +++ b/test.js @@ -829,13 +829,6 @@ var cases = test.Cases({ { toString: function(){ return 'func_w_tostring(){ .. }' } }) - assert( - object.create(func).toString() == object.normalizeIndent(func.toString()), - 'create(..): function .toString() proxy (builtin).') - assert( - object.create(func_w_tostring).toString() == func_w_tostring.toString(), - 'create(..): function .toString() proxy (custom).') - var callable_a = object.Constructor('callable_a', function(){ @@ -853,6 +846,7 @@ var cases = test.Cases({ return this.constructor.name + '.toString()' }, })() + // .toString(..) assert( callable_b.toString() == object.normalizeIndent(callable_b.__call__.toString()), 'toString(..) proxy to .__call__(..)') @@ -863,6 +857,14 @@ var cases = test.Cases({ callable_c.toString() == callable_c.__proto__.toString(), 'toString(..) proxy to .toString(..)') + // create(..)... + assert( + object.create(func).toString() == object.normalizeIndent(func.toString()), + 'create(..): function .toString() proxy (builtin).') + assert( + object.create(func_w_tostring).toString() == func_w_tostring.toString(), + 'create(..): function .toString() proxy (custom).') + assert( object.create(callable_a).toString() == callable_a.toString(), 'create(..): callable .toString() proxy (func).')