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.6 to 1.0.7

28

dist/index.d.ts

@@ -146,2 +146,28 @@ /**

export { addDays, average, camelCase, capitalize, clamp, escapeHTML, factorial, fibonacci, gcd, gcdTwoNumbers, getCalendarDays, getDayOfWeek, getRandomNumber, getWorkingDays, isLeapYear, isPrime, lcm, lcmTwoNumbers, reverseString, round, subtractDays, sum };
/**
* Randomly shuffle the elements of an array.
* @param {any[]} array The array to shuffle.
* @returns {any[]} The shuffled array.
*/
declare function shuffleArray(array: any[]): any[];
/**
* Remove duplicates from an array.
* @param {any[]} array The array to remove duplicates from.
* @returns {any[]} The array with duplicates removed.
*/
declare function uniqueArray(array: any[]): any[];
/**
* Flatten a nested array.
* @param {any[]} array The nested array to flatten.
* @returns {any[]} The flattened array.
*/
declare function flattenArray(array: any[]): any[];
/**
* Split an array into chunks of a specified size.
* @param {any[]} array The array to chunk.
* @param {number} size The size of each chunk.
* @returns {any[][]} An array containing the chunked arrays.
*/
declare function chunkArray(array: any[], size: number): any[][];
export { addDays, average, camelCase, capitalize, chunkArray, clamp, escapeHTML, factorial, fibonacci, flattenArray, gcd, gcdTwoNumbers, getCalendarDays, getDayOfWeek, getRandomNumber, getWorkingDays, isLeapYear, isPrime, lcm, lcmTwoNumbers, reverseString, round, shuffleArray, subtractDays, sum, uniqueArray };

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

capitalize: () => capitalize,
chunkArray: () => chunkArray,
clamp: () => clamp,

@@ -32,2 +33,3 @@ escapeHTML: () => escapeHTML,

fibonacci: () => fibonacci,
flattenArray: () => flattenArray,
gcd: () => gcd,

@@ -45,4 +47,6 @@ gcdTwoNumbers: () => gcdTwoNumbers,

round: () => round,
shuffleArray: () => shuffleArray,
subtractDays: () => subtractDays,
sum: () => sum
sum: () => sum,
uniqueArray: () => uniqueArray
});

@@ -202,2 +206,24 @@ module.exports = __toCommonJS(src_exports);

}
// src/arrays.ts
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function uniqueArray(array) {
return Array.from(new Set(array));
}
function flattenArray(array) {
return array.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenArray(val)) : acc.concat(val), []);
}
function chunkArray(array, size) {
const result = [];
for (let i = 0; i < array.length; i += size) {
result.push(array.slice(i, i + size));
}
return result;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -209,2 +235,3 @@ 0 && (module.exports = {

capitalize,
chunkArray,
clamp,

@@ -214,2 +241,3 @@ escapeHTML,

fibonacci,
flattenArray,
gcd,

@@ -227,4 +255,6 @@ gcdTwoNumbers,

round,
shuffleArray,
subtractDays,
sum
sum,
uniqueArray
});

8

package.json
{
"name": "basic-utility-belt",
"version": "1.0.6",
"version": "1.0.7",
"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.",

@@ -35,6 +35,8 @@ "main": "./dist/index.js",

"math",
"date manipulation",
"date",
"calendar",
"arithmetic",
"string manipulation"
"string",
"array",
"manipulation"
],

@@ -41,0 +43,0 @@ "author": "Nika Jobava",

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

- [strings](#strings)
- [arrays](#arrays)
- [License](#license)

@@ -37,2 +38,4 @@

- [dates.js](#datesjs)
- [strings](#strings)
- [arrays](#arrays)

@@ -219,5 +222,43 @@ ### numbers

### arrays.js
- [shuffleArray](#shufflearray)
- [uniqueArray](#uniquearray)
- [flattenArray](#flattenarray)
- [chunkArray](#chunkarray-size)
#### shuffleArray(array)
Randomly shuffle the elements of an array.
- `array`: The array to shuffle.
- Returns: The shuffled array.
#### uniqueArray(array)
Remove duplicates from an array.
- `array`: The array to remove duplicates from.
- Returns: The array with duplicates removed.
#### flattenArray(array)
Flatten a nested array.
- `array`: The nested array to flatten.
- Returns: The flattened array.
#### chunkArray(array, size)
Split an array into chunks of a specified size.
- `array`: The array to chunk.
- `size`: The size of each chunk.
- Returns: An array containing the chunked arrays.
## License
This project is licensed under the MIT License - see the LICENSE file for details.

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