Class patch.Patch

Create a new instance of a patch command based on the given factory objects.

Constructor

class patch.Patch(resolverFactory, docFactory, deltaFactory)
Arguments:
  • resolverFactory (Object) – A reference to a resolver profile.
  • docFactory (Object) – A reference to a document profile.
  • deltaFactory (Object) – A reference to a delta profile.

Usage example:

var resolverProfile = require('./lib/profiles/algo-resolver-xcc');
var docProfile = require('./lib/profiles/doc-tree-xml');
var deltaProfile = require('./lib/profiles/delta-tree-xml');
var patch = require('./lib/delta/patch');

var p = new patch.Patch(resolverProfile, docProfile, deltaProfile);

var doc = docProfile.loadOriginalDocument(document_content);
var fragadapter = docProfile.createFragmentAdapter(doc.type);
var delta = deltaProfile.loadDocument(patch_content, fragadapter);

p.patch(doc, delta);

var result = docProfile.serializeDocument(doc);

Methods

Patch#patch

patch.Patch.Patch#patch(doc, deltadoc)
Arguments:
  • doc (Object) –
    An instance returned by the document factory
    loadInputDocument method.
  • deltadoc (Object) –
    An instance returned from the delta factory
    loadDocument method.
Returns Number:

The number of changes which were not resolved properly.

Patch the doc using the operations found in deltadoc. Resolve all operations, install change handlers and activate all of them in one step.

Patch#resolve

patch.Patch.Patch#resolve(deltadoc, deltadoc)
Arguments:
  • deltadoc (Object) –
    An instance returned from the delta factory
    loadDocument method.
  • deltadoc (Object) –
Returns Number:

The number of changes which were not resolved properly.

Resolve all operations in the given delta document and create an attached operation for each of them.

Table Of Contents

Previous topic

Class diff.Diff

Next topic

Class Document