Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nanomorph

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanomorph

Hyper fast diffing algorithm for real DOM nodes

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-16.01%
Maintainers
2
Weekly downloads
 
Created
Source

nanomorph stability

npm version build status test coverage downloads js-standard-style

Hyper fast diffing algorithm for real DOM nodes :zap:

Usage

var morph = require('nanomorph')
var html = require('bel')

var tree = html`<div>hello people</div>`
tree = morph(html`<div>nanananana-na-no</div>`, tree)
tree = morph(html`<div>teeny, tiny, tin bottle</div>`, tree)

Appending to the DOM

var update = require('nanomorph/update')
var html = require('bel')

// create the initial tree, save it and append to DOM
var tree = html`<div>hello people</div>`
var morph = update(tree)
document.body.appendChild(tree)

// now each consecutive update will be rendered on the DOM
morph(html`<div>hello people</div>`, tree)

// even if the type of the root node changes
morph(html`<p>nanananana-na-no</p>`, tree)

API

tree = nanomorph(newTree, oldTree)

Diff a tree of HTML elements against another tree of HTML elements and create a patched result that can be applied on the DOM.

morph = update(newTree)

Create a diffing function that morphs one tree into another, even if the type of the root node changes

tree = morph(newTree)

Diff the previous tree with a new tree using the function returned from update()

Installation

$ npm install nanomorph

See Also

Similar Packages

Further Reading

Authors

License

MIT

Keywords

FAQs

Package last updated on 11 Jan 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc