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
/** | |
* Calculates the best tile grid based on the specified sizes, ratios and tile | |
* count. | |
*/ | |
function calcTileGrid(gridWidth, gridHeight, ratioWidth, ratioHeight, tileCount) { | |
// Get the aspect ratio for the grid. | |
const gridAspect = gridWidth / gridHeight; | |
// Keep adding columns or rows until you have enough for the amount of | |
// tiles needed. |
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
/** | |
* Takes an object representing a nested CSS stylesheet and returns the | |
* corresponding normal CSS (non-nested) string. | |
* @param {CSSObject} objCSS | |
* @returns {string} | |
*/ | |
function nestCSS(objCSS) { | |
/** | |
* @returns {string[]} | |
*/ |
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
var getRGBA = (() => { | |
const DIV = document.createElement('div'); | |
DIV.style.display = 'none!important'; | |
document.body.appendChild(DIV); | |
/** | |
* Takes a valid CSS color (eg. hsl(...), red, transparent, rgb(...)) and | |
* returns the corresponding rgba CSS color code while factoring the | |
* specified alpha. | |
* @param {string} cssColor |
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
/** | |
* Determines if the DOMContentLoaded event was fired and if so it immediately | |
* calls the `callback` function, otherwise it will be called when the | |
* DOMContentLoaded event is fired off. | |
* @param {(immediate: boolean) => any} callback | |
* A function that is called with one argument which indicates if it was | |
* called immediately. | |
* @returns {boolean} | |
* A boolean indicating if the callback function is run immediately. | |
*/ |
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
// Used by parseSOQLs() to parse SF queries by targetting strings, dash | |
// comments, block comments and semicolons. | |
static final Pattern RGX_SOQL_PARTS = Pattern.compile( | |
'(?s)\'(?:[^\\\\\']+|\\\\.)*\'|(--[^\\r\\n]*|/\\*.*?\\*/)|(\\s*;\\s*)' | |
); | |
/** | |
* Parses a SOQL query string into 0 or more SOQL query strings with all | |
* dash comments and block comments removed. | |
*/ |
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
/** | |
* Gets all of the records of the specified SObject type. | |
*/ | |
static SObject[] getAllRecords(String sobjectName, String soqlSuffix, Map<String,Object> bindMap) { | |
String soql = String.join(new String[]{ | |
'SELECT ' + String.join(new List<String>(Schema.getGlobalDescribe().get(sobjectName).getDescribe().fields.getMap().keySet()), ','), | |
'FROM ' + sobjectName | |
}, '\n'); | |
if (!String.isBlank(soqlSuffix)) soql += '\n' + soqlSuffix; | |
System.debug(soql); |
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
/** | |
* Translates the substrings of a string from one substring or RegExp match | |
* another substring. | |
* @param {string} string | |
* The string to be updated. | |
* @param {[string|RegExp,Function|string][]|{[key: string]: Function|string}} mappings | |
* If this is an object it will be interpreted as if it was passed in as | |
* `Object.entries()` so that it is an array of arrays. For each subarray the | |
* first value will be searched for within string and the replacement will be | |
* determined by the second value of the subarray. If the second value of the |
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 copySign(toUpdate, signedNum) { | |
return toUpdate + 1 / toUpdate < 0 === signedNum + 1 / signedNum < 0 | |
? toUpdate | |
: -toUpdate; | |
} |
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
/** | |
* @param {...(string|{source: (function|string), args?: any[], optional?: boolean, this?: (number|"this"), spreadThis?: boolean})} functions | |
* @returns {(input: any) => any} | |
*/ | |
function chain(...functions) { | |
return input => { | |
for (let isFunctions = [], i = 0, l = functions.length; i < l; i++) { | |
let fn = functions[i]; | |
const fnType = typeof fn; | |
if (fnType === 'string' || fnType === 'function') { |