Re:4B If Statements
by RugnirViking on Thursday December 28, 2023 @08:16AM
(#38793150)
A more catastrophic number of programmers a) dont know how dependencies work and b) think everyone else are idiots.
Re:4B If Statements
by kristopolous on Thursday December 28, 2023 @12:15PM
(#38795681)
Maybe the person you're talking to on hn isn't a total moron.
Perhaps, I solidly understand how dependencies work and in this case my observation is correct
Someone made the decision to use that and someone thought using stuff made by a person's who makes those kinds of decisions was a good idea and so on.
You can git blame dependencies all the way down and research the parties involved. I've done it, built tools for it even.
A stack of people who make bad decisions doesn't make good software.
Re:4B If Statements
by robertlagrant on Friday December 29, 2023 @04:53PM
(#38810675)
More likely the author made another, more useful, package that uses it.
I have not read the source but I had always assumed that this was the lovingly crafted effort of someone who is intimately familiar with the js standard making sure that some hypothetical expression like ![1] is neither odd nor even. Surely the idea that modulo is beyond developers is too horrifying to contemplate.
Re:4B If Statements
by umanwizard on Thursday December 28, 2023 @11:24AM
(#38795070)
Here you go:
/*!
* is-odd <https://github.com/jonschlinkert/is-odd>
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'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 does some checking the `value` is an integer in the safe range, which doesn't even seem right to me. Why shouldn't you be able to call this on integers outside the save range?All non-safe integers are even, yes?
(10e15 + 1) % 2 === 0
I mean we're talking FizzBuzz secret sauce here. This must be total black magic for a catastrophic percentage of programmers