1.0.14 • Published 10 months ago

nearest-prime v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
10 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

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago