0.3.0 • Published 6 years ago

@hugov/step v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@hugov/step

ConstructorInstanceGotchaLicense

Constructor

Step(Function): Step If the Function is binary, it is considered to be an async CPS function with the callback as a second parameter Works as a constructor (step = new Step()) and as a factory (step = Step())

Step.all(Array<Step>, [Function]) If the Function is binary, it is considered to be an async CPS function with the callback as a second parameter

Step.last(Function|Step) If the Function is binary, it is considered to be an async CPS function with the callback as a second parameter Creates a step wrapper that debounces the inner step to only keep the latest outcome

Step.pick( v => i ) Creates a step that switches to a single dependent depending on the input value

Instances

step.push(v): this Pushes a value to the step and it's dependents

step.pipe(Function|Step): Step If the Function is binary, it is considered to be an async CPS function with the callback as a second parameter Creates and returns a dependent step

step.from(Function|Step): Step If the Function is binary, it is considered to be an async CPS function with the callback as a second parameter Creates and return a predecessor step

Factories

require('@hugov/step/from-async)(nodeAsyncFunction): Step Creates a new step from a node-style async function (val, (err,res) => void) => void

require('@hugov/step/from-port)(MessagePort): Step Creates a new step from an object having postMessage and onmessage methods

require('@hugov/step/from-xhr)(): Step Creates a new step from a remote GET request. The steps accepts an url and will fire a json object as a response

Gotcha

  • no error handling. On error, throw.
  • the async CPS style functions (value, v=>void)=>void are different from node style callbacks (err, res)=>void

License

MIT © Hugo Villeneuve

0.3.0

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago