Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
basic-utility-belt
Advanced tools
Basic Utility Belt is a versatile collection of essential utility functions designed to simplify a wide range of common programming tasks. Whether you need to manipulate dates, perform arithmetic operations, or process strings, this toolkit has you covere
Basic Utility Belt is a versatile collection of essential utility functions designed to simplify a wide range of common programming tasks. Whether you need to manipulate dates, perform arithmetic operations, or process strings, this toolkit has you covered. Enhance your development workflow with these reliable and easy-to-use functions, all in one convenient package.
You can install Basic Utility Belt via npm:
npm install basic-utility-belt
Generate a UUID (Universally Unique Identifier).
Convert an object to a URL query string.
obj
: The object to convert.Parse a URL query string into an object.
queryString
: The URL query string to parse.Convert a HEX color code to RGB.
hex
: The HEX color code to convert.opacity
: The opacity of the color (optional, default is 1).Calculate the product of an array of numbers.
array
: The array of numbers.Calculate the modulus of two numbers.
a
: The dividend.b
: The divisor.a
divided by b
.Convert radians to degrees.
radians
: The angle in radians to convert.Convert degrees to radians.
degrees
: The angle in degrees to convert.Generate a random integer within a specified range.
min
: The minimum value of the range (inclusive).max
: The maximum value of the range (inclusive).Generate a random float within a specified range.
min
: The minimum value of the range (inclusive).max
: The maximum value of the range (exclusive).Format a number to a specified precision.
num
: The number to format.precision
: The number of significant digits.Format a number using fixed-point notation.
num
: The number to format.digits
: The number of digits to appear after the decimal point.Check if a number is an integer.
num
: The number to check.Check if a number is a float.
num
: The number to check.Check if a number is even.
num
: The number to check.Check if a number is odd.
num
: The number to check.Clamp a number within a specified range.
num
: The number to clamp.min
: The minimum value.max
: The maximum value.Round a number to a specified number of decimal places.
num
: The number to round.decimalPlaces
: The number of decimal places.Calculate the average of a variable number of numbers.
...numbers
: The numbers.Calculate the sum of a variable number of numbers.
...numbers
: The numbers.Calculate the factorial of a number.
num
: The number to calculate the factorial of.Generate a Fibonacci sequence up to a specified number of terms.
numTerms
: The number of terms in the Fibonacci sequence.Check if a number is a prime number.
num
: The number to check.Calculate the greatest common divisor of multiple numbers.
...numbers
: Numbers for which to calculate the greatest common divisor.Calculate the least common multiple of multiple numbers.
...numbers
: Numbers for which to calculate the least common multiple.Convert a number to a Roman numeral.
num
: The number to convert.Convert a Roman numeral to a number.
roman
: The Roman numeral to convert.Get the day of the year from a date.
date
: The date object from which to get the day of the year.Get the week of the year from a date.
date
: The date object from which to get the week of the year.Parse a date string into a JavaScript Date object.
dateString
: The date string to parse.Note: Dates are returned in UTC time.
Format a date object into a string.
date
: The date object to format.Note: Dates are formatted in UTC time.
Calculate the number of days between two dates, inclusive of both the start and end dates.
startDate
: The start date.endDate
: The end date.Calculate the number of working days (Monday to Friday) between two dates, inclusive of both the start and end dates.
startDate
: The start date.endDate
: The end date.Add a specified number of days to a date.
date
: The date to add days to.days
: The number of days to add.Subtract a specified number of days from a date.
date
: The date to subtract days from.days
: The number of days to subtract.Add a specified number of months to a date.
date
: The date object to which to add months.months
: The number of months to add. Positive values add months in the future, negative values subtract months.Subtract a specified number of months from a date.
date
: The date object from which to subtract months.months
: The number of months to subtract. Positive values subtract months, negative values add months.Add a specified number of years to a date.
date
: The date object to which to add years.years
: The number of years to add. Positive values add years in the future, negative values subtract years.Subtract a specified number of years from a date.
date
: The date object from which to subtract years.years
: The number of years to subtract. Positive values subtract years, negative values add years.Get the day of the week from a date.
date
: The date to get the day of the week from.Check if a date falls on a weekend (Saturday or Sunday).
date
: The date object to check.Check if a date falls on a weekday (Monday to Friday).
date
: The date object to check.Check if a year is a leap year.
year
: The year to check.true
if the year is a leap year, false
otherwise.Counts the number of consonants in a string.
str
: The string to check.Counts the number of vowels in a string.
str
: The string to check.Replaces all occurrences of a substring in a string with a new substring.
str
: The original string.search
: The substring to search for.replace
: The substring to replace with.Checks if a string is a palindrome.
str
: The string to check.Checks if two strings are anagrams.
str1
: The first string.str2
: The second string.Capitalize the first letter of a string.
str
: The input string.Decapitalize the first letter of a string.
str
: The string to decapitalize.Convert a string to camel case.
str
: The input string.Convert a string to snake_case.
str
: The string to convert.Convert a string to kebab-case.
str
: The string to convert.Convert a string to PascalCase.
str
: The string to convert.Capitalize the first letter of each word in a string.
str
: The string to capitalize.Reverse a given string.
str
: The input string.Escape HTML special characters in a string.
str
: The input string.Escape special characters in a string for use in a regular expression.
str
: The string to escape.Truncate a string to a specified length and add ellipsis if necessary.
str
: The string to truncate.length
: The maximum length of the truncated string including the ellipsis.Repeat a string a specified number of times.
str
: The string to repeat.count
: The number of times to repeat the string. Default is 10.Check if a string starts with a given substring.
str
: The string to check.searchString
: The substring to search for at the beginning of the string.Check if a string ends with a given substring.
str
: The string to check.searchString
: The substring to search for at the end of the string.Check if a string includes a given substring.
str
: The string to check.searchString
: The substring to search for within the string.Count the occurrences of a substring in a string.
str
: The string to search in.subString
: The substring to count occurrences of.Remove leading and trailing whitespace from a string.
str
: The string to trim.Pad a string with a specified character to a given length.
str
: The string to pad.length
: The desired length of the padded string.char
: The character to use for padding. Default is space.Remove non-ASCII characters from a string.
str
: The string to remove non-ASCII characters from.Reverse the words in a string.
str
: The string whose words to reverse.Convert an object to an array of key-value pairs.
obj
: The object to convert.Convert an array of key-value pairs to an object.
pairs
: The array of key-value pairs to convert.Perform a deep comparison between two values to determine if they are equivalent.
value1
: The first value to compare.value2
: The second value to compare.true
if the values are equivalent, false
otherwise.Merge multiple objects into one.
...objects
: The objects to merge.Deeply clone an object.
obj
: The object to clone.Sort an array of objects by a specified (possibly nested) property.
array
: The array of objects to sort.propertyPath
: The property path to sort by, using dot notation for nested properties.Calculate the median of an array of numbers.
array
: The array of numbers.Find the minimum value in an array.
array
: The array in which to find the minimum value.Find the maximum value in an array.
array
: The array in which to find the maximum value.Remove duplicate elements from an array, leaving only non-duplicated values.
array
: The array from which to remove duplicates.Remove all falsy values from an array.
array
: The array from which to remove falsy values.Get the symmetric difference of two arrays.
array1
: The first array.array2
: The second array.Get the union of two arrays.
array1
: The first array.array2
: The second array.Get the intersection of two arrays.
array1
: The first array.array2
: The second array.Get the difference between two arrays.
array1
: The first array.array2
: The second array.Randomly shuffle the elements of an array.
array
: The array to shuffle.Remove duplicates from an array.
array
: The array to remove duplicates from.Flatten a nested array.
array
: The nested array to flatten.Split an array into chunks of a specified size.
array
: The array to chunk.size
: The size of each chunk.Validate an email address format.
email
: The email address to validate.true
if the email address is valid, false
otherwise.Validate a URL format.
url
: The URL to validate.true
if the URL is valid, false
otherwise.Validate a credit card number format.
cardNumber
: The credit card number to validate.true
if the credit card number is valid, false
otherwise.Validate an IPv4 address format.
ipv4Address
: The IPv4 address to validate.true
if the IPv4 address is valid, false
otherwise.Validate an IPv6 address format.
ipv6Address
: The IPv6 address to validate.true
if the IPv6 address is valid, false
otherwise.Validate a date string format.
dateString
: The date string to validate.true
if the date string is valid, false
otherwise. Note: This function supports many common date formats but may not cover all edge cases.Create a debounced function that delays invoking a function until after a specified wait time.
func
: The function to debounce.wait
: The number of milliseconds to delay.This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Basic Utility Belt is a versatile collection of essential utility functions designed to simplify a wide range of common programming tasks. Whether you need to manipulate dates, perform arithmetic operations, or process strings, this toolkit has you covere
We found that basic-utility-belt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.