@sapphire/utilities
References
filterNullish
Renames and re-exports filterNullAndUndefined
filterNullishAndEmpty
Renames and re-exports filterNullAndUndefinedAndEmpty
filterNullishAndZero
Renames and re-exports filterNullAndUndefinedAndZero
filterNullishOrEmpty
Renames and re-exports filterNullAndUndefinedAndEmpty
filterNullishOrZero
Renames and re-exports filterNullAndUndefinedAndZero
isNullish
Renames and re-exports isNullOrUndefined
isNullishOrEmpty
Renames and re-exports isNullOrUndefinedOrEmpty
isNullishOrZero
Renames and re-exports isNullOrUndefinedOrZero
kebabToCamelCase
Renames and re-exports snakeToCamelCase
parseURL
Renames and re-exports tryParseURL
tryParse
Renames and re-exports tryParseJSON
Interfaces
Interface | Description |
---|---|
DebounceSettings | lodash (Custom Build) https://lodash.com/ Build: lodash modularize exports="npm" -o ./ Copyright jQuery Foundation and other contributors https://jquery.org/ Released under MIT license https://lodash.com/license Based on Underscore.js 1.8.3 http://underscorejs.org/LICENSE Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors |
DebouncedFunc | Call the original function, but applying the debounce rules. |
GetDeepObjectKeysOptions | The options for getDeepObjectKeys |
PollOptions | The options for the poll function |
SleepOptions | - |
SyncPollOptions | The options for the pollSync function |
Thenable | - |
ToTitleCaseOptions | The options to use when converting a string to title case |
Type Aliases
Type alias | Description |
---|---|
AbstractConstructor | A generic abstract constructor without parameters |
AbstractCtor | A generic abstract constructor with parameters |
AnyObject | An object that can have any structure, this is an alternative to NonNullObject for situations where that leads to unexpected type resolutions. |
AnyReadonlyArray | A readonly array of any values. |
ArgumentTypes | - |
ArrayElementType | Gets a union type of all the keys that are in an array. |
Awaitable | ReturnType for a function that can return either a value or a Promise with that value |
Builtin | - |
Constructor | A generic constructor without parameters |
Ctor | A generic constructor with parameters |
DeepPartial | - |
DeepReadonly | - |
DeepRequired | - |
FirstArgument | Gets the first argument of any given function |
Mutable | Transforms a readonly type to be mutable |
NonNullObject | An object that is non nullable, to bypass TypeScript not easily working with Record<PropertyKey, unknown> in various instances. |
NonNullableProperties | Similar to the built in NonNullable, but properly removes null from all keys in the class or interface This does not recurse deeply, for that use DeepRequired |
Nullish | Type union for the full 2 billion dollar mistake in the JavaScript ecosystem |
PartialRequired | - |
PickByValue | Gets all the keys (as a string union) from a type T that match value V |
Primitive | - |
RequiredExcept | - |
SecondArgument | Gets the second argument of any given function |
StrictRequired | Transforms every key in an object to be strictly required, essentially removing undefined and null from the type. |
ThrottleFn | - |
Variables
Variable | Description |
---|---|
toTitleCaseDiscordJsVariants | The variants that will not strictly follow the toTitleCase algorithm and will instead return the value matched with the key. |
Functions
Function | Description |
---|---|
arrayStrictEquals | Compare if both arrays are strictly equal |
capitalizeFirstLetter | Transforms the first letter to a capital then adds all the rest after it |
cast | Casts any value to T |
chunk | Splits up an array into chunks |
classExtends | Checks whether or not the value class extends the base class. |
codeBlock | Wraps the content inside a codeblock with no language |
cutText | - |
debounce | Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a cancel method to cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to the debounced function return the result of the last func invocation. |
deepClone | Deep clone an object |
filterNullAndUndefined | Checks whether a value is not null nor undefined . This can be used in Array.filter to remove null and undefined from the array type |
filterNullAndUndefinedAndEmpty | Checks whether a value is not null nor undefined nor '' (empty string). This can be used in Array.filter to remove null , undefined from the array type |
filterNullAndUndefinedAndZero | Checks whether a value is not null nor undefined nor 0 . This can be used in Array.filter to remove null , undefined from the array type |
getDeepObjectKeys | Flattens an object to a list of its keys, traversing deeply into nested objects and arrays of objects. |
hasAtLeastOneKeyInMap | Checks whether any of the keys are in the map |
hasAtLeastOneKeyInObject | Checks whether any of the keys are in the obj |
inlineCodeBlock | Wraps text in a markdown inline codeblock |
isClass | Verify if the input is a class constructor. |
isFunction | Verify if the input is a function. |
isNullOrUndefined | Checks whether or not a value is null or undefined |
isNullOrUndefinedOrEmpty | Checks whether or not a value is null , undefined or '' , [] |
isNullOrUndefinedOrZero | Checks whether or not a value is null , undefined or 0 |
isNumber | Verify if a number is a finite number. |
isObject | Verify if the input is an object literal (or class). |
isPrimitive | Check whether a value is a primitive |
isThenable | Verify if an object is a promise. |
lazy | Lazily creates a constant or load a module and caches it internally |
makeObject | Turn a dotted path into a json object. |
mergeDefault | Deep merges 2 objects. Properties from the second parameter are applied to the first. |
mergeObjects | Merges two objects |
noop | - |
objectEntries | - |
objectKeys | - |
objectToTuples | Convert an object to a tuple |
objectValues | - |
omitKeysFromObject | Clones the source object using deepClone then deletes the specified keys with Reflect.deleteProperty |
partition | Partitions array into a tuple of two arrays, where one array contains all elements that satisfies predicate , and the other contains all elements that do not satisfy predicate . |
pickRandom | Picks a random element from an array |
poll | Executes a function cb and validates the result with function cbCondition, and repeats this until cbCondition returns true or the timeout is reached. |
pollSync | Executes a function cb and validates the result with function cbCondition, and repeats this until cbCondition returns true or the timeout is reached. |
range | Get an array of numbers with the selected range |
regExpEsc | Cleans a string from regex injection |
retry | Asynchronously calls the callback function until it either succeeds or it runs out of retries. For a synchronous variant, see retrySync. |
retrySync | Synchronously calls the callback function until it either succeeds or it runs out of retries. For an asynchronous variant, see retry. |
roundNumber | Properly rounds up or down a number. Also supports strings using an exponent to indicate large or small numbers. |
sleep | Sleeps for the specified number of milliseconds. For a synchronous variant, see sleepSync. |
sleepSync | Sleeps for the specified number of milliseconds synchronously. We should probably note that unlike sleep (which uses CPU tick times), sleepSync uses wall clock times, so the precision is near-absolute by comparison. That, and that synchronous means that nothing else in the thread will run for the length of the timer. |
snakeToCamelCase | Transforms text from snAkE_cASE to camelCase . |
splitText | - |
throttle | Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled function comes with a flush method to reset the last time the throttled function was invoked. |
toTitleCase | Converts a string to Title Case |
tryParseJSON | Try parse a stringified JSON string. |
tryParseURL | Tries parse a string to a URL object |