New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

smart-searcher

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-searcher

⚡ Tiny, fast, zero-dependency search toolkit (exact + fuzzy + indexed)

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
353
Maintainers
1
Weekly downloads
 
Created
Source

smart-searcher

⚡ Tiny, fast, zero-dependency search toolkit for JavaScript/TypeScript. Supports exact lookup, fuzzy search, weighted multi-key search, indexing, filtering, and plugins.

Features

  • 🔹 Exact search (findExact)
  • 🔹 Indexed lookup (createIndex)
  • 🔹 Fuzzy search (createSearch with fuzzy: true)
  • 🔹 Weighted multi-key fuzzy search
  • 🔹 Filtering by criteria
  • 🔹 Plugin system for query/response transforms
  • ✅ Tiny bundle, tree-shakable, zero dependencies
  • ✅ TypeScript ready

Installation

npm install smart-searcher
# or
yarn add smart-searcher

Usage Examples

import { findExact } from 'smart-searcher';

const data = [
  { id: 1, title: 'Apartment Gyumri' },
  { id: 2, title: 'House Yerevan' },
];

const index = findExact(data, 2, 'id');
console.log(index); // 1 (array index)

2️⃣ Indexed lookup (O(1))

import { createIndex } from 'smart-searcher';

const data = [
  { id: 1, title: 'Apartment Gyumri' },
  { id: 2, title: 'House Yerevan' },
];

const indexMap = createIndex(data, 'id');
console.log(indexMap.get(2)); // 1

3️⃣ Filter by criteria

import { filter } from 'smart-searcher';

const data = [
  { id: 1, title: 'Apartment Gyumri', price: 30000 },
  { id: 2, title: 'House Yerevan', price: 80000 },
];

const results = filter(data, { price: { min: 20000, max: 50000 } });
console.log(results);
// [{ id: 1, title: 'Apartment Gyumri', price: 30000 }]
import { createSearch } from 'smart-searcher';

const data = [
  { id: 1, title: 'Apartment Gyumri' },
  { id: 2, title: 'House Yerevan' },
];

const search = createSearch(data, { key: 'title', fuzzy: true });

console.log(search.search('gyumr'));
// [{ id: 1, title: 'Apartment Gyumri' }]
const search = createSearch(data, {
  keys: [
    { key: 'title', weight: 0.7 },
    { key: 'location', weight: 0.3 },
  ],
  fuzzy: true
});

console.log(search.search('gyumr'));
// prioritizes matches in `title` over `location`

6️⃣ Plugins

const searchWithPlugin = createSearch(data, {
  key: 'title',
  fuzzy: true,
  plugins: [
    () => ({
      beforeSearch: (query) => query.trim().toLowerCase(),
      afterSearch: (results) => results.slice(0, 5) // top 5 only
    })
  ]
});

console.log(searchWithPlugin.search(' gyumr '));

7️⃣ Combined API

const search = createSearch(data, { keys: ['title', 'location'], fuzzy: true });

console.log(search.find(1)); // exact find by id
console.log(search.search('gyumr')); // fuzzy
console.log(search.filter({ price: { max: 50000 } })); // filtered results

📦 Why use smart-searcher?

  • Lightweight ✅
  • TypeScript support ✅
  • Zero dependencies ✅
  • Very fast (precomputed tokens, optional index) ✅
  • Multi-key weighted fuzzy search ✅
  • Plugins for custom transformations ✅

License

MIT License

Keywords

search

FAQs

Package last updated on 26 Mar 2026

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