Package Exports
- @stdlib/assert-is-positive-integer
- @stdlib/assert-is-positive-integer/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/assert-is-positive-integer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
isPositiveInteger
Test if a value is a number having a positive integer value.
Installation
npm install @stdlib/assert-is-positive-integer
Usage
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' );
isPositiveInteger( value )
Tests if a value
is a number
having a positive integer
value.
var Number = require( '@stdlib/number-ctor' );
var bool = isPositiveInteger( 5.0 );
// returns true
bool = isPositiveInteger( new Number( 5.0 ) );
// returns true
bool = isPositiveInteger( -5.0 );
// returns false
bool = isPositiveInteger( 0.0 );
// returns false
bool = isPositiveInteger( 3.14 );
// returns false
bool = isPositiveInteger( null );
// returns false
isPositiveInteger.isPrimitive( value )
Tests if a value
is a primitive number
having a positive integer
value.
var Number = require( '@stdlib/number-ctor' );
var bool = isPositiveInteger.isPrimitive( 3.0 );
// returns true
bool = isPositiveInteger.isPrimitive( new Number( 3.0 ) );
// returns false
isPositiveInteger.isObject( value )
Tests if a value
is a Number
object having a positive integer
value.
var Number = require( '@stdlib/number-ctor' );
var bool = isPositiveInteger.isObject( 3.0 );
// returns false
bool = isPositiveInteger.isObject( new Number( 3.0 ) );
// returns true
Examples
var Number = require( '@stdlib/number-ctor' );
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' );
var bool = isPositiveInteger( 5.0 );
// returns true
bool = isPositiveInteger( new Number( 5.0 ) );
// returns true
bool = isPositiveInteger( 0.0 );
// returns false
bool = isPositiveInteger( 3.14 );
// returns false
bool = isPositiveInteger( -5.0 );
// returns false
bool = isPositiveInteger( '5' );
// returns false
bool = isPositiveInteger( null );
// returns false
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2022. The Stdlib Authors.