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

fergies-inverted-index

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fergies-inverted-index - npm Package Compare versions

Comparing version 13.0.0-rc.4 to 13.0.0-rc.5

2

package.json
{
"name": "fergies-inverted-index",
"version": "13.0.0-rc.4",
"version": "13.0.0-rc.5",
"description": "An inverted index that allows javascript objects to be easily serialised and retrieved using promises and map-reduce",

@@ -5,0 +5,0 @@ "browser": "src/entrypoints/browser.js",

@@ -125,3 +125,3 @@ # Fergie's Inverted Index

const ii = await InvertedIndex({ name: 'myIndex' })
const ii = InvertedIndex({ name: 'myIndex' })
```

@@ -141,5 +141,6 @@

### `AGGREGATION_FILTER(aggregation, query).then(result)`
### `AGGREGATION_FILTER(aggregation, query, trimEmpty).then(result)`
The aggregation (either FACETS or BUCKETS) is filtered by the query
The aggregation (either FACETS or BUCKETS) is filtered by the
query. Use boolean `trimEmpty` to show or hide empty buckets

@@ -146,0 +147,0 @@ ```javascript

@@ -184,9 +184,20 @@ import charwise from 'charwise'

// return the filtered aggregation
const AGGREGATION_FILTER = (aggregation, filterSet) => {
if (!filterSet || filterSet.length === 0) return aggregation
const AGGREGATION_FILTER = (aggregation, filterSet, trimEmpty = true) => {
// console.log(aggregation)
// console.log(JSON.stringify(filterSet, null, 2))
if (!filterSet) return aggregation // no filter provided- return everything
if (filterSet.length === 0) return [] // search returned no results
filterSet = new Set(filterSet.map(item => item._id))
return aggregation.map(bucket =>
Object.assign(bucket, {
_id: [...new Set([...bucket._id].filter(x => filterSet.has(x)))]
})
return (
aggregation
.map(bucket =>
Object.assign(bucket, {
_id: [...new Set([...bucket._id].filter(x => filterSet.has(x)))]
})
)
// remove empty buckets
.filter(facet => (trimEmpty ? facet._id.length : true))
)

@@ -193,0 +204,0 @@ }

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