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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    165
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    165
  • 0.0.1
    2

Package Sidebar

Install

npm i tryparse

Weekly Downloads

120

Version

0.0.2

License

MIT

Last publish

Collaborators

  • mrdnk