Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

is-positive-integer Build Status js-standard-style

check if a number is a positive integer

Installation

npm --save i is-positive-integer

Usage

var isPositiveInteger = require('is-positive-integer')

isPositiveInteger(1) // true
isPositiveInteger(10) // true
isPositiveInteger(100) // true
isPositiveInteger(1000) // true
isPositiveInteger(0) // false
isPositiveInteger(-1) // false
isPositiveInteger(-10) // false
isPositiveInteger(-100) // false
isPositiveInteger(-1000) // false
isPositiveInteger(1.1) // false
isPositiveInteger(10.1) // false
isPositiveInteger(100.1) // false
isPositiveInteger(1000.1) // false
isPositiveInteger(-1.1) // false
isPositiveInteger(-10.1) // false
isPositiveInteger(-100.1) // false
isPositiveInteger(-1000.1) // false
isPositiveInteger(Infinity) // false
isPositiveInteger({}) // false
isPositiveInteger([]) // false
isPositiveInteger('10') // false
isPositiveInteger('what') // false
isPositiveInteger(/what/) // false
isPositiveInteger(null) // false
// ...

isSafePositiveInteger

Ensure positive integer less than Number.MAX_SAFE_INTEGER https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

var isSafePositiveInteger = require('is-positive-integer').isSafePositiveInteger
// max safe integer doesn't exist in older engines
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991

isSafePositiveInteger(MAX_SAFE_INTEGER) // true
isSafePositiveInteger(MAX_SAFE_INTEGER + 1) // false
isSafePositiveInteger(Number.MAX_VALUE) // false
// ...

License

MIT

About

check if a number is a positive integer

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
You can’t perform that action at this time.