1.3.1 • Published 7 years ago

obj-denied v1.3.1

Weekly downloads
7
License
GPL-3.0
Repository
-
Last release
7 years ago

obj-denied

Check if the required properties are set, the easy way!

Build Status Dependency Status NSP Status

Requirements

To use this module, the following is required:

  • An env that accepts ES6' const and let

Installation

You can install this module with NPM:

npm install --save obj-denied

Usage

Require the library

    const denied = require('obj-denied');

Define an Object (or get one)

    const obj = {
        foo: 'bar',
        baz: 'qux',
        nope: null,
        sub_obj: {exists: 'Yes!'},
        sub_arr: ['element']
    }

Start checking!

Success!

    if(denied(obj, ['foo', 'baz'])) {
        return 'Not all required props are given';
    }

    // Go on with life

Oops!

    if(denied(obj, ['nope', 'non-existend'])) {
        return 'Not all required props are given';
    }

    // Nothing going on here, debug the part above, because denied returned true
1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago