Git Product home page Git Product logo

is-eleven's Introduction

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

is-eleven's People

Contributors

piemekanika avatar dvgololobov avatar snegirekk avatar

Stargazers

Sevapp avatar  avatar Alexandr Nomokonov avatar  avatar  avatar Arseniy avatar  avatar

Watchers

James Cloos avatar  avatar

is-eleven's Issues

Documentation is too much poor

Actually the doc is missing some important examples of usage. What will be returned by the function in such case isEleven('eleven') for example? Looks like it should be 'true', but it's not so clear in the docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.