Socket
Socket
Sign inDemoInstall

es-toolkit

Package Overview
Dependencies
Maintainers
0
Versions
740
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-toolkit - npm Package Compare versions

Comparing version 1.7.1-dev.154 to 1.7.1-dev.155

dist/array/orderBy.d.mts

1

dist/array/index.d.ts

@@ -20,2 +20,3 @@ export { chunk } from './chunk.js';

export { minBy } from './minBy.js';
export { orderBy } from './orderBy.js';
export { partition } from './partition.js';

@@ -22,0 +23,0 @@ export { sample } from './sample.js';

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

minBy: () => minBy,
orderBy: () => orderBy,
partition: () => partition,

@@ -246,2 +247,27 @@ sample: () => sample,

// src/array/orderBy.ts
function orderBy(collection, keys, orders) {
const compareValues = (a, b, order) => {
if (a < b) {
return order === "asc" ? -1 : 1;
}
if (a > b) {
return order === "asc" ? 1 : -1;
}
return 0;
};
const effectiveOrders = keys.map((_, index) => orders[index] || orders[orders.length - 1]);
return collection.slice().sort((a, b) => {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const order = effectiveOrders[i];
const result = compareValues(a[key], b[key], order);
if (result !== 0) {
return result;
}
}
return 0;
});
}
// src/array/partition.ts

@@ -493,2 +519,3 @@ function partition(arr, isInTruthy) {

minBy,
orderBy,
partition,

@@ -495,0 +522,0 @@ sample,

@@ -20,2 +20,3 @@ export { chunk } from './array/chunk.js';

export { minBy } from './array/minBy.js';
export { orderBy } from './array/orderBy.js';
export { partition } from './array/partition.js';

@@ -22,0 +23,0 @@ export { sample } from './array/sample.js';

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

once: () => once,
orderBy: () => orderBy,
partition: () => partition,

@@ -284,2 +285,27 @@ pick: () => pick,

// src/array/orderBy.ts
function orderBy(collection, keys, orders) {
const compareValues = (a, b, order) => {
if (a < b) {
return order === "asc" ? -1 : 1;
}
if (a > b) {
return order === "asc" ? 1 : -1;
}
return 0;
};
const effectiveOrders = keys.map((_, index) => orders[index] || orders[orders.length - 1]);
return collection.slice().sort((a, b) => {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const order = effectiveOrders[i];
const result = compareValues(a[key], b[key], order);
if (result !== 0) {
return result;
}
}
return 0;
});
}
// src/array/partition.ts

@@ -774,2 +800,3 @@ function partition(arr, isInTruthy) {

once,
orderBy,
partition,

@@ -776,0 +803,0 @@ pick,

2

package.json
{
"name": "es-toolkit",
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
"version": "1.7.1-dev.154+1918eec3",
"version": "1.7.1-dev.155+1eada4d8",
"homepage": "https://es-toolkit.slash.page",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/toss/es-toolkit/issues",

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

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

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