New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@antoniovdlc/sort

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antoniovdlc/sort - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

2

dist/index.cjs.js

@@ -1,1 +0,1 @@

"use strict";function n(n,r){return String(r).split(".").reduce((function(n,r){var t;return null!==(t=null==n?void 0:n[r])&&void 0!==t?t:null}),n)}function r(r,t){function e(n,e,u){void 0===u&&(u=1);var i=r(n),o=r(e);return t(i,o,u)}return void 0===r&&(r=String),void 0===t&&(t=function(n,r,t){return void 0===t&&(t=1),n<r?-1*t:n>r?1*t:0}),e.asc=function(n,r){return e(n,r,1)},e.desc=function(n,r){return e(n,r,-1)},e.by=function(e){function u(u,i,o){void 0===o&&(o=1);var c=r(n(u,e)),l=r(n(i,e));return t(c,l,o)}return u.asc=function(n,r){return u(n,r,1)},u.desc=function(n,r){return u(n,r,-1)},u},e}Object.defineProperty(exports,"__esModule",{value:!0});var t=r(String),e=r((function(n){return String(n).toLowerCase()})),u=r((function(n){return new Date(n).getTime()})),i=r(Number);exports.alphabetically=t,exports.alphabeticallyBase=e,exports.chronologically=u,exports.numerically=i;
"use strict";function n(n,r){return String(r).split(".").reduce((function(n,r){var t;return null!==(t=null==n?void 0:n[r])&&void 0!==t?t:null}),n)}function r(r,t){function e(n,e,u){void 0===u&&(u=1);var i=r(n),o=r(e);return t(i,o,u)}return void 0===r&&(r=String),void 0===t&&(t=function(n,r,t){return void 0===t&&(t=1),n<r?-1*t:n>r?1*t:0}),e.asc=function(n,r){return e(n,r,1)},e.desc=function(n,r){return e(n,r,-1)},e.by=function(e){function u(u,i,o){void 0===o&&(o=1);var c=r(n(u,e)),l=r(n(i,e));return t(c,l,o)}return u.asc=function(n,r){return u(n,r,1)},u.desc=function(n,r){return u(n,r,-1)},u},e}Object.defineProperty(exports,"__esModule",{value:!0});var t=r(String),e=r((function(n){return String(n).toLowerCase()})),u=r((function(n){return new Date(n).getTime()})),i=r(Number);exports.alphabetically=t,exports.alphabeticallyBase=e,exports.chronologically=u,exports.combine=function n(r){return function(t,e){if(1===r.length)return r[0](t,e);var u=r[0](t,e);return 0===u?n(r.slice(1))(t,e):u}},exports.numerically=i;
/**
* Combine multipe sorting functions in order.
*
* Example:
* [
* { name: "Alice", age: 32 },
* { name: "Bob", age: 45 },
* { name: "Alice", age: 28 },
* ].sort(combine([
* alphabetically.by("name"),
* numerically.by("age").desc
* ]))
* =>
* [
* { name: "Alice", age: 32 },
* { name: "Alice", age: 28 },
* { name: "Bob", age: 45 },
* ]
*
* @param sortFns List of sorting functions
* @returns
*/
declare function combine(sortFns: Array<Function>): Function;
/**
* Sorts arrays alphabetically (taking into account case)

@@ -29,2 +52,3 @@ *

declare const numerically: Function;
export { combine };
export { alphabetically, alphabeticallyBase, chronologically, numerically };

@@ -1,1 +0,1 @@

function n(n,r){return String(r).split(".").reduce((function(n,r){var t;return null!==(t=null==n?void 0:n[r])&&void 0!==t?t:null}),n)}function r(r,t){function u(n,u,i){void 0===i&&(i=1);var e=r(n),o=r(u);return t(e,o,i)}return void 0===r&&(r=String),void 0===t&&(t=function(n,r,t){return void 0===t&&(t=1),n<r?-1*t:n>r?1*t:0}),u.asc=function(n,r){return u(n,r,1)},u.desc=function(n,r){return u(n,r,-1)},u.by=function(u){function i(i,e,o){void 0===o&&(o=1);var c=r(n(i,u)),f=r(n(e,u));return t(c,f,o)}return i.asc=function(n,r){return i(n,r,1)},i.desc=function(n,r){return i(n,r,-1)},i},u}var t=r(String),u=r((function(n){return String(n).toLowerCase()})),i=r((function(n){return new Date(n).getTime()})),e=r(Number);export{t as alphabetically,u as alphabeticallyBase,i as chronologically,e as numerically};
function n(n,r){return String(r).split(".").reduce((function(n,r){var t;return null!==(t=null==n?void 0:n[r])&&void 0!==t?t:null}),n)}function r(r,t){function u(n,u,e){void 0===e&&(e=1);var i=r(n),o=r(u);return t(i,o,e)}return void 0===r&&(r=String),void 0===t&&(t=function(n,r,t){return void 0===t&&(t=1),n<r?-1*t:n>r?1*t:0}),u.asc=function(n,r){return u(n,r,1)},u.desc=function(n,r){return u(n,r,-1)},u.by=function(u){function e(e,i,o){void 0===o&&(o=1);var c=r(n(e,u)),f=r(n(i,u));return t(c,f,o)}return e.asc=function(n,r){return e(n,r,1)},e.desc=function(n,r){return e(n,r,-1)},e},u}function t(n){return function(r,u){if(1===n.length)return n[0](r,u);var e=n[0](r,u);return 0===e?t(n.slice(1))(r,u):e}}var u=r(String),e=r((function(n){return String(n).toLowerCase()})),i=r((function(n){return new Date(n).getTime()})),o=r(Number);export{u as alphabetically,e as alphabeticallyBase,i as chronologically,t as combine,o as numerically};
{
"name": "@antoniovdlc/sort",
"version": "0.1.0",
"version": "1.0.0",
"description": "Custom compare functions for sorting arrays.",

@@ -47,3 +47,3 @@ "main": "dist/index.cjs.js",

"@rollup/plugin-typescript": "^8.2.1",
"@types/jest": "^26.0.23",
"@types/jest": "^27.0.1",
"babel-jest": "^27.0.2",

@@ -53,3 +53,3 @@ "eslint": "^7.29.0",

"eslint-plugin-jest": "^24.3.6",
"husky": "^6.0.0",
"husky": "^7.0.2",
"jest": "^27.0.4",

@@ -56,0 +56,0 @@ "jest-extended": "^0.11.5",

@@ -115,3 +115,29 @@ # sort

## Combining sorting functions
You can also combine multiple sorting functions.
Let's say that for example, you need to sort an array of users first by name, and then by age (descending). You can achieve that as follows:
```js
const arr = [
{ name: "Bob", age: 23 },
{ name: "Alice", age: 32 },
{ name: "Tom", age: 60 },
{ name: "Candice", age: 45 },
{ name: "Alice", age: 28 },
];
arr.sort(combine([alphabetically.by("name"), numerically.by("age").desc]));
/*
[
{ name: "Alice", age: 32 },
{ name: "Alice", age: 28 },
{ name: "Bob", age: 23 },
{ name: "Candice", age: 45 },
{ name: "Tom", age: 60 },
]
*/
```
## License
MIT
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