gets

1.0.1 • Public • Published

gets - create safe javascript getter functions.

The examples below should explain the whole API.

var gets = require('gets'),
    fn = gets('a', 'b', 'c');

fn({ a: 7 }); // => undefined
fn({ a: { b: 8 } }); // => undefined
fn({ a: { b: 8 } }).or(9); // => 9
fn({ a: { b: { c: 10 } } }).or(9); // => 10
fn({ a: { b: { c: 10 } } }).or(9).map(function(d) {
  return d + 1;
});  // => 11

Note: you can infinitely chain mappers and ors.

/gets/

    Package Sidebar

    Install

    npm i gets

    Weekly Downloads

    87

    Version

    1.0.1

    License

    none

    Last publish

    Collaborators

    • rthomps7
    • uhray