useme
v1.0.0
Published
a bunch of hacky useful things
Downloads
2
Readme
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')); // prints wahoo
valProperty
return a default value if object property is unset
var data = useme.valProperty({
one : 1,
two : 2
}, 'wahoo');
console.log(data.three); // prints wahoo
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); // [2, 4]
console.log(excluded); // [1, 3]
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);
})