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

lighthouse-provider

v1.2.1

Published

Provide the lighthouse launcher with commands in an easy fashion.

Downloads

8

Readme

lighthouse-provider

Build Status

This module provides a way to easily define providers for menu entries to the lighthouse launcher. It depends on generators, so run node with the --harmony flag (or use io.js).

Quickstart

lighthouse.js:

#!/usr/bin/env node
var Lighthouse = require('lighthouse-provider');
var lighthouse = new Lighthouse();

lighthouse.attach(function *(input) {
	return {
		icon: '/some/path/to/icon.png',
		title: 'Execute [' + input + ']',
		action: input
	};
});

process.stdin.pipe(lighthouse).pipe(process.stdout);

You may now use this file as a cmd file for lighthouse.

API

Once you created a provider instance via

var lighthouse = new Lighthouse();

You can use it as a duplex stream:

process.stdin.pipe(lighthouse).pipe(process.stdout);

lighthouse.attach(identifier, handler)

This function allows you to provide a generator function for asynchronous data retrieval (will be run through co).

Identifier

The identifier parameter is optional and may be used, to filter for specific handlers.

So if your input to lighthouse looks like :someId actual input, only the handlers with the identifier someId will be called. You may use :: as an identifier to filter out only those handlers without an identifier.

Handler Function

The handler function will be called with whatever the user types into lighthouse (minus the identifier). It should return a co yieldable (so you may use a generator function here). As a second argument, it is provided a boolean signifying if the handlers flag was supplied. Your function may then do whatever it likes with it, retrieve data from the web, a file system or simply reformat the input etc.

Once done, simply return an object of the form:

{
	icon: '/some/path/to/icon.png',
	title: 'Execute [' + input + ']',
	action: input
}

The icon property may be omitted, but title and action are required. lighthouse-provider will then take care of escaping and formatting the output for you.

If you return anything but an object, your handler will not be output.

An array may be returned for multiple new entries.

lighthouse-provider-common

You may want to check out the lighthouse-provider-common module, for some useful providers.