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

vel

v1.2.0

Published

Create and render virtual-dom elements with ease

Downloads

37

Readme

vel

NPM version build status Test coverage Downloads js-standard-style

Efficiently create and render virtual-dom elements.

Installation

$ npm install vel

Usage

const vel = require('vel')

const el = vel((h, state) => h.html(`<p>hello ${state.type} world</p>`))
const node = el({ type: 'cruel' })

document.body.appendChild(node)
// <p>hello cruel world</p>

API

el = vel(cb(h, state))

Initialize a new virtual element. Listen to the render event. Expects a vdom tree to be returned. h accepts virtual-dom elements, h.html accepts HTML strings and h.svg accepts virtual-dom SVG elements.

el([state])

Render the element's vdom tree to DOM nodes which can be mounted on the DOM. Uses main-loop under the hood. Calling the method again will re-render the DOM nodes with the new state. Alias: el.render([state]).

el.toString([state])

Render the element's vdom tree to a string. For example useful to pre-render HTML on the server, or save to a static file.

vtree = el.vtree([data])

Get the element's vdom tree. Useful for element composition.

FAQ

why did you write this?

Using virtual-dom requires quite some boilerplate. vel removes the need for that boilerplate without adding extra features, making it easier to write virtual-dom systems.

why is there no state transport mechanism included?

vel does one thing, and only one thing. Instead of including a state transport mechanism I felt it made more sense to let users decide for themselves how they want their state to flow between components.

what's the difference between virtual-dom and react?

react is an opinionated framework that uses non-standard syntax to create systems. It forces users to write JS in OO style and is hard to switch from once you buy into it. virtual-dom does away with those opinions, giving users a blazingly fast rendering engine without the overhead of a framework.

this module sound lot like base-element!

Yeah, definitely! I'm actually a huge fan of base-element. However I wanted something a little more barebone favoring composition over inheritance. If inheritance is your thing, definitely check out base-element (and say hi to @shama for me :grin:).

See Also

License

MIT