JSFiddle - React, Tailwind, and code Playground
by Daniel Lizik
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script>
<input type="text" id="input" />
<pre id="output"></pre>
JavaScript
(function($win, $output, $input, $model) {
$input.addEventListener("keyup", function() {
var sorted = _.filter($model, function(obj) {
if (obj.a.indexOf($input.value) > -1) return true;
});
$output.textContent = JSON.stringify(sorted, null, 2)
});
})(window, document.querySelector("#output"), document.querySelector("#input"), [
{ a: 'dog', b: 'cat' },
{ a: 'giraffe', b: 'fish' },
{ a: 'lion', b: 'horse' },
{ a: 'rhino', b: 'beaver' },
{ a: 'parrot', b: 'monkey' },
{ a: 'whale', b: 'bee' },
{ a: 'shark', b: 'ant' },
{ a: 'bird', b: 'slug' },
]);