From 7dc31c92544392c73892aa754284dd07c86e3d68 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 30 Apr 2020 19:50:19 +0300 Subject: [PATCH 1/2] docs... Signed-off-by: Alex A. Naanou --- object.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/object.js b/object.js index 92e2288..07129e9 100755 --- a/object.js +++ b/object.js @@ -58,6 +58,7 @@ function(text, tab_size){ //--------------------------------------------------------------------- +// Prototype chain content access... // Get a list of sources/definitions for a prop/attr... // @@ -211,6 +212,8 @@ function(proto, name, that, ...args){ //--------------------------------------------------------------------- +// Mixin utils... +// XXX should we add mixout(..) and friends ??? // Mix a set of methods/props/attrs into an object... // @@ -254,7 +257,9 @@ function(root, ...objects){ //--------------------------------------------------------------------- -// Make/get the base instance object... +// Constructor... + +// Make an uninitialized instance object... // // makeRawInstance(context, constructor, ...) // -> instance @@ -327,8 +332,7 @@ function(context, constructor, ...args){ return obj } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Make a JavaScript object constructor... +// Make an object constructor function... // // Make a constructor with an object prototype... // Constructor(name, proto) From e1d07053fc0ac40b39698f0e00fbbeb6b8c7f3f1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 30 Apr 2020 20:04:42 +0300 Subject: [PATCH 2/2] some formatting... Signed-off-by: Alex A. Naanou --- object.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/object.js b/object.js index f8f149d..d2dd2dc 100755 --- a/object.js +++ b/object.js @@ -3,7 +3,8 @@ * * * XXX should this extend Object??? -* ...if yes then it would also be logical to move Object.run(..) here +* ...if yes then it would also be logical to move Object.run(..) +* here... * **********************************************************************/ ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) @@ -22,10 +23,10 @@ module.TAB_SIZE = 4 // // // This will remove common indent from each like of text, this is useful -// for printing function code of functions that were defined at deep levels -// of indent. +// for printing function code of functions that were defined at deep +// levels of indent. // -// NOTE: this will trim out both leading and trailing whitespace. +// NOTE: this will trim out both leading and trailing white-space. // // XXX is this the right place for this??? // ...when moving take care that ImageGrid's core.doc uses this... @@ -146,7 +147,8 @@ function(obj, name, callback){ // var a = object.parent(X.prototype, 'attr') // // // get method... -// var ret = object.parent(X.prototype.method, this).call(this, ...arguments) +// var ret = object.parent(X.prototype.method, this) +// .call(this, ...arguments) // // // ... // } @@ -301,8 +303,8 @@ function(root, ...objects){ // // // NOTE: context is only passed to .__new__(..) if defined... -// NOTE: as this simply an extension to the base JavaScript protocol this -// can be used to construct using any object... +// NOTE: as this simply an extension to the base JavaScript protocol +// this can be used to construct using any object... // Example: // var O = function(){} // // new is optional... @@ -332,14 +334,16 @@ function(context, constructor, ...args){ : constructor.prototype instanceof Function ? _mirror_doc( function(){ - return constructor.prototype.call(obj, this, ...arguments) }, + return constructor.prototype + .call(obj, this, ...arguments) }, constructor.prototype) // callable instance -- prototype defines .__call__(..)... // NOTE: we need to isolate the .__call__ from instances... : constructor.prototype.__call__ instanceof Function ? _mirror_doc( function(){ - return constructor.prototype.__call__.call(obj, this, ...arguments) }, + return constructor.prototype.__call__ + .call(obj, this, ...arguments) }, constructor.prototype.__call__) // default object base... : {} @@ -463,12 +467,12 @@ function(context, constructor, ...args){ // // // Motivation: -// The general motivation here is to standardise the constructor protocol -// and make a single simple way to go with minimal variation. This is due -// to the JavaScript base protocol though quite simple, being too flexible -// making it very involved to produce objects in a consistent manner by -// hand, especially in long running projects, in turn spreading all the -// refactoring over multiple sites and styles. +// The general motivation here is to standardise the constructor +// protocol and make a single simple way to go with minimal variation. +// This is due to the JavaScript base protocol though quite simple, +// being too flexible making it very involved to produce objects in a +// consistent manner by hand, especially in long running projects, +// in turn spreading all the refactoring over multiple sites and styles. // // This removes part of the flexibility and in return gives us: // - single, well defined protocol @@ -478,8 +482,8 @@ function(context, constructor, ...args){ // // // NOTE: this sets the proto's .constructor attribute, thus rendering it -// not reusable, to use the same prototype for multiple objects clone -// it via. Object.create(..) or copy it... +// not reusable, to use the same prototype for multiple objects +// clone it via. Object.create(..) or copy it... // NOTE: to disable .__rawinstance__(..) handling set it to false in the // class prototype... (XXX EXPERIMENTAL) // @@ -523,7 +527,8 @@ function Constructor(name, a, b){ var args = proto.__init__ ? proto.__init__ .toString() - .split(/\n/)[0].replace(/function\(([^)]*)\){.*/, '$1') + .split(/\n/)[0] + .replace(/function\(([^)]*)\){.*/, '$1') : '' var code = proto.__init__ ? proto.__init__