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

dominiq

v0.17.2

Published

A happy medium between classic DOMs and upcoming new ES features

Downloads

13

Readme

Dominiq

Travis CI Codecov npm

A happy medium between classic DOMs and upcoming new ES features:

  • listen() DOM events and extract data from them in Observable way.
  • App class provides an easy way to handle states and actions:
    • app.commit() to mutate its state
    • app.dispatch() to call an action

Dominiq found a natural way to build an application with modern methods. We fully respect these native JavaScript features and just combined them:

Contents

  • Core concept (see below)
  • Basic usages (see below)
  • Installation
  • Extraction
    • Nested names / From events / Via Observables / Full or partial data / Event delegation
  • State
    • Set and get / Flat or nested / Computed properties / Input validations / Sanitization
  • Action
    • Dispatch / Mutation / Async operation / Separated code
  • Events
    • render / rendered / started / stopped / changed:*
  • APIs

Core concept

From such a DOM tree:

<body>
  <input name="first" value="John">
  <input name="last" value="Doe">
</body>

Extract the data:

const data = extract(document.body) // { first: "John", last: "Doe" }

Or, merge them into the state continuously in Observable way:

const state = { first: "", last: "" }
listen(document.body, "change") // Create event observable
  .subscribe(e => merge(state, toData(e))) // Extract the data

Basic usages

Prepare such a view file:

// view.js
import { html } from "lit-html/lib/lit-extended"
export default state => html`
  <h1>Hello ${ state.first }!</h1>
  <input name="first" value="${ state.first }">
  <input name="last" value="${ state.last }">
  <button name="submit">Click me!</button>
`

Note: In the example, we use lit-html as a HTML renderer, but you can choose any library/framework for it.

import { render } from "lit-html"
import { listen, App } from "dominiq"
import view from "./view.js"

const initialState = { first: "", last: "" }
const actions = {
  submit (state) { console.log(`Hello ${ state.first }!`) }
}
const dom = document.body
const app = new App({ initialState, actions })

// Listen <input> and commit changes into the state
listen(dom, "change").subscribe(app.commit)
// Listen <button> and dispatch actions
listen(dom, "click").subscribe(app.dispatch)
// Listen app and render the view
listen(app, "render").subscribe(state => render(view(state), dom))
app.start()

Note: listen() is just a thin helper and equivalent to RxJS's fromEvent()

License

MIT