1.0.14 • Published 1 year ago
nearest-prime v1.0.14
Nearest Prime
Overview
- This package exports one function with the signature:
nearestPrime(input: number | string, allowInvalidInput: boolean = false): number | undefined- The function takes a number (including decimal numbers), and returns the nearest prime number, rounding up if necessary. (Ex. passing 6 will return 7, not 5)
- The function takes an optional argument
allowInvalidInputwhich defaults to false. When passed as true, numbers less than 1 will return2instead ofundefined
How to use
- In your project, run
npm install nearest-primeto install the latest version to your node_modules dependency folder
- In the file you'd like to use the
nearestPrimefunction, add
import { nearestPrime } from 'nearest-prime'to the top of the file
In Action

Fixes & Improvements
Head over to the GitHub Issues tab to report a bug or suggest an improvement. Feel free to contribute to the code or documentation by raising a pull request.