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

parallelax

v1.0.3

Published

Execute multiple Blockspring functions in parallel.

Downloads

3

Readme

Parallelax

Leverage async to execute multiple Blockspring functions in parallel. A more general version of this library can be accessed at https://api.blockspring.com/SaiWebApps/parallelax.


Installation via NPM

npm install parallelax

Usage

Let us say that the user wants to execute 2+ Blockspring APIs parallely because she wants to amalgamate specific information from each API into a single record/object in some database.

Now, say that the Blockspring APIs in question are:

  • https://open.blockspring.com/SaiWebApps/stock-parser
  • https://open.blockspring.com/SaiWebApps/synonyms-crawler

To execute these 2 APIs in parallel and get back all of their results in 1 go:

// API Key can optionally be specified as a constructor argument. Sign up for a Blockspring account to get an API key.
var blockList = require("parallelax");

// Add input API blocks to BlockList.
// First arg is API name, and second is inputs to the API.
blockList.addBlock("synonyms-crawler", { "word": "belie", "max_degrees_of_separation": 1 });
blockList.addBlock("stock-parser", { "symbols": "FB" });

// Execute in parallel, and handle outputs.
blockList.executeInParallel(function(allResults) {
  console.log(allResults);
});

The output of the above code will be organized as follows:

{
    "synonyms-crawler": {
        "0": [
            "belie"
        ],
        "1": [
            "pervert",
            "gloss over",
            "disguise",
            "miscolor",
            ...
        ]
    },

    "stock-parser": {
        "stock_info": {
            "FB": {
                "YearLow": "85.72",
                "DividendShare": null,
                "PricePaid": null,
                "DaysLow": "125.10",
                "EPSEstimateNextQuarter": "1.24",
                "EarningsShare": "2.09",
                "TickerTrend": null,
                "DaysRange": "125.10 - 126.22",
                "YearHigh": "128.33",
                "EBITDA": "11.08B",
                "ErrorIndicationreturnedforsymbolchangedinvalid": null,
                "LastTradeDate": "8/31/2016",
                "Bid": "126.30",
                "PriceSales": "16.31",
                ...
            }
        }
    }
}

In other words, the output will be a JSON object, where the key is the Blockspring API name, and the value is that API's output for the supplied API inputs. If the user executes the same API multiple times, then the value corresponding to the API will be a list consisting of the outputs for each run/execution.

You can find another example in test/test.js.


Use Case

One use case for this API is to create a JSON object with a word, its synonyms, and the first image from Google Images for that word, and then to save this object to a database. Without this library, we would otherwise have to invoke the necessary Blockspring APIs individually, in which case we would either have to:,

  • Coordinate their execution ourselves so that we can save all of the info to the database in 1 go. (nasty & complicated in NodeJS)
  • Or save bits and pieces to the database at a time, which would result in multiple writes. (expensive)

This library solves the aforementioned problem as our callback to executeInParallel can simply extract the necessary info, assemble the JSON object, and save it to the database.


Dependencies

  • https://github.com/caolan/async
  • https://github.com/blockspring/blockspring.js

Check package.json.


My Versioning Methodology

1.0.0 1 (Major Number) = Update upon making a breaking change. 0 (Minor Number) = Update after adding new features, fixing bugs, or making other "non-breaking" changes. 0 (Patch Number) = Update after changing documentation or tests.