186186 < div id ="sidebar " class ="interface ">
187187
188188 < a class ="toc_title " href ="# ">
189- Underscore.js < span class ="version "> (1.10.2 )</ span >
189+ Underscore.js < span class ="version "> (1.11.0 )</ span >
190190 </ a >
191191 < ul class ="toc_section ">
192192 < li > » < a href ="https://github.com/jashkenas/underscore "> GitHub Repository</ a > </ li >
193193 < li > » < a href ="docs/modules/index-all.html "> Annotated Source (modular)</ a > </ li >
194194 < li > » < a href ="docs/underscore-esm.html "> Annotated Source (single read)</ a > </ li >
195195 < li > » < a href ="https://documentcloud.github.io/underscore-contrib/ "> Underscore-contrib</ a > </ li >
196+ < li > » < a href ="https://twitter.com/underscoredotjs "> Twitter</ a > </ li >
196197 </ ul >
197198
198199 < input id ="function_filter " placeholder ="Filter " type ="text " autofocus />
333334 < li data-name ="isWeakMap "> - < a href ="#isWeakMap "> isWeakMap</ a > </ li >
334335 < li data-name ="isSet "> - < a href ="#isSet "> isSet</ a > </ li >
335336 < li data-name ="isWeakSet "> - < a href ="#isWeakSet "> isWeakSet</ a > </ li >
337+ < li data-name ="isArrayBuffer "> - < a href ="#isArrayBuffer "> isArrayBuffer</ a > </ li >
338+ < li data-name ="isDataView "> - < a href ="#isDataView "> isDataView</ a > </ li >
339+ < li data-name ="isTypedArray " data-aliases ="isInt8Array isUint8Array isUint8ClampedArray isInt16Array isUint16Array isInt32Array isUint32Array isBigInt64Array isBigUint64Array isFloat32Array isFloat64Array "> - < a href ="#isTypedArray "> isTypedArray</ a > </ li >
336340 < li data-name ="isNaN "> - < a href ="#isNaN "> isNaN</ a > </ li >
337341 < li data-name ="isNull "> - < a href ="#isNull "> isNull</ a > </ li >
338342 < li data-name ="isUndefined "> - < a href ="#isUndefined "> isUndefined</ a > </ li >
427431 </ p >
428432
429433 < p >
430- You may also read through the < a href ="docs/underscore.html "> annotated source code</ a > .
434+ You may also read through the < a
435+ href ="docs/underscore-esm.html "> annotated source code</ a > . There is a < a
436+ href ="docs/modules/index-all.html "> modular version</ a > with clickable
437+ import references as well.
438+ </ p >
439+
440+ < p >
441+ You may choose between monolithic and modular imports. There is a quick
442+ summary of the options below, as well as a more comprehensive
443+ discussion in < a
444+ href ="https://juliangonggrijp.com/article/introducing-modular-underscore.html "
445+ > the article</ a > .
431446 </ p >
432447
433448 < p >
447462 < i > Underscore is an open-source component of < a href ="https://documentcloud.org/ "> DocumentCloud</ a > .</ i >
448463 </ p >
449464
450- < h2 > v1.10.2 Downloads < i style ="padding-left: 12px; font-size:12px; "> (Right-click, and use "Save As")</ i > </ h2 >
465+ < h2 > v1.11.0 Downloads < i style ="padding-left: 12px; font-size:12px; "> (Right-click, and use "Save As")</ i > </ h2 >
451466
452467 < table >
453468 < tr >
454- < td class ="dl-link "> < a href ="modules/index.js "> ES Module</ a > </ td >
469+ < td class ="dl-link "> < a href ="underscore-esm.js "> ESM (Development)</ a > </ td >
470+ < td >
471+ < i > 62kb, Uncompressed with Plentiful Comments</ i >
472+ < small > (< a href ="underscore-esm.js.map "> Source Map</ a > )</ small >
473+ </ td >
474+ </ tr >
475+ < tr >
476+ < td class ="dl-link "> < a href ="underscore-esm-min.js "> ESM (Production)</ a > </ td >
455477 < td >
456- < i > 56kb, Uncompressed with Plentiful Comments</ i >
478+ < i > 8.18kb, Minified and Gzipped</ i >
479+ < small > (< a href ="underscore-esm-min.js.map "> Source Map</ a > )</ small >
457480 </ td >
458481 </ tr >
459482 < tr >
460483 < td class ="dl-link "> < a href ="underscore.js "> UMD (Development)</ a > </ td >
461484 < td >
462- < i > 60kb , Uncompressed with Bountiful Comments</ i >
485+ < i > 64kb , Uncompressed with Bountiful Comments</ i >
463486 < small > (< a href ="underscore.js.map "> Source Map</ a > )</ small >
464487 </ td >
465488 </ tr >
466489 < tr >
467490 < td class ="dl-link "> < a href ="underscore-min.js "> UMD (Production)</ a > </ td >
468491 < td >
469- < i > 6.78kb , Minified and Gzipped</ i >
492+ < i > 7.15kb , Minified and Gzipped</ i >
470493 < small > (< a href ="underscore-min.js.map "> Source Map</ a > )</ small >
471494 </ td >
472495 </ tr >
473496 < tr >
474497 < td colspan ="2 "> < div class ="rule "> </ div > </ td >
475498 </ tr >
476499 < tr >
477- < td class ="dl-link "> < a href ="https://raw.github.com/jashkenas/underscore/master/modules/index .js "> Edge ES Module </ a > </ td >
500+ < td class ="dl-link "> < a href ="https://raw.github.com/jashkenas/underscore/master/underscore-esm .js "> Edge ESM </ a > </ td >
478501 < td > < i > Unreleased, current < tt > master</ tt > , use by your own judgement and at your own risk</ i > </ td >
479502 </ tr >
480503 < tr >
@@ -483,7 +506,36 @@ <h2>v1.10.2 Downloads <i style="padding-left: 12px; font-size:12px;">(Right-clic
483506 </ tr >
484507 </ table >
485508
486- < h2 > Installation</ h2 >
509+ < h2 > v1.11.0 CDN URLs < i style ="padding-left: 12px; font-size:12px; "> (Use with < tt > <script src="..."></script></ tt > )</ i > </ h2 >
510+
511+ < ul >
512+ < li >
513+ < tt > https://cdn.jsdelivr.net/npm/underscore@1.11.0/underscore-min.js</ tt >
514+ </ li >
515+ < li >
516+ < tt > https://cdn.jsdelivr.net/npm/underscore@1.11.0/underscore-esm-min.js</ tt >
517+ </ li >
518+ < li >
519+ < tt > https://unpkg.com/underscore@1.11.0/underscore-min.js</ tt >
520+ </ li >
521+ < li >
522+ < tt > https://unpkg.com/underscore@1.11.0/underscore-esm-min.js</ tt >
523+ </ li >
524+ < li >
525+ < tt > https://pagecdn.io/lib/underscore/1.11.0/underscore-min.js</ tt >
526+ </ li >
527+ < li >
528+ < tt > https://pagecdn.io/lib/underscore/1.11.0/underscore-esm-min.js</ tt >
529+ </ li >
530+ < li >
531+ < tt > https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.11.0/underscore-min.js</ tt >
532+ </ li >
533+ < li >
534+ < tt > https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.11.0/underscore-esm-min.js</ tt >
535+ </ li >
536+ </ ul >
537+
538+ < h2 > Package Installation</ h2 >
487539
488540 < ul >
489541 < li >
@@ -493,22 +545,49 @@ <h2>Installation</h2>
493545 < b > Meteor.js</ b > < tt > meteor add underscore</ tt >
494546 </ li >
495547 < li >
496- < b > Require.js</ b > < tt > require(["underscore"], ...</ tt >
548+ < b > Bower</ b > < tt > bower install underscore</ tt >
549+ </ li >
550+ </ ul >
551+
552+ < h2 > Monolithic Import</ h2 >
553+
554+ < ul >
555+ < li >
556+ < b > ESM</ b > < tt > import _, { map } from 'underscore';</ tt >
497557 </ li >
498558 < li >
499- < b > Bower</ b > < tt > bower install underscore</ tt >
559+ < b > AMD</ b > < tt > require(['underscore'], ...)</ tt >
560+ </ li >
561+ < li >
562+ < b > CommonJS</ b > < tt > var _ = require('underscore');</ tt >
500563 </ li >
501564 < li >
502565 < b > ExtendScript</ b > < tt > #include "underscore.js"</ tt >
503566 </ li >
567+ </ ul >
568+
569+ < h2 > Modular Import</ h2 >
570+
571+ < ul >
572+ < li >
573+ < b > ESM</ b > < tt > import map from 'underscore/modules/map.js'</ tt >
574+ </ li >
575+ < li >
576+ < b > AMD</ b > < tt > require(['underscore/amd/map.js'], ...)</ tt >
577+ </ li >
504578 < li >
505- < b > Rollup</ b > If you want to enable treeshaking and you don’t
506- need the full < tt > _</ tt > object (with all Underscore functions as
507- properties), you can import individual functions by name from
508- < tt > underscore/modules/index</ tt > instead of < tt > underscore</ tt > .
579+ < b > CommonJS</ b > < tt > var map = require('underscore/cjs/map.js');</ tt >
509580 </ li >
510581 </ ul >
511582
583+ < p >
584+ < i > For functions with multiple aliases, the file name of the module is
585+ always the < b > first</ b > name that appears in the documentation. For
586+ example, < tt > _.reduce</ tt > /< tt > _.inject</ tt > /< tt > _.foldl</ tt > is exported
587+ from < tt > underscore/modules/reduce.js</ tt > . Modular usage is mostly
588+ recommended for creating a customized build of Underscore.</ i >
589+ </ p >
590+
512591 < div id ="documentation ">
513592
514593 < h2 id ="collections "> Collection Functions (Arrays or Objects)</ h2 >
@@ -966,17 +1045,24 @@ <h2 id="arrays">Array Functions</h2>
9661045</ pre >
9671046
9681047 < p id ="flatten ">
969- < b class ="header "> flatten</ b > < code > _.flatten(array, [shallow ])</ code >
1048+ < b class ="header "> flatten</ b > < code > _.flatten(array, [depth ])</ code >
9701049 < br />
971- Flattens a nested < b > array</ b > (the nesting can be to any depth). If you
972- pass < b > shallow</ b > , the array will only be flattened a single level.
1050+ Flattens a nested < b > array</ b > . If you pass < tt > true</ tt > or < tt > 1</ tt >
1051+ as the < b > depth</ b > , the array will only be flattened a single level.
1052+ Passing a greater number will cause the flattening to descend deeper
1053+ into the nesting hierarchy. Omitting the < b > depth</ b > argument, or
1054+ passing < tt > false</ tt > or < tt > Infinity</ tt > , flattens the array all the
1055+ way to the deepest nesting level.
9731056 </ p >
9741057 < pre >
9751058_.flatten([1, [2], [3, [[4]]]]);
9761059=> [1, 2, 3, 4];
9771060
9781061_.flatten([1, [2], [3, [[4]]]], true);
9791062=> [1, 2, 3, [[4]]];
1063+
1064+ _.flatten([1, [2], [3, [[4]]]], 2);
1065+ => [1, 2, 3, [4]];
9801066</ pre >
9811067
9821068 < p id ="without ">
@@ -1948,6 +2034,36 @@ <h2 id="objects">Object Functions</h2>
19482034 < pre >
19492035_.isWeakSet(WeakSet());
19502036=> true
2037+ </ pre >
2038+
2039+ < p id ="isArrayBuffer ">
2040+ < b class ="header "> isArrayBuffer</ b > < code > _.isArrayBuffer(object)</ code >
2041+ < br />
2042+ Returns < i > true</ i > if < b > object</ b > is an < a href ="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer "> ArrayBuffer</ a > .
2043+ </ p >
2044+ < pre >
2045+ _.isArrayBuffer(new ArrayBuffer(8));
2046+ => true
2047+ </ pre >
2048+
2049+ < p id ="isDataView ">
2050+ < b class ="header "> isDataView</ b > < code > _.isDataView(object)</ code >
2051+ < br />
2052+ Returns < i > true</ i > if < b > object</ b > is a < a href ="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView "> DataView</ a > .
2053+ </ p >
2054+ < pre >
2055+ _.isDataView(new DataView(new ArrayBuffer(8)));
2056+ => true
2057+ </ pre >
2058+
2059+ < p id ="isTypedArray ">
2060+ < b class ="header "> isTypedArray</ b > < code > _.isTypedArray(object)</ code >
2061+ < br />
2062+ Returns < i > true</ i > if < b > object</ b > is a < a href ="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray "> TypedArray</ a > .
2063+ </ p >
2064+ < pre >
2065+ _.isTypedArray(new Int8Array(8));
2066+ => true
19512067</ pre >
19522068
19532069 < p id ="isNaN ">
@@ -2484,6 +2600,87 @@ <h2 id="notes">Notes</h2>
24842600
24852601 < h2 id ="changelog "> Change Log</ h2 >
24862602
2603+ < p id ="1.11.0 ">
2604+ < b class ="header "> 1.11.0</ b > — < small > < i > <!-- TODO: date --> </ i > </ small > — < a href ="https://github.com/jashkenas/underscore/compare/1.10.2...1.11.0 "> Diff</ a > — < a href ="https://cdn.rawgit.com/jashkenas/underscore/1.11.0/index.html "> Docs</ a > — < a href ="https://juliangonggrijp.com/article/introducing-modular-underscore.html "> Article</ a > < br />
2605+ < ul >
2606+ < li >
2607+ Puts the source of every function in a separate module, following
2608+ up on the move to EcmaScript 6 < tt > export</ tt > notation in < a
2609+ href ="#1.10.0 "> version 1.10.0</ a > . AMD and CommonJS versions of the
2610+ function modules are provided as well. This brings perfect
2611+ treeshaking to all users and unlocks the possibility to create
2612+ arbitrary custom Underscore builds without code size overhead.
2613+ < tt > modules/index.js</ tt > is still present and the UMD bundle is
2614+ still recommended for most users.< br >
2615+ Since the modularization obfuscates the diff, piecewise diffs are provided below.
2616+ < ul >
2617+ < li > < a href ="https://github.com/jashkenas/underscore/compare/1.10.2...3236023 ">
2618+ Changes before modularization
2619+ </ a > </ li >
2620+ < li > < a href ="https://github.com/jashkenas/underscore/compare/3236023...240d60a ">
2621+ Modularization itself
2622+ </ a > </ li >
2623+ < li > < a href ="https://github.com/jashkenas/underscore/compare/240d60a...1.11.0 ">
2624+ Changes after modularization
2625+ </ a > </ li >
2626+ </ ul >
2627+ </ li >
2628+ < li >
2629+ Adds a monolithic bundle in EcmaScript 6 module format,
2630+ < tt > underscore-esm.js</ tt > , as a modern alternative to the
2631+ monolithic UMD bundle. Users who want to use ES module imports in
2632+ the browser are advised to use this new bundle instead of
2633+ < tt > modules/index.js</ tt > , because < tt > underscore-esm.js</ tt >
2634+ provides the complete Underscore interface in a single download.
2635+ </ li >
2636+ < li >
2637+ Adds a modular version of the annotated source, reflecting the full
2638+ internal structure of the primary source code.
2639+ </ li >
2640+ < li >
2641+ Adds < tt > _.isArrayBuffer</ tt > , < tt > _.isDataView</ tt > and
2642+ < tt > _.isTypedArray</ tt > functions, as well as support for the
2643+ corresponding value types to < tt > _.isEqual</ tt > .
2644+ </ li >
2645+ < li >
2646+ Adds the option to flatten arrays to a specific depth:
2647+ < tt > _.flatten(anArray, 3)</ tt > .
2648+ </ li >
2649+ < li >
2650+ Adds < tt > _.transpose</ tt > as an alias to < tt > _.unzip</ tt > .
2651+ </ li >
2652+ < li >
2653+ Fixes an inconsistency where < tt > Array.prototype</ tt > methods on
2654+ the Underscore wrapper would error when the wrapped value is
2655+ < tt > null</ tt > or < tt > undefined</ tt > . These methods now perform a
2656+ no-op on null values like the other Underscore functions.
2657+ </ li >
2658+ < li >
2659+ Fixes a bug that caused < tt > _.first</ tt > and < tt > _.last</ tt > to
2660+ return < tt > []</ tt > instead of < tt > undefined</ tt > for empty arrays
2661+ when used as an iteratee.
2662+ </ li >
2663+ < li >
2664+ Fixes a regression introduced in version 1.9.0 that caused
2665+ < tt > _.bindAll</ tt > to return < tt > undefined</ tt > instead of the
2666+ bound object.
2667+ </ li >
2668+ < li >
2669+ Restores continuous integration testing with Travis CI.
2670+ </ li >
2671+ < li >
2672+ Replaces stigmatizing
2673+ “whitelist”/“blacklist” terminology in
2674+ comments and documentation by neutral
2675+ “allowed”/“disallowed” terminology.
2676+ </ li >
2677+ < li >
2678+ Various clarifications and minor enhancements and fixes to the
2679+ documentation, source comments and a test.
2680+ </ li >
2681+ </ ul >
2682+ </ p >
2683+
24872684 < p id ="1.10.2 ">
24882685 < b class ="header "> 1.10.2</ b > — < small > < i > March 30, 2020</ i > </ small > — < a href ="https://github.com/jashkenas/underscore/compare/1.10.1...1.10.2 "> Diff</ a > — < a href ="https://cdn.rawgit.com/jashkenas/underscore/1.10.2/index.html "> Docs</ a > < br />
24892686 < ul >
0 commit comments