npm

5 Most Depended-upon NPM Packages

July 15, 2014

So after my last post on npm packages being removed, I started to realise that I don’t know that many packages and most of the times I use what was already installed in the project. So I took to the interwebs looking for some most used packages. This led me to the list of the most depended-upon packages and here is a run down of the top 5:

 

Underscore

6481 Packages

Underscore is a until library that is not only used for NodeJs application but for any JavaScript application, it can be easily seen by the signature “_.”  with methods that can manage a wide range of action from simple null and undefined checks to searching, filtering and mapping arrays. I use underscore currently with an Angular application to add more functionality to arrays.  The most popular methods include _.each, _.some and _.uniq. Looping an array, searching an array and removing duplicates are all simple operations but do require some redundant code. Underscore provides a simple to use array of helper methods all working from closures. Although recent advancements in JavaScript performance has seen other libraries such as Lazy JS come out and claim to be faster than underscore.

 

Async

5833 packages

Async is a utility package that provides powerful functions for working with asynchronous JavaScript. It supports usage with Node and the browser. Async allows you to process a block of data using a predefined function and deal with the results. This can be very useful for dealing with the opening and processing of multiple files. All these functions assume you follow the Node.js convention of providing a single callback as the last argument of your async function. I have yet to work with this library,as the library is built around async processing I feel something like Q or another promise library could be used instead.

 

Request

4905 packages

Request a simple lightweight and easy to use http library, providing the standard http CRUD methods. The request developers boast that the library is the easiest to use, I have used this before on some project for talking to third party APIs. This has proved tricky when you run into same site origin errors, however this was due to the scenario that I was working with.  The below code shows how easy request is to use.

 Lo-Dash

 

3985 packages

Lo-dash is another utility library that actually was the parent to the above mentioned underscore library. It contains many of the method’s such as map, each and some other advanced functions for creating curried functions and other patterns.  It has since become a superset of Underscore, providing more consistent API behavior, more features (like AMD support, deep clone, and deep merge), more thorough documentation and unit tests (tests which run in Node, Ringo, Rhino, Narwhal, PhantomJS, and browsers), better overall performance and optimizations for large arrays/object iteration, and more flexibility with custom builds and template pre-compilation utilities.

Commander

 

3294 packages

Commander is a on stop shop for command line integration with Node JS.  Following a method chaining structure commander allows you to pass options for the shell command. The library is strongly influenced by the Ruby commander gem. The main purpose of the commander package is to create a command line interface for your application. A very useful feature is the auto generation of help information and example is shown below:  

 

Tags: , ,

  • http://www.ponyfoo.com/ Nicolás Bevacqua

    I love Lo-Dash, I use it very often, and the custom builds are also published on npm, for instance if you just need lodash.where you can pull it from npm individually[1]. Similar packages are available for every method.

    On the `async` topic, I wrote an alternative to `async`, called `contra`, which is 10 times smaller and has tests for IE6+ browsers. It’s also a bit more consistent and doesn’t have all of the methods found in `async`, while it has some other methods like a more feature-rich `queue` implementation and an event emitter variant in it.

    [1]: https://www.npmjs.org/package/lodash.where
    [2]: https://github.com/bevacqua/contra

    • chrislaughlin

      Just had a quick look at the _.where func looks very powerful and very useful. Reminds me of the searching functionality that comes with most NoSQL databases, I have had times where I want to find a object based on a prop and each time had to write a custom loop and had code the IF statement to find the object. Contra looks very cool but what is the key binding for that char :) I could see that being a pain for people who have never used seen the library before. However will be following Contra and maybe get a post on it in the future.

      • http://www.ponyfoo.com/ Nicolás Bevacqua

        Yeah, that’s exactly the reason why contra is available on the `contra` global and not published as `λ`.

        • chrislaughlin

          Ah cool, was not sure looking at the examples on Github if you needed to use `λ`.functionName….. Will definitely have a play about with it,

  • http://tur-nr.github.io/ Christopher Turner

    Async FTW!!!

  • alex

    Cool list, it might be a different definition of parent but I believe lo-dash came after underscore in an effort to improve and add onto it.

    Might be relevant if someone wanted to choose one or the other (go lo-dash!)

    http://stackoverflow.com/questions/13789618/differences-between-lodash-and-underscore

    • chrislaughlin

      I was a little caught out with this myself, which came first? I had thought it was underscore but was told it was the other way around.

      • alex

        Looks like it was based on underscore 1.6.0 from the header in lodash.

        Probably it doesn’t matter in the long run! Have a good weekend and thanks for summarizing the list, looking forward to checking out the others on the top :-)

        • chrislaughlin

          Thanks man you to :)