Skip to content
Check if a string represents an integer
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.editorconfig init
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
bower.json
is-string-int-cjs.js
is-string-int.js introduce @shinnn/eslint-config
package.json release v1.0.2
test.js use ES.next code fro testing

README.md

is-string-int

NPM version Bower version Build Status Coverage Status devDependency Status

Check if a string represents an integer

isStringInt('123'); //=> true
isStringInt('1.23'); //=> false

Installation

Package managers

npm

npm install is-string-int

Bower

bower install is-string-int

Standalone

Download the script file directly.

API

isStringInt(string, option)

string: String
option: Object
Return: Boolean

See the test for more detailed specifications.

isStringInt('1'); //=> true
isStringInt('0'); //=> true
isStringInt('-1'); //=> true

isStringInt('0.1'); //=> false
isStringInt('foo'); //=> false
isStringInt(' 1'); //=> false
isStringInt('01'); //=> false
isStringInt('0x1'); //=> false
isStringInt('0e+0'); //=> false
isStringInt('NaN'); //=> false

option.parseLiteral

Type: Boolean
Default: false

Returns true even if the string includes octal/hexadecimal expressions and exponential notation. (By default it returns false in that case.)

isStringInt('01', {parseLiteral: true}); //=> true
isStringInt('0x1', {parseLiteral: true}); //=> true
isStringInt('0e+0', {parseLiteral: true}); //=> true

License

Copyright (c) 2014 - 2015 Shinnosuke Watanabe

Licensed under the MIT License.

Something went wrong with that request. Please try again.