mirror of
https://github.com/flynx/object.js.git
synced 2025-10-30 19:10:11 +00:00
some nore clanup and refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a1716b53fa
commit
8c2a30de42
23
object.js
23
object.js
@ -334,9 +334,15 @@ function Constructor(name, a, b){
|
|||||||
var cls_proto = b == null ? b : a
|
var cls_proto = b == null ? b : a
|
||||||
proto = proto || {}
|
proto = proto || {}
|
||||||
|
|
||||||
|
// XXX EXPERIMENTAL...
|
||||||
|
var _rawinstance = function(){
|
||||||
|
return (_constructor.__proto__ || {}).__rawinstance__ ?
|
||||||
|
_constructor.__proto__.__rawinstance__.call(this, ...arguments)
|
||||||
|
: makeRawInstance(this, _constructor, ...arguments) }
|
||||||
|
|
||||||
// the actual constructor...
|
// the actual constructor...
|
||||||
var _constructor = function Constructor(){
|
var _constructor = function Constructor(){
|
||||||
var obj = makeRawInstance(this, _constructor, ...arguments)
|
var obj = _rawinstance.call(this, ...arguments)
|
||||||
obj.__init__ instanceof Function
|
obj.__init__ instanceof Function
|
||||||
&& obj.__init__(...arguments)
|
&& obj.__init__(...arguments)
|
||||||
return obj }
|
return obj }
|
||||||
@ -350,8 +356,7 @@ function Constructor(name, a, b){
|
|||||||
&& eval('_constructor = '+ _constructor
|
&& eval('_constructor = '+ _constructor
|
||||||
.toString()
|
.toString()
|
||||||
.replace(/Constructor/g, name))
|
.replace(/Constructor/g, name))
|
||||||
|
// set .toString(..)...
|
||||||
// set an informative Constructor .toString(..)...
|
|
||||||
// NOTE: do this only if .toString(..) is not defined by user...
|
// NOTE: do this only if .toString(..) is not defined by user...
|
||||||
;((cls_proto || {}).toString() == ({}).toString())
|
;((cls_proto || {}).toString() == ({}).toString())
|
||||||
// XXX is this the right way to go or should we set this openly???
|
// XXX is this the right way to go or should we set this openly???
|
||||||
@ -370,17 +375,11 @@ function Constructor(name, a, b){
|
|||||||
return `${this.name}(${args})${normalizeIndent(code)}` },
|
return `${this.name}(${args})${normalizeIndent(code)}` },
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
_constructor.__proto__ = cls_proto
|
_constructor.__proto__ = cls_proto
|
||||||
_constructor.prototype = proto
|
_constructor.prototype = proto
|
||||||
// XXX EXPERIMENTAL...
|
_constructor.__rawinstance__ = _rawinstance
|
||||||
// wrapper to makeRawInstance(..)...
|
|
||||||
_constructor.__rawinstance__ = function(...args){
|
// set .prototype.constructor
|
||||||
return (_constructor.__proto__ || {}).__rawinstance__ ?
|
|
||||||
// XXX revise / test...
|
|
||||||
// XXX should we hardcode cls_proto here???
|
|
||||||
_constructor.__proto__.__rawinstance__.call(this, ...args)
|
|
||||||
: makeRawInstance(this, _constructor, ...args) }
|
|
||||||
Object.defineProperty(_constructor.prototype, 'constructor', {
|
Object.defineProperty(_constructor.prototype, 'constructor', {
|
||||||
value: _constructor,
|
value: _constructor,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-object",
|
"name": "ig-object",
|
||||||
"version": "2.3.0",
|
"version": "2.4.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user