I'm using fuzzy
module with node but I have long JSON Array contain object. I need matched object whole. Like
link of module Fuzzy Modules
var list = [
{rompalu: 'baconing', zibbity: 'simba'}
, {rompalu: 'narwhal' , zibbity: 'mufasa'}
, {rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'}
];
I have above list of JSON Array and if I pass word narwhal
than It's return only matched words in Array but I need array of matched object. output like :
[
{rompalu: 'narwhal' , zibbity: 'mufasa'}
]
There seem to be various options.
Filter the list manually using fuzzy.test()
:
var results = list.filter(function(obj) { return fuzzy.test('narwhal', obj.rompalu); });
Extract the "originals":
var options = { extract: function(el) { return el.rompalu; } }; var results = fuzzy.filter('narwhal', list, options).map(function(r) { return r.original; });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.