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

beckon

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beckon

beckon ======

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

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

beckon

Callback based program flow with built in context. Use like a callback, but with the power of flow like programming (similar to promises).

Usage

var Beckon = require('beckon');

var callback = Beckon(function (arg) {
  this.arg = arg;
  setTimeout(this.next, 0);
});

callback.next(function () {
  console.log(this.arg);
});

callback('foo');

// => 'foo'

Methods

Beckon(fn)

Creates the callback flow, exposing callback.next which can be used to define the functions in the flow.

callback.next([name], fn)

Adds provided function to the callbacks prototype. Pass in an optional name that can be used to call the function directly bypassing any functions between the named function and the one calling it.

var Beckon = require('beckon');

var fileName = 'file.json';

var data = {
  foo: 'bar'
};

var callback = Beckon(function (err, file) {
  if (err || !file) {
    return createFile(fileName, data, this.done);
  }

  validateFile(file, data, this.next);
});

// Not called if the file does not exist, goes to done instead
callback.next(function (err) {
  if (err) {
    return updateFile(file, data, this.next);
  }

  this.next();
});

callback.next('done', function () {
  console.log('File updated');
});

openFile(file, callback);

callback([args])

Starts the callback flow, by first calling the initial function passed into Beckon, and flowing through as this.next or this.functionName is called.

this.next([arguments])

Is used to call the next function in the callback flow, even named functions are included in the flow.

FAQs

Package last updated on 09 Mar 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