
is-even - tosh
https://www.npmjs.com/package/is-even
======
wsc981
Kinda funny such a package exists. I was looking at the source and to be fair
the author states "I created this in 2014, when I was learning how to
program.". The project is archived.

Anyways, source seems to be as such:

    
    
      'use strict';
    
      var isOdd = require('is-odd');
    
      module.exports = function isEven(i) {
        return !isOdd(i);
      };
    

Then we look as the is-odd package and we see the following:

    
    
      'use strict';
    
      const isNumber = require('is-number');
    
      module.exports = function isOdd(value) {
        const n = Math.abs(value);
        if (!isNumber(n)) {
          throw new TypeError('expected a number');
        }
        if (!Number.isInteger(n)) {
          throw new Error('expected an integer');
        }
        if (!Number.isSafeInteger(n)) {
          throw new Error('value exceeds maximum safe integer');
        }
        return (n % 2) === 1;
      };
    

It's kinda sad that JavaScript needs so many lines of code to figure out if a
number is even, but understandable due to its dynamic nature. Not even sure
how many lines the is-number package contains, but I'm guessing it's more than
2. And who knows, perhaps is-number has other dependencies?

I'm no web dev, but I feel it'd be nice if there was some modern, statically
typed language integrated into every browser that would be a viable
replacement of JavaScript.

~~~
krapp
>It's kinda sad that JavaScript needs so many lines of code to figure out if a
number is even, but understandable due to its dynamic nature

It doesn't. Javascript doesn't need this many lines of code to figure out if a
number is even. A simple modulo 2 check works just fine.

~~~
wsc981
Ah, so I guess it's just some over-engineered piece of code. Again I'm no web
dev, so very limited JavaScript experience.

Well, at least the author made it clear it was code from back when he was
still learning JavaScript.

~~~
krapp
Yeah, unfortunately the entire javascript ecosystem is ridiculously over-
engineered.

In my day, all you needed was a text editor. Now you need a package manager
and an abritrarily deep dependency tree of libraries, a complex toolchain and
a test framework to write Hello World... often in _another language_ that gets
compiled into javascript.

It was a simple, almost elegant language. You looked at a JQuery module, and
you could understand it, modify it on your own, and use it without needing to
understand the quirks of sixteen distinct build systems that would just be
obsolete by next month. No one could delete a repository and break your
software. There wasn't a single company and a single package manager basically
controlling everything. There was _competition_ and innovation and...

I'll be in the angry dome if anyone needs me.

