mirror of
https://github.com/flynx/object.js.git
synced 2025-11-01 12:00:10 +00:00
updated docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f8c03077f1
commit
e97156350e
27
object.js
27
object.js
@ -20,6 +20,7 @@ module.TAB_SIZE = 4
|
|||||||
// normalizeIndent(text)
|
// normalizeIndent(text)
|
||||||
// -> text
|
// -> text
|
||||||
//
|
//
|
||||||
|
//
|
||||||
// This will remove common indent from each like of text, this is useful
|
// 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
|
// for printing function code of functions that were defined at deep levels
|
||||||
// of indent.
|
// of indent.
|
||||||
@ -118,6 +119,7 @@ function(method, name, that){
|
|||||||
// parentCall(<meth>, <name>, this>, ...)
|
// parentCall(<meth>, <name>, this>, ...)
|
||||||
// -> <res>
|
// -> <res>
|
||||||
//
|
//
|
||||||
|
//
|
||||||
// NOTE: this is just like parent(..) but will call the retrieved method,
|
// NOTE: this is just like parent(..) but will call the retrieved method,
|
||||||
// essentially this is a shorthand to:
|
// essentially this is a shorthand to:
|
||||||
// parent(method, name, this).call(this, ...)
|
// parent(method, name, this).call(this, ...)
|
||||||
@ -264,7 +266,6 @@ function(context, constructor, ...args){
|
|||||||
// attributes.
|
// attributes.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
|
||||||
// The resulting constructor can produce objects in one of these ways:
|
// The resulting constructor can produce objects in one of these ways:
|
||||||
//
|
//
|
||||||
// Basic constructor use...
|
// Basic constructor use...
|
||||||
@ -303,22 +304,15 @@ function(context, constructor, ...args){
|
|||||||
// A simple way to build C -> B -> A chain would be:
|
// A simple way to build C -> B -> A chain would be:
|
||||||
//
|
//
|
||||||
// // NOTE: new is optional...
|
// // NOTE: new is optional...
|
||||||
// var A = new Constructor('A', {})
|
// var A = new Constructor('A')
|
||||||
//
|
//
|
||||||
// // NOTE: the prototype is an instance and not a constructor,
|
// // NOTE: in a prototype chain the prototypes are "inherited"
|
||||||
// // this is obvious if one considers that in JS there are
|
// // NOTE: JS has no classes and the prototype is just another
|
||||||
// // no classes and inheritance is done via object prototypes
|
// // object, the only difference is that it's used by the
|
||||||
// // but this might be a gotcha to people coming from the
|
// // constructor to link other objects i.e. "instances" to...
|
||||||
// // class-object world.
|
// var B = Constructor('B', {__proto__: A.prototype})
|
||||||
// // NOTE: we are creating instances here to provide isolation
|
|
||||||
// // between A and B prototypes...
|
|
||||||
// // two other ways to do this would be:
|
|
||||||
// // Object.create(A.prototype)
|
|
||||||
// // or:
|
|
||||||
// // {__proto__: A.prototype}
|
|
||||||
// var B = Constructor('B', A())
|
|
||||||
//
|
//
|
||||||
// var C = Constructor('C', {__proto__: B.prototype})
|
// var C = Constructor('C', Objec.create(B.prototype))
|
||||||
//
|
//
|
||||||
// var c = C()
|
// var c = C()
|
||||||
//
|
//
|
||||||
@ -347,10 +341,11 @@ function(context, constructor, ...args){
|
|||||||
// - easy refactoring without touching the client code
|
// - easy refactoring without touching the client code
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// NOTE: this sets the proto's .constructor attribute, this rendering it
|
// NOTE: this sets the proto's .constructor attribute, thus rendering it
|
||||||
// not reusable, to use the same prototype for multiple objects clone
|
// not reusable, to use the same prototype for multiple objects clone
|
||||||
// it via. Object.create(..) or copy it...
|
// it via. Object.create(..) or copy it...
|
||||||
//
|
//
|
||||||
|
// XXX EXPERIMENTAL: calling .__rawinstance__(..) to create an instance...
|
||||||
// XXX Q: should the context in .__new__(..) be _constructor or .prototype???
|
// XXX Q: should the context in .__new__(..) be _constructor or .prototype???
|
||||||
// ...currently it's .prototype...
|
// ...currently it's .prototype...
|
||||||
var Constructor =
|
var Constructor =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user