Socket
Socket
Sign inDemoInstall

evaluate

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    evaluate

Evaluate your variables


Version published
Maintainers
1
Install size
69.7 kB
Created

Readme

Source

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, 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); // '', Thu Sep 17 2015 15:04:56 GMT-0300 (BRT), 10 
}

Supported Types

Number

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

String

evaluate(vari, 'string', default); // If vari is undefined and default is not send  the returned value is ''

Boolean

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

Date

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

Object

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

Array

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

Keywords

FAQs

Last updated on 28 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc