From a96a1fb803a24e516c40b6247a9d901c70f721b4 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 9 Aug 2020 17:19:17 +0300 Subject: [PATCH] bugfix... Signed-off-by: Alex A. Naanou --- object.js | 5 ++++- package.json | 4 ++-- test.js | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/object.js b/object.js index e0f3416..3c9c748 100755 --- a/object.js +++ b/object.js @@ -1083,7 +1083,10 @@ function Constructor(name, a, b, c){ .forEach(function(n){ proto[n] || Object.defineProperty(proto, n, - Object.getOwnPropertyDescriptor(Function.prototype, n)) }) + Object.assign( + Object.getOwnPropertyDescriptor(Function.prototype, n), + { value: function(){ + return this.__call__[n](...arguments) }, })) }) return _constructor } diff --git a/package.json b/package.json index cc81954..6c71b5d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "5.2.0", + "version": "5.2.1", "description": "", "main": "object.js", "scripts": { @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/flynx/object.js#readme", "devDependencies": { - "c8": "^7.2.1", + "c8": "^7.3.0", "colors": "^1.4.0", "ig-argv": "^2.11.2" } diff --git a/test.js b/test.js index 89a7af6..2730b7f 100755 --- a/test.js +++ b/test.js @@ -690,7 +690,23 @@ module.cases = { assert.array(object.deepKeys(c, b), ['c', 'b'], 'partial chain') assert.array(object.deepKeys(c, c), ['c'], 'partial chain') - } + }, + funcMethods: function(assert){ + var X = object.C('X', { + __call__: function(){ + return true }, + }) + + var x = new X() + + assert(x(), 'x()') + assert(x.call(null), 'x.call(null)') + + var xx = Object.create(x) + + assert(typeof(xx.call) == 'function', 'xx.call is a function') + assert(xx.call(null), 'xx.call(null)') + }, }