From 3b5b36a62e1a90d7363bb8c4fa64e986b45553b3 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 2 May 2020 21:01:51 +0300 Subject: [PATCH] cleanup... Signed-off-by: Alex A. Naanou --- object.js | 30 ++++++------------------------ package.json | 2 +- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/object.js b/object.js index c845fe8..d400f26 100755 --- a/object.js +++ b/object.js @@ -286,26 +286,6 @@ function(root, ...objects){ //--------------------------------------------------------------------- // 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... // // makeRawInstance(context, constructor, ...) @@ -318,6 +298,8 @@ function(target, obj){ // -> call and use its return value // - if prototype is a function or if .__call__(..) is defined // -> use a wrapper function +// - if constructor.__proto__ is a constructor +// -> use it to create an instance // - else // -> use {} // - link the object into the prototype chain @@ -382,9 +364,8 @@ function(context, constructor, ...args){ return constructor.prototype.__call__ .call(obj, this, ...arguments) }, constructor.prototype.__call__) - // XXX EXPERIMENTAL... + // use parent's constructor... (XXX EXPERIMENTAL) // XXX do a better test... - // use parent's constructor... : (constructor.__proto__ instanceof Function && constructor.__proto__ !== (function(){}).__proto__) ? Reflect.construct(constructor.__proto__, [], constructor) @@ -584,12 +565,13 @@ function Constructor(name, a, b){ _constructor.__proto__ : cls_proto _constructor.prototype = proto - // generic raw instance constructor... + // set generic raw instance constructor... _constructor.__rawinstance__ instanceof Function || (_constructor.__rawinstance__ = function(context, ...args){ return makeRawInstance(context, this, ...args) }) - // set .prototype.constructor + + // set constructor.prototype.constructor Object.defineProperty(_constructor.prototype, 'constructor', { value: _constructor, enumerable: false, diff --git a/package.json b/package.json index eb49472..541ec95 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "2.7.1", + "version": "2.7.2", "description": "", "main": "object.js", "scripts": {