Socket
Socket
Sign inDemoInstall

frecency

Package Overview
Dependencies
Maintainers
24
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frecency - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

CHANGELOG.md
## Release History
* 1.2.0 Add keepScores to SortParams [backward compatible] #10
* 1.1.0 Add support for custom storage providers i.e. Node (#8 - @hugomano)

@@ -4,0 +6,0 @@

@@ -384,2 +384,3 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

* @prop {Object[]} results - The list of search results to sort.
* @prop {boolean} keepScores - Keep the frecency score attached to each item.
* @return {Object[]} Search results sorted by frecency.

@@ -392,3 +393,5 @@ */

var searchQuery = _ref3.searchQuery,
results = _ref3.results;
results = _ref3.results,
_ref3$keepScores = _ref3.keepScores,
keepScores = _ref3$keepScores === undefined ? false : _ref3$keepScores;

@@ -411,2 +414,4 @@ if (!this._localStorageEnabled) return results;

if (keepScores) return sortedResults;
return sortedResults.map(function (result) {

@@ -413,0 +418,0 @@ delete result._frecencyScore;

@@ -375,2 +375,3 @@ 'use strict';

* @prop {Object[]} results - The list of search results to sort.
* @prop {boolean} keepScores - Keep the frecency score attached to each item.
* @return {Object[]} Search results sorted by frecency.

@@ -383,3 +384,5 @@ */

var searchQuery = _ref3.searchQuery,
results = _ref3.results;
results = _ref3.results,
_ref3$keepScores = _ref3.keepScores,
keepScores = _ref3$keepScores === undefined ? false : _ref3$keepScores;

@@ -402,2 +405,4 @@ if (!this._localStorageEnabled) return results;

if (keepScores) return sortedResults;
return sortedResults.map(function (result) {

@@ -404,0 +409,0 @@ delete result._frecencyScore;

2

package.json
{
"name": "frecency",
"version": "1.1.0",
"version": "1.2.0",
"description": "Frecency sorting for search results.",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -57,2 +57,9 @@ # Frecency

Frecency adds and removes `_frecencyScore` attribute for compare results.
You can output results with scores by assigning `keepScores` parameter to `true`.
Keep the frecency score allow you to do extra operations like usage analytics, debugging
and/or mix with other algorithms.
## Configuring Frecency

@@ -59,0 +66,0 @@ Frecency will sort on the `_id` attribute by default. You can change this by setting an

@@ -236,5 +236,6 @@ // @flow

* @prop {Object[]} results - The list of search results to sort.
* @prop {boolean} keepScores - Keep the frecency score attached to each item.
* @return {Object[]} Search results sorted by frecency.
*/
sort({ searchQuery, results }: SortParams): Object[] {
sort({ searchQuery, results, keepScores = false }: SortParams): Object[] {
if (!this._localStorageEnabled) return results;

@@ -253,2 +254,4 @@ this._calculateFrecencyScores(results, searchQuery);

if (keepScores) return sortedResults;
return sortedResults.map((result) => {

@@ -255,0 +258,0 @@ delete result._frecencyScore;

@@ -70,3 +70,4 @@ // @flow

searchQuery: ?string,
results: Object[]
results: Object[],
keepScores?: boolean
};
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