0.0.9 • Published 3 years ago

is-eleven v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

What is this?

Function that returns true when the given number equals to eleven.

Why to use

When you have to create a function that check whether the value really equals to eleven, there is a big chance to end up with code like this:

const check = val => Number(val) === 11;

Seems good, right? But this code doesn't really work the way you expect it to work. Let's see an example:

check([11]); // true

See? That simple oneliner isn't really a universal solution. And this is where our package comes to play.

const { isEleven } = require('is-eleven');

isEleven([11]); // false, yay!

With is-eleven package, you can forget about javascript's unexpected behavior and concentrate on the logic in your code instead of type checking.

Installation

# npm
npm i --save is-eleven

# yarn
yarn add is-eleven

Usage

const { isEleven } = require('is-eleven');

// or

import { isEleven } from 'is-eleven'

Examples

/* true */
isEleven(11);
isEleven(0b1011);
isEleven('11');
isEleven('  11');

/* false */
isEleven(12);
isEleven([11]);
isEleven(0x11);
isEleven('12');
isEleven('eleven');
isEleven('foo');
isEleven('11foo');
0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago