diff --git a/bower.json b/bower.json index a53714ccb..38f3d3e75 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "underscore", - "version": "1.8.0", + "version": "1.8.1", "main": "underscore.js", "keywords": ["util", "functional", "server", "client", "browser"], "ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md"] diff --git a/component.json b/component.json index 760a1da01..9a2d5a267 100644 --- a/component.json +++ b/component.json @@ -5,6 +5,6 @@ "repo" : "jashkenas/underscore", "main" : "underscore.js", "scripts" : ["underscore.js"], - "version" : "1.8.0", + "version" : "1.8.1", "license" : "MIT" } diff --git a/docs/underscore.html b/docs/underscore.html index 0cbfad36c..726cc10ef 100644 --- a/docs/underscore.html +++ b/docs/underscore.html @@ -27,7 +27,7 @@

underscore.js

-
Underscore.js 1.8.0
+              
Underscore.js 1.8.1
 http://underscorejs.org
 (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 Underscore may be freely distributed under the MIT license.
@@ -155,7 +155,7 @@ 

Baseline setup

-

Reusable constructor function for prototype setting.

+

Naked function reference for surrogate-prototype-swapping.

@@ -217,7 +217,7 @@

Baseline setup

-
  _.VERSION = '1.8.0';
+
  _.VERSION = '1.8.1';
@@ -1620,9 +1620,10 @@

Function (ahem) Functions

if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); var args = slice.call(arguments, 2); - return function bound() { + var bound = function() { return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); }; + return bound; };
@@ -1642,7 +1643,7 @@

Function (ahem) Functions

  _.partial = function(func) {
     var boundArgs = slice.call(arguments, 1);
-    return function bound() {
+    var bound = function() {
       var position = 0, length = boundArgs.length;
       var args = Array(length);
       for (var i = 0; i < length; i++) {
@@ -1651,6 +1652,7 @@ 

Function (ahem) Functions

while (position < arguments.length) args.push(arguments[position++]); return executeBound(func, bound, this, this, args); }; + return bound; };
@@ -1994,36 +1996,6 @@

Object Functions

-

Keys in IE < 9 that won’t be iterated by for key in ... and thus missed.

- - - -
  var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
-  var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
-                      'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
-
-  function collectNonEnumProps(obj, keys) {
-    var nonEnumIdx = nonEnumerableProps.length;
-    var proto = typeof obj.constructor === 'function' ? FuncProto : ObjProto;
-
-    while (nonEnumIdx--) {
-      var prop = nonEnumerableProps[nonEnumIdx];
-      if (prop === 'constructor' ? _.has(obj, prop) : prop in obj &&
-        obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
-        keys.push(prop);
-      }
-    }
-  }
- - - - -
  • -
    - -
    - -

    Retrieve the names of an object’s own properties. Delegates to ECMAScript 5‘s native Object.keys

    @@ -2033,33 +2005,18 @@

    Object Functions

    if (!_.isObject(obj)) return []; if (nativeKeys) return nativeKeys(obj); var keys = []; - for (var key in obj) if (_.has(obj, key)) keys.push(key);
  • - - - - -
  • -
    - -
    - -
    -

    Ahem, IE < 9.

    - -
    - -
        if (hasEnumBug) collectNonEnumProps(obj, keys);
    +    for (var key in obj) if (_.has(obj, key)) keys.push(key);
         return keys;
       };
  • -
  • +
  • - +

    Retrieve all the property names of an object.

    @@ -2068,33 +2025,18 @@

    Object Functions

      _.allKeys = function(obj) {
         if (!_.isObject(obj)) return [];
         var keys = [];
    -    for (var key in obj) keys.push(key);
    - -
  • - - -
  • -
    - -
    - -
    -

    Ahem, IE < 9.

    - -
    - -
        if (hasEnumBug) collectNonEnumProps(obj, keys);
    +    for (var key in obj) keys.push(key);
         return keys;
       };
  • -
  • +
  • - +

    Retrieve the values of an object’s properties.

    @@ -2113,11 +2055,11 @@

    Object Functions

  • -
  • +
  • - +

    Returns the results of applying the iteratee to each element of the object In contrast to _.map it returns an object

    @@ -2140,11 +2082,11 @@

    Object Functions

  • -
  • +
  • - +

    Convert an object into a list of [key, value] pairs.

    @@ -2163,11 +2105,11 @@

    Object Functions

  • -
  • +
  • - +

    Invert the keys and values of an object. The values must be serializable.

    @@ -2185,11 +2127,11 @@

    Object Functions

  • -
  • +
  • - +

    Return a sorted list of the function names available on the object. Aliased as methods

    @@ -2207,11 +2149,11 @@

    Object Functions

  • -
  • +
  • - +

    Extend a given object with all the properties in passed-in object(s).

    @@ -2222,11 +2164,11 @@

    Object Functions

  • -
  • +
  • - +

    Assigns a given object with all the own properties in the passed-in object(s) (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)

    @@ -2238,11 +2180,11 @@

    Object Functions

  • -
  • +
  • - +

    Returns the first key on an object that passes a predicate test

    @@ -2260,11 +2202,11 @@

    Object Functions

  • -
  • +
  • - +

    Return a copy of the object only containing the whitelisted properties.

    @@ -2275,7 +2217,9 @@

    Object Functions

    if (obj == null) return result; if (_.isFunction(iteratee)) { iteratee = optimizeCb(iteratee, context); - for (key in obj) { + var keys = _.allKeys(obj); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; var value = obj[key]; if (iteratee(value, key, obj)) result[key] = value; } @@ -2293,11 +2237,11 @@

    Object Functions

  • -
  • +
  • - +

    Return a copy of the object without the blacklisted properties.

    @@ -2318,11 +2262,11 @@

    Object Functions

  • -
  • +
  • - +

    Fill in a given object with default properties.

    @@ -2333,11 +2277,11 @@

    Object Functions

  • -
  • +
  • - +

    Create a (shallow-cloned) duplicate of an object.

    @@ -2351,11 +2295,11 @@

    Object Functions

  • -
  • +
  • - +

    Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to “tap into” a method chain, in @@ -2371,11 +2315,11 @@

    Object Functions

  • -
  • +
  • - +

    Returns whether an object has a given set of key:value pairs.

    @@ -2395,11 +2339,11 @@

    Object Functions

  • -
  • +
  • - +

    Internal recursive comparison function for isEqual.

    @@ -2410,11 +2354,11 @@

    Object Functions

  • -
  • +
  • - +

    Identical objects are equal. 0 === -0, but they aren’t identical. See the Harmony egal proposal.

    @@ -2426,11 +2370,11 @@

    Object Functions

  • -
  • +
  • - +

    A strict comparison is necessary because null == undefined.

    @@ -2441,11 +2385,11 @@

    Object Functions

  • -
  • +
  • - +

    Unwrap any wrapped objects.

    @@ -2457,11 +2401,11 @@

    Object Functions

  • -
  • +
  • - +

    Compare [[Class]] names.

    @@ -2474,11 +2418,11 @@

    Object Functions

  • -
  • +
  • - +

    Strings, numbers, regular expressions, dates, and booleans are compared by value.

    @@ -2489,11 +2433,11 @@

    Object Functions

  • -
  • +
  • - +

    RegExps are coerced to strings for comparison (Note: ‘’ + /a/i === ‘/a/i’)

    @@ -2504,11 +2448,11 @@

    Object Functions

  • -
  • +
  • - +

    Primitives and their corresponding object wrappers are equivalent; thus, "5" is equivalent to new String("5").

    @@ -2521,11 +2465,11 @@

    Object Functions

  • -
  • +
  • - +

    NaNs are equivalent, but non-reflexive. Object(NaN) is equivalent to NaN

    @@ -2537,11 +2481,11 @@

    Object Functions

  • -
  • +
  • - +

    An egal comparison is performed for other numeric values.

    @@ -2554,11 +2498,11 @@

    Object Functions

  • -
  • +
  • - +

    Coerce dates and booleans to numeric primitive values. Dates are compared by their millisecond representations. Note that invalid dates with millisecond representations @@ -2576,11 +2520,11 @@

    Object Functions

  • -
  • +
  • - +

    Objects with different constructors are not equivalent, but Objects or Arrays from different frames are.

    @@ -2598,11 +2542,11 @@

    Object Functions

  • -
  • +
  • - +

    Assume equality for cyclic structures. The algorithm for detecting cyclic structures is adapted from ES 5.1 section 15.12.3, abstract operation JO.

    @@ -2612,11 +2556,11 @@

    Object Functions

  • -
  • +
  • - +

    Initializing stack of traversed objects. It’s done here since we only need them for objects and arrays comparison.

    @@ -2631,11 +2575,11 @@

    Object Functions

  • -
  • +
  • - +

    Linear search. Performance is inversely proportional to the number of unique nested structures.

    @@ -2648,11 +2592,11 @@

    Object Functions

  • -
  • +
  • - +

    Add the first object to the stack of traversed objects.

    @@ -2664,11 +2608,11 @@

    Object Functions

  • -
  • +
  • - +

    Recursively compare objects and arrays.

    @@ -2679,11 +2623,11 @@

    Object Functions

  • -
  • +
  • - +

    Compare array lengths to determine if a deep comparison is necessary.

    @@ -2695,11 +2639,11 @@

    Object Functions

  • -
  • +
  • - +

    Deep compare the contents, ignoring non-numeric properties.

    @@ -2713,11 +2657,11 @@

    Object Functions

  • -
  • +
  • - +

    Deep compare objects.

    @@ -2729,11 +2673,11 @@

    Object Functions

  • -
  • +
  • - +

    Ensure that both objects contain the same number of properties before comparing deep equality.

    @@ -2745,11 +2689,11 @@

    Object Functions

  • -
  • +
  • - +

    Deep compare each member

    @@ -2763,11 +2707,11 @@

    Object Functions

  • -
  • +
  • - +

    Remove the first object from the stack of traversed objects.

    @@ -2781,11 +2725,11 @@

    Object Functions

  • -
  • +
  • - +

    Perform a deep comparison to check if two objects are equal.

    @@ -2798,11 +2742,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given array, string, or object empty? An “empty” object has no enumerable own-properties.

    @@ -2818,11 +2762,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value a DOM element?

    @@ -2835,11 +2779,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value an array? Delegates to ECMA5’s native Array.isArray

    @@ -2853,11 +2797,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given variable an object?

    @@ -2871,11 +2815,11 @@

    Object Functions

  • -
  • +
  • - +

    Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.

    @@ -2890,11 +2834,11 @@

    Object Functions

  • -
  • +
  • - +

    Define a fallback version of the method in browsers (ahem, IE < 9), where there isn’t any inspectable “Arguments” type.

    @@ -2910,11 +2854,11 @@

    Object Functions

  • -
  • +
  • - +

    Optimize isFunction if appropriate. Work around some typeof bugs in old v8, IE 11 (#1621), and in Safari 8 (#1929).

    @@ -2930,11 +2874,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given object a finite number?

    @@ -2947,11 +2891,11 @@

    Object Functions

  • -
  • +
  • - +

    Is the given value NaN? (NaN is the only number which does not equal itself).

    @@ -2964,11 +2908,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value a boolean?

    @@ -2981,11 +2925,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value equal to null?

    @@ -2998,11 +2942,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given variable undefined?

    @@ -3015,11 +2959,11 @@

    Object Functions

  • -
  • +
  • - +

    Shortcut function for checking if an object has a given property directly on itself (in other words, not on a prototype).

    @@ -3033,11 +2977,11 @@

    Object Functions

  • -
  • +
  • - +

    Utility Functions

    @@ -3046,11 +2990,11 @@

    Utility Functions

  • -
  • +
  • - +
    @@ -3058,11 +3002,11 @@

    Utility Functions

  • -
  • +
  • - +

    Run Underscore.js in noConflict mode, returning the _ variable to its previous owner. Returns a reference to the Underscore object.

    @@ -3077,11 +3021,11 @@

    Utility Functions

  • -
  • +
  • - +

    Keep the identity function around for default iteratees.

    @@ -3094,11 +3038,11 @@

    Utility Functions

  • -
  • +
  • - +

    Predicate-generating functions. Often useful outside of Underscore.

    @@ -3121,11 +3065,11 @@

    Utility Functions

  • -
  • +
  • - +

    Generates a function for a given object that returns a given property.

    @@ -3140,11 +3084,11 @@

    Utility Functions

  • -
  • +
  • - +

    Returns a predicate for checking whether an object has a given set of key:value pairs.

    @@ -3161,11 +3105,11 @@

    Utility Functions

  • -
  • +
  • - +

    Run a function n times.

    @@ -3181,11 +3125,11 @@

    Utility Functions

  • -
  • +
  • - +

    Return a random integer between min and max (inclusive).

    @@ -3202,11 +3146,11 @@

    Utility Functions

  • -
  • +
  • - +

    A (possibly faster) way to get the current timestamp as an integer.

    @@ -3219,11 +3163,11 @@

    Utility Functions

  • -
  • +
  • - +

    List of HTML entities for escaping.

    @@ -3242,11 +3186,11 @@

    Utility Functions

  • -
  • +
  • - +

    Functions for escaping and unescaping strings to/from HTML interpolation.

    @@ -3260,11 +3204,11 @@

    Utility Functions

  • -
  • +
  • - +

    Regexes for identifying a key that needs to be escaped

    @@ -3284,11 +3228,11 @@

    Utility Functions

  • -
  • +
  • - +

    If the value of the named property is a function then invoke it with the object as context; otherwise, return it.

    @@ -3306,11 +3250,11 @@

    Utility Functions

  • -
  • +
  • - +

    Generate a unique integer id (unique within the entire client session). Useful for temporary DOM ids.

    @@ -3326,11 +3270,11 @@

    Utility Functions

  • -
  • +
  • - +

    By default, Underscore uses ERB-style template delimiters, change the following template settings to use alternative delimiters.

    @@ -3346,11 +3290,11 @@

    Utility Functions

  • -
  • +
  • - +

    When customizing templateSettings, if you don’t want to define an interpolation, evaluation or escaping regex, we need one that is @@ -3363,11 +3307,11 @@

    Utility Functions

  • -
  • +
  • - +

    Certain characters need to be escaped so that they can be put into a string literal.

    @@ -3392,11 +3336,11 @@

    Utility Functions

  • -
  • +
  • - +

    JavaScript micro-templating, similar to John Resig’s implementation. Underscore templating handles arbitrary delimiters, preserves whitespace, @@ -3412,11 +3356,11 @@

    Utility Functions

  • -
  • +
  • - +

    Combine delimiters into one regular expression via alternation.

    @@ -3431,11 +3375,11 @@

    Utility Functions

  • -
  • +
  • - +

    Compile the template source, escaping string literals appropriately.

    @@ -3458,11 +3402,11 @@

    Utility Functions

  • -
  • +
  • - +

    Adobe VMs need the match returned to produce the correct offest.

    @@ -3475,11 +3419,11 @@

    Utility Functions

  • -
  • +
  • - +

    If a variable is not specified, place data values in local scope.

    @@ -3505,11 +3449,11 @@

    Utility Functions

  • -
  • +
  • - +

    Provide the compiled source as a convenience for precompilation.

    @@ -3524,11 +3468,11 @@

    Utility Functions

  • -
  • +
  • - +

    Add a “chain” function. Start chaining a wrapped Underscore object.

    @@ -3543,11 +3487,11 @@

    Utility Functions

  • -
  • +
  • - +

    OOP

    @@ -3556,11 +3500,11 @@

    OOP

  • -
  • +
  • - +

    If Underscore is called as a function, it returns a wrapped object that can be used OO-style. This wrapper holds altered versions of all the @@ -3571,11 +3515,11 @@

    OOP

  • -
  • +
  • - +

    Helper function to continue chaining intermediate results.

    @@ -3588,11 +3532,11 @@

    OOP

  • -
  • +
  • - +

    Add your own custom functions to the Underscore object.

    @@ -3612,11 +3556,11 @@

    OOP

  • -
  • +
  • - +

    Add all of the Underscore functions to the wrapper object.

    @@ -3627,11 +3571,11 @@

    OOP

  • -
  • +
  • - +

    Add all mutator Array functions to the wrapper.

    @@ -3650,11 +3594,11 @@

    OOP

  • -
  • +
  • - +

    Add all accessor Array functions to the wrapper.

    @@ -3670,11 +3614,11 @@

    OOP

  • -
  • +
  • - +

    Extracts the result from a wrapped and chained object.

    @@ -3687,11 +3631,11 @@

    OOP

  • -
  • +
  • - +

    Provide unwrapping proxy for some methods used in engine operations such as arithmetic and JSON stringification.

    @@ -3707,11 +3651,11 @@

    OOP

  • -
  • +
  • - +

    AMD registration happens at the end for compatibility with AMD loaders that may not enforce next-turn semantics on modules. Even though general diff --git a/index.html b/index.html index 26325fc9d..fc005639d 100644 --- a/index.html +++ b/index.html @@ -180,7 +180,7 @@