1.1.0 • Published 4 years ago

udomdiff v1.1.0

Weekly downloads
1,082
License
ISC
Repository
github
Last release
4 years ago

µdomdiff

Build Status Coverage Status

a different tree

Social Media Photo by Christopher Rusev on Unsplash

An essential diffing algorithm for µhtml.

Signature

futureNodes = udomdiff(
  parentNode,           // where changes happen
  [...currentNodes],    // Array of current items/nodes
  [...futureNodes],     // Array of future items/nodes (returned)
  get(node, toDoWhat),  // a callback to retrieve the node
  before                // the anchored node to insertBefore
);

What is get and how does it work?

You can find all info from domdiff, as it's exactly the same concept:

  • get(node, 1) to retrieve the node that's being appended
  • get(node, 0) to get the node to use for an insertBefore operation
  • get(node, -0) to get the node to use for an insertAfter operation
  • get(node, -1) to retrieve the node that's being removed

If you don't care about any of those second arguments values, const get = o => o; is a valid get too.

How to import it:

  • via CDN, as global variable: https://unpkg.com/udomdiff
  • via ESM, as external module: import udomdiff from 'https://unpkg.com/udomdiff/esm/index.js'
  • via CJS: const udomdiff = require('udomdiff'); ( or require('udomdiff/cjs') )
  • via bundlers/transpilers: import udomdiff from 'udomdiff'; ( or from 'udomdiff/esm' )
1.1.0

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.0

4 years ago