minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-07-02 21:50:25 +03:00
parent b2741f958f
commit d1e443fd8c
3 changed files with 13 additions and 16 deletions

View File

@ -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,
})

View File

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

16
test.js
View File

@ -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).')