New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

basic-utility-belt

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-utility-belt - npm Package Compare versions

Comparing version 1.0.14 to 1.0.15

39

dist/index.d.ts

@@ -405,5 +405,25 @@ /**

/**
* Validate an email address format.
* Perform a deep comparison between two values to determine if they are equivalent.
* @param {any} value1 The first value to compare.
* @param {any} value2 The second value to compare.
* @returns {boolean} True if the values are equivalent, false otherwise.
*/
declare function deepEqual(value1: any, value2: any): boolean;
/**
* Deeply clone an object.
* @param {T} obj The object to clone.
* @returns {T} A deep clone of the original object.
*/
declare function deepClone<T>(obj: T): T;
/**
* Merge multiple objects into one.
* @param {...object} objects The objects to merge.
* @returns {object} The merged object.
*/
declare function mergeObjects(...objects: object[]): object;
/**
* Validate if a given string is a valid email address.
* @param {string} email The email address to validate.
* @returns {boolean} True if the email address format is valid, false otherwise.
* @returns {boolean} True if the email is valid, false otherwise.
*/

@@ -448,2 +468,8 @@ declare function validateEmail(email: string): boolean;

/**
* Convert an object to a URL query string.
* @param {any} obj The object to convert.
* @returns {string} The URL query string.
*/
declare function objectToQueryString(obj: any): string;
/**
* Parse a URL query string into an object.

@@ -461,10 +487,3 @@ * @param {string} queryString The URL query string to parse.

declare function hexToRgb(hex: string, opacity?: number): [number, number, number, number];
/**
* Perform a deep comparison between two values to determine if they are equivalent.
* @param {any} value1 The first value to compare.
* @param {any} value2 The second value to compare.
* @returns {boolean} True if the values are equivalent, false otherwise.
*/
declare function deepEqual(value1: any, value2: any): boolean;
export { addDays, addMonths, addYears, arrayDifference, arrayIntersection, arrayMedian, arraySymmetricDifference, arrayUnion, average, camelCase, capitalize, capitalizeWords, chunkArray, clamp, countOccurrences, deepEqual, endsWith, escapeHTML, escapeRegExp, factorial, fibonacci, findMax, findMin, flattenArray, formatDate, gcd, gcdTwoNumbers, generateUUID, getCalendarDays, getDayOfWeek, getDayOfYear, getRandomNumber, getWeekOfYear, getWorkingDays, hexToRgb, includesSubstring, isLeapYear, isPrime, isWeekday, isWeekend, lcm, lcmTwoNumbers, numberToRoman, padString, parseDate, parseQueryString, removeDuplicates, removeFalsyValues, removeNonAscii, repeatString, reverseString, reverseWords, romanToNumber, round, shuffleArray, startsWith, subtractDays, subtractMonths, subtractYears, sum, toKebabCase, toPascalCase, toSnakeCase, trimWhitespace, truncateString, uniqueArray, validateCreditCard, validateDate, validateEmail, validateIPv4, validateIPv6, validateURL };
export { addDays, addMonths, addYears, arrayDifference, arrayIntersection, arrayMedian, arraySymmetricDifference, arrayUnion, average, camelCase, capitalize, capitalizeWords, chunkArray, clamp, countOccurrences, deepClone, deepEqual, endsWith, escapeHTML, escapeRegExp, factorial, fibonacci, findMax, findMin, flattenArray, formatDate, gcd, gcdTwoNumbers, generateUUID, getCalendarDays, getDayOfWeek, getDayOfYear, getRandomNumber, getWeekOfYear, getWorkingDays, hexToRgb, includesSubstring, isLeapYear, isPrime, isWeekday, isWeekend, lcm, lcmTwoNumbers, mergeObjects, numberToRoman, objectToQueryString, padString, parseDate, parseQueryString, removeDuplicates, removeFalsyValues, removeNonAscii, repeatString, reverseString, reverseWords, romanToNumber, round, shuffleArray, startsWith, subtractDays, subtractMonths, subtractYears, sum, toKebabCase, toPascalCase, toSnakeCase, trimWhitespace, truncateString, uniqueArray, validateCreditCard, validateDate, validateEmail, validateIPv4, validateIPv6, validateURL };

@@ -38,2 +38,3 @@ "use strict";

countOccurrences: () => countOccurrences,
deepClone: () => deepClone,
deepEqual: () => deepEqual,

@@ -66,3 +67,5 @@ endsWith: () => endsWith,

lcmTwoNumbers: () => lcmTwoNumbers,
mergeObjects: () => mergeObjects,
numberToRoman: () => numberToRoman,
objectToQueryString: () => objectToQueryString,
padString: () => padString,

@@ -526,6 +529,61 @@ parseDate: () => parseDate,

// src/objects.ts
function deepEqual(value1, value2) {
if (value1 === value2) {
return true;
}
if (value1 && typeof value1 === "object" && value2 && typeof value2 === "object") {
if (Array.isArray(value1) && Array.isArray(value2)) {
if (value1.length !== value2.length) {
return false;
}
for (let i = 0; i < value1.length; i++) {
if (!deepEqual(value1[i], value2[i])) {
return false;
}
}
return true;
} else if (!Array.isArray(value1) && !Array.isArray(value2)) {
const keys1 = Object.keys(value1);
const keys2 = Object.keys(value2);
if (keys1.length !== keys2.length) {
return false;
}
for (let key of keys1) {
if (!deepEqual(value1[key], value2[key])) {
return false;
}
}
return true;
}
}
return false;
}
function deepClone(obj) {
if (obj === null || typeof obj !== "object") {
return obj;
}
if (Array.isArray(obj)) {
const arrCopy = [];
for (let i = 0; i < obj.length; i++) {
arrCopy[i] = deepClone(obj[i]);
}
return arrCopy;
}
const objCopy = {};
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
objCopy[key] = deepClone(obj[key]);
}
}
return objCopy;
}
function mergeObjects(...objects) {
return Object.assign({}, ...objects);
}
// src/regexs.ts
function validateEmail(email) {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(email);
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}

@@ -594,2 +652,5 @@ function validateURL(url) {

}
function objectToQueryString(obj) {
return Object.keys(obj).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join("&");
}
function parseQueryString(queryString) {

@@ -611,33 +672,2 @@ const params = new URLSearchParams(queryString);

}
function deepEqual(value1, value2) {
if (value1 === value2) {
return true;
}
if (value1 && typeof value1 === "object" && value2 && typeof value2 === "object") {
if (Array.isArray(value1) && Array.isArray(value2)) {
if (value1.length !== value2.length) {
return false;
}
for (let i = 0; i < value1.length; i++) {
if (!deepEqual(value1[i], value2[i])) {
return false;
}
}
return true;
} else if (!Array.isArray(value1) && !Array.isArray(value2)) {
const keys1 = Object.keys(value1);
const keys2 = Object.keys(value2);
if (keys1.length !== keys2.length) {
return false;
}
for (let key of keys1) {
if (!deepEqual(value1[key], value2[key])) {
return false;
}
}
return true;
}
}
return false;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -660,2 +690,3 @@ 0 && (module.exports = {

countOccurrences,
deepClone,
deepEqual,

@@ -688,3 +719,5 @@ endsWith,

lcmTwoNumbers,
mergeObjects,
numberToRoman,
objectToQueryString,
padString,

@@ -691,0 +724,0 @@ parseDate,

{
"name": "basic-utility-belt",
"version": "1.0.14",
"version": "1.0.15",
"description": "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.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -15,2 +15,3 @@ # Basic Utility Belt

- [strings](#strings)
- [objects](#objects)
- [arrays](#arrays)

@@ -47,4 +48,4 @@ - [regexs](#regexs)

- [generateUUID](#generateuuid)
- [objectToQueryString](#objectToQueryStringobj)
- [parseQueryString](#parsequerystringqueryString)
- [deepEqual](#deepEqualvalue1-value2)
- [hexToRgb](#hextorgbhex-opacity)

@@ -59,3 +60,11 @@

#### objectToQueryString(obj)
Convert an object to a URL query string.
- `obj`: The object to convert.
- Returns: The URL query string.
#### parseQueryString(queryString)

@@ -68,10 +77,3 @@

#### deepEqual(value1, value2)
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.
- Returns: `true` if the values are equivalent, `false` otherwise.
#### hexToRgb(hex, opacity?)

@@ -527,2 +529,33 @@

### objects
- [deepEqual](#deepEqualvalue1-value2)
- [deepClone](#deepCloneobj)
- [mergeObjects](#mergeObjectsobjects)
#### deepEqual(value1, value2)
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.
- Returns: `true` if the values are equivalent, `false` otherwise.
#### mergeObjects(...objects)
Merge multiple objects into one.
- `...objects`: The objects to merge.
- Returns: The merged object.
#### deepClone(obj)
Deeply clone an object.
- `obj`: The object to clone.
- Returns: A deep clone of the original object.
### arrays

@@ -529,0 +562,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc