🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

wft-utils

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wft-utils - npm Package Compare versions

Comparing version
1.45.2
to
1.46.0
+1
-1
package.json
{
"name": "wft-utils",
"version": "1.45.2",
"version": "1.46.0",
"description": "The commonly used tool functions in daily development",

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

@@ -8,3 +8,3 @@ /**

if (typeof source !== 'object' || source === null) return source
const target = source.constructor === Array ? [] : {}
const target = Array.isArray(source) ? [] : {}
for (let key in source) {

@@ -99,2 +99,19 @@ if (source.hasOwnProperty(key)) {

/**
* 将数组分块为指定大小的较小数组。
* @param {Array} arr - 要分块的数组
* @param {number} chunkSize - 每个块的大小
* @returns {Array} 一组较小的二维数组
*/
export function chunkArray(arr, chunkSize) {
if(!Array.isArray(arr) || chunkSize < 1) {
return [];
}
const chunks = [];
for (let i = 0; i < arr.length; i += chunkSize) {
chunks.push(arr.slice(i, i + chunkSize));
}
return chunks;
}
/**
* 随机打乱数组顺序

@@ -101,0 +118,0 @@ * @param {Array} arr