npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

underscore-es

v1.9.8

Published

javaScript's functional programming helper library for ES6 and beyond.

Readme

                   __
                  /\ \                                                         __
 __  __    ___    \_\ \     __   _ __   ____    ___    ___   _ __    __       /\_\    ____
/\ \/\ \ /' _ `\  /'_  \  /'__`\/\  __\/ ,__\  / ___\ / __`\/\  __\/'__`\     \/\ \  /',__\
\ \ \_\ \/\ \/\ \/\ \ \ \/\  __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\  __/  __  \ \ \/\__, `\
 \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
  \/___/  \/_/\/_/\/__,_ /\/____/ \/_/ \/___/  \/____/\/___/  \/_/ \/____/\/_//\ \_\ \/___/
                                                                              \ \____/
                                                                               \/___/

Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects. It's available in ES6 and UMD (cjs, amd, iife) formats

ES6 & Beyond usage:

  • partial importation of features (just import what you need, with a name that suits you).
import _template from 'underscore-es/template';

var basicTemplate = _template("Ok, i use <%= builder %> for my es6 and beyond stuff !");
var result = basicTemplate({builder: 'rollup'});
console.log( result ); 
// => "Ok, i use rollup for my es6 and beyond stuff !"

nb: only _chain isn't available in this case. another way to use chaining feature here is through _compose or _use.

import _use from 'underscore-es/use';
import _initial from 'underscore-es/initial';
import _filter from 'underscore-es/filter';
import _union from 'underscore-es/union';
import _last from 'underscore-es/last';

function note (num) {return 'result: '+ (num + 10) + " / 20"}
var test = _use([1, 2, 3, 6, 9])
          .do(_union, [1, 3, 11], [2, 6])
          .do([], Array.prototype.concat, [10, 14]) // or simply .do([], [].concat, [10, 14])
          .do(_filter, (num) => num % 2 == 0)
          .do(_initial)
          .do(_last)
          .do(note)
          .value();
console.log( test );
// => result: 20 / 20

import features depending of their category

import * as $co from 'underscore-es/_collections';
import * as $ar from 'underscore-es/_arrays';
import * as $ob from 'underscore-es/_objects';
import * as $fu from 'underscore-es/_functions';
import * as $ut from 'underscore-es/_utilities';

console.log( $ar._union([4,7], [7,0,3]) );
// => [4, 7, 0, 3]
  • global importation of all features
import _ from 'underscore-es'; // or from 'underscore-es/_namespace'

_.chain([4,7])
 .union([7,0,3])
 .initial()
 .reverse()
 .head()
 .value()
 // => 0
  • breaking changes

Since this underscore source code has been rewritten to be more es6 friendly :

the _.templateSettings property is now _.template.settings

import _template from 'underscore-es/template';

_template.settings = {
   evaluate: /\{\{([\s\S]+?)\}\}/g,
   interpolate: /\{\{=([\s\S]+?)\}\}/g
};

var custom = _template('<ul>{{ for (var key in people) { }}<li>{{= people[key] }}</li>{{ } }}</ul>');
var result = custom({people: {moe: 'Moe', larry: 'Larry', curly: 'Curly'}});
console.log( result );
// => <ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>

the _.iteratee shall now (for global importation) be overwritten through _.setIteratee([fn]) method

import _iteratee, {_setIteratee} from './underscore-es/iteratee';
import _countBy from './underscore-es/countBy';
import _isRegExp from './underscore-es/isRegExp';
import _filter from './underscore-es/filter';

_setIteratee( function(value) {
   // RegEx values return a function that returns the number of matches
   if (_isRegExp(value)) return function(obj) {
      return (obj.match(value) || []).length;
   };
   return value;
});

// test some methods that claim to be transformed through `_iteratee`
var collection = ['foo', 'bar', 'bbiz'];
console.log(_countBy(collection, /b/g))
// => {0: 1, 1: 1, 2: 1}
console.log(_filter(collection, /b/g))
// => ['bar', 'bbiz']

Documentation is the place to find what you need to know !

This project adheres to a code of conduct. By participating, you are expected to uphold this code.

For support and questions, please use the gitter channel or stackoverflow

Underscore is an open-sourced component of DocumentCloud: https://github.com/documentcloud

Many thanks to our contributors: https://github.com/tnga/underscore-es/contributors https://github.com/jashkenas/underscore/contributors