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

idom2string

v0.3.0

Published

Drop-in IncremtalDOM to string interpreter

Downloads

4

Readme

idom2string

Early experiments with IncrementalDOM server-side rendering. As of now this is just a proof of concept, all comments and ideas are welcome.

Usage

Import it as you would import the real thing, your app will start rendering to string:

var IncrementalDOM = require('idom2string')

A target output can be set before your app calls IncrementalDOM.patch:

IncrementalDOM.setOutput(prettyPrint, output, doneCallback, keepOpen)
  • prettyPrint: nothing or a string to be used for indentation.
  • output:
    • an object: will get a .rendered property containing the output. it defaults to a new Object.
    • a stream: will be directly filled using it's .write method, it's reference is then passed to the callback, it can be an http response, a file stream, std.process...
  • doneCallback: a function being called when patch is done, it receives the output reference.
  • keepOpen: prevents flushing the internal state when patch is done.

IncrementalDOM.patch "node" argument can be empty or one of the following:

  • a function: get passed the patch description function as a partial, this can be used to wrap the patch into an outer description function to generate an approot, note that executing the partial is responsability of the node function. Check document.js in the demos for examples
  • an object: when a .innerHTML property is present it will be assigned the patch rendered result, this can enable some other kind of composition or fill an Element.innerHTML when testing in a browser. When .setOuput is not called the node reference, if any, can be an alternative way to read the output.

The methods expected to return an element will return a mock object, you can assign or merge to this object whatever suits your code:

IncrementalDOM.setElementDummy(obj, merge)

To forcefully clean up the internal state (mostly when using keepOpen on a strem output):

IncrementalDOM.forceReset()

Examples

All examples are based on localvoid's incremental dom port of dbmonster. App code is untouched, document reference is mocked via incremental-dom calls.

dbmonster-server
$ cd demo/dbmonster-server
$ node server.js

Serves a server side rendered version of dbmonster, look at server.js to check some possible usages of .setOutput for serving. Once the prerendered document is loaded the normal js app will kick in (throttle your network to notice it)

dbmonster-streaming
$ cd demo/dbmonster-streaming
$ node server.js

Streams a live dbmonster output, be advised that when streming to http it will likely flood your browser tab process in a few seconds.

dbmonster-browser

start a static server in the root of the project

localhost:8080/demo/dbmonster-browser/index.html is a client side dbmonster only using the string interpreter, this is just usefull for test and development.