moderndash
Advanced tools
Comparing version 3.7.0 to 3.7.1
@@ -84,3 +84,3 @@ import { Call, Tuples, Objects } from 'hotscript'; | ||
* @template TArrays The type of the arrays provided | ||
* @returns Returns the new array of filtered values | ||
* @returns Returns a new array of filtered values | ||
*/ | ||
@@ -191,4 +191,4 @@ declare function difference<TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2>): TElem[]; | ||
* @throws If index is out of bounds | ||
* @template TArr Type of the array elements | ||
* @returns The modified array with the moved element | ||
* @template TArr Type of the array elements | ||
*/ | ||
@@ -299,3 +299,3 @@ declare function move<TArr>(array: TArr[], fromIndex: number, toIndex: number): TArr[]; | ||
* @template TElem The type of the array elements. | ||
* @returns Returns the slice of `array`. | ||
* @returns A new array of taken elements. | ||
*/ | ||
@@ -371,3 +371,3 @@ declare function takeWhile<TElem>(array: readonly TElem[], predicate: (elem: TElem) => boolean): TElem[]; | ||
/** | ||
* Generates a hash from the given data using the specified algorithm. | ||
* Generates a hash of the given data using the specified algorithm. | ||
* | ||
@@ -374,0 +374,0 @@ * It uses the Web Crypto API to generate the hash. |
@@ -85,10 +85,3 @@ // src/array/chunk.ts | ||
for (const value of array) { | ||
let isUnique = true; | ||
for (const uniqueValue of uniqueArray) { | ||
if (compareFn(value, uniqueValue)) { | ||
isUnique = false; | ||
break; | ||
} | ||
} | ||
if (isUnique) | ||
if (!uniqueArray.some((uniqueValue) => compareFn(value, uniqueValue))) | ||
uniqueArray.push(value); | ||
@@ -164,11 +157,9 @@ } | ||
return [...array].sort((a, b) => { | ||
for (const { order, by } of criteria) { | ||
const aValue = by ? by(a) : a; | ||
const bValue = by ? by(b) : b; | ||
if (aValue < bValue) { | ||
return order === "desc" ? 1 : -1; | ||
for (const { order = "asc", by = (item) => item } of criteria) { | ||
const aValue = by(a); | ||
const bValue = by(b); | ||
if (aValue !== bValue) { | ||
const compare = aValue < bValue ? -1 : 1; | ||
return order === "asc" ? compare : -compare; | ||
} | ||
if (aValue > bValue) { | ||
return order === "desc" ? -1 : 1; | ||
} | ||
} | ||
@@ -175,0 +166,0 @@ return 0; |
{ | ||
"name": "moderndash", | ||
"version": "3.7.0", | ||
"version": "3.7.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A Typescript-First utility library inspired by Lodash. Optimized for modern browsers.", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
297897
3251