dezalgo
Contain async insanity so that the dark pony lord doesn't eat souls
Last updated 5 years ago by othiym23 .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dezalgo 
SYNC missed versions from official npm registry.

dezalgo

Contain async insanity so that the dark pony lord doesn't eat souls

See this blog post.

USAGE

Pass a callback to dezalgo and it will ensure that it is always called in a future tick, and never in this tick.

var dz = require('dezalgo')

var cache = {}
function maybeSync(arg, cb) {
  cb = dz(cb)

  // this will actually defer to nextTick
  if (cache[arg]) cb(null, cache[arg])

  fs.readFile(arg, function (er, data) {
    // since this is *already* defered, it will call immediately
    if (er) cb(er)
    cb(null, cache[arg] = data)
  })
}

Current Tags

  • 1.0.3                                ...           latest (5 years ago)

4 Versions

  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Downloads
Today 54
This Week 11,470
This Month 35,241
Last Day 2,024
Last Week 13,081
Last Month 55,154
Dependencies (2)
Dev Dependencies (1)
Dependents (147)

Copyright 2014 - 2016 © taobao.org |