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

u-lr

v2.0.0

Published

Micro LiveReload is a micro websocket server that send an event to reload your browser whenever you call notifyReload from an instance of the exported Server class

Downloads

2

Readme

Micro LiveReload Server

Downloads Dependencies status MIT Licensed

Micro Live Reload server is a websocket server which delivers a message whenever notifyReload server instance method is called; the only purpose of it is as a development tool.

NOTE: My aim to build this server was because I faced a problem with common tiny-lr server which implements LiveReload wide extended live reload protocol and gulp-livereload and after I spent some hours figuring out the issue and I couldn't find it, I developed it and later on, I found a workaround, therefore I discourage to use it as a replacement of any LiveReload implementation and the implementation will remain here as historical documentation.

Be aware that its project is not currently maintained

Introduction

It is a module which exports a Server class method whose instances wrap a websocket server built with engine.io that allows to send a websocket message (client side must use engine.io-client which a basic implementation of a browserify module is delivered by this server) each time that notifyReload of a server instances is called.

When the provided client side script for this server is used, it basically reloads the page calling in the browser window.location.reload(), without any other secret.

Usage

Install

npm install u-lr

Functionality

The module export a Server class method whose constructor accept an options object which is provided straightaway to attach of an instance of engine.io#Server, with only one optional parameter more, port, which is the port number to use by the HTTP Server and by default, it listens on 49000.

Each Server instance has three methods:

  • start
  • stop
  • notifyReload

All of them, only receive one parameter, a callback function, which is called with an error object if it something goes wrong, the well-known callback node convention.

start and stop are self-explained. notifyReload is used to notify to server to send a websocket message to warn to the connected socket clients to reload the page.

The client side must be a engine.io-client which listens messages (message event) which receive a data packet with a JSON object always with this values:

{
	message: 'reload'
	data: {
		type: '*'
	}
}

The message content is not significant, because it only delivers one message and always with the same value, but I thought to use it, than an empty message, to easy backward compatibility if in some point I decided to extend it.

The server is a HTTP server with only has one route /require-module, any other request, it will send back a response with status code 501 Not Implemented.

The mentioned route, send a browserify module (javascript file) with a self container require function definition; this module can be required using require('u-lr'), which exports a function that receives one optional parameters, an object with this options:

  • host: The host where the server is listening, by default localhost
  • port: The port where the server is listening, by default 49000

When the exported function is called, a client websocket connection is stablished and a message event listener is registered, which reload the page whenever a message is received.

##License Just MIT, read LICENSE file for more information.