diff --git a/README.md b/README.md index 85a76be..bc04efd 100755 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ class B extends A { - [`hasMixin(..)`](#hasmixin) - [`mixout(..)`](#mixout) - [`mixinFlat(..)`](#mixinflat) - - [`makeRawInstance(..)`](#makerawinstance) + - [`RawInstance(..)`](#rawinstance) - [`Constructor(..)` / `C(..)`](#constructor--c) - [Utilities](#utilities) - [`normalizeIndent(..)` / `normalizeTextIndent(..)`](#normalizeindent--normalizetextindent) @@ -450,7 +450,7 @@ JavaScript object. For example, this will happily create a normal native array object `['a', 'b', 'c']`: ```javascript -var l = object.makeRawInstance(null, Array, 'a', 'b', 'c') +var l = object.RawInstance(null, Array, 'a', 'b', 'c') ``` @@ -586,15 +586,15 @@ This is like `Object.assign(..)` but copies property descriptors rather than property values. -### `makeRawInstance(..)` +### `RawInstance(..)` Make a raw (un-initialized) instance ``` -makeRawInstance(, , ..) +RawInstance(, , ..) -> ``` -`makeRawInstance(..)` will do the following: +`RawInstance(..)` will do the following: - Create an instance object - get result of `.__new__(..)` if defined, or - if prototype is a function or `.__call__(..)` is defined, create a @@ -622,12 +622,12 @@ Constructor(, , ) `Constructor(..)` essentially does the following: - Creates a _constructor_ function, - Sets constructor `.name` and `.toString(..)` for introspection, -- Creates `.__rawinstance__(..)` wrapper to `makeRawInstance(..)` +- Creates `.__rawinstance__(..)` wrapper to `RawInstance(..)` - Sets constructor `.__proto__`, `.prototype` and `.prototype.constructor`, - Mixes in _constructor-mixin_ if given. The resulting _constructor_ function when called will: -- call constructor's `.__rawinstance__(..)` if defined or `makeRawInstance(..)` +- call constructor's `.__rawinstance__(..)` if defined or `RawInstance(..)` to create an instance, - call instance's `.__init__(..)` if present. diff --git a/object.js b/object.js index c530d41..4968af7 100755 --- a/object.js +++ b/object.js @@ -447,7 +447,7 @@ function(base, ...objects){ // Make an uninitialized instance object... // -// makeRawInstance(context, constructor, ...) +// RawInstance(context, constructor, ...) // -> instance // // @@ -473,7 +473,7 @@ function(base, ...objects){ // can be used to construct any object... // Example: // // new is optional... -// var l = new makeRawInstance(null, Array, 'a', 'b', 'c') +// var l = new RawInstance(null, Array, 'a', 'b', 'c') // NOTE: the following are not the same in structure but functionally // are identical: // var C = Constructor('C', function(){ .. }) @@ -482,8 +482,9 @@ function(base, ...objects){ // the difference is in C.prototype vs. C2.prototype, the first // being a function while the second is an object with a call // method... -var makeRawInstance = -module.makeRawInstance = +// NOTE: essentially this is an extended version of Reflect.construct(..) +var RawInstance = +module.RawInstance = function(context, constructor, ...args){ var _mirror_doc = function(func, target){ Object.defineProperty(func, 'toString', { @@ -563,7 +564,7 @@ function(context, constructor, ...args){ // // Create raw/uninitialized instance... // constructor.__rawinstance__(..) -// makeRawInstance(null, constructor, ..) +// RawInstance(null, constructor, ..) // -> raw-instance // // @@ -575,7 +576,7 @@ function(context, constructor, ...args){ // // Create and initialization protocol: // 1) raw instance is created: -// a) constructor.__rawinstance__(..) / makeRawInstance(..) called: +// a) constructor.__rawinstance__(..) / RawInstance(..) called: // - call .__new__(..) if defined and get return value as // instance, or // - if .__call__(..) defined or prototype is a function, wrap @@ -607,7 +608,7 @@ function(context, constructor, ...args){ // Handle uninitialized instance construction // .__rawinstance__(context, ...) // -> instance -// NOTE: This is a shorthand to makeRawInstance(..) see it for +// NOTE: This is a shorthand to RawInstance(..) see it for // details. // // @@ -626,7 +627,7 @@ function(context, constructor, ...args){ // -> .. // // -// NOTE: raw instance creation is defined by makeRawInstance(..) so see +// NOTE: raw instance creation is defined by RawInstance(..) so see // it for more info. // NOTE: raw instance creation can be completely overloaded by defining // .__rawinstance__(..) on the constructor. @@ -720,7 +721,7 @@ function Constructor(name, a, b, c){ // create raw instance... var obj = _constructor.__rawinstance__ ? _constructor.__rawinstance__(this, ...arguments) - : makeRawInstance(this, _constructor, ...arguments) + : RawInstance(this, _constructor, ...arguments) // initialize... obj.__init__ instanceof Function && obj.__init__(...arguments) @@ -760,7 +761,7 @@ function Constructor(name, a, b, c){ _constructor.__rawinstance__ instanceof Function || (_constructor.__rawinstance__ = function(context, ...args){ - return makeRawInstance(context, this, ...args) }) + return RawInstance(context, this, ...args) }) !!constructor_proto && (_constructor.__proto__ = constructor_proto) _constructor.prototype = proto diff --git a/package.json b/package.json index 2ec69d8..01371f5 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "3.3.2", + "version": "4.0.0", "description": "", "main": "object.js", "scripts": {