summaryrefslogtreecommitdiff
path: root/together/node_modules/dezalgo/README.md
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-08-21 17:31:56 +0200
committerMinteck <contact@minteck.org>2022-08-21 17:31:56 +0200
commita2df9a69dcc14cb70118cda2ded499055e7ee358 (patch)
tree6dd283e4e9452d38bce81ddaaae49b5335755842 /together/node_modules/dezalgo/README.md
parent84dd0735820b16b60f600284d35183d76547a71f (diff)
downloadpluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz
pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2
pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip
m. update
Diffstat (limited to 'together/node_modules/dezalgo/README.md')
-rw-r--r--together/node_modules/dezalgo/README.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/together/node_modules/dezalgo/README.md b/together/node_modules/dezalgo/README.md
new file mode 100644
index 0000000..bdfc8ba
--- /dev/null
+++ b/together/node_modules/dezalgo/README.md
@@ -0,0 +1,29 @@
+# dezalgo
+
+Contain async insanity so that the dark pony lord doesn't eat souls
+
+See [this blog
+post](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony).
+
+## USAGE
+
+Pass a callback to `dezalgo` and it will ensure that it is *always*
+called in a future tick, and never in this tick.
+
+```javascript
+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)
+ })
+}
+```