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

verso

v0.2.2

Published

A framework for writing very dumb single page apps.

Downloads

3

Readme

Verso

A framework for writing very dumb single page apps.

Build Status

Some single page apps are almost all static content. For those apps, a small client library that just swaps out the innerHTML of a dom node when navitation occurs, might be all that's needed.

The idea is that the page content can be generated in any number of fancy ways, but when it's time to deploy the app, it gets rendered down to a dumb app that's mostly just string pushing.

##API API is still a work in progress and will likely change greatly until v1.0 is published.

###Verso(pages, context): Verso Creates a verso instance that's can serve the pages defined in the pages map.

The context is used to resolve params referenced in the page's function.

Verso.run(uri, el): Promise

Runs the page for the given uri, and places the result inside the element passed in.

Resolves to the element that was updated, or rejects if no page matches the uri.

Verso.render(uri): Promise

Resolves to the html for the generated page, or rejects if an no page matches the uri.

Verso.compile(): Promise

Crawls the app starting from the root "/" and resolves to a hash with all of the reachable pages rendered and indexed by their uris.

Example Usage


// Pages this app can display, normally I'd break each page out into 
// its own module to keep things cleaner.
let pages = { 
    '/' : {            
      render: (contacts) => {
          return `<div>Welcome <span id="user-name"></span><div>
            ${contacts.map(contact => {
              let {id,name} = contact
              return `<a href="/contact/${id}">${name}</a>`
            }).join('')}
          </div></div>`
      },
      
      // Executes when the page is run
      customize: (el, user) => {
        el.querySelector('#user-name').innerHTML = user.name
      }
    },
    
    // Implicitly defines the page spec with a render function
    '/contact/:id': (id, contacts) => {
      let contact = contacts.find(c => c.id == id)
      return `<h1>${contact.name}'s Page</h1>`
    },
    
    // Simple String as page content
    '/about': 'About Page Here'
}
            
let context = {
  contacts: [
    {id: 1, name: 'Allain'},
    {id: 2, name: 'Debby'}
  ],
  user: {
    name: 'Guest'
  }
}
            
let v = Verso(pages, context)

v.run('/', document.getElementById('app')) // Renders the contact list into the DOM

v.compile().then(compiled => {
  console.log(compiled); 
})

The compiled output above would contain the keys /, /contact/1, /contact/2 but would not contain /about because it cannot be accessed by crawling from the root of the app (/).