tryparse

0.0.2 • Public • Published

TryParse

TryParse allows you to test if a value is an integer, a float

Installation

npm install tryparse

Usage

var tryparse = require('tryparse')
 
// Good values, as good as using parseInt or parseFloat
var myInt = tryparse.int(4)
> 4
var myFloat = tryparse.float(4.5)
> 4.5
 
// Bad values, return null
var notInt = tryParse.int('fhjdsk')
> null
var notFloat = tryParse.float('dhgjsjkg')
> null
 
// Good values as strings
var myIntString = tryparse.int("4")
> 4
var myFloatString = tryparse.float("4.5")
> 4.5
 

Run Tests (requires tap: https://npmjs.org/package/tap)

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i tryparse

Weekly Downloads

82

Version

0.0.2

License

MIT

Last publish

Collaborators

  • mrdnk