Giter Site home page Giter Site logo

bcomnes / udomdiff Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webreflection/udomdiff

0.0 2.0 0.0 179 KB

An essential diffing algorithm for µhtml.

Home Page: https://medium.com/@WebReflection/the-web-smallest-dom-diffing-library-5b69ac4d1f4d

License: ISC License

JavaScript 95.21% HTML 4.79%

udomdiff's Introduction

µ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' )

udomdiff's People

Contributors

webreflection avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.