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

davit

v1.0.5

Published

Lightweight, Live reload, Dev Server

Downloads

3

Readme

Davit

"A small crane on board a ship, especially one of a pair for suspending or lowering a lifeboat."

This project is extremely work in progress.

Davit is a live-reload, development server made because the tool I used previously, Browser-Sync, doesn't seem to be maintained much and also does a lot more than I need. I also wasn't able to find anything else that also supported cleanly running some code before reloading the page.

Davit aims to as lightweight as possible. There's only two dependencies, ws, which might be replaced with my own code as it's also doing way more than I need it for, and mime, just used as a prepackaged way to determine mime-types.

Basic Usage

The following code will start a davit server that watches for changes to the style sheet.

const { Davit } = require('davit');

const dv = new Davit({
	root: 'src'
});

dv.watch('media/style.css');

dv.start();

CLI Usage

To run Davit on the command line, simply run davit followed by the directory you wish to serve up. You can optionally specify options from the list below.

Options

port: number - Port to bind server. Defaults to 3000.

host: string - The hostname to bind the server. Default to localhost.

root: string - Path to serve files from.

source: string - Let's you watch files from a different folder.

glyph: string - Prints next to the server address on startup :) Defaults to ♨.

verbose: boolean - Prints out every time a watch event fires. Defaults to false.

To specify these options in the CLI, simply either type --option where option is the name of the option or -o where o is the first letter of the option, followed by the value you'd like to pass. Boolean values don't take parameters, instead are flipped upon call.

Running Code before Reload

If you'd like to perform some actions before the watch service reloads the site, you can do so like this.

dv.watch('media/*.css', (fileName, fullPath) => {
	codeHere();
});

Disclaimer

In order to make live reloading work, davit inserts a script into the head tag of every html file it serves. The script will open up a web socket and connect back to davit so the browser can receive commands for the live reload. The full source code of this script can be found in src/live-reload/injection.js. Specifically in the function called payload.