New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

udomdiff

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

udomdiff

An essential diffing algorithm for µhtml

1.1.2
latest
Source
npm
Version published
Weekly downloads
7.4K
6.31%
Maintainers
0
Weekly downloads
 
Created
Source

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

Keywords

domdiff

FAQs

Package last updated on 27 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts