mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 18:40:08 +00:00
updated docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e92cab8659
commit
b180412f68
30
README.md
30
README.md
@ -1,29 +1,37 @@
|
|||||||
# object.js
|
# object.js
|
||||||
|
|
||||||
object.js provides a set of tools for making and maintaining object
|
_object.js_ provides a set of tools for making and maintaining object
|
||||||
constructors and for managing their inheritance relations.
|
constructors and for managing their inheritance relations.
|
||||||
|
|
||||||
|
|
||||||
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 normal and class methods, properties and attributes,
|
- Simple way to define instance and "class" 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 or special syntax,
|
object syntax, no special cases, special syntax or _"the same but slightly
|
||||||
- _transparently_ based on _JavaScript's_ prototypical inheritance model,
|
different"_ ways to do things,
|
||||||
- more granular instance construction (a-la _Python's_ `.__new__(..)`
|
- _Transparently_ based on JavaScript's prototypical inheritance model,
|
||||||
|
- Granular instance construction (a-la _Python's_ `.__new__(..)`
|
||||||
and `.__init__(..)` methods)
|
and `.__init__(..)` methods)
|
||||||
- less restrictive:
|
- Simple way to define callable instances (including a-la _Python's_
|
||||||
|
`.__call__(..)`)
|
||||||
|
- Less restrictive:
|
||||||
- `new` is optional
|
- `new` is optional
|
||||||
- all input components are reusable
|
- all input components are reusable
|
||||||
- no artificial restrictions
|
- no artificial restrictions
|
||||||
|
|
||||||
Disadvantages compared to the `class` syntax:
|
Disadvantages compared to the `class` syntax:
|
||||||
- no _syntactic sugar_
|
- No _syntactic sugar_
|
||||||
- slightly more complicated calling of _super_ or `parent` methods
|
- Slightly more complicated calling of `parent` (_super_) methods
|
||||||
|
|
||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install ig-object
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var object = require('ig-object')
|
var object = require('ig-object')
|
||||||
```
|
```
|
||||||
@ -168,8 +176,8 @@ take care of both the _function constructor_ and `prototype.__call__(..)`
|
|||||||
handling.
|
handling.
|
||||||
|
|
||||||
**Notes:**
|
**Notes:**
|
||||||
- `.__new__(..)` is an instance method, contrary to _Python_ that served
|
- `.__new__(..)` is an instance method, contrary to _Python_ (the
|
||||||
as an inspiration for this protocol. This is done intentionally as in
|
inspiration for this protocol). This is done intentionally as in
|
||||||
JavaScript there is no distinction between an instance and a class and
|
JavaScript there is no distinction between an instance and a class and
|
||||||
defining `.__new__(..)` in the class would both add complexity as well
|
defining `.__new__(..)` in the class would both add complexity as well
|
||||||
as restrict the use-cases for the constructor.
|
as restrict the use-cases for the constructor.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user