Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bluelilo/search-utils

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bluelilo/search-utils - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

63

lib/sort.js

@@ -18,17 +18,56 @@ "use strict";

function sortPriceHighLow(results) {
const sortedResults = results.slice(0).sort((a, b) => {
const minA = Math.min(...boardOptionsToTotals(a.boardOptions));
const minB = Math.min(...boardOptionsToTotals(b.boardOptions));
return minB - minA;
});
return sortBoardOptions(sortedResults);
}
function sortPriceLowHigh(results) {
const sortedResults = results.slice(0).sort((a, b) => {
const minA = Math.min(...boardOptionsToTotals(a.boardOptions));
const minB = Math.min(...boardOptionsToTotals(b.boardOptions));
return minA - minB;
});
return sortBoardOptions(sortedResults);
}
function sortRecommended(results) {
const sortedResults = sortPriceLowHigh(results);
const providerResults = Object.values(sortedResults.reduce((providers, result) => {
if (!providers[result.provider]) providers[result.provider] = [];
providers[result.provider].push(result);
return providers;
}, {}));
const zippedResults = [];
let hasResult = true;
while (hasResult) {
hasResult = false;
for (const providerResult of providerResults) {
const result = providerResult.shift();
if (result) {
zippedResults.push(result);
}
if (providerResult.length > 0) {
hasResult = true;
}
}
}
return zippedResults;
}
function sort(results, sortBy) {
if (sortBy === 'PRICE_HIGH_LOW') {
const sortedResults = results.slice(0).sort((a, b) => {
const minA = Math.min(...boardOptionsToTotals(a.boardOptions));
const minB = Math.min(...boardOptionsToTotals(b.boardOptions));
return minB - minA;
});
return sortBoardOptions(sortedResults);
return sortPriceHighLow(results);
} else if (sortBy === 'PRICE_LOW_HIGH') {
const sortedResults = results.slice(0).sort((a, b) => {
const minA = Math.min(...boardOptionsToTotals(a.boardOptions));
const minB = Math.min(...boardOptionsToTotals(b.boardOptions));
return minA - minB;
});
return sortBoardOptions(sortedResults);
return sortPriceLowHigh(results);
} else if (sortBy === 'RECOMMENDED') {
return sortRecommended(results);
}

@@ -35,0 +74,0 @@

2

package.json
{
"name": "@bluelilo/search-utils",
"version": "1.2.1",
"version": "1.3.0",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

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