Comparing version 1.1.0 to 1.2.0
## 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; |
{ | ||
"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 | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
59971
1303
141
0