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

hmu-core

v1.0.0

Published

Run HMU requests and get raw output.

Downloads

18

Readme

hmu-core

Run HMU requests and get raw output

hmu([
  // A request:
  { target: require('hmu-npm'),
    input: [ 'foo', 'bar', 'baz' ],
    options: { filter: 'free' } }
], function (err, res) {
  // Handle results however
  // Display in whatever environment
  // e.g. terminal, chat, web
})

This module is for running HMU requests (otherwise called plugins) and getting raw output.

If you are looking for a CLI version, see hmu.

This module is for using the same easy function for different displays like chat, web, email, etc.

Installation

$ npm install --save hmu-core

Usage

hmu(requests, [callback])

Runs the given requests and gives the mapped results in callback.

Parameters

  • requests (Array): An array of "request objects" in the form { target, input, options }
  • callback (Function): Collected results. Called with params (err, res). res being a map of requests.

Examples

hmu([
  { target: require('hmu-npm'),
    input: [ 'foo', 'bar', 'baz' ] },
  { target: require('hmu-gh'),
    input: [ 'foojs', 'barjs', 'bazjs' ],
    options: { filter: 'free' } }
], function (err, res) {
  t.same(res, [
    [ 'foo taken', 'bar taken', 'baz taken' ],
    [ 'barjs free', 'bazjs free' ]
  ])
})

request

A request is a plain object in the form:

{
  target: Function,
  input: Array, // optional (undefined, null)
  options: Array // optional
}

A target is otherwise called a "plugin". A plugin is more on the front-end side as it gets resolved into a target (which then gets ran). This is so you can do dynamic plugins, e.g. a function loaded as a target from chat messages.

plugin

A plugin gets called with target(input, options, callback). input and options are from request if ran with hmu-core, but this form makes them reusable as any normal function.

The callback is called in (err, output). You can think of output as a map or reduce of input, and your options can trigger varying output alongside that.

Examples

// Simple HTTP fetch plugin using `pull-stream` and `pull-fetch`
function plugin (input, opts, cb) {
  pull(
    values(input),
    asyncMap((item, done) => {
      // pull-fetch on url
      pull(fetch.result(item, opts), collect(done))
    }),
    collect(cb)
  )
}

License

MIT © Jamen Marz


version travis downloads license follow