javascript-search-input
Search for terms in objects and nested objects
Install
yarn add git://github.com/arojunior/javascript-search-input#0.1.0
Usage
; const sampleData = id: 1 user: name: 'Junior Oliveira' job: 'Software Engineer' subject: 'Hi!' dest: name: 'Bruno' job: 'Developer' name: 'Helio' job: 'Lawyer' id: 2 user: name: 'Fabiano' job: 'UX Designer' subject: 'javascript' dest: name: 'Cordeiro' job: 'CEO' ; const KEYS_TO_FILTERS = 'user.name' 'subject' 'dest.name';const myFilter = const filtered = sampleData; // should return the object { ... user: { name: 'Junior Oliveira'} ... }
The library is framework agnostic, but if you wanna use with React, for example:
const useFilter = { const inputText setInputText = ; const myFilter = ; const filtered = data; return inputText setInputText filtered ;}; const App = { const inputText setInputText filtered = ; return <div className="App"> <input type="text" value=inputText onChange= /> JSON </div> ;};