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

polyflow

v0.0.2

Published

A flow-based programming framework

Downloads

11

Readme

PolyFlow

PolyFlow is a flow-based programming framework. It is made to be highly asynchronous.

Nano

A nano is an elementary component of a graph.

var param = {
    inputs: ['in1', 'in2'],
	outputs: {
		out: ['out1'], /* standard output */
        other: ['out1', 'out2']
		err: ['error']
	}
}

polyflow.nano('nano1', param, function ($inputs, $outputs) {
    if (/* condition */) {
	    $outputs.out($inputs.in1 + $inputs.in2);
    } else if (/* condition */) {
        $outputs.other($inputs.in1, $inputs.in2)
    } else {
        $outputs.err(new Error('error'));
    }
});

Graph

A graph defines a workflow.

var graph = polyflow.graph('graph');

graph.begin()
    .then('nano1', 'A') /* named node */
    .then('nano2')
    .then('nano3')
    .label('B')
    .then('nano6');
    /* ... */
    
graph.select('A').on('other')
    .then('nano4')
    .then('nano5')
    .then('B');
    
graph.select('A').on('err')
    .then(function ($flow) {
        console.log($flow.error);
    });
    
var network = graph.compile();
network.digest({
    in1: 1,
    in2: 2
});

Binder

Inputs and/or outputs of nano could be bound to something in the flow or to a constant value. For example:

var graph = polyflow.graph('graph');

graph.begin()
    .then('nano1', 'A') /* named node */
    .then('nano2')
    /* ... */
    
graph.select('A')
    .bind.input('in1').to('obj1')
    .bind.input('in2').to([1, 2, 3])
    .bind.output('out', 'out1').to('obj1.field')
    /* ... */
    
var network = graph.compile();
network.digest({
    obj1: 1
});

Shortcut

A nano could defined a shortcut. Shortcuts are used to define a graph. For example:

var graph = polyflow.graph('graph');

graph.begin()
    .set('values', [])
    .forEach([1, 2, 3]).as('value')
    .append('value').to('values')
    .end()
    .then(function ($flow) {
        console.log($flow.values);
    });
    
var network = graph.compile();
network.digest();

Service

PolyFlow has a dependency injection system which allows nano and/or service to depend on other services.

polyflow.service('service1', function () {
    return /* the service */;
});

polyflow.service('service2', function (service1) {
    return /* the service */;
});

polyflow.nano('nano1', param, function ($inputs, service2) {
    /* ... */
});