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 timeoutPromise = timeout => | |
new Promise(resolve => setTimeout(resolve, timeout)); | |
describe('some tests on async await and promises all', function() { | |
it('should run async function in map loop', async function(done) { | |
// GIVEN | |
const mockFunction = jest.fn(); | |
const asyncFunctionWithAwait = async timeout => { | |
await timeoutPromise(timeout); |
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 Benchmark = require('benchmark'); | |
const axios = require('axios'); | |
const got = require('got'); | |
const superagent = require('superagent'); | |
const suite = new Benchmark.Suite(); | |
const targetUrl = 'http://httpbin.org/ip'; | |
suite |
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
// https://medium.freecodecamp.org/here-are-examples-of-everything-new-in-ecmascript-2016-2017-and-2018-d52fa3b5a70e | |
// EcmaScript2017 | |
// 1. Object.values() | |
const car = {BMW: 1, Audi: 2, Tesla: 3}; | |
console.log(Object.values(car)); // [1, 2, 3] | |
// ESMA2015 | |
console.log(Object.keys(car)); // ["BMW", "Audi", "Tesla"] |
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
// https://medium.freecodecamp.org/here-are-examples-of-everything-new-in-ecmascript-2016-2017-and-2018-d52fa3b5a70e | |
// 1. Array.prototype.includes | |
const trois = {id:3}; | |
const arr = [1, "deux", trois, NaN]; | |
console.log(arr.includes(1)); // true | |
console.log(arr.includes("deux")); // true | |
console.log(arr.includes(trois)); // true | |
console.log(arr.includes(NaN)); // true | |
console.log(arr.includes(4)); // false |