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

butler

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

butler

NodeJS Butler

  • 0.0.3
  • Source
  • npm
  • Socket score

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

Node Butler

This module helps when you need to call several asynchronous calls one after each other.

Install

npm install butler

Example

// fs.readFile() implementation (check examples/fs.js)
var fs = require("fs"),
    Butler = require("./../lib/butler").Butler,
    Alfred = new Butler();

// fs.readFile()
function readFileAsync(filename, cb) {
  Alfred
    .add(fs.open, filename, "r")
    .store("fd") // store return value from previous call as 'fd'
    .add(fs.fstat)
    .wait(function (err) {
      if (err) { cb(err); return false; }

      var size = this.params.get(0).size;
      this.params.set(this.storage.fd, new Buffer(size), 0, size, 0); // remember 'fd' ?
    })
    .add(fs.read)
    .wait(function (err) {
      if (err) { cb(err); return false; }

      this.storage.data = this.params.get(1);
      this.params.set(this.storage.fd);
    })
    .add(fs.close)
    .wait(function (err) {
      if (err) { cb(err); return false; }
      cb(null, this.storage.data);
    });
}

readFileAsync(__dirname + "/fs.js", function (err, data) {
  if (err) {
    return console.log("error reading file", err);
  }
  console.log("FILE\n-------------------------");
  console.log(data);
  console.log("-------------------------");
});

Keywords

FAQs

Package last updated on 11 Aug 2011

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