fuzzyset-obj
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

FuzzySetObject

A simple upgrade to fuzzyset.js to allow usage of objects instead of strings only.

Install

npm i fuzzyset-obj

General Usage Information

When using this library, you can either create a FuzzySetContainer that contains strings, or objects, but not both. All arguments will take both.

Usage (JavaScript)

import { FuzzySetContainer } from 'fuzzyset-obj';
 
const fuzzySet = new FuzzySetContainer();
 
// add an item to the set
fuzzySet.add('Test');
fuzzySet.add('Apples are great');
fuzzySet.add('Bananas are great');
 
// search the set for one item
const res = fuzzySet.getFirst('te'); // returns 'Test'
 
// search the set for multiple items, getting them in descending order
const res = fuzzySet.getAll('are great') // returns ['Apples are great', 'Bananas are great']

Usage (TypeScript)

import { FuzzySetContainer } from 'fuzzyset-obj';
 
interface Fruit {
  fruit: string
}
 
const fuzzySet = new FuzzySetContainer<Fruit>({ key: 'fruit' });
 
// add an item to the set
fuzzySet.add({ fruit: 'Banana' });
fuzzySet.add({ fruit: 'Blueberry' });
 
// search the set for one item
const res = fuzzySet.getFirst('Banber'); // returns { fruit: 'Banana' }
 
// search the set for multiple items, getting them in descending order
const res = fuzzySet.getAll('Banber'); // returns [{ fruit: 'Banana' }, { fruit: 'Blueberry' }]

Contributing

Feel free to contribute features by sending a pull request.

Package Sidebar

Install

npm i fuzzyset-obj

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

53.1 kB

Total Files

10

Last publish

Collaborators

  • seiyria