Socket
Socket
Sign inDemoInstall

procedure

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

procedure

Simple JS async develpoment, easy error handling, chained results, declarative way.


Version published
Maintainers
1
Created
Source

Procedure

Simple JS async development.

function fileLoader(path,done){                        // File loader simulation.
  console.log("Opening file:'"+path+"'...");
  if(path==='./secundary2.key'){
    //throw new Error("Ops!");                         // Error simulation
  }
  done.result({file:path});                            // Finalize task & return result
}
var shared = {};                                       // Shared closure
var procedure = new Procedure();                       // Create procedure
procedure
.add("Load primary",fileLoader,'./primary.key')        // Add new task
.add("Load secundary",fileLoader,'./secundary.key')    // Add new task
.add("Load shared",fileLoader,'./shared.key')          // Add new task
.race()                                                // Resolve tasks in race mode
.add(function(files,done){                             // Add new task
    shared.files1 = files;
    console.log(shared);
    done();                                            // Finalize task
})
.queue()                                               // Resolve tasks in queue mode
.add("Load primary",fileLoader,'./primary2.key')       // Add new task
.add("Load secundary",fileLoader,'./secundary2.key')   // Add new task
.add("Load shared",fileLoader,'./shared2.key')         // Add new task
.race()                                                // Resolve tasks in race mode
.add(function(files,done){                             // Add new task
    shared.files2 = files;
    console.log(shared);
    done.result(shared);                                 // Finalize task & return result
})
.launch(function(errors){                              // Procedure controller.
    if(errors){                                        // Array of Errors || undefined
        console.log("END[ERROR]",arguments);
    } else {
        console.log("END[OK]",arguments);
    }
})
;

Keywords

FAQs

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