This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+15
View File
@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+29
View File
@@ -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)
})
}
```
+22
View File
@@ -0,0 +1,22 @@
var wrappy = require('wrappy')
module.exports = wrappy(dezalgo)
var asap = require('asap')
function dezalgo (cb) {
var sync = true
asap(function () {
sync = false
})
return function zalgoSafe() {
var args = arguments
var me = this
if (sync)
asap(function() {
cb.apply(me, args)
})
else
cb.apply(me, args)
}
}
+46
View File
@@ -0,0 +1,46 @@
{
"name": "dezalgo",
"version": "1.0.4",
"description": "Contain async insanity so that the dark pony lord doesn't eat souls",
"main": "dezalgo.js",
"files": [
"dezalgo.js"
],
"directories": {
"test": "test"
},
"dependencies": {
"asap": "^2.0.0",
"wrappy": "1"
},
"devDependencies": {
"tap": "^12.4.0"
},
"scripts": {
"test": "tap test/*.js"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/dezalgo"
},
"keywords": [
"async",
"zalgo",
"the dark pony",
"he comes",
"asynchrony of all holy and good",
"To invoke the hive mind representing chaos",
"Invoking the feeling of chaos. /Without order",
"The Nezperdian Hive Mind of Chaos, (zalgo………………)",
"He who waits beyond the wall",
"ZALGO",
"HE COMES",
"there used to be some funky unicode keywords here, but it broke the npm website on chrome, so they were removed, sorry"
],
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/dezalgo/issues"
},
"homepage": "https://github.com/npm/dezalgo"
}