0.1.0 • Published 8 years ago

@f/loose-parse-int v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

loose-parse-int

Build status Git tag NPM version Code style

Parses a string and returns an integer if possible. If it cannot be converted it'll just return the original string.

Installation

$ npm install @f/loose-parse-int

Usage

var looseParseInt = require('@f/loose-parse-int')

looseParseInt('1') // -> 1
looseParseInt('') // -> ''
looseParseInt('abc') // -> 'abc'
looseParseInt('123abc') // -> '123abc'

API

looseParseInt(str)

  • str - A string to convert to an integer

Returns: Parsed number or if not possible, the original string

License

MIT