npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

utilibjs

v0.0.3

Published

My collection of most common used function in javascript. Most of them found in stackoverflow.

Readme

utilibjs

My collection of most common used function in javascript. Most of them found in stackoverflow.

Table of Contents

Install

npm install utilibjs

API

BrowserFunctions

isSafari() ⇒ boolean

Check if the browser is Safari.

Kind: global function
Returns: boolean - true if the browser is Safari, false otherwise.

isChrome() ⇒ boolean

Check if the browser is Chrome.

Kind: global function
Returns: boolean - true if the browser is Chrome, false otherwise.

isOffline() ⇒ boolean

Check if the browser is currently offline.

Kind: global function
Returns: boolean - true if the browser is offline, false otherwise.

openInNewTab(url)

Open the given URL in a new tab.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | url | string | The URL to open in a new tab. |

triggerDownload(fileUrl, [fileName], [target])

Download the file at the given URL with the given filename and target.

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | fileUrl | string | | The URL of the file to download. | | [fileName] | string | null | null | The name of the file to save as. | | [target] | string | null | null | The target window or tab to open the file in. |

downloadFile(file)

Download the given file by creating a download link and clicking it.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | file | File | The file to download. |

FileFunctions

getFileType(fileName) ⇒ string

Get file type based on the file name extension.

Kind: global function
Returns: string - The file type.

| Param | Type | Description | | --- | --- | --- | | fileName | string | The file name. |

getRelativePath(path) ⇒ string

Get the relative path from a full path.

Kind: global function
Returns: string - The relative path.

| Param | Type | Description | | --- | --- | --- | | path | string | The full path. |

renameFile(file, name) ⇒ File

Rename a file with a new name.

Kind: global function
Returns: File - A new File instance with the new name.

| Param | Type | Description | | --- | --- | --- | | file | File | The file to rename. | | name | string | The new name to assign to the file. |

getFileName(url) ⇒ string

Get the file name from a URL.

Kind: global function
Returns: string - The file name.

| Param | Type | Description | | --- | --- | --- | | url | string | The file URL. |

convertMBToBytes(mb) ⇒ number

Convert megabytes to bytes.

Kind: global function
Returns: number - The size in bytes.

| Param | Type | Description | | --- | --- | --- | | mb | number | The size in megabytes. |

convertKBToBytes(kb) ⇒ number

Convert kilobytes to bytes.

Kind: global function
Returns: number - The size in bytes.

| Param | Type | Description | | --- | --- | --- | | kb | number | The size in kilobytes. |

removeFileExtension(fileName) ⇒ string

Remove the file extension from a file name.

Kind: global function
Returns: string - The file name without the extension.

| Param | Type | Description | | --- | --- | --- | | fileName | string | The file name. |

KeyboardFunctions

isEnterKeyPressed(event) ⇒ boolean

Check if the Enter key is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Enter key is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

isSpacebarKeyPressed(event) ⇒ boolean

Check if the Spacebar key is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Spacebar key is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

isEscKeyPressed(event) ⇒ boolean

Check if the Escape key is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Escape key is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

isBackspaceKeyPressed(event) ⇒ boolean

Check if the Backspace key is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Backspace key is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

isTabKeyPressed(event) ⇒ boolean

Check if the Tab key is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Tab key is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

isShiftKeyPressed(event) ⇒ boolean

Check if the Shift key is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Shift key is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

isUndoKeyPressed(event) ⇒ boolean

Check if the Undo (Ctrl + Z) key combination is pressed in the keyboard event.

Kind: global function
Returns: boolean - - True if Undo key combination is pressed, false otherwise.

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | The keyboard event. |

StringFunctions

isEmail(email) ⇒

Determines whether the input is a valid email address.

Kind: global function
Returns: true if the input is a valid email address, false otherwise.

| Param | Description | | --- | --- | | email | The email address to check. |

generateRandomString(length) ⇒

Generates a random string.

Kind: global function
Returns: A random string of the specified length.

| Param | Description | | --- | --- | | length | The length of the string to generate. |

truncateStart(fullStr, strLen, separator) ⇒

Truncates a string from the beginning and adds a separator at the end.

Kind: global function
Returns: The truncated string with the separator at the end.

| Param | Description | | --- | --- | | fullStr | The string to truncate. | | strLen | The maximum length of the truncated string. | | separator | The separator to add at the end of the truncated string. Default is "...". |

truncateMiddle(fullStr, strLen, separator) ⇒

Truncates a string from both the beginning and the end and adds a separator in the middle.

Kind: global function
Returns: The truncated string with the separator in the middle.

| Param | Description | | --- | --- | | fullStr | The string to truncate. | | strLen | The maximum length of the truncated string. | | separator | The separator to add in the middle of the truncated string. Default is "...". |

truncateEmail(email, strLen, separator) ⇒

Truncates an email address and adds a separator in the middle.

Kind: global function
Returns: The truncated email address with the separator in the middle.

| Param | Description | | --- | --- | | email | The email address to truncate. | | strLen | The maximum length of the truncated email address. | | separator | The separator to add in the middle of the truncated email address. Default is "...". |

toCapitalize(str) ⇒

Converts the first letter of each word in a string to uppercase.

Kind: global function
Returns: The input string with the first letter of each word in uppercase.

| Param | Description | | --- | --- | | str | The string to convert. |

MISC

Happy coding!