This package has been deprecated

Author message:

@WARNING: @WARNING: @WARNING: THIS PACKAGE IS NO LONGER MAINTAINED! Please consider using another package.

fuzzy-path

1.0.1 • Public • Published

fuzzy-path

String -> { k: v } -> v | undefined

Drill down an object in a fuzzy fashion.

Build Status

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); // 'Trevor'
fpath('first', info); // 'Trevor'
fpath('add.city', info); // 'Seattle'
fpath('add.phone.mob', info); // 111222333
 
fpath('foo', info); // undefined
fpath('address.foo', info); // undefined
 
// throws error! too many options to choose from
fpath('name', info);
 
// throws error! invalid path (firstName is a string)
fpath('first.foo', info);

Currying

var getMobileNumber = fpath('add.phone.mob');
 
getMobileNumber(info); // 111222333

Install

npm install --save fuzzy-path

Readme

Keywords

Package Sidebar

Install

npm i fuzzy-path

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • akm8ihc78quzbfy
  • 7fs9jsaipnxzg2agkaegqgnbappcpw