Skip to content
clothes iron, hammer, axe, flashlight and pitcher on brown wooden table

Strumenti

An ever-growing collection of useful utility functions.

There's no need to reinvent the wheel…!

Functions

🛠️ 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

  1. value: The number to convert
  2. lang (Optional): The language to use when converting
  3. compact (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

Cover image courtesy of Todd Quackenbush.

Comments

In almost all cases, the comments section is a vile cesspool of Reply Guys, racists, and bots.

I don't want to have to deal with that kind of hell so I don't have a comments section.

If you want to continue the conversation, you can always hit me up on Twitter (which is, in its own way, a vile cesspool of Reply Guys, racists, and bots).

Thomas Rigby

Thomas Rigby

When I'm not building things for the internet, I take photos of stuff.
Loading Invisible Visible Navigation Close Arrow Info Online Online