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

kgo

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kgo

Flow control the super easy way

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-6.85%
Maintainers
1
Weekly downloads
 
Created
Source

kgo

A stupidly easy flow control function.

Why

flow contol should be seamless, you should be able to say what you want done, and say kgo.

Usage

kgo is black magic, use it with caution.

require kgo:

var kgo = require('./kgo');

use kgo:

note: functions MUST have function names!

another note: functions MUST have argument names that match the names of other functions!

and another note: functions MUST define a callback as the last argument.

kgo('things', function(cb){

    //Something async
    setTimeout(function(){
        cb(null, 1);
    }, 100);

})('stuff', function(cb){

    //Something async
    setTimeout(function(){
        cb(null, 2);
    }, 100);

})('whatsits', function(things, stuff, cb){

    //Something async
    setTimeout(function(){
        cb(null, things + stuff);
    }, 100);

})('dooby', function(things, cb){

    //Something async
    setTimeout(function(){
        cb(null, things/2);
    }, 100);

})(function(whatsits, dooby, cb){

    //Done
    console.log(whatsits, dooby);

});

The above will log 3, 0.5;

HOW!??!?!

kgo toStrings the functions, figures out their parameters, stirs over high heat, adds eye of newt and then profit.

USE WITH CAUTION!

Errors

Yeah them annoying things.

You can assign error handlers to your functions by name, if you want to.

kgo('things', function(cb){

    //Something async
    setTimeout(function(){
        cb(null, 1);
    }, 100);

})('stuff', function(cb){

    //Something async
    setTimeout(function(){
        cb(new Error('Whoops'));
    }, 100);

})(function(things, stuff, cb){

    //Something async
    setTimeout(function(){
        console.log(things, stuff);
        cb()
    }, 100);

}).errors({
    'stuff':function(error){
        // will recieve the Whoops error.
    }
});

FAQs

Package last updated on 19 Jan 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