TypeScript icon, indicating that this package has built-in type declarations

1.2.21 • Public • Published

Utils: A Comprehensive JavaScript Utility Library

The Utils class is a comprehensive JavaScript utility library that provides a wide range of functions to enhance the development of web applications. This library offers a variety of features, including audio element creation, HTML element manipulation, regular expression generation, path resolution, and more.

GitHub stars GitHub issues npm version License jsDelivr downloads


To use the Utils library in your project, you can either directly include the Utils cdn in your HTML document or install it as a module using a package manager like npm.

Direct Inclusion

To include the Utils library directly in your HTML document, simply add the following script tag to the <head> section of your document:

<script src="https://cdn.jsdelivr.net/npm/@easylibs/utils@latest/dist/utils.min.js"></script>
<script src="https://unpkg.com/@easylibs/utils@latest/dist/utils.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@easylibs/utils@latest/dist/utils.js"></script>
<script src="https://unpkg.com/@easylibs/utils@latest/dist/utils.js"></script>

npm, yarn or pnpm Installation

To install the Utils library as a module using npm, run the following command in your terminal:

npm install @easylibs/utils
# Or
yarn add @easylibs/utils
# Or
pnpm add @easylibs/utils

Once installed, you can import the library into your JavaScript files using the following syntax:

import Utils from '@easylibs/utils';


The Utils library provides a wide range of methods that can be used in various scenarios. Here are some examples of how you can use the library:

Creating Audio Elements

The setAudio() function allows you to create audio elements with a specified audio path and optional CSS class. Here's an example of how to use it:

const audio = Utils.setAudio('path/to/audio.mp3', 'my-audio-class');

Manipulating HTML Elements

The textToHTMLElement() function converts a string of HTML code into an HTML element. It also provides options to return the first child element or all children elements of the created element. Here's an example of how to use it:

const divElement = Utils.textToHTMLElement('<div>Hello World!</div>');

Generating Regular Expressions

The getRegexp() function generates regular expressions based on a specified type. It supports various types of regular expressions, including email, phone number, strong password, and more. Here's an example of how to use it:

let's test a password which must contain at least one capital letter, a number, a special character and at least 8 characters.

const strongPasswordRegex = Utils.getRegexp('strong-password');
strongPasswordRegex.test('1234') // return false
strongPasswordRegex.test('Azerty@1234') // return true

Package Sidebar


npm i @easylibs/utils

Weekly Downloads






Unpacked Size

83.2 kB

Total Files


Last publish


  • nelsallg