lunr-folding
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

lunr-folding

An extension to lunr.js to do basic character folding, converting various accented and non-ASCII characters to their (presumed) ASCII equivalents.

For example, searching for "facade" will return results for "façade" and searching for for "façade" will return results for "facade."

Usage

Install via npm npm install lunr-folding. After lunr is loaded do:

require("lunr-folding")(lunr);

Or in TypeScript:

import folding from "lunr-folding";
folding(lunr)

You can now create indexes with accented characters and search them without accents, for example:

folding(lunr);
const idx = lunr(function () {
    this.ref("id");
    this.field("text");
    this.add({ id: "1", text: "Étape 1: Collecter des bobettes" });
    this.add({ id: "2", text: "Étape 2: ???" });
    this.add({ id: "3", text: "Étape 3: Profit" });
});
const results = idx.search("etape 3");
console.log(JSON.stringify(results[0]));

Credits

Based on the original lunr.unicodeNormalizer.js by Christopher Van and the NPM-ified version by Dániel Boros

Readme

Keywords

Package Sidebar

Install

npm i lunr-folding

Weekly Downloads

51

Version

0.1.0

License

MIT

Unpacked Size

10.9 kB

Total Files

6

Last publish

Collaborators

  • dhdaines