npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

innerhtml

v1.0.2

Published

Stream content to/from a DOM node

Downloads

68

Readme

innerhtml Build Status Dependency Status

Stream content to/from a DOM node

Example

Copy content from one DOM node to another:

index.html

<!doctype html>
<div id="input">
  <h1>Lorem Ipsum</p>
  <p>Pellentesque habitant morbi tristique senectus.</p>
</div>
<div id="output"></div>
<script src="bundle.js"></script>

main.js

var innerhtml = require("innerhtml")
  , input = document.getElementById("input")
  , output = document.getElementById("output")

innerhtml.createReadStream(input).pipe(innerhtml.createWriteStream(output))

Finally, use browserify to create bundle.js:

npm install -g browserify
npm install innerhtml
browserify main.js > bundle.js

API

innerhtml.createReadStream(element [, options])

Create a new readable stream whose source is the passed DOM element. If no options are passed, the readable stream will emit element's innerHTML.

options.objectMode

Setting this to true will cause the readable stream to emit a cloned node for each of element's childNodes.

options.remove

Setting this to true will cause the readable stream to empty the contents of element by setting it's innerHTML to "" after it has been emitted.

If objectMode is also set to true, the readable stream will remove and emit each of element's childNodes.

innerhtml.createWriteStream(element [, options])

Create a new writable stream whose destination is the passed DOM element. If no options are passed, the writable stream will replace the element's innerHTML with the content piped to it.

options.objectMode

Setting this to true will cause the writable stream to expect DOM nodes to be written to it.

options.append

Setting this to true will cause the writable stream to append to the existing contents of the node instead of replacing it.

options.clone

When objectMode is set to true, setting this option to true causes the writeable stream to clone the node written to it before it is appended to element. It allows a readable stream to pipe to multiple destinations when in objectMode.