0.0.7 • Published 6 years ago

silent-fn v0.0.7

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
6 years ago

silent-fn

Silents a function in case of error, and returns an optional default value instead (undefined by default)

Can be used as alternative to Lodash's get function, just instead of string or array it gets a function (and the 'path' part remains javascript)

Installation

$ npm i --save silent-fn

Usage

import { silent } from 'silent-fn';

...

const getC = silent(x => x.a.b.c);
getC({a: 5}); // returns undefined instead of error
getC(undefined); // returns undefined instead of error
getC({}); // returns undefined instead of error
getC({a: {b: {c: 5}}}); // returns 5
0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago