Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-05-06 19:00:39 +03:00
parent 4c3505c735
commit 58461b949a

View File

@ -8,14 +8,12 @@ object model and interfaces.
This is an alternative to the ES6 `class` syntax in JavaScript and provides This is an alternative to the ES6 `class` syntax in JavaScript and provides
several advantages: several advantages:
- Simple way to define instance and constructor methods, properties and
attributes,
- Uniform and minimalistic definition syntax based on basic JavaScript - Uniform and minimalistic definition syntax based on basic JavaScript
object syntax, no special cases, special syntax or _"the same but slightly object syntax, no special cases, special syntax or _"the same but slightly
different"_ ways to do things, different"_ ways to do things,
- _Transparently_ based on JavaScript's prototypical inheritance model, - _Transparently_ based on JavaScript's prototypical inheritance model,
- Granular instance construction (a-la _Python's_ `.__new__(..)` - Granular 2-stage instance construction and initialization (a-la
and `.__init__(..)` methods), _Python's_ `.__new__(..)` and `.__init__(..)` methods),
- Simple way to define callable instances (including a-la _Python's_ - Simple way to define callable instances (including a-la _Python's_
`.__call__(..)`), `.__call__(..)`),
- Produces fully introspectable constructors/instances, i.e. no _direct_ - Produces fully introspectable constructors/instances, i.e. no _direct_
@ -23,7 +21,7 @@ several advantages:
- Does not try to emulate constructs not present in the language (classes), - Does not try to emulate constructs not present in the language (classes),
- Less restrictive: - Less restrictive:
- `new` is optional, - `new` is optional,
- all input components are reusable, - all input components are reusable JavaScript objects,
- no artificial restrictions. - no artificial restrictions.
Disadvantages compared to the `class` syntax: Disadvantages compared to the `class` syntax:
@ -436,7 +434,7 @@ var myArray = object.Constructor('myArray', Array, {
Note that all of the following are generic and will work on any relevant Note that all of the following are generic and will work on any relevant
JavaScript object. JavaScript object.
For example this will happily create and array `['a', 'b', 'c']`... For example, this will happily create and array `['a', 'b', 'c']`:
```javascript ```javascript
var l = object.makeRawInstance(null, Array, 'a', 'b', 'c') var l = object.makeRawInstance(null, Array, 'a', 'b', 'c')
``` ```
@ -533,8 +531,8 @@ This is the opposite of `mixin(..)`
Mixin contents of objects into one Mixin contents of objects into one
``` ```
mixinFlat(<root>, <object>, ..) mixinFlat(<base>, <object>, ..)
-> <object> -> <base>
``` ```
This is like `Object.assign(..)` but copies property descriptors rather This is like `Object.assign(..)` but copies property descriptors rather
than property values. than property values.