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
module.exports = function (fn) { | |
return (req, res, next) => { | |
return fn(req, res).catch(next); | |
} | |
} |
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
function checkAnagram(str1, str2) { | |
if(str1.length != str2.length) { | |
return false; | |
} | |
let sorted1 = str1.split("").sort().join(); | |
let sorted2 = str2.split("").sort().join(); | |
return sorted1 == sorted2; | |
} |
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
{ | |
a: 2, | |
b: 2 | |
} |
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
function crunchTheNumbers() { | |
return Promise.all([getSensorAData(), getSensorBData(), getSensorCData()]).then((results) => { | |
console.log(results); | |
}) | |
} |
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
async function crunchTheNumbersAsync() { | |
let sensorAData = await getSensorAData(); | |
let sensorBData = await getSensorBData(); | |
let sensorCData = await getSensorCData(); | |
console.log(sensorAData, sensorBData, sensorCData); | |
} |
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
async function getSensorAData() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve("Sensor A Data"); | |
}, 2000); | |
}) | |
} | |
async function getSensorBData() { | |
return new Promise((resolve, reject) => { |
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
async function joinEvent(email, password, event) { | |
let user = await login(email, password); | |
let userInfo = await getUserInfo(user); | |
let success = await event.join(userInfo.id); | |
if (success) { | |
console.log("Joined!"); | |
} | |
else { | |
console.log("Not joined"); | |
} |
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
function joinEvent(email, password, event) { | |
login(email, password).then(user => { | |
return getUserInfo(user); | |
}).then(userInfo => { | |
return event.join(userInfo.id); | |
}).then((success) => { | |
if (success) { | |
console.log("Joined!"); | |
} | |
else { |
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
function joinEvent(email, password, event) { | |
login(email, password, function (user) { | |
getUserInfo(user, function (userInfo) { | |
event.join(userInfo.id, function (success) { | |
if (success) { | |
console.log("Joined!"); | |
} | |
else { | |
console.log("Not joined"); |
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
using System; | |
using System.Diagnostics; | |
namespace HttpClientPerformanceTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
SlowWay.RequestsCount = FastWay.RequestsCount = 30; |