This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.env.UV_THREADPOOL_SIZE = 5; | |
const crypto = require('crypto'); | |
const start = Date.now(); | |
crypto.pbkdf2( 'a', 'b', 100000, 512, 'sha512', () => { | |
console.log( '1:', Date.now() - start ); | |
}); | |
crypto.pbkdf2( 'a', 'b', 100000, 512, 'sha512', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https'); | |
const start = Date.now(); | |
https.request('https://www.google.com', res => { | |
res.on('data', () => {}); | |
res.on('end', () => { | |
console.log(Date.now() - start); | |
}); | |
}).end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aws = require('aws-sdk'); | |
const multer = require('multer'); | |
const multerS3 = require('multer-s3'); | |
const keys = require('../secret/keys'); | |
const awsS3 = new aws.S3({ | |
accessKeyId: keys.aws.AWSAccessKeyId, | |
secretAccessKey: keys.aws.AWSSecretKey | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// views/admin/dashbard.ejs | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
<link rel="stylesheet" href="/css/dashboard.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//index.js | |
setTimeout(function(){ | |
console.log("SETTIMEOUT"); | |
}, 0); | |
setImmediate(function(){ | |
console.log("SETIMMEDIATE"); | |
}); | |
// output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//index.js | |
setTimeout(function(){ | |
console.log("Timeout"); | |
}, 1000); | |
setImmediate(function(){ | |
console.log("Immedate"); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//index.js | |
setTimeout(function(){ | |
console.log("Timeout"); | |
}, 0); | |
setImmediate(function(){ | |
console.log("Immediate"); | |
}); | |
// output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
function addNextTickRecurs(count) { | |
let self = this; | |
if (self.id === undefined) { | |
self.id = 0; | |
} | |
if (self.id === count) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const start = process.hrtime(); | |
setTimeout(() => { | |
const end = process.hrtime(start); | |
console.log(`timeout callback executed after ${end[0]}s and ${end[1]/Math.pow(10,9)}ms`); | |
}, 1000); | |
// output | |
// timeout callback executed after 1s and 0.001875707ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
fs.readFile('hello.txt', () => { | |
setTimeout(() => { | |
console.log('timeout') | |
}, 0); | |
setImmediate(() => { | |
console.log('immediate') | |
}); | |
}); |