thiago / evaluate

Evaluate your variables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

evaluate

======== Build Status Coverage Status

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) The evaluate function need a variable and a type to works. In other cases it will throw an error.

var evaluate = require('evaluate');

function(vari, varDate) {
	vari = evaluate(vari, 'string');
	varDate = evaluate(varDate, 'date');

	console.log(vari, varDate); // '', Thu Sep 17 2015 15:04:56 GMT-0300 (BRT) 
}

##Supported Types

###Number

evaluate(vari, 'number'); // If vari is undefined the returned value is 0

##String

evaluate(vari, 'string'); // If vari is undefined the returned value is ''

##Boolean

evaluate(vari, 'boolean'); // If vari is undefined the returned value is false

##Date

evaluate(vari, 'date'); // If vari is undefined the returned value is the current date

##Object

evaluate(vari, 'object'); // If vari is undefined the returned value is {}

##Array

evaluate(vari, 'array'); // If vari is undefined the returned value is []

About

Evaluate your variables

License:MIT License


Languages

Language:JavaScript 95.9%Language:Shell 4.1%