From 82f68b254f8c59f0fc1db6b68e8f071c9e22c7af Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 31 Jul 2018 02:46:58 +0300 Subject: [PATCH] some more docs.. Signed-off-by: Alex A. Naanou --- README.md | 7 +++++++ diff.js | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index b4fd6ff..ccbf085 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,13 @@ ExtendedDiff.types.delete('Text') The [source code](./diff.js#L1098) is a good example for this as the base `Diff(..)` is built using this API, but note that we are registering types on the `Types` object rather than on the `Diff` itself, there is no functional difference other than how the main code is structured internally. +The handler methods are all called in the context of the `Diff.types` object. + +To call a different type handler's methods use: +```javascript +this.typeCall(HandlerType, 'method', ...args) +``` +For an example see: `Object` handler's `.walk(..)` in [diff.js](./diff.js#L1178). ## The Diff format diff --git a/diff.js b/diff.js index 8311a6d..ad4e13f 100644 --- a/diff.js +++ b/diff.js @@ -1662,6 +1662,12 @@ var DiffPrototype = { get version(){ return this.constructor.version }, + // XXX is this the right thing to do??? + // ...the bad thing here is that this can be mutated from the + // instance when returned like this... + get types(){ + return this.constructor.type }, + structure: null, placeholders: null, options: null,