New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

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

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