New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

is-four

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-four

Check if a number is equal to 4.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
0
Created
Source

is-four

Join us on Gitter

Check if a number is equal to 4.

Installation

Install the package using npm:

npm install is-four

Usage

The is-four package allows you to determine if a number (or other representations of "four") is equal to 4. It also provides methods to check for approximate equality or proximity to 4.

Basic Example

var isFour = require('is-four');

// Exact match
console.log(isFour(4).four()); // true
console.log(isFour(5).four()); // false

// Works with string representations of "four"
console.log(isFour("four").four()); // true
console.log(isFour("cuatro").four()); // true
console.log(isFour("IV").four()); // true

// Works with binary
console.log(isFour(0b100).four()); // true

roughly.four

// Rough equality
console.log(isFour(3.9).roughly.four()); // true
console.log(isFour(4.4).roughly.four()); // true
console.log(isFour(4.6).roughly.four()); // false

within(y).of.four

// Within 1 of 4
console.log(isFour(3).within(1).of.four()); // true
console.log(isFour(5).within(1).of.four()); // true
console.log(isFour(6).within(1).of.four()); // false

// Within 2 of 4
console.log(isFour(6).within(2).of.four()); // true
console.log(isFour(7).within(2).of.four()); // false

Test

npm test

Keywords

isFour

FAQs

Package last updated on 09 Dec 2024

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