is-positive-integer
check if a number is a positive integer
Last updated 5 years ago by tjmehta .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-positive-integer 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.1.1                                ...           latest (5 years ago)

4 Versions

  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)

Copyright 2014 - 2017 © taobao.org |