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

bhiv

v3.1.45

Published

Extended asynchronous execution controller with composer syntax

Downloads

15

Readme

Bhiv.js

Bhiv is a utility module which provide a complete syntax to build an asynchronous workflow.

It provides also some basic features like EventEmitter, Object manipulation, or basic functions patterns.

It works on any side

Test:

javascript:(function(s){document.head.appendChild(s);s.src='https://rawgit.com/np42/bhiv/master/Bhiv.js';})(document.createElement('script'));

Install:

<!-- This is not a CDN so don't use it in production -->
<script src="https://rawgit.com/np42/bhiv/master/Bhiv.js"></script>
npm install --save bhiv

Browser Multi Fetching Exemple

// Assuming jQuery & Bhiv loaded

var fetchAllJsonpUrl = (function () {
  var priv = { jQuery: {}, console: {} };
  var bhiv = new Bhiv(priv);

  priv.console.log = function (data) { console.log('Requesting:', data.name, data.url); };

  priv.jQuery.request = function (data, callback) {
    var success = function (data) { return callback(null, data); };
    jQuery.ajax({ url: data.url, dataType: 'jsonp', success: success, error: callback });
  };

  return new bhiv.Bee()

    // iterating on the direct flow, key is named index, value named url
    .Map('.', 'name', 'url')

    // the following is synchronous, that's why '=' character
    .  then('= console.log')

    // requesting and storing the result into the content field
    .  then('jQuery.request', null, { url: '${url}', content: '${.}' })

    // closing the loop (created by the Map keyword, limit parallel execute to 3 tasks)
    .close({ max: 3 })

    // finishing the workflow build
    .end();

})();

fetchAllJsonpUrl
( { github: 'https://api.github.com', ip: 'http://jsonip.com' }
, function (err, data) { console.log(err, data); }
);

Node Module Example


var Bhiv = require('Bhiv');

module.exports = new function () {
  var priv = {};
  var bhiv = new Bhiv(priv, this);

  this.sayHello = new bhiv.Bee()
    .pipe('= getData', null, { words: '${.}' })
    .Map('words', null, 'word')
    .  pipe('= uppercase', '${word}')
    .close()
    .pipe('= join', '${words}')
    .end();

  (function () {

    this.getData = function () {
      return ['hello', 'world'];
    };

    this.uppercase = function (word, callback) {
      return word.toUpperCase();
    };

    this.join = function (array) {
      return array.join(' ');
    };

  }).call(priv);

};

See full syntax documentation into source code at Bee Builder Syntax

Some methods:

 * Trap(<pattern>, <work>, <inglue>, <outglue>): do <work> if an error match <pattern>
 * Map(<path>, <key>, <value>): iter on <path> and do work for each elements
 *  -> replace the old list value by result
 * Go(<work>, <inglue>, <outglue>): create a une parallel waterfall
 * close(<properties>): close task, and set properties
 * emit(<event>, <data>): to emit an event (maybe catched by a bucket)
 * add(<glue>): allow you to add some thing in the flow
 * flatten(): flatten an inherited data structure
 * pipe(<work>, <inglue>, <outglue>): execute a task after the previous one if any
 *  -> replace the result
 * then(<work>, <inglue>, <outglue>): execute a task after the previous one if any
 *  -> merge the result
 * waterfall(<tasks>): do all tasks sequencially, with data replacing the previous one
 * bucket(<event>, <outglue>, <end>): retrieve data for an <event> even until the <end> event
 * extract(<glue>): extract <glue> pattern from data and keep only it
 * keep(<fields>): keep only field list
 * end(<data>, <callback>): execute the bee or wrap either the <data> or the <callback>