is-eleven

0.0.9 • Public • Published

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');

Readme

Keywords

Package Sidebar

Install

npm i is-eleven

Weekly Downloads

0

Version

0.0.9

License

MIT

Unpacked Size

5.38 kB

Total Files

6

Last publish

Collaborators

  • piemekanika