mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 18:40:08 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2c7b43663d
commit
51f8335f0c
39
object.js
39
object.js
@ -312,18 +312,7 @@ function(obj){
|
|||||||
.toString()
|
.toString()
|
||||||
.replace(/function\(/, `function ${name}(`) +')'))
|
.replace(/function\(/, `function ${name}(`) +')'))
|
||||||
func.__proto__ = obj
|
func.__proto__ = obj
|
||||||
//* XXX DOC
|
__toStringProxy(func)
|
||||||
__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,
|
|
||||||
})
|
|
||||||
//*/
|
|
||||||
return func }
|
return func }
|
||||||
// normal object...
|
// normal object...
|
||||||
return Object.create(obj) }
|
return Object.create(obj) }
|
||||||
@ -703,14 +692,15 @@ function(a, b){
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Constructor...
|
// Constructor...
|
||||||
|
|
||||||
// helper...
|
// Create a .toString(..) proxy
|
||||||
// create a .toString(..) proxy...
|
//
|
||||||
var __mirror_doc =
|
// This is needed to show the user code instead of the library code that
|
||||||
//module.__mirror_doc =
|
// callas it...
|
||||||
function(func, constructor=null){
|
var __toStringProxy =
|
||||||
|
//module.__toStringProxy =
|
||||||
|
function(func){
|
||||||
Object.defineProperty(func, 'toString', {
|
Object.defineProperty(func, 'toString', {
|
||||||
value: function(...args){
|
value: function(...args){
|
||||||
//* XXX DOC
|
|
||||||
var f = (
|
var f = (
|
||||||
// explicitly defined .toString(..)
|
// explicitly defined .toString(..)
|
||||||
this.__proto__.toString !== Function.prototype.toString
|
this.__proto__.toString !== Function.prototype.toString
|
||||||
@ -720,14 +710,6 @@ function(func, constructor=null){
|
|||||||
: '__call__' in this ?
|
: '__call__' in this ?
|
||||||
this.__call__
|
this.__call__
|
||||||
: this.__proto__)
|
: 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' ?
|
return typeof(f) == 'function' ?
|
||||||
module.normalizeIndent(f.toString(...args))
|
module.normalizeIndent(f.toString(...args))
|
||||||
: undefined },
|
: undefined },
|
||||||
@ -795,7 +777,7 @@ function(context, constructor, ...args){
|
|||||||
// XXX autogenerate/set .name ...
|
// XXX autogenerate/set .name ...
|
||||||
: (typeof(constructor.prototype) == 'function'
|
: (typeof(constructor.prototype) == 'function'
|
||||||
|| constructor.prototype.__call__ instanceof Function) ?
|
|| constructor.prototype.__call__ instanceof Function) ?
|
||||||
__mirror_doc(
|
__toStringProxy(
|
||||||
function(){
|
function(){
|
||||||
return (
|
return (
|
||||||
// .prototype is a function...
|
// .prototype is a function...
|
||||||
@ -809,8 +791,7 @@ function(context, constructor, ...args){
|
|||||||
constructor.prototype, obj, [this, ...arguments])
|
constructor.prototype, obj, [this, ...arguments])
|
||||||
// .__call__(..) or fail semi-gracefully...
|
// .__call__(..) or fail semi-gracefully...
|
||||||
: constructor.prototype.__call__
|
: constructor.prototype.__call__
|
||||||
.call(obj, this, ...arguments)) },
|
.call(obj, this, ...arguments)) })
|
||||||
constructor)
|
|
||||||
// recursively call .__rawinstance__(..)
|
// recursively call .__rawinstance__(..)
|
||||||
: constructor.__proto__.__rawinstance__ ?
|
: constructor.__proto__.__rawinstance__ ?
|
||||||
constructor.__proto__.__rawinstance__(context, ...args)
|
constructor.__proto__.__rawinstance__(context, ...args)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-object",
|
"name": "ig-object",
|
||||||
"version": "5.5.4",
|
"version": "5.5.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user