strumenti v1.0.9
🛠️ Strumenti
An ever-growing collection of useful utility functions.
There's no need to reinvent the wheel…!
Functions
bool
Converts a given value to its Boolean equivalent
calculatePixelsFromPoints
Converts a given 'pt' value to 'px'
copyStringToClipboard
Adds the given input to the user's clipboard
delay
Delays the running of the next function
generateUUID
Generates RFC4122 guid
getCssValue
Finds the value of a given element's given css property
getFileExtension
Returns the file extension from the given path
getFilename
Returns the filename from the given path
getKeyByValue
Finds the first key matching the given value in a given object
hasTrailingSlash
Detects whether the given string ends in a /
character
htmlEntities
Replaces problematic characters with HTML Entity equivalents
humanReadableDate
Returns a date as a string value appropriate to the host environment's current locale
humanReadableDateTime
Returns a date and time as a string value appropriate to the host environment's current locale
humanReadableFilesize
Converts a given filesize in bytes to a human-readable string
humanReadableNumber
Converts a number to a string by using the current or specified locale
Params
value
: The number to convertlang
(Optional): The language to use when convertingcompact
(Optional): Whether to display short-form or long form
Examples
humanReadableNumber(12345.67) // 12,345.67
humanReadableNumber(12345.67, 'de') // 12.345,67
humanReadableNumber(12345.67, null, true) // 123K
indexOfMax
Provides the index of the largest number in an array
numberizeValue
Removes the units from a given string value
objectsMatch
Compares the given objects
salt
Provides a unique-ish identifier
slugify
Converts string to RFC 952 Hostname format
sortObjectByKeyAlphabetically
Sorts the given object's keys alphabetically
stripLogs
Prevents console logging in the provided environment
toCamelCase
Returns the given string in camelCase format
toTitleCase
Capitalizes The First Letter Of Each Word In A Given String
trimTrailingSlash
Removes /
character from a given string
whichMotionEvent
Detects the end of a css animation or transition based on a given element's css