mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 11:00:12 +00:00
even more docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e1a705a648
commit
c97d14b491
52
README.md
52
README.md
@ -4,6 +4,7 @@ XXX Intro
|
|||||||
|
|
||||||
- [Object diff](#object-diff)
|
- [Object diff](#object-diff)
|
||||||
- [Motivation](#motivation)
|
- [Motivation](#motivation)
|
||||||
|
- [Goals / Features](#goals--features)
|
||||||
- [General](#general)
|
- [General](#general)
|
||||||
- [Diff](#diff)
|
- [Diff](#diff)
|
||||||
- [Diff class API](#diff-class-api)
|
- [Diff class API](#diff-class-api)
|
||||||
@ -24,7 +25,14 @@ XXX Intro
|
|||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
|
||||||
XXX goals
|
XXX
|
||||||
|
|
||||||
|
### Goals / Features
|
||||||
|
- Full JSON *diff* support
|
||||||
|
- Support for JavaScript objects without restrictions
|
||||||
|
- *Text diff* support
|
||||||
|
- Configurable and extensible implementation
|
||||||
|
- As simple as possible
|
||||||
|
|
||||||
XXX alternatives
|
XXX alternatives
|
||||||
|
|
||||||
@ -32,7 +40,7 @@ XXX alternatives
|
|||||||
## General
|
## General
|
||||||
|
|
||||||
Install the package:
|
Install the package:
|
||||||
```bash
|
```shell
|
||||||
$ npm install --save object-diff
|
$ npm install --save object-diff
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -59,22 +67,29 @@ var diff = new Diff(A, B)
|
|||||||
|
|
||||||
#### Diff class API
|
#### Diff class API
|
||||||
|
|
||||||
`.cmp(A, B) -> bool`
|
`Diff.cmp(A, B) -> bool`
|
||||||
|
Deep compare `A` to `B`.
|
||||||
|
|
||||||
`.clone(<title>)`
|
`Diff.clone(<title>)`
|
||||||
|
Clone the `Diff` constructor, useful for extending or tweaking the type handlers (see: [Extending](#extending-diff) below).
|
||||||
|
|
||||||
`.fromJSON(json) -> diff`
|
`Diff.fromJSON(json) -> diff`
|
||||||
|
Build a diff object from JSON (exported via `.json()`).
|
||||||
|
|
||||||
|
|
||||||
#### Diff object API
|
#### Diff object API
|
||||||
|
|
||||||
`.patch(X) -> X'`
|
`diff.patch(X) -> X'`
|
||||||
|
Apply "diff* (or *patch*) `X` to `X'` state.
|
||||||
|
|
||||||
`.unpatch(X') -> X`
|
`diff.unpatch(X') -> X`
|
||||||
|
Undo *diff" application to `X'` returning it to `X` state.
|
||||||
|
|
||||||
`.check(X) -> bool`
|
`diff.check(X) -> bool`
|
||||||
|
Check if *diff* is compatible/applicable to `X`. This essentially checks if the *left hand side* of the *diff* matches the corresponding nodes of `X`.
|
||||||
|
|
||||||
`.json() -> JSON`
|
`diff.json() -> JSON`
|
||||||
|
Serialize the *diff* to JSON. Note that the output may or may not be JSON compatible depending on the inputs.
|
||||||
|
|
||||||
|
|
||||||
#### Supported JavaScript objects
|
#### Supported JavaScript objects
|
||||||
@ -89,7 +104,7 @@ Containers that support item changes include:
|
|||||||
- ~~`Map` / `WeakMap`~~ *(planned but not done yet)*
|
- ~~`Map` / `WeakMap`~~ *(planned but not done yet)*
|
||||||
- ~~`Set` / `WeakSet`~~ *(planned but not done yet)*
|
- ~~`Set` / `WeakSet`~~ *(planned but not done yet)*
|
||||||
|
|
||||||
Additionally attribute changes are supported for all non basic objects (i.e. anything that `typeof X` yeilds `"object"`) and can be disabled by setting `options.no_attributes` to `true`.
|
Additionally attribute changes are supported for all non basic objects (i.e. anything for which `typeof X` yeilds `"object"`). This can be disabled by setting `options.no_attributes` to `true` (see: [Options](#options) below).
|
||||||
|
|
||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
@ -133,19 +148,24 @@ cmp(A, B)
|
|||||||
|
|
||||||
Diff.cmp(A, B)
|
Diff.cmp(A, B)
|
||||||
```
|
```
|
||||||
|
XXX
|
||||||
|
|
||||||
|
|
||||||
### Patterns
|
### Patterns
|
||||||
|
|
||||||
XXX General description...
|
XXX General description...
|
||||||
|
|
||||||
`ANY` - matches anything
|
`ANY`
|
||||||
|
Matches anything
|
||||||
|
|
||||||
`NOT(A)` - match anything but `A`
|
`NOT(A)`
|
||||||
|
Match anything but `A`
|
||||||
|
|
||||||
`OR(A[, .. ])` - match if *one* of the arguments matches
|
`OR(A[, .. ])`
|
||||||
|
Match if *one* of the arguments matches
|
||||||
|
|
||||||
`AND(A[, .. ])` - matches of *all* of the arguments match
|
`AND(A[, .. ])`
|
||||||
|
Matches of *all* of the arguments match
|
||||||
|
|
||||||
XXX examples...
|
XXX examples...
|
||||||
|
|
||||||
@ -264,7 +284,9 @@ This format is used internally but may be useful for introspection.
|
|||||||
|
|
||||||
## Contacts, feedback and contributions
|
## Contacts, feedback and contributions
|
||||||
|
|
||||||
XXX github, npm, email, ...
|
- https://github.com/flynx/object-diff.js
|
||||||
|
- XXX npm
|
||||||
|
- https://github.com/flynx
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user