UNPKG

@pawan9303/react-search

Version:

A simple utility for searching through arrays of strings or numbers. Case-insensitive search functionality.

106 lines (70 loc) 2.22 kB
# @pawan9303/react-search A simple utility for searching through arrays of strings or numbers in React applications. Case-insensitive search functionality. --- ## 🚀 Features - Case-insensitive search - Filters array based on a search query - Ideal for use in React applications --- ## 📦 Installation ```bash npm install @pawan9303/react-search ``` --- ## 📚 Usage ```js import search from '@pawan9303/react-search'; const items = ['apple', 'banana', 'orange', 'apple pie']; // Search for "apple" const result = search(items, 'apple'); console.log(result); // Output: [ 'apple', 'apple pie' ] ``` --- ## 🔧 API Reference ### `search(list, query)` | Param | Type | Description | |---------------|--------|----------------------------------------------------------| | `list` | Array | The array to search through | | `query` | Qurey | The search query (case-insensitive) --- ## ✅ Example ```js import React, { useState } from 'react'; import search from '@pawan9303/react-search'; const SearchExample = () => { const [query, setQuery] = useState(''); const items = ['apple', 'banana', 'orange', 'apple pie']; const handleSearch = (e) => { setQuery(e.target.value); }; const filteredItems = search(items, query); return ( <div> <input type="text" placeholder="Search..." value={query} onChange={handleSearch} /> <ul> {filteredItems.map((item, index) => ( <li key={index}>{item}</li> ))} </ul> </div> ); }; export default SearchExample; ``` --- ## 👨‍💻 Author Made by [@pawan9303](https://www.npmjs.com/~pawan9303) --- ## 📄 License ### What's Included: - **Installation** instructions. - **Usage examples** (both simple search and React component usage). - **API reference** for the search function. - **Author info** and **license details**. Now all the information you requested is neatly packed in a **single markdown file**.