setTimeout(function, delay)
docs: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
I've always thought that setTimeout
would call the function when the delay was up,
maybe a little later,
but never before.
'use strict' | |
const asyncHooks = require('async_hooks') | |
const asyncIds = new Set() | |
const asyncHook = asyncHooks.createHook({ | |
init (asyncId, type, triggerAsyncId, resource) { | |
const eid = asyncHooks.executionAsyncId() | |
process._rawDebug(`${type}(${asyncId}): trigger: ${triggerAsyncId} execution: ${eid}`, resource) |
watson% traceroute google.com | |
traceroute: Warning: google.com has multiple addresses; using 173.194.70.139 | |
traceroute to google.com (173.194.70.139), 64 hops max, 52 byte packets | |
1 192.168.33.1 (192.168.33.1) 1.203 ms 1.333 ms 0.859 ms | |
2 * * * | |
3 * * * | |
4 * * * | |
5 192.168.14.106 (192.168.14.106) 3277.827 ms 2498.515 ms 1261.000 ms | |
6 192.168.14.102 (192.168.14.102) 833.789 ms 1879.912 ms 3759.086 ms | |
7 2.239.214.82.in-addr.arpa (82.214.239.2) 2454.781 ms 1959.662 ms 1167.737 ms |
'use strict' | |
const { Writable } = require('readable-stream') | |
let stream | |
console.log('write') | |
stream = getStream() | |
stream.write('foo') |
'use strict' | |
const zlib = require('zlib') | |
const http = require('http') | |
const body = zlib.gzipSync(JSON.stringify({ | |
errors: { | |
ERR_QUEUE_FULL: { | |
count: 23, | |
message: 'queue is full' |
'use strict' | |
const http = require('http') | |
const server = http.createServer(function (req, res) { | |
console.log(req.method, req.url) | |
res.socket.end() // Half-close the socket by sending FIN packet | |
}) | |
server.listen(8200, function () { |
var request = require('request') | |
var JSONStream = require('JSONStream') | |
var opts = { | |
url: 'https://api.github.com/users/watson/repos', | |
headers: {'User-Agent': 'request'} | |
} | |
request(opts) | |
.pipe(JSONStream.parse('*')) |
setTimeout(function, delay)
docs: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
I've always thought that setTimeout
would call the function when the delay was up,
maybe a little later,
but never before.
var assert = require('assert') | |
var events = require('events') | |
assert(events.usingDomains) |
Write-Host "Downloading Redis..." -ForegroundColor Cyan | |
$redisRoot = "$env:SYSTEMDRIVE\Redis" | |
$zipPath = "$($env:USERPROFILE)\redis-2.8.19.zip" | |
(New-Object Net.WebClient).DownloadFile('https://github.com/MSOpenTech/redis/releases/download/win-2.8.19/redis-2.8.19.zip', $zipPath) | |
7z x $zipPath -y -o"$redisRoot" | Out-Null | |
del $zipPath | |
Write-Host "Installing Redis as a Windows service..." | |
& "$redisRoot\redis-server.exe" --service-install |