useme


a set of functions that I refuse to rewrite all over the place though they are just one liners
Install it
npm install useme --save
Usage
val
returns a default value if value is unset
var empty = null;
console.log(useme.val(empty, 'wahoo'));
valProperty
return a default value if object property is unset
var data = useme.valProperty({
one : 1,
two : 2
}, 'wahoo');
console.log(data.three);
include, exclude
Nothing fancy, I jus don't like writing this kind of filters over and over
var array = [1, 2, 3, 4];
var included = useme.include(array, [2, 4]);
var excluded = useme.exclude(array, [2, 4]);
console.log(included);
console.log(excluded);
send
wrapper around request module, returning a promise
useme.send({ uri : myawesomeuri })
.then(function (data) {
console.log(data.request);
console.log(data.response);
})
.fail(function (data) {
console.log(data.error);
})