Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

breeze

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

breeze

Functional async flow control library

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
131
increased by13.91%
Maintainers
2
Weekly downloads
 
Created
Source

Breeze

Functional async flow control library. Turn your asynchronous code into bite-sized synchronous looking functions.

version License Downloads Dependencies

Install

  • Download the latest package
  • NPM: npm install breeze

Usage

Node.js / Browserify

var breeze = require('breeze')

API

  • breeze(next) - Initialize breeze flow system, supports initial .then method.
  • .pass(value) - Introduce new value into flow system, argument is appended to system arguments passed through next.
  • .when(check, next) - When check is truthy, add next to the stack
  • .maybe(check, next) - When check is truthy, add next to the stack, sugar for breeze.when
  • .some(check, next) - When check is truthy and no other some or none has ran, add to the stack
  • .none(next) - Whenever no some have ran, add callback to the stack
  • .then(next) - Add callback to stack
  • .each(iterables, iteratee, next) - Iterate over an object / array and invoke a method for each entry. iterables is not a reference therefore, you must properly store iterables outside of the flow if you plan to update or modify the object.
  • .catch(next) - Any error caught will terminate stack and be sent here
  • .deferred() - Returns a deferred promise system, allowing for a passable then / catch.
  • .reset() - Reset current system

Next

The next method passed through breeze has a very small api. It accepts two variants of usage, normal node style err, arguments..., and promise, arguments....

When a truthy err is passed the system will halt (no other actions will be taken) and .catch will be triggered.

Promises

When a promise is passed the system will attach to either the then / catch methods, or the .then(then, catch) method style depending on the promise type passed. Whenever the then is invoked, any arguments passed along with the passed promise are placed at the front of the arguments array, and the success arguments will be last.

This allows you to chain multiple promises while still passing values down the chain.

next(promise, arguments...)
Skipping Steps

When you pass the string skip as the first argument in the next method, the next step in the sequence will be skipped completely.

You can skip multiple steps by providing a number as the second argument to next equalling the number of steps you wish to skip. Defaults to 1.

next('skip', 1 /* optional; number of steps to skip */)

Examples

  • basic - Bare-bones example (breeze, then, catch)
  • promises - Returning and using promises within breeze (then, next(promise))
  • each - Breeze array iteration (then, pass, each, catch)
  • when - Conditional flows (then, when)

Check out the examples directory for more in-depth examples and tutorials of how to use breeze.

License

Licensed under The MIT License.

Keywords

FAQs

Package last updated on 12 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc