evaluate
========
Evaluate your variables, with a simples function.
This is a simple way to check if a variable is setted and evaluate
a value default depends the type of the variable.
Instalation
npm install --save evaluate
How to use
evaluate(vari, type, default)
The evaluate function need a variable and a type to works. In other cases it will throw an error. You can send a default value to the variable if the current variable is undefined.
var evaluate = require('evaluate');
function(vari, varDate) {
vari = evaluate(vari, 'string');
varDate = evaluate(varDate, 'date');
varInt = evaluate(varInt, 'integer', 10);
console.log(vari, varDate, varInt);
}
Supported Types
Number
evaluate(vari, 'number', default);
String
evaluate(vari, 'string', default);
Boolean
evaluate(vari, 'boolean', default);
Date
evaluate(vari, 'date', default);
Object
evaluate(vari, 'object', default);
Array
evaluate(vari, 'array', default);