Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-natural-number

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-natural-number

Check if a value is a natural number

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5M
decreased by-16.33%
Maintainers
1
Weekly downloads
 
Created

What is is-natural-number?

The is-natural-number npm package is a utility for checking if a given value is a natural number. A natural number is a non-negative integer (0, 1, 2, 3, ...). This package is useful for validation purposes in various applications where ensuring the input is a natural number is necessary.

What are is-natural-number's main functionalities?

Basic Validation

This feature allows you to check if a given value is a natural number. It returns true for non-negative integers and false otherwise.

const isNaturalNumber = require('is-natural-number');

console.log(isNaturalNumber(5)); // true
console.log(isNaturalNumber(-1)); // false
console.log(isNaturalNumber(0)); // true
console.log(isNaturalNumber(3.14)); // false

Strict Mode

This feature allows you to enable strict mode where zero is not considered a natural number. By default, zero is included as a natural number.

const isNaturalNumber = require('is-natural-number');

console.log(isNaturalNumber(5, { includeZero: false })); // true
console.log(isNaturalNumber(0, { includeZero: false })); // false

Other packages similar to is-natural-number

Keywords

FAQs

Package last updated on 16 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc