🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

list-search

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

list-search

A basic search functionality for lists.

1.0.0
latest
npm
Version published
Maintainers
1
Created
Source

Simple search implementation for a list of objects.

installation

$npm install --save list-search

usage

  • Provide a list of objects with a common set of fields.
  • Perform a query, returning a subset of the input list sorted by relevance.

Relevance is determined by the amount of times words in the input query appear as words within the list of words to compare against, which is constructed by taking the value from all the defined fields, splitting them into words and then merging those lists together.

examples

const search = require('./index');

const provider = search([
  { name: 'test' },
  { name: 'another test' },
  { name: 'yet another test' },
  { name: 'yet another test again' }
], ['name']);

console.log(provider.query('test').length); // 4
console.log(provider.query('a').length); // 3
console.log(provider.query('again test').length); // 1
console.log(provider.query('yet').length); // 2

FAQs

Package last updated on 20 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts