Socket
Socket
Sign inDemoInstall

fuzzy-array-filter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuzzy-array-filter

A simple array fuzzy filtering


Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

fuzzy-array-filter

A simple fuzzy filter function for array.prototype.filter using fuse.js.

How to use it

Simple

ìmport fuzzyFilter from 'fuzzy-array-filter';

const array = ['There is a house in New Orleans',
  'They call the Rising Sun',
  'And \'s been the ruin of many a poor boy',
  'And God, I know I\'m one',
  'My mother was a tailor',
  'She sewed my new blue jeans',
  'My father was a gamblin man',
  'Down in New Orleans',
  'Now the only thing a gambler needs',
  'Is a suitcase and trunk',
  'And the only time he\'s satisfied',
  'Is when he\'s on a drunk',
  'Oh mother, tell your children',
  'Not to do what I have done',
  'Spend your lives in sin and misery',
  'In the House of the Rising Sun' ];

console.log(array.filter(fuzzySearch('new orleans')));
// => [ 'There is a house in New Orleans', 'Down in New Orleans' ]

Default fuzzy options are

{
  "threshold": 0.4,
  "location": 0,
  "distance": 100,
  "maxPatternLength": 32,
  "keys": []
}

With custom options

ìmport fuzzyFilter from 'fuzzy-array-filter';

const array = theRisingSunArray; // the previous one

const options = {
  caseSensitive: true,
};

console.log(array.filter(fuzzySearch('new orleans', options)));
// => []

console.log(array.filter(fuzzySearch('man', options)));
// => [ 'And \'s been the ruin of many a poor boy', 'My father was a gamblin man' ]


For more details, please see the fuse.js options documentation

Dependencies

  • fuse.js

ToDo

  • It must filter more complex arrays

Keywords

FAQs

Package last updated on 30 Sep 2016

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