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 to 1.8.0-dev.158

dist/array/orderBy.d.mts

8

CHANGELOG.md
# es-toolkit Changelog
## Version v1.8.0
Released on July 5th, 2024.
- Add support for [orderBy](https://es-toolkit.slash.page/reference/array/orderBy.html). (https://github.com/toss/es-toolkit/pull/123)
- Add support for [invert](https://es-toolkit.slash.page/reference/array/invert.html). (https://github.com/toss/es-toolkit/pull/125)
- Add support for [inRange](https://es-toolkit.slash.page/reference/array/inRange.html). (https://github.com/toss/es-toolkit/pull/124)
## Version v1.7.1

@@ -4,0 +12,0 @@

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';

@@ -49,2 +50,3 @@ export { sample } from './array/sample.js';

export { clamp } from './math/clamp.js';
export { inRange } from './math/inRange.js';
export { mean } from './math/mean.js';

@@ -61,2 +63,3 @@ export { meanBy } from './math/meanBy.js';

export { pickBy } from './object/pickBy.js';
export { invert } from './object/invert.js';
export { isNil } from './predicate/isNil.js';

@@ -63,0 +66,0 @@ export { isNotNil } from './predicate/isNotNil.js';

@@ -54,5 +54,7 @@ "use strict";

groupBy: () => groupBy,
inRange: () => inRange,
intersection: () => intersection,
intersectionBy: () => intersectionBy,
intersectionWith: () => intersectionWith,
invert: () => invert,
isNil: () => isNil,

@@ -71,2 +73,3 @@ isNotNil: () => isNotNil,

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

@@ -283,2 +286,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

@@ -586,2 +614,14 @@ function partition(arr, isInTruthy) {

// src/math/inRange.ts
function inRange(value, minimum, maximum) {
if (maximum == null) {
maximum = minimum;
minimum = 0;
}
if (minimum >= maximum) {
throw new Error("The maximum value must be greater than the minimum value.");
}
return minimum <= value && value < maximum;
}
// src/math/sum.ts

@@ -678,2 +718,12 @@ function sum(nums) {

// src/object/invert.ts
function invert(obj) {
const result = {};
for (const key in obj) {
const value = obj[key];
result[value] = key;
}
return result;
}
// src/predicate/isNil.ts

@@ -735,5 +785,7 @@ function isNil(x) {

groupBy,
inRange,
intersection,
intersectionBy,
intersectionWith,
invert,
isNil,

@@ -752,2 +804,3 @@ isNotNil,

once,
orderBy,
partition,

@@ -754,0 +807,0 @@ pick,

export { clamp } from './clamp.js';
export { inRange } from './inRange.js';
export { mean } from './mean.js';

@@ -3,0 +4,0 @@ export { meanBy } from './meanBy.js';

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

clamp: () => clamp,
inRange: () => inRange,
mean: () => mean,

@@ -43,2 +44,14 @@ meanBy: () => meanBy,

// src/math/inRange.ts
function inRange(value, minimum, maximum) {
if (maximum == null) {
maximum = minimum;
minimum = 0;
}
if (minimum >= maximum) {
throw new Error("The maximum value must be greater than the minimum value.");
}
return minimum <= value && value < maximum;
}
// src/math/sum.ts

@@ -112,2 +125,3 @@ function sum(nums) {

clamp,
inRange,
mean,

@@ -114,0 +128,0 @@ meanBy,

@@ -5,1 +5,2 @@ export { omit } from './omit.js';

export { pickBy } from './pickBy.js';
export { invert } from './invert.js';

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

__export(object_exports, {
invert: () => invert,
omit: () => omit,

@@ -86,4 +87,15 @@ omitBy: () => omitBy,

}
// src/object/invert.ts
function invert(obj) {
const result = {};
for (const key in obj) {
const value = obj[key];
result[value] = key;
}
return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
invert,
omit,

@@ -90,0 +102,0 @@ omitBy,

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",
"version": "1.8.0-dev.158+a2e42b8d",
"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

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