diff --git a/docs/modules/_setup.html b/docs/modules/_setup.html index b3a5d86c3..40635f2be 100644 --- a/docs/modules/_setup.html +++ b/docs/modules/_setup.html @@ -850,7 +850,7 @@

_setup.js

-
export var VERSION = '1.12.0';
+
export var VERSION = '1.12.1';
diff --git a/docs/modules/debounce.html b/docs/modules/debounce.html index 8a4f8b12c..0a08b47b2 100644 --- a/docs/modules/debounce.html +++ b/docs/modules/debounce.html @@ -850,7 +850,7 @@

debounce.js

import restArguments from './restArguments.js';
-import delay from './delay.js';
+import now from './now.js'; @@ -869,29 +869,47 @@

debounce.js

export default function debounce(func, wait, immediate) {
-  var timeout, result;
+  var timeout, previous, args, result, context;
 
-  var later = function(context, args) {
-    timeout = null;
-    if (args) result = func.apply(context, args);
+  var later = function() {
+    var passed = now() - previous;
+    if (wait > passed) {
+      timeout = setTimeout(later, wait - passed);
+    } else {
+      timeout = null;
+      if (!immediate) result = func.apply(context, args);
+ + + + +
  • +
    + +
    + +
    +

    This check is needed because func can recursively invoke debounced.

    + +
    + +
          if (!timeout) args = context = null;
    +    }
       };
     
    -  var debounced = restArguments(function(args) {
    -    if (timeout) clearTimeout(timeout);
    -    if (immediate) {
    -      var callNow = !timeout;
    +  var debounced = restArguments(function(_args) {
    +    context = this;
    +    args = _args;
    +    previous = now();
    +    if (!timeout) {
           timeout = setTimeout(later, wait);
    -      if (callNow) result = func.apply(this, args);
    -    } else {
    -      timeout = delay(later, wait, this, args);
    +      if (immediate) result = func.apply(context, args);
         }
    -
    -    return result;
    +    return result;
       });
     
    -  debounced.cancel = function() {
    +  debounced.cancel = function() {
         clearTimeout(timeout);
    -    timeout = null;
    +    timeout = args = context = null;
       };
     
       return debounced;
    diff --git a/docs/modules/index.html b/docs/modules/index.html
    index 10f8dac94..d51af3aab 100644
    --- a/docs/modules/index.html
    +++ b/docs/modules/index.html
    @@ -865,7 +865,7 @@ 

    Named Exports

    -
    Underscore.js 1.12.0
    +              
    Underscore.js 1.12.1
     https://underscorejs.org
     (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
     Underscore may be freely distributed under the MIT license.
    diff --git a/docs/modules/template.html b/docs/modules/template.html index 9d7b91122..66ea4af77 100644 --- a/docs/modules/template.html +++ b/docs/modules/template.html @@ -897,7 +897,9 @@

    template.js

    function escapeChar(match) { return '\\' + escapes[match]; -}
    +} + +var bareIdentifier = /^\s*(\w|\$)+\s*$/;
  • @@ -980,7 +982,12 @@

    template.js

        return match;
       });
    -  source += "';\n";
    + source += "';\n"; + + var argument = settings.variable; + if (argument) { + if (!bareIdentifier.test(argument)) throw new Error(argument); + } else { @@ -995,7 +1002,9 @@

    template.js

    -
      if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
    +            
        source = 'with(obj||{}){\n' + source + '}\n';
    +    argument = 'obj';
    +  }
     
       source = "var __t,__p='',__j=Array.prototype.join," +
         "print=function(){__p+=__j.call(arguments,'');};\n" +
    @@ -1003,7 +1012,7 @@ 

    template.js

    var render; try { - render = new Function(settings.variable || 'obj', '_', source); + render = new Function(argument, '_', source); } catch (e) { e.source = source; throw e; @@ -1026,8 +1035,7 @@

    template.js

    -
      var argument = settings.variable || 'obj';
    -  template.source = 'function(' + argument + '){\n' + source + '}';
    +            
      template.source = 'function(' + argument + '){\n' + source + '}';
     
       return template;
     }
    diff --git a/docs/underscore-esm.html b/docs/underscore-esm.html index 1c76fe823..66149e4e0 100644 --- a/docs/underscore-esm.html +++ b/docs/underscore-esm.html @@ -27,7 +27,7 @@

    underscore-esm.js

    -
    Underscore.js 1.12.0
    +              
    Underscore.js 1.12.1
     https://underscorejs.org
     (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
     Underscore may be freely distributed under the MIT license.
    @@ -46,7 +46,7 @@

    underscore-esm.js

    -
    var VERSION = '1.12.0';
    +
    var VERSION = '1.12.1';
    @@ -2380,7 +2380,9 @@

    underscore-esm.js

    function escapeChar(match) { return '\\' + escapes[match]; -}
    +} + +var bareIdentifier = /^\s*(\w|\$)+\s*$/; @@ -2463,7 +2465,12 @@

    underscore-esm.js

        return match;
       });
    -  source += "';\n";
    + source += "';\n"; + + var argument = settings.variable; + if (argument) { + if (!bareIdentifier.test(argument)) throw new Error(argument); + } else { @@ -2478,7 +2485,9 @@

    underscore-esm.js

    -
      if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
    +            
        source = 'with(obj||{}){\n' + source + '}\n';
    +    argument = 'obj';
    +  }
     
       source = "var __t,__p='',__j=Array.prototype.join," +
         "print=function(){__p+=__j.call(arguments,'');};\n" +
    @@ -2486,7 +2495,7 @@ 

    underscore-esm.js

    var render; try { - render = new Function(settings.variable || 'obj', '_', source); + render = new Function(argument, '_', source); } catch (e) { e.source = source; throw e; @@ -2509,8 +2518,7 @@

    underscore-esm.js

    -
      var argument = settings.variable || 'obj';
    -  template.source = 'function(' + argument + '){\n' + source + '}';
    +            
      template.source = 'function(' + argument + '){\n' + source + '}';
     
       return template;
     }
    @@ -2894,29 +2902,47 @@

    underscore-esm.js

    function debounce(func, wait, immediate) {
    -  var timeout, result;
    +  var timeout, previous, args, result, context;
     
    -  var later = function(context, args) {
    -    timeout = null;
    -    if (args) result = func.apply(context, args);
    +  var later = function() {
    +    var passed = now() - previous;
    +    if (wait > passed) {
    +      timeout = setTimeout(later, wait - passed);
    +    } else {
    +      timeout = null;
    +      if (!immediate) result = func.apply(context, args);
    + + + + +
  • +
    + +
    + +
    +

    This check is needed because func can recursively invoke debounced.

    + +
    + +
          if (!timeout) args = context = null;
    +    }
       };
     
    -  var debounced = restArguments(function(args) {
    -    if (timeout) clearTimeout(timeout);
    -    if (immediate) {
    -      var callNow = !timeout;
    +  var debounced = restArguments(function(_args) {
    +    context = this;
    +    args = _args;
    +    previous = now();
    +    if (!timeout) {
           timeout = setTimeout(later, wait);
    -      if (callNow) result = func.apply(this, args);
    -    } else {
    -      timeout = delay(later, wait, this, args);
    +      if (immediate) result = func.apply(context, args);
         }
    -
    -    return result;
    +    return result;
       });
     
    -  debounced.cancel = function() {
    +  debounced.cancel = function() {
         clearTimeout(timeout);
    -    timeout = null;
    +    timeout = args = context = null;
       };
     
       return debounced;
    @@ -2925,11 +2951,11 @@ 

    underscore-esm.js

  • -
  • +
  • - +

    Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and @@ -2944,11 +2970,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns a negated version of the passed-in predicate.

    @@ -2963,11 +2989,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows.

    @@ -2988,11 +3014,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns a function that will only be executed on and after the Nth call.

    @@ -3009,11 +3035,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns a function that will only be executed up to (but not including) the Nth call.

    @@ -3034,11 +3060,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization.

    @@ -3050,11 +3076,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns the first key on an object that passes a truth test.

    @@ -3072,11 +3098,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Internal function to generate _.findIndex and _.findLastIndex.

    @@ -3097,11 +3123,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns the first index on an array-like that passes a truth test.

    @@ -3112,11 +3138,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns the last index on an array-like that passes a truth test.

    @@ -3127,11 +3153,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search.

    @@ -3152,11 +3178,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Internal function to generate the _.indexOf and _.lastIndexOf functions.

    @@ -3189,11 +3215,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. @@ -3207,11 +3233,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array.

    @@ -3223,11 +3249,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the first value which passes a truth test.

    @@ -3242,11 +3268,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Convenience version of a common use case of _.find: getting the first object containing specific key:value pairs.

    @@ -3260,11 +3286,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    The cornerstone for collection functions, an each implementation, aka forEach. @@ -3292,11 +3318,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the results of applying the iteratee to each element.

    @@ -3317,11 +3343,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Internal helper to create a reducing function, iterating left or right.

    @@ -3332,11 +3358,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Wrap code that reassigns argument variables in a separate function than the one that accesses arguments.length to avoid a perf hit. (#1991)

    @@ -3367,11 +3393,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Reduce builds up a single result from a list of values, aka inject, or foldl.

    @@ -3383,11 +3409,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    The right-associative version of reduce, also known as foldr.

    @@ -3398,11 +3424,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return all the elements that pass a truth test.

    @@ -3420,11 +3446,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return all the elements for which a truth test fails.

    @@ -3437,11 +3463,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Determine whether all of the elements pass a truth test.

    @@ -3461,11 +3487,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Determine if at least one element in the object passes a truth test.

    @@ -3485,11 +3511,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Determine if the array or object contains a given item (using ===).

    @@ -3504,11 +3530,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Invoke a method (with arguments) on every item in a collection.

    @@ -3539,11 +3565,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Convenience version of a common use case of _.map: fetching a property.

    @@ -3556,11 +3582,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Convenience version of a common use case of _.filter: selecting only objects containing specific key:value pairs.

    @@ -3574,11 +3600,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the maximum element (or element-based computation).

    @@ -3611,11 +3637,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the minimum element (or element-based computation).

    @@ -3648,11 +3674,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Sample n random values from a collection using the modern version of the Fisher-Yates shuffle. @@ -3682,11 +3708,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Shuffle a collection.

    @@ -3699,11 +3725,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Sort the object’s values by a criterion produced by an iteratee.

    @@ -3732,11 +3758,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    An internal function used for aggregate “group by” operations.

    @@ -3757,11 +3783,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Groups the object’s values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion.

    @@ -3775,11 +3801,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Indexes the object’s values by a criterion, similar to _.groupBy, but for when you know that your index values will be unique.

    @@ -3793,11 +3819,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the @@ -3812,11 +3838,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Split a collection into two arrays: one whose elements all pass the given truth test, and one whose elements all do not pass the truth test.

    @@ -3830,11 +3856,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Safely create a real, live array from anything iterable.

    @@ -3849,11 +3875,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Keep surrogate pair characters together.

    @@ -3868,11 +3894,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return the number of elements in a collection.

    @@ -3886,11 +3912,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Internal _.pick helper function to determine whether key is an enumerable property name of obj.

    @@ -3904,11 +3930,11 @@

    underscore-esm.js

  • -
  • +
  • - +

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

    @@ -3936,11 +3962,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return a copy of the object without the disallowed properties.

    @@ -3963,11 +3989,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns everything but the last entry of the array. Especially useful on the arguments object. Passing n will return all the values in @@ -3982,11 +4008,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Get the first element of an array. Passing n will return the first N values in the array. The guard check allows it to work with _.map.

    @@ -4002,11 +4028,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Returns everything but the first entry of the array. Especially useful on the arguments object. Passing an n will return the rest N values in the @@ -4021,11 +4047,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Get the last element of an array. Passing n will return the last N values in the array.

    @@ -4041,11 +4067,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Trim out all falsy values from an array.

    @@ -4058,11 +4084,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Flatten out an array, either recursively (by default), or up to depth. Passing true or false as depth means 1 or Infinity, respectively.

    @@ -4076,11 +4102,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain.

    @@ -4097,11 +4123,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Return a version of the array that does not contain the specified value(s).

    @@ -4114,11 +4140,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. @@ -4158,11 +4184,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Produce an array that contains the union: each distinct element from all of the passed-in arrays.

    @@ -4176,11 +4202,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Produce an array that contains every item shared between all the passed-in arrays.

    @@ -4205,11 +4231,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Complement of zip. Unzip accepts an array of arrays and groups each array’s elements on shared indices.

    @@ -4229,11 +4255,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Zip together multiple lists into a single array – elements that share an index go together.

    @@ -4245,11 +4271,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Converts lists into objects. Pass either a single array of [key, value] pairs, or two parallel arrays of the same length – one of keys, and one of @@ -4272,11 +4298,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Generate an integer Array containing an arithmetic progression. A port of the native Python range() function. See @@ -4306,11 +4332,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Chunk a single array into multiple arrays, each containing count or fewer items.

    @@ -4330,11 +4356,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Helper function to continue chaining intermediate results.

    @@ -4347,11 +4373,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Add your own custom functions to the Underscore object.

    @@ -4372,11 +4398,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Add all mutator Array functions to the wrapper.

    @@ -4399,11 +4425,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Add all accessor Array functions to the wrapper.

    @@ -4421,11 +4447,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Named Exports

    @@ -4585,11 +4611,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Default Export

    @@ -4598,11 +4624,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Add all of the Underscore functions to the wrapper object.

    @@ -4613,11 +4639,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    Legacy Node.js API.

    @@ -4628,11 +4654,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    ESM Exports

    @@ -4645,11 +4671,11 @@

    underscore-esm.js

  • -
  • +
  • - +

    sourceMappingURL=underscore-esm.js.map

    diff --git a/index.html b/index.html index f1283e7f4..ba2d166f9 100644 --- a/index.html +++ b/index.html @@ -186,7 +186,7 @@