@is-it/fifteen is a lightweight, flexible utility to check if a number equals 15. With added options for loose comparison, binary numbers, negative values, and more, this package is designed to meet modern development needs while being simple to use.
- Lightweight and Fast: Minimal size for optimal performance.
- Flexible Comparisons: Supports strict or loose equality (
===
or==
). - Binary Number Support: Allows checking binary strings like
'1111'
(binary for 15). - Negative Number Checks: Enables validation of
-15
when needed. - JavaScript and TypeScript Ready: Comes with full TypeScript support for type safety.
- No Dependencies: Pure and lean package with zero dependencies.
- Developer Friendly: Easy to integrate with any project, big or small.
Install the package via npm or any other package managers:
npm install @is-it/fifteen
You can use @is-it/fifteen in both JavaScript and TypeScript projects.
import { isItFifteen } from '@is-it/fifteen'
console.log(isItFifteen(15)) // true
console.log(isItFifteen('15', { strict: false })) // true
console.log(isItFifteen(-15, { allowNegative: true })) // true
console.log(isItFifteen('1111', { checkBinary: true })) // true
Checks if a number or string is equal to 15 based on provided options.
value
(number | string
):
The number or string to check.options
(CheckOptions
, optional):
An object to configure comparison behavior:strict
(boolean
):
Iftrue
, uses strict equality (===
) for comparison. Default istrue
.allowNegative
(boolean
):
Iftrue
, allows checking for-15
. Default isfalse
.checkBinary
(boolean
):
Iftrue
, treats binary strings like'1111'
as valid input. Default isfalse
.
boolean
:
true
if the value matches the criteria, otherwisefalse
.
console.log(isItFifteen(15)) // true
console.log(isItFifteen('15')) // false
console.log(isItFifteen('15', { strict: false })) // true
console.log(isItFifteen(15, { strict: false })) // true
console.log(isItFifteen(-15, { allowNegative: true })) // true
console.log(isItFifteen(-15)) // false (default behavior)
console.log(isItFifteen('1111', { checkBinary: true })) // true (binary for 15)
console.log(isItFifteen('1111')) // false (default behavior)
We welcome contributions! Here's how you can help:
- Fork the repository.
- Clone your forked repository to your local machine.
- Create a new branch for your feature or bug fix.
- Write tests for your changes if applicable.
- Open a pull request with a clear description of your changes.
This project is licensed under the MIT License.