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
// Visitor Pattern | |
// Some existing raw data to be altered | |
const cars = [ | |
["Ford Escort", 10000, 50], | |
["Fiat Panda", 20000, 42], | |
["VW Polo", 25000, 59], | |
["BMW 320", 100000, 10], | |
["Dodge Viper", 200000, 3], | |
["Honda Civic", 21000, 33] | |
]; |
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
// Simple react profiling code to wrap components into react profiler | |
// Event timings are shown via a console statement of the profiler's callback | |
// Below the list of the documented arguments passed to the callback as shown in React docs | |
// ---------- | |
// id - the "id" prop of the Profiler tree that has just committed | |
// phase - either "mount" (if the tree just mounted) or "update" (if it re-rendered) | |
// actualDuration - time spent rendering the committed update | |
// baseDuration - estimated time to render the entire subtree without memoization | |
// startTime - when React began rendering this update | |
// commitTime - when React committed this update |
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
/* specify an array of strings with parameters and a matching pattern for the template used */ | |
/* Default is template literals style */ | |
const convertStrings = (stringsArray, matchPattern=/\$\{(\w+)\}/g) => { | |
let inp = stringsArray; | |
if( typeof inp === 'object' && !Array.isArray(inp) ) { | |
inp = [stringsArray]; | |
} else if(!Array.isArray(inp)) { | |
throw `Error: invalid data type on convertStrings got ${typeof stringsArray} instead of an Array or Object`; | |
} |