fuzzy-path
String -> { k: v } -> v | undefined
Drill down an object in a fuzzy fashion.
Example
import fpath from 'fuzzy-path';
const info = {
firstName: 'Trevor',
lastName: 'Senior',
address: {
city: 'Seattle',
state: 'VA',
zip: 12345,
address1: '55 W St.',
address2: '#4',
phoneNumbers: {
home: 9993334444,
mobile: 1112223333
}
}
};
fpath('firstName', info);
fpath('first', info);
fpath('add.city', info);
fpath('add.phone.mob', info);
fpath('foo', info);
fpath('address.foo', info);
fpath('name', info);
fpath('first.foo', info);
Currying
var getMobileNumber = fpath('add.phone.mob');
getMobileNumber(info);
Install
npm install --save fuzzy-path