andand.js

0.0.3 • Public • Published

andand.js

require('andand');

var obj = {
    someProp: 42,
    someMethod: function() {
        return {
            anotherProp: 100
        }
    }
}

obj.andand().someProp
// 42

obj.andand().someMethod().anotherProp
// 100

obj.andand().someMethod().someUnknownProp
// falsy (0)

Tests

npm test

Note: only call methods that you know will exist.

For example,

if ({}.andand().myMethod().andand().someReturnProperty) {
    // blah
}

will fail because myMethod is the number 0, which is not a method.

If you are sure that the method exists on an object (even though the object containing it may or may not exist), feel free to call the method in the middle of the chain.

var obj = {
    test: function(){
        return {
            someProp: 42
        };
    }
};

if (obj.andand().test().andand().someProp == 42) {
    //blah
}

Readme

Keywords

Package Sidebar

Install

npm i andand.js

Weekly Downloads

7

Version

0.0.3

License

ISC

Last publish

Collaborators

  • shrugs