diff --git a/.travis.yml b/.travis.yml index 9ce3ad6fd..da6b33043 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ language: node_js -addons: - firefox: "10.0" node_js: - "0.8" - "0.12" @@ -9,15 +7,26 @@ matrix: include: - node_js: "0.10" env: BROWSER=true -env: BROWSER=false before_install: - npm install -g npm - - if [[ $BROWSER == true ]]; then npm install karma-phantomjs-launcher karma-firefox-launcher; fi + - npm install -g karma-cli before_script: + - npm install karma-sauce-launcher - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start script: - npm test - - "[ $BROWSER == false ] || ./node_modules/karma/bin/karma start --browsers Firefox,PhantomJS" + - "[ $BROWSER == false ] || npm run test-browser" + # Karma sauce is limited to running about 5-7 browsers (or it will tiemout) at a time so we just run vendor by vendor here + - "[ $BROWSER == false ] || karma start karma.conf-sauce.js --browsers FIREFOX_V4,FIREFOX_V11,FIREFOX_V20,FIREFOX_V30,FIREFOX_V35" + - "[ $BROWSER == false ] || karma start karma.conf-sauce.js --browsers CHROME_V28,CHROME_V35,CHROME_V40,ANDROID_V4.0,ANDROID_V4.3" + - "[ $BROWSER == false ] || karma start karma.conf-sauce.js --browsers INTERNET_EXPLORER_V9,INTERNET_EXPLORER_V10,INTERNET_EXPLORER_V11" + - "[ $BROWSER == false ] || karma start karma.conf-sauce.js --browsers SAFARI_V5,SAFARI_V6,SAFARI_V7" + - "[ $BROWSER == false ] || karma start karma.conf-sauce.js --browsers OPERA_V11,OPERA_V12" notifications: email: false +env: + global: + - secure: bDZSBQfqr21hCayjcZ20IxrV6+XGhxQPFIfwWqEKLrF93Gu8LLVjZRxXE/mE8I8N4Z5WtDNb4ZHrm/TTzmcPa5MuHgIxEdknQCncobH8oimwc83SHwEPk6okeNKl39VlCjvvnmoe/V/KpnknuYn3Rqghtl/Uv9KLpCwskwjTtcw= + - secure: SRECgXuwcZTcD3GVxTS2bYNgRyye4vq6BLrV2PH9FyNenowsKQR2EwlC/dppc1Q8NWMgv79J/R96q9JOFh+mEH9L5dlBb2yhnGH8amVeM/ChAJHT/F8YktKM453uVpz5fR00QcCQDDUOx6Pvx374ID0OKNpWKAkQBWA9mPTsLnE= + matrix: BROWSER=false \ No newline at end of file diff --git a/bower.json b/bower.json index 38f3d3e75..2955fd23f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "underscore", - "version": "1.8.1", + "version": "1.8.2", "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 9a2d5a267..e76680c83 100644 --- a/component.json +++ b/component.json @@ -5,6 +5,6 @@ "repo" : "jashkenas/underscore", "main" : "underscore.js", "scripts" : ["underscore.js"], - "version" : "1.8.1", + "version" : "1.8.2", "license" : "MIT" } diff --git a/docs/underscore.html b/docs/underscore.html index 726cc10ef..d32de5fc9 100644 --- a/docs/underscore.html +++ b/docs/underscore.html @@ -27,7 +27,7 @@

underscore.js

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

Baseline setup

-
  _.VERSION = '1.8.1';
+
  _.VERSION = '1.8.2';
@@ -656,9 +656,9 @@

Collection Functions

-
  _.contains = _.includes = _.include = function(obj, target) {
+            
  _.contains = _.includes = _.include = function(obj, target, fromIndex) {
     if (!isArrayLike(obj)) obj = _.values(obj);
-    return _.indexOf(obj, target) >= 0;
+    return _.indexOf(obj, target, typeof fromIndex == 'number' && fromIndex) >= 0;
   };
@@ -1996,6 +1996,52 @@

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 = ['valueOf', 'isPrototypeOf', 'toString',
+                      'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
+
+  function collectNonEnumProps(obj, keys) {
+    var nonEnumIdx = nonEnumerableProps.length;
+    var constructor = obj.constructor;
+    var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
+ + + + +
  • +
    + +
    + +
    +

    Constructor is a special case.

    + +
    + +
        var prop = 'constructor';
    +    if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
    +
    +    while (nonEnumIdx--) {
    +      prop = nonEnumerableProps[nonEnumIdx];
    +      if (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

    @@ -2005,18 +2051,33 @@

    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); + for (var key in obj) if (_.has(obj, key)) keys.push(key);
  • + + + + +
  • +
    + +
    + +
    +

    Ahem, IE < 9.

    + +
    + +
        if (hasEnumBug) collectNonEnumProps(obj, keys);
         return keys;
       };
  • -
  • +
  • - +

    Retrieve all the property names of an object.

    @@ -2025,18 +2086,33 @@

    Object Functions

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

    Ahem, IE < 9.

    + +
    + +
        if (hasEnumBug) collectNonEnumProps(obj, keys);
         return keys;
       };
  • -
  • +
  • - +

    Retrieve the values of an object’s properties.

    @@ -2055,11 +2131,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2082,11 +2158,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2105,11 +2181,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2127,11 +2203,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2149,11 +2225,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2164,27 +2240,27 @@

    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)

    -
      _.extendOwn = createAssigner(_.keys);
    +
      _.extendOwn = _.assign = createAssigner(_.keys);
  • -
  • +
  • - +

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

    @@ -2202,34 +2278,31 @@

    Object Functions

  • -
  • +
  • - +

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

    -
      _.pick = function(obj, iteratee, context) {
    -    var result = {}, key;
    +            
      _.pick = function(object, oiteratee, context) {
    +    var result = {}, obj = object, iteratee, keys;
         if (obj == null) return result;
    -    if (_.isFunction(iteratee)) {
    -      iteratee = optimizeCb(iteratee, context);
    -      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;
    -      }
    +    if (_.isFunction(oiteratee)) {
    +      keys = _.allKeys(obj);
    +      iteratee = optimizeCb(oiteratee, context);
         } else {
    -      var keys = flatten(arguments, false, false, 1);
    -      obj = new Object(obj);
    -      for (var i = 0, length = keys.length; i < length; i++) {
    -        key = keys[i];
    -        if (key in obj) result[key] = obj[key];
    -      }
    +      keys = flatten(arguments, false, false, 1);
    +      iteratee = function(value, key, obj) { return key in obj; };
    +      obj = Object(obj);
    +    }
    +    for (var i = 0, length = keys.length; i < length; i++) {
    +      var key = keys[i];
    +      var value = obj[key];
    +      if (iteratee(value, key, obj)) result[key] = value;
         }
         return result;
       };
    @@ -2237,11 +2310,11 @@

    Object Functions

  • -
  • +
  • - +

    Return a copy of the object without the blacklisted properties.

    @@ -2262,11 +2335,11 @@

    Object Functions

  • -
  • +
  • - +

    Fill in a given object with default properties.

    @@ -2277,11 +2350,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2295,11 +2368,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 @@ -2315,11 +2388,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2339,11 +2412,11 @@

    Object Functions

  • -
  • +
  • - +

    Internal recursive comparison function for isEqual.

    @@ -2354,11 +2427,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2370,11 +2443,11 @@

    Object Functions

  • -
  • +
  • - +

    A strict comparison is necessary because null == undefined.

    @@ -2385,11 +2458,11 @@

    Object Functions

  • -
  • +
  • - +

    Unwrap any wrapped objects.

    @@ -2401,11 +2474,11 @@

    Object Functions

  • -
  • +
  • - +

    Compare [[Class]] names.

    @@ -2418,11 +2491,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2433,11 +2506,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2448,11 +2521,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2465,11 +2538,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2481,11 +2554,11 @@

    Object Functions

  • -
  • +
  • - +

    An egal comparison is performed for other numeric values.

    @@ -2498,11 +2571,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 @@ -2520,11 +2593,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2542,11 +2615,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.

    @@ -2556,11 +2629,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2575,11 +2648,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2592,11 +2665,11 @@

    Object Functions

  • -
  • +
  • - +

    Add the first object to the stack of traversed objects.

    @@ -2608,11 +2681,11 @@

    Object Functions

  • -
  • +
  • - +

    Recursively compare objects and arrays.

    @@ -2623,11 +2696,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2639,11 +2712,11 @@

    Object Functions

  • -
  • +
  • - +

    Deep compare the contents, ignoring non-numeric properties.

    @@ -2657,11 +2730,11 @@

    Object Functions

  • -
  • +
  • - +

    Deep compare objects.

    @@ -2673,11 +2746,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2689,11 +2762,11 @@

    Object Functions

  • -
  • +
  • - +

    Deep compare each member

    @@ -2707,11 +2780,11 @@

    Object Functions

  • -
  • +
  • - +

    Remove the first object from the stack of traversed objects.

    @@ -2725,11 +2798,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2742,11 +2815,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2762,11 +2835,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value a DOM element?

    @@ -2779,11 +2852,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2797,11 +2870,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given variable an object?

    @@ -2815,11 +2888,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2834,11 +2907,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2854,11 +2927,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2874,11 +2947,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given object a finite number?

    @@ -2891,11 +2964,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2908,11 +2981,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value a boolean?

    @@ -2925,11 +2998,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given value equal to null?

    @@ -2942,11 +3015,11 @@

    Object Functions

  • -
  • +
  • - +

    Is a given variable undefined?

    @@ -2959,11 +3032,11 @@

    Object Functions

  • -
  • +
  • - +

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

    @@ -2977,11 +3050,11 @@

    Object Functions

  • -
  • +
  • - +

    Utility Functions

    @@ -2990,11 +3063,11 @@

    Utility Functions

  • -
  • +
  • - +
    @@ -3002,11 +3075,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3021,11 +3094,11 @@

    Utility Functions

  • -
  • +
  • - +

    Keep the identity function around for default iteratees.

    @@ -3038,11 +3111,11 @@

    Utility Functions

  • -
  • +
  • - +

    Predicate-generating functions. Often useful outside of Underscore.

    @@ -3065,11 +3138,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3084,11 +3157,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3105,11 +3178,11 @@

    Utility Functions

  • -
  • +
  • - +

    Run a function n times.

    @@ -3125,11 +3198,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3146,11 +3219,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3163,11 +3236,11 @@

    Utility Functions

  • -
  • +
  • - +

    List of HTML entities for escaping.

    @@ -3186,11 +3259,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3204,11 +3277,11 @@

    Utility Functions

  • -
  • +
  • - +

    Regexes for identifying a key that needs to be escaped

    @@ -3228,11 +3301,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3250,11 +3323,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3270,11 +3343,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3290,11 +3363,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3336,11 +3409,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    Utility Functions

  • -
  • +
  • - +

    Combine delimiters into one regular expression via alternation.

    @@ -3375,11 +3448,11 @@

    Utility Functions

  • -
  • +
  • - +

    Compile the template source, escaping string literals appropriately.

    @@ -3402,11 +3475,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3419,11 +3492,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3449,11 +3522,11 @@

    Utility Functions

  • -
  • +
  • - +

    Provide the compiled source as a convenience for precompilation.

    @@ -3468,11 +3541,11 @@

    Utility Functions

  • -
  • +
  • - +

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

    @@ -3487,11 +3560,11 @@

    Utility Functions

  • -
  • +
  • - +

    OOP

    @@ -3500,11 +3573,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 @@ -3515,11 +3588,11 @@

    OOP

  • -
  • +
  • - +

    Helper function to continue chaining intermediate results.

    @@ -3532,11 +3605,11 @@

    OOP

  • -
  • +
  • - +

    Add your own custom functions to the Underscore object.

    @@ -3556,11 +3629,11 @@

    OOP

  • -
  • +
  • - +

    Add all of the Underscore functions to the wrapper object.

    @@ -3571,11 +3644,11 @@

    OOP

  • -
  • +
  • - +

    Add all mutator Array functions to the wrapper.

    @@ -3594,11 +3667,11 @@

    OOP

  • -
  • +
  • - +

    Add all accessor Array functions to the wrapper.

    @@ -3614,11 +3687,11 @@

    OOP

  • -
  • +
  • - +

    Extracts the result from a wrapped and chained object.

    @@ -3631,11 +3704,11 @@

    OOP

  • -
  • +
  • - +

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

    @@ -3651,11 +3724,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 fc005639d..c7c16e248 100644 --- a/index.html +++ b/index.html @@ -180,7 +180,7 @@