• # Autres exemples rigolos

    Posté par (site web personnel) . En réponse au journal Comment 11 lignes de code ont provoqué un #npmgate. Évalué à 10.

    On pourrait croire que left-pad est un exemple qui sort de l'ordinaire... mais en JS, non, malheureusement.

    http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/

    There’s a package called isArray that has 880,000 downloads a day, and 18 million downloads in February of 2016. It has 72 dependent NPM packages. Here’s it’s entire 1 line of code:

    return toString.call(arr) == '[object Array]';

    There’s a package called is-positive-integer (GitHub) that is 4 lines long and as of yesterday required 3 dependencies to use. The author has since refactored it to require 0 dependencies, but I have to wonder why it wasn’t that way in the first place.
    A fresh install of the Babel package includes 41,000 files
    A blank jspm/npm-based app template now starts with 28,000+ files

    Mais comment une lib qui fait quelque chose d'aussi compliqué que vérifier qu'un objet est un entier positif ou nul peut-elle avoir 3 dépendances ? C'est simple :

    var passAll = require('101/pass-all')
    var isPositive = require('is-positive')
    var isInteger = require('is-integer')
    module.exports = passAll(isPositive, isInteger)