mirror of
https://github.com/flynx/object.js.git
synced 2025-10-30 19:10:11 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2772e29d92
commit
3b5b36a62e
30
object.js
30
object.js
@ -286,26 +286,6 @@ function(root, ...objects){
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Constructor...
|
// Constructor...
|
||||||
|
|
||||||
// Make an object extending target...
|
|
||||||
//
|
|
||||||
// extend(target)
|
|
||||||
// -> object
|
|
||||||
//
|
|
||||||
// extend(target, object)
|
|
||||||
// -> object
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// NOTE: this will modify the input object.
|
|
||||||
//
|
|
||||||
// XXX EXPERIMENTAL...
|
|
||||||
var extend =
|
|
||||||
module.extend =
|
|
||||||
function(target, obj){
|
|
||||||
obj = obj || {}
|
|
||||||
obj.__proto__ = target.prototype
|
|
||||||
return obj }
|
|
||||||
|
|
||||||
|
|
||||||
// Make an uninitialized instance object...
|
// Make an uninitialized instance object...
|
||||||
//
|
//
|
||||||
// makeRawInstance(context, constructor, ...)
|
// makeRawInstance(context, constructor, ...)
|
||||||
@ -318,6 +298,8 @@ function(target, obj){
|
|||||||
// -> call and use its return value
|
// -> call and use its return value
|
||||||
// - if prototype is a function or if .__call__(..) is defined
|
// - if prototype is a function or if .__call__(..) is defined
|
||||||
// -> use a wrapper function
|
// -> use a wrapper function
|
||||||
|
// - if constructor.__proto__ is a constructor
|
||||||
|
// -> use it to create an instance
|
||||||
// - else
|
// - else
|
||||||
// -> use {}
|
// -> use {}
|
||||||
// - link the object into the prototype chain
|
// - link the object into the prototype chain
|
||||||
@ -382,9 +364,8 @@ function(context, constructor, ...args){
|
|||||||
return constructor.prototype.__call__
|
return constructor.prototype.__call__
|
||||||
.call(obj, this, ...arguments) },
|
.call(obj, this, ...arguments) },
|
||||||
constructor.prototype.__call__)
|
constructor.prototype.__call__)
|
||||||
// XXX EXPERIMENTAL...
|
// use parent's constructor... (XXX EXPERIMENTAL)
|
||||||
// XXX do a better test...
|
// XXX do a better test...
|
||||||
// use parent's constructor...
|
|
||||||
: (constructor.__proto__ instanceof Function
|
: (constructor.__proto__ instanceof Function
|
||||||
&& constructor.__proto__ !== (function(){}).__proto__) ?
|
&& constructor.__proto__ !== (function(){}).__proto__) ?
|
||||||
Reflect.construct(constructor.__proto__, [], constructor)
|
Reflect.construct(constructor.__proto__, [], constructor)
|
||||||
@ -584,12 +565,13 @@ function Constructor(name, a, b){
|
|||||||
_constructor.__proto__
|
_constructor.__proto__
|
||||||
: cls_proto
|
: cls_proto
|
||||||
_constructor.prototype = proto
|
_constructor.prototype = proto
|
||||||
// generic raw instance constructor...
|
// set generic raw instance constructor...
|
||||||
_constructor.__rawinstance__ instanceof Function
|
_constructor.__rawinstance__ instanceof Function
|
||||||
|| (_constructor.__rawinstance__ =
|
|| (_constructor.__rawinstance__ =
|
||||||
function(context, ...args){
|
function(context, ...args){
|
||||||
return makeRawInstance(context, this, ...args) })
|
return makeRawInstance(context, this, ...args) })
|
||||||
// set .prototype.constructor
|
|
||||||
|
// set constructor.prototype.constructor
|
||||||
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.7.1",
|
"version": "2.7.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user