1.0.14 • Published 7 months ago

nearest-prime v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

npm (scoped) NPM npm Sponsor

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 allowInvalidInput which defaults to false. When passed as true, numbers less than 1 will return 2 instead of undefined

How to use

  • In your project, run
npm install nearest-prime

to install the latest version to your node_modules dependency folder

  • In the file you'd like to use the nearestPrime function, add
import { nearestPrime } from 'nearest-prime'

to the top of the file

In Action

alt text

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.

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago