Socket
Book a DemoInstallSign in
Socket

fuzzysort-collection

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

fuzzysort-collection

Fast SublimeText-like fuzzy search for collections

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

fuzzysort-collection NPM version Build Status Dependency Status Coverage percentage

Fast SublimeText-like fuzzy search for collections

Thanks to @farzher for fuzzysort

Installation

$ npm install --save fuzzysort-collection

Usage

const fuzz = require('fuzzysort-collection');

// You can config fuzzysort options:
// https://github.com/farzher/fuzzysort#options
fuzz.fuzzysort.highlightOpen = '<strong>';
fuzz.fuzzysort.highlightClose = '</strong>';

const crop = [{
  a: {
    b: 'Snap'
  }
}, {
  a: {
    b: 'Paypal'
  }
}, {
  a: {
    b: 'Google'
  }
}, {
  a: {
    b: 'Apple'
  }
}];

let cream = fuzz('ap', crop, 'a.b');
/*
[
  {
    "meta": {
      "matches": [
        0,
        1
      ],
      "target": "Apple",
      "lower": "apple",
      "score": 3,
      "theMatches": [
        0,
        1
      ],
      "highlighted": "<strong>Ap</strong>ple"
    },
    "data": {
      "a": {
        "b": "Apple"
      }
    }
  },
  {
    "meta": {
      "matches": [
        2,
        3
      ],
      "target": "Snap",
      "lower": "snap",
      "score": 2002,
      "theMatches": [
        2,
        3
      ],
      "highlighted": "Sn<strong>ap</strong>"
    },
    "data": {
      "a": {
        "b": "Snap"
      }
    }
  },
  {
    "meta": {
      "matches": [
        1,
        3
      ],
      "target": "Paypal",
      "lower": "paypal",
      "score": 4004,
      "theMatches": [
        1,
        3
      ],
      "highlighted": "P<strong>a</strong>y<strong>p</strong>al"
    },
    "data": {
      "a": {
        "b": "Paypal"
      }
    }
  }
]
*/

License

ISC © Buster Collings

Keywords

fuzzy

FAQs

Package last updated on 21 Aug 2017

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