Needle-Pinpointing Machine
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

is-positive-integer

1.1.1 • Public • Published

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

install

npm i is-positive-integer

Downloadsweekly downloads

125

version

1.1.1

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar