This file contains hidden or 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 task(callback){ | |
//do task | |
if(failed){ | |
callback(error,null); | |
}else{ | |
callback(null,error); | |
} | |
} | |
//calling task |
This file contains hidden or 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 task(){ | |
return new Promise((resolve,reject)=>{ | |
//do task | |
if(failed){ | |
reject(err); | |
}else{ | |
resolve(data); | |
} | |
}); | |
} |
This file contains hidden or 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 task(){ | |
return new Promise((resolve,reject)=>{ | |
//do task | |
if(failed){ | |
reject(err); | |
}else{ | |
resolve(data); | |
} | |
}); | |
} |
This file contains hidden or 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
try { | |
let lambda = require(`/tmp/${projectName}/${event.lambda}`); | |
lambda.handler(event.testEvent, context, callback); | |
} catch (e) { | |
console.error(e); | |
callback("Runtime Error Occurred", null); | |
} |
This file contains hidden or 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
let obj = { | |
key1: "value1", | |
key2: "value2", | |
key3: "value3" | |
} | |
//convinient forEach | |
Object.entries(obj).forEach(entry => { | |
let key = entry[0]; | |
let value = entry[1]; |
This file contains hidden or 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
let obj = { | |
key1: "value1", | |
key2: "value2", | |
key3: "value3" | |
} | |
//convinient forEach | |
Object.values(obj).forEach(value => { | |
//use value here | |
}); |
This file contains hidden or 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
let obj = { | |
key1: "value1", | |
key2: "value2", | |
key3: "value3" | |
} | |
//convinient forEach | |
Object.keys(obj).forEach(key => { | |
let value = obj[key]; | |
//use key and value here |
This file contains hidden or 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
let obj = { | |
key1: "value1", | |
key2: "value2", | |
key3: "value3" | |
} | |
for (const key in obj) { | |
let value = obj[key]; | |
//optional check for properties from prototype chain |
This file contains hidden or 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
let obj = { | |
key1: "value1", | |
key2: "value2", | |
key3: "value3" | |
} | |
// convinient forEach | |
Object.getOwnPropertyNames(obj).forEach(key => { | |
let value = obj[key]; | |
//use key and value here |
This file contains hidden or 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 { PerformanceObserver, performance } = require('perf_hooks'); | |
let objectSize = 1000000; | |
let iterations = 100; | |
console.log("Starting performance test with %d object size and %d iterations", | |
objectSize, iterations); | |
let values = { | |
ENTRIES: 0, |