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

if-async

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

if-async

async conditional execution for standalone or async.js use

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66K
increased by0.29%
Maintainers
1
Weekly downloads
 
Created
Source

if-async

async conditional execution for standalone or async.js use

Example 1: Using with Async.js

var async = require('async')
var ifAsync = require('if-async')

async.series([
    foo,
    ifAsync(predicate1).then(consequent1).else(else1),
    bar
])

function foo(callback) { ... }
function predicate1(callback) { fs.stat(... callback ...) }
function consequent1(callback) { ... }
function else1(callback) { ... }
function bar(callback) { ... }

Example 2: Standalone usage

var ifAsync = require('if-async')

var functor = ifAsync(predicate).then(consequent).else(elseClause)

functor(function(err) {
    console.log('done')
})

function predicate(callback) { fs.stat(... callback ...) }
function consequent(callback) { ... }
function elseClause(callback) { ... }

API Reference

Using fluent interface

var functor = ifAsync(predicate1).then(consequent1).elseIf(predicate2).then(consequent2).else(defaultConsequent)

Using function arguments

var functor = ifAsync(predicate1, consequent1, predicate2, consequent2, defaultConsequent)

Keywords

FAQs

Package last updated on 25 Jan 2015

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