@f/loose-parse-int
v0.1.0
Published
Parses a string and returns an integer if possible
Downloads
5
Readme
loose-parse-int
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