mojipiperun

0.3.1 • Public • Published

mojipiperun

This library exports only two functions that were inspired by [MojiScript][ms]:

  • pipeAsync to create an async pipe of functions
  • run to actually execute such a pipe

install

$ npm install mojipiperun

run

As in MojiScript, the run function accepts an object with 3 possible properties:

  • state : the initial state
  • dependencies : an object to inject as dependency to the main pipe
  • main : the main pipe to run

It returns a Promise.

pipeAsync

The pipeAsync function takes an array of values, which may be functions. It returns a function that can be composed with other pipes and can be passed as main to run.

When executed, that function receives a value (state passed to run), and passes it down to the first function (or value) in the pipe. The returned value of that function (which is the value itself if it isn't a function, or the function's return value, or the Promise's resolved value if the function returns a promise) is then passed to the next function, until the last function executes and its returned value is that of run.

An error/thrown exception/rejected promise short-circuits the pipe and results in run returning a rejected promise.

license

MIT, like MojiScript's license.

Readme

Keywords

none

Package Sidebar

Install

npm i mojipiperun

Weekly Downloads

2

Version

0.3.1

License

MIT

Unpacked Size

13.1 kB

Total Files

6

Last publish

Collaborators

  • puerkitobio