Skip to content

A bidirectional pipeline to chain data processing (similar to streams)

Notifications You must be signed in to change notification settings

darlanalves/pipeline

Repository files navigation

Processing Pipeline

Usage

let pipeline = new Pipeline();

let firstLayer = {
	request: function(input) {
		// cannot handle the request
		if (input.value !== 'foo') {
			input.next();
		}

		input.resolve('foo');
	},

	response: function(value) {
		return 'the ' + value;
	}
};

let secondLayer = {
	request: function(input) {
		// handle the request
		input.resolve('response');
	}
};

pipeline.run('request').then(function(result) {
	// result comes from the __second__ layer here
	// after being processed in the __first__ layer
	// having the value 'the response'
});

pipeline.run('foo').then(function(result) {
	// result now comes from the __first__ layer,
	// and 'the foo' is the returned value
});

About

A bidirectional pipeline to chain data processing (similar to streams)

Resources

Stars

Watchers

Forks

Packages

No packages published