Nonvoluntary Professional Mangling
Need private packages and team management tools?Check out npm Teams »

is-natural-number-string

1.0.1 • Public • Published

is-natural-number-string

NPM version Bower version Build Status Coverage Status devDependency Status

Check if a given value is a string that represents natural number

isNaturalNumberString('9478123289889839898438984843498934894'); //=> true
isNaturalNumberString('-1'); //=> false

Unlike is-natural-number, is-natural-number-string can handle a too large number that exceeds the JavaScript maximum safe integer 9007199254740991.

Installation

Package managers

npm

npm install is-natural-number-string

bower

bower install is-natural-number-string

Standalone

Download the script file directly.

API

isNaturalNumberString(val [, option])

val: String
option: Object
Return: Boolean

isNaturalNumberString('15'); //=> true
isNaturalNumberString('4.3'); //=> false
 
isNaturalNumberString('1'); //=> true
isNaturalNumberString('1.0'); //=> true
isNaturalNumberString('1.00000000000000000000000000'); //=> true
 
// non-string
isNaturalNumberString(15); //=> false
isNaturalNumberString(); //=> false

option.includeZero

Type: Boolean
Default: false

Determine whether this library regards 0 as a natural number or not.

isNaturalNumberString('0'); //=> false
isNaturalNumberString('0', {includeZero: true}); //=> true

License

Copyright (c) 2016 Shinnosuke Watanabe

Licensed under the MIT License.

Install

npm i is-natural-number-string

DownloadsWeekly Downloads

7,437

Version

1.0.1

License

MIT

Last publish

Collaborators

  • avatar