0.0.3 • Published 9 years ago

andand.js v0.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

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
}
0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago