Giter Site home page Giter Site logo

swint-pipe's Introduction

swint-pipe

Greenkeeper badge Pipeline logic flow for Swint

Warning: This is not the final draft yet, so do not use this until its official version is launched

Installation

$ npm install --save swint-pipe

Edge

  • Atomic task(can be synchronous or asynchronous) defined by function.
  • Usage
var edge1 = Pipe.Edge(function(system, input, output) {
		db.fetch({
			// ...
		}, function(err, res) {
			output(/* ... */);
		});
	}); // asynchronous task

var edge2 = Pipe.Edge(function(system, input) {
		return input * 2;
	}); // synchronous task

edge1.input(1); // When edge is the input of whole system, the data flows to the `input` of the main function.
edge2.output(system, 'edge2'); // When edge is the output of whole system, the data flows to `system.out()`.

System

  • Defines the data flow using connect() and branch().
  • Handles the error using error().
  • Usage
var system = Pipe.System({
		foo: 'bar' // Global variable throughout the system
	});

system.connect(edge1, edge2); // `edge2` will wait for `edge1` to be finished
system.connect(edge2, [edge3, edge4]); // `edge3` and `edge4` will be fired right after `edge2` is finished
system.connect([edge3, edge4], edge5); // `edge5` will wait for both `edge3` and `edge4` to be finished
system.connect(edge5, edge6, function(before, after) {
	after(before * 2);
}); // can morph the pipelined data on connection
system.branch(edge6, [edge7, edge8, edge9], function(before, after) {
	switch(before.type) {
		case 'A':
			after(0, 'type A'); // `'type A'` will be passed to `edge7`(`0`th edge on the array), while `edge8` and `edge9` outputs `undefined`.
			break;
		case 'B':
			after(1, 'type B');
			break;
		case 'C':
			after(2, 'type C');
			break;
	}
}); // can branch between edges

system.end(function(output) {
	// ...
}); // executed when the whole system is ended

var edge1 = Pipe.Edge(function(system, input, output) {
		db.fetch({
			// ...
		}, function(err, res) {
			if(err) {
				system.throw('MyError', 'something happened'); // throws error to the system
				return;
			}
			// ...
		});
	});
system.error(function(type, err) {
	// handling the thrown error
});

system.start(); // actually starts the system

swint-pipe's People

Contributors

kivol avatar chosh31 avatar yihyunjoon avatar greenkeeper[bot] avatar

Stargazers

BYUNGI avatar Joel Kuntz avatar Tyler Pachal avatar Ukjin Yang avatar Jiwon Choi avatar Jinwoo Oh avatar  avatar hogle avatar  avatar 강은석 (Ethan) avatar Myeongju Kim avatar ms_kim avatar kukibar avatar YoungTaek avatar Jun avatar Jungwoo Lee avatar Goonoo Kim avatar Yeongtaek Hong avatar MK CHOI avatar Eric Han avatar Chanshik Lim avatar Jeong-Hee Kang avatar

Watchers

James Cloos avatar KnowRe avatar  avatar

Forkers

soomtong

swint-pipe's Issues

can't install by npm

I am having a issue with npm install. Please see after run the command 'npm install swint-pipe'

C:\Users\user\callback>npm install swint-pipe
npm WARN install Couldn't install optional dependency: Unsupported
C:\Users\user
└── [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.