search-filterer
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -75,3 +75,3 @@ "use strict"; | ||
})); | ||
exports.search = ramda_1.curry((query, list) => { | ||
exports.search = ramda_1.curry(ramda_1.memoizeWith((query, list) => `${query} --- ${JSON.stringify(list)}`, (query, list) => { | ||
if (!query) { | ||
@@ -83,4 +83,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.searchPreservingOrder = ramda_1.curry((query, list) => { | ||
})); | ||
exports.searchPreservingOrder = ramda_1.curry(ramda_1.memoizeWith((query, list) => `${query} --- ${JSON.stringify(list)}`, (query, list) => { | ||
if (!query) { | ||
@@ -92,4 +92,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.vagueSearch = ramda_1.curry((query, list) => { | ||
})); | ||
exports.vagueSearch = ramda_1.curry(ramda_1.memoizeWith((query, list) => `${query} --- ${JSON.stringify(list)}`, (query, list) => { | ||
if (!query) { | ||
@@ -101,4 +101,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.vagueSearchPreservingOrder = ramda_1.curry((query, list) => { | ||
})); | ||
exports.vagueSearchPreservingOrder = ramda_1.curry(ramda_1.memoizeWith((query, list) => `${query} --- ${JSON.stringify(list)}`, (query, list) => { | ||
if (!query) { | ||
@@ -110,3 +110,3 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
})); | ||
const coreObjectSearch = (query, keys, list) => list.map(item => { | ||
@@ -127,3 +127,3 @@ const scores = keys | ||
}); | ||
exports.objectSearch = ramda_1.curry((query, keys, list) => { | ||
exports.objectSearch = ramda_1.curry(ramda_1.memoizeWith((query, keys, list) => `${query} --- ${JSON.stringify(keys)} --- ${JSON.stringify(list)}`, (query, keys, list) => { | ||
if (!query) { | ||
@@ -135,4 +135,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.objectSearchPreservingOrder = ramda_1.curry((query, keys, list) => { | ||
})); | ||
exports.objectSearchPreservingOrder = ramda_1.curry(ramda_1.memoizeWith((query, keys, list) => `${query} --- ${JSON.stringify(keys)} --- ${JSON.stringify(list)}`, (query, keys, list) => { | ||
if (!query) { | ||
@@ -144,4 +144,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.vagueObjectSearch = ramda_1.curry((query, keys, list) => { | ||
})); | ||
exports.vagueObjectSearch = ramda_1.curry(ramda_1.memoizeWith((query, keys, list) => `${query} --- ${JSON.stringify(keys)} --- ${JSON.stringify(list)}`, (query, keys, list) => { | ||
if (!query) { | ||
@@ -153,4 +153,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.vagueObjectSearchPreservingOrder = ramda_1.curry((query, keys, list) => { | ||
})); | ||
exports.vagueObjectSearchPreservingOrder = ramda_1.curry(ramda_1.memoizeWith((query, keys, list) => `${query} --- ${JSON.stringify(keys)} --- ${JSON.stringify(list)}`, (query, keys, list) => { | ||
if (!query) { | ||
@@ -162,3 +162,3 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
})); | ||
const coreGetterSearch = (query, getters, list) => list.map(item => { | ||
@@ -179,3 +179,3 @@ const scores = getters | ||
}); | ||
exports.searchUsingGetters = ramda_1.curry((query, getters, list) => { | ||
exports.searchUsingGetters = ramda_1.curry(ramda_1.memoizeWith((query, getters, list) => `${query} --- ${JSON.stringify(getters.map(v => v.name || Math.random()))} --- ${JSON.stringify(list)}`, (query, getters, list) => { | ||
if (!query) { | ||
@@ -187,4 +187,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.searchUsingGettersPreservingOrder = ramda_1.curry((query, getters, list) => { | ||
})); | ||
exports.searchUsingGettersPreservingOrder = ramda_1.curry(ramda_1.memoizeWith((query, getters, list) => `${query} --- ${JSON.stringify(getters.map(v => v.name || Math.random()))} --- ${JSON.stringify(list)}`, (query, getters, list) => { | ||
if (!query) { | ||
@@ -196,4 +196,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.vagueSearchUsingGetters = ramda_1.curry((query, getters, list) => { | ||
})); | ||
exports.vagueSearchUsingGetters = ramda_1.curry(ramda_1.memoizeWith((query, getters, list) => `${query} --- ${JSON.stringify(getters.map(v => v.name || Math.random()))} --- ${JSON.stringify(list)}`, (query, getters, list) => { | ||
if (!query) { | ||
@@ -205,4 +205,4 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
exports.vagueSearchUsingGettersPreservingOrder = ramda_1.curry((query, getters, list) => { | ||
})); | ||
exports.vagueSearchUsingGettersPreservingOrder = ramda_1.curry(ramda_1.memoizeWith((query, getters, list) => `${query} --- ${JSON.stringify(getters.map(v => v.name || Math.random()))} --- ${JSON.stringify(list)}`, (query, getters, list) => { | ||
if (!query) { | ||
@@ -214,2 +214,2 @@ return list; | ||
.map(ramda_1.prop("v")); | ||
}); | ||
})); |
{ | ||
"name": "search-filterer", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A curried memoized search library", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/amatthews4851/search-filterer", |
@@ -19,3 +19,3 @@ # search-filterer | ||
All functions listed here are curried, memoized, and are named exports. They will return a new list consisting of items in the `list` that passed the checks. To use, simply | ||
All functions listed here are curried, memoized†, and are named exports. They will return a new list consisting of items in the `list` that passed the checks. To use, simply | ||
@@ -100,1 +100,22 @@ ```ts | ||
`searchPreservingOrder()`, `vagueSearchPreservingOrder()`, `objectSearchPreservingOrder()`, `vagueObjectSearchPreservingOrder()`, `searchWithGettersPreservingOrder()`, `searchWithGettersPreservingOrder()` are all the same as their base functions, but the list returned preserves the same order as the `list` argument that was passed in. | ||
<small>† all of the `searchWithGetters` functions are memoized based on a key created by the query, the list of items, and a string created based on the names of the functions passed in. If these functions are anonymous functions, a random number is used for the key instead and will always be recomputed. In order to take advantage of the memoization, it would be best to extract these out to a named function | ||
```ts | ||
searchWithGetters("foo", [item => item.bar], items); // this will not be memoized | ||
// ------ | ||
searchWithGetters( | ||
"foo", | ||
[ | ||
function(item) { | ||
return item.bar; | ||
} | ||
], | ||
items | ||
); // this will not be memoized | ||
// ------ | ||
const myGetter = item => item.bar; | ||
searchWithGetters("foo", [myGetter], items); // this will be memoized | ||
``` | ||
</small> |
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
13815
120