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 getData = (selectColumns = []) => { | |
let subset = object2 | |
if (columnsOnly.length !== 0) { | |
subset = object2.map(obj => | |
Object.fromEntries( | |
columnsOnly | |
.filter(key => key in obj) | |
.map(key => [key, obj[key]]) | |
) | |
) |
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
/** | |
* Emulates python's range() built-in. Returns an array of integers, counting | |
* up (or down) from start to end. Note that the range returned is up to, but | |
* NOT INCLUDING, end. | |
*. | |
* @param start integer from which to start counting. If the end parameter is | |
* not provided, this value is considered the end and start will | |
* be zero. | |
* @param end integer to which to count. If omitted, the function will count | |
* up from zero to the value of the start parameter. Note that |
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 elementGetStyle(element, style) { | |
var value = element.style[style]; | |
if (!value) { | |
if (document.defaultView && document.defaultView.getComputedStyle) { | |
var css = document.defaultView.getComputedStyle(element, null); | |
value = css ? css.getPropertyValue(style) : null; | |
} else if (element.currentStyle) { | |
value = element.currentStyle[style]; | |
} | |
} |
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 elementSetStyle(element, style) { | |
for (var name in style) { | |
var value = style[name]; | |
if (value == null) value = ""; | |
element.style[name] = value; | |
} | |
} |
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 isArray(x) { | |
return ((typeof x) == "object") && (x["length"] != null); | |
} |
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 _group_by(list, key) { | |
const groupBy = (array, key) => { | |
// Return the end result | |
return array.reduce((result, currentValue) => { | |
// If an array already present for key, push it to the array. Else create an array and push the object | |
(result[currentValue[key]] = result[currentValue[key]] || []).push( | |
currentValue | |
); | |
// Return the current iteration `result` value, this will be taken as next iteration `result` value and accumulate | |
return result; |