🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

jwero-javascript-utils

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwero-javascript-utils

A collection of utility functions for Node.js, React, and React Native.

1.2.7
latest
npm
Version published
Maintainers
1
Created
Source

Jwero 🚀 JavaScript Utilities

A collection of utility functions for Node.js, React, and React Native.

Table of Contents

  • Installation
  • Usage
  • Utility Functions

Installation

npm install jwero-javascript-utils

Usage

import { getTimeInSeconds, getRandomString } from 'jwero-javascript-utils';

Utility Functions

Time/Date

getTimeInSeconds()
Returns the current time in seconds.
getTimeInMilliSeconds()
Returns the current time in milliseconds.
formatDate(date: Date, format: String, options?: FormatDateOptions)
Formats a date according to the given format string and options.
mysqlDateToJS()

The function `mysqlDateToJS` converts a MySQL date string to a JavaScript Date object.
@param {date} date - The `date` parameter is the input date that needs to be converted. It can be
either a string representation of a date in MySQL format (YYYY-MM-DD HH:MM:SS) or a valid JavaScript
Date object.
@returns the converted JavaScript Date object.
isValidDate()

 The function checks if a given value is a valid date.
 @param {date} d - The parameter "d" is of type "date".
 @returns a boolean value.

String

getRandomString(length: number)
Generates a random string of a given length.

Axios

getAxiosError(error: any)
Extracts the error message from an Axios error object.

Array

isArrayWithValues(arr: any[])
Checks if a variable is an array with values.

Object

isObjWithValues(obj: object)
Checks if a variable is an object with values.

Number

validateNumber(num: any)
Validates a number and returns a valid number.

Random

getRandomInt(max: number)
Generates a random integer up to a maximum value.
getRandomId()
Generates a random ID.

Text

containsText(text: string, searchText: string)
Checks if a text contains a search text.
capitalizeFirstLetter(string: string)
Capitalizes the first letter of a string.

FAQs

Package last updated on 07 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts