New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

callback-ops

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback-ops

Callback wrappers

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

Callback ops

Just a few callback wrappers to abstract out common result or error wrangling code.

Installation

npm install callback-ops

Usage

var co = require('callback-ops');

return(results..., callback)

Alias: result.

Overwrites return value(s) passed to a callback. Errors are propagated unchanged.

function insertLinks(links, callback) {
    // Create query
    var query = db.insert('link', links);
    // Run query, but ignore its result, pass number or links inserted instead
    query.run(co.return(links.length, callback));
}

Can be used to completely strip results:

// Run query, but don't pass it result to callback
query.run(co.return(callback));

select(keys..., callback)

Select part of result passed to callback. keys could be strings for object properties or numbers for array indexes.

// Pass func2 result to callback
async.serial([func1, func2, func3], co.select(1, callback))

// Select .rows[0].name from result before passing to callback
client.query('select name from user', [],
    co.select('rows', 0, 'name', callback))

fallback(defaultValue, callback)

Passes default to callback instead of error.

Keywords

FAQs

Package last updated on 20 Oct 2014

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