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
/** | |
* Sorts an array based on one or more criteria. | |
* | |
* @template T | |
* @param {T[]} array - The array to sort. | |
* @param {...(((item: T, index: number) => any) | ({getter: (item: T, index: number) => any, reverse: boolean}))} criterion - | |
* One or more sorting criteria. Each can be a getter function or an object with a getter and a reverse flag. | |
* @returns {T[]} A new array sorted based on the provided criteria. | |
*/ | |
function order(array, ...criterion) { |
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
/** | |
* @template T | |
* @param {T} value | |
* @param {boolean} [omitCircularRefs=false] | |
* @returns {T} | |
*/ | |
function copyJSON(value, omitCircularRefs = false) { | |
const ancestors = new WeakSet(); | |
function recurse(value) { |
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
public static String[] getFieldNames(String sobjectName) { | |
String[] fieldNames = new String[]{}; | |
Schema.SObjectType sobjectType = Schema.getGlobalDescribe().get(sobjectName); | |
if (sobjectType != null) { | |
Map<String, Schema.SObjectField> fieldsMap = sobjectType.getDescribe().fields.getMap(); | |
fieldNames.addAll(fieldsMap.keySet()); | |
} | |
return fieldNames; | |
} |
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
from typing import Optional | |
def split( | |
input_string: str, | |
sep: Optional[str] = None, | |
max_split: int = -1, | |
exclusions: Optional[list[str]] = None, | |
strip_items: bool = False | |
) -> list[str]: |
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
/** | |
* Converts a positive integer into an alphabetic representation, similar to | |
* ordered list lettering and Excel column naming. | |
* | |
* @param {number} int | |
* The positive integer to convert. Non-integers will be floored. | |
* @param {boolean} [returnLowerCase=false] | |
* If `true`, returns lowercase letters (e.g., 'a', 'b', ...). | |
* If `false`, returns uppercase letters (e.g., 'A', 'B', ...). | |
* @returns {string} |
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
/** | |
* Shows the file selector dialog and returns an array of the selected files. | |
* @param {?selectFile__Options=} options | |
* @returns {Promise<File[]>} | |
*/ | |
function selectFile(options) { | |
return new Promise(resolve => { | |
function onClose(e) { | |
resolve([...e.target.files]); | |
} |
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
/** | |
* @param {Record<"codeEditor"|"diffEditor",boolean|string>} defsToInclude | |
* @returns {Record<string,any>} | |
*/ | |
function getMonacoEditorCompDefs(defsToInclude) { | |
/** | |
* @param {(script?: HTMLScriptElement) => T} getter | |
* Function that will be called to get the result of a script running. This | |
* function will initially be called without any arguments to determine if | |
* the desired results already exist but if not the script tag will be added |
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
/** | |
* Finds the smallest multiple of `multipleOf` that is greater than or equal to | |
* `baseValue + offset`. | |
* | |
* @param {number} multipleOf | |
* The number whose multiple needs to be found. | |
* @param {number} baseValue | |
* The base value to start from. | |
* @param {number} [offset=0] | |
* The optional value to add to `baseValue` (default is 0). |
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
/** | |
* Destructures values from a `root` object based on one or more `nestedMaps` | |
* structures. | |
* @param {Object} root | |
* The root object or array containing the data to destructure. | |
* @param {...NestedMap} nestedMaps | |
* One or more nested mapping objects. Each key in the `NestedMap` is a | |
* string, and each value is either: | |
* - A string (which specifies the key in the result object), or | |
* - A `NestedMap` (which specifies further nested extraction). |
NewerOlder