diff --git a/lodash.js b/lodash.js index d92b91144..133b30f39 100644 --- a/lodash.js +++ b/lodash.js @@ -8,13 +8,13 @@ */ ;(function() { - /** Used as a safe reference for `undefined` in pre ES5 environments */ + /** Used as a safe reference for `undefined` in pre ES5 environments. */ var undefined; - /** Used as the semantic version number */ + /** Used as the semantic version number. */ var VERSION = '3.0.0-pre'; - /** Used to compose bitmasks for wrapper metadata */ + /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_FLAG = 4, @@ -24,38 +24,38 @@ PARTIAL_RIGHT_FLAG = 64, REARG_FLAG = 128; - /** Used as default options for `_.trunc` */ + /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = '...'; - /** Used to detect when a function becomes hot */ + /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150, HOT_SPAN = 16; - /** Used to indicate the type of lazy iteratees */ + /** Used to indicate the type of lazy iteratees. */ var LAZY_FILTER_FLAG = 0, LAZY_MAP_FLAG = 1, LAZY_WHILE_FLAG = 2; - /** Used as the `TypeError` message for "Functions" methods */ + /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; - /** Used as the internal argument placeholder */ + /** Used as the internal argument placeholder. */ var PLACEHOLDER = '__lodash_placeholder__'; - /** Used to generate unique IDs */ + /** Used to generate unique IDs. */ var idCounter = 0; - /** Used to match empty string literals in compiled template source */ + /** Used to match empty string literals in compiled template source. */ var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - /** Used to match HTML entities and HTML characters */ + /** Used to match HTML entities and HTML characters. */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g; - /** Used to match template delimiters */ + /** Used to match template delimiters. */ var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; @@ -67,22 +67,22 @@ */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - /** Used to match `RegExp` flags from their coerced string values */ + /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; - /** Used to detect named functions */ + /** Used to detect named functions. */ var reFuncName = /^\s*function[ \n\r\t]+\w/; - /** Used to detect hexadecimal string values */ + /** Used to detect hexadecimal string values. */ var reHexPrefix = /^0[xX]/; - /** Used to detect host constructors (Safari > 5) */ + /** Used to detect host constructors (Safari > 5). */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters (excluding mathematical operators) */ + /** Used to match latin-1 supplement letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; - /** Used to ensure capturing order of template delimiters */ + /** Used to ensure capturing order of template delimiters. */ var reNoMatch = /($^)/; /** @@ -92,13 +92,13 @@ */ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g; - /** Used to detect functions containing a `this` reference */ + /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; - /** Used to match unescaped characters in compiled string literals */ + /** Used to match unescaped characters in compiled string literals. */ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - /** Used to match words to create compound words */ + /** Used to match words to create compound words. */ var reWords = (function() { var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; @@ -106,19 +106,19 @@ return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); - /** Used to detect and test whitespace */ + /** Used to detect and test for whitespace. */ var whitespace = ( - // whitespace + // Basic whitespace characters. ' \t\x0b\f\xa0\ufeff' + - // line terminators + // Line terminators. '\n\r\u2028\u2029' + - // unicode category "Zs" space separators + // Unicode category "Zs" space separators. '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' ); - /** Used to assign default `context` object properties */ + /** Used to assign default `context` object properties. */ var contextProps = [ 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', @@ -128,16 +128,16 @@ 'window', 'WinRTError' ]; - /** Used to fix the JScript `[[DontEnum]]` bug */ + /** Used to fix the JScript `[[DontEnum]]` bug. */ var shadowedProps = [ 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf' ]; - /** Used to make template sourceURLs easier to identify */ + /** Used to make template sourceURLs easier to identify. */ var templateCounter = -1; - /** `Object#toString` result references */ + /** `Object#toString` result references. */ var argsClass = '[object Arguments]', arrayClass = '[object Array]', boolClass = '[object Boolean]', @@ -163,7 +163,7 @@ uint16Class = '[object Uint16Array]', uint32Class = '[object Uint32Array]'; - /** Used to identify object classifications that are treated like arrays */ + /** Used to identify object classifications that are treated like arrays. */ var arrayLikeClasses = {}; arrayLikeClasses[argsClass] = arrayLikeClasses[arrayClass] = arrayLikeClasses[float32Class] = @@ -178,7 +178,7 @@ arrayLikeClasses[regexpClass] = arrayLikeClasses[setClass] = arrayLikeClasses[stringClass] = arrayLikeClasses[weakMapClass] = false; - /** Used to identify object classifications that `_.clone` supports */ + /** Used to identify object classifications that `_.clone` supports. */ var cloneableClasses = {}; cloneableClasses[argsClass] = cloneableClasses[arrayClass] = cloneableClasses[arrayBufferClass] = cloneableClasses[boolClass] = @@ -193,14 +193,14 @@ cloneableClasses[funcClass] = cloneableClasses[mapClass] = cloneableClasses[setClass] = cloneableClasses[weakMapClass] = false; - /** Used as an internal `_.debounce` options object by `_.throttle` */ + /** Used as an internal `_.debounce` options object by `_.throttle`. */ var debounceOptions = { 'leading': false, 'maxWait': 0, 'trailing': false }; - /** Used to map latin-1 supplementary letters to basic latin letters */ + /** Used to map latin-1 supplementary letters to basic latin letters. */ var deburredLetters = { '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', @@ -221,20 +221,7 @@ '\xdf': 'ss' }; - /** - * Used to map characters to HTML entities. - * - * **Note:** Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't require escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](http://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * Backticks are escaped because in Internet Explorer < 9, they can break out - * of attribute values or HTML comments. See [#102](http://html5sec.org/#102), - * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of - * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. - */ + /** Used to map characters to HTML entities. */ var htmlEscapes = { '&': '&', '<': '<', @@ -244,7 +231,7 @@ '`': '`' }; - /** Used to map HTML entities to characters */ + /** Used to map HTML entities to characters. */ var htmlUnescapes = { '&': '&', '<': '<', @@ -254,13 +241,13 @@ '`': '`' }; - /** Used to determine if values are of the language type `Object` */ + /** Used to determine if values are of the language type `Object`. */ var objectTypes = { 'function': true, 'object': true }; - /** Used to escape characters for inclusion in compiled string literals */ + /** Used to escape characters for inclusion in compiled string literals. */ var stringEscapes = { '\\': '\\', "'": "'", @@ -278,19 +265,19 @@ */ var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this; - /** Detect free variable `exports` */ + /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `module` */ + /** Detect free variable `module`. */ var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { root = freeGlobal; } - /** Detect the popular CommonJS extension `module.exports` */ + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /*--------------------------------------------------------------------------*/ @@ -586,7 +573,7 @@ } /** - * Used by `_.sortBy` to compare transformed elements of `collection` and stable + * Used by `_.sortBy` to compare transformed elements of a collection and stable * sort them in ascending order. * * @private @@ -861,7 +848,7 @@ // See http://es5.github.io/#x11.1.5. context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; - /** Native constructor references */ + /** Native constructor references. */ var Array = context.Array, Date = context.Date, Error = context.Error, @@ -873,34 +860,34 @@ String = context.String, TypeError = context.TypeError; - /** Used for native method references */ + /** Used for native method references. */ var arrayProto = Array.prototype, errorProto = Error.prototype, objectProto = Object.prototype, stringProto = String.prototype; - /** Used to detect DOM support */ + /** Used to detect DOM support. */ var document = (document = context.window) && document.document; - /** Used to resolve the decompiled source of functions */ + /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; - /** Used to check objects for own properties */ + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - /** Used to restore the original `_` reference in `_.noConflict` */ + /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = context._; - /** Used to resolve the internal `[[Class]]` of values */ + /** Used to resolve the internal `[[Class]]` of values. */ var toString = objectProto.toString; - /** Used to detect if a method is native */ + /** Used to detect if a method is native. */ var reNative = RegExp('^' + escapeRegExp(toString) .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); - /** Native method references */ + /** Native method references. */ var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, ceil = Math.ceil, @@ -916,7 +903,7 @@ unshift = arrayProto.unshift, WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; - /** Used to clone array buffers */ + /** Used to clone array buffers. */ var Float64Array = (function() { // Safari 5 errors when using an array buffer to initialize a typed array // where the array buffer's `byteLength` is not a multiple of the typed @@ -928,7 +915,7 @@ return result; }()); - /* Native method references for those with the same name as other `lodash` methods */ + /* Native method references for those with the same name as other `lodash` methods. */ var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, @@ -940,15 +927,15 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used as references for `-Infinity` and `Infinity` */ + /** Used as references for `-Infinity` and `Infinity`. */ var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - /** Used as references for the max length and index of an array */ + /** Used as references for the max length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - /** Used as the size, in bytes, of each Float64Array element */ + /** Used as the size, in bytes, of each Float64Array element. */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** @@ -958,10 +945,10 @@ */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - /** Used to store function metadata */ + /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; - /** Used to lookup a built-in constructor by `[[Class]]` */ + /** Used to lookup a built-in constructor by `[[Class]]`. */ var ctorByClass = {}; ctorByClass[float32Class] = context.Float32Array; ctorByClass[float64Class] = context.Float64Array; @@ -973,7 +960,7 @@ ctorByClass[uint16Class] = context.Uint16Array; ctorByClass[uint32Class] = context.Uint32Array; - /** Used to avoid iterating over non-enumerable properties in IE < 9 */ + /** Used to avoid iterating over non-enumerable properties in IE < 9. */ var nonEnumProps = {}; nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true }; nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true }; @@ -1677,8 +1664,7 @@ } /** - * The base implementation of `_.callback` without support for creating - * "_.pluck" and "_.where" style callbacks. + * The base implementation of `_.callback`. * * @private * @param {*} [func=_.identity] The value to convert to a callback. @@ -2482,7 +2468,7 @@ /** * The base implementation of `_.reduce` and `_.reduceRight` without support * for callback shorthands or `this` binding, which iterates over `collection` - * usingthe provided `eachFunc`. + * using the provided `eachFunc`. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2920,6 +2906,8 @@ key = func; function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it to other functions. var length = arguments.length, index = length, args = Array(length); @@ -2994,7 +2982,7 @@ /** * Creates a function that wraps `func` and invokes it with the optional `this` - * binding of `thisArg` and the `partialArgs` prepended to those provided to + * binding of `thisArg` and the `partials` prepended to those provided to * the wrapper. * * @private @@ -3010,7 +2998,7 @@ function wrapper() { // Avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it to `composeArgs`. + // converting it to an array before providing it `func`. var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, @@ -3046,7 +3034,7 @@ * 128 - `_.rearg` * @param {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partialArgs` placeholder indexes. + * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. @@ -3342,7 +3330,7 @@ } /** - * Checks if `value` is valid array-like length. + * Checks if `value` is a valid array-like length. * * @private * @param {*} value The value to check. @@ -8564,6 +8552,17 @@ * **Note:** No other characters are escaped. To escape additional characters * use a third-party library like [_he_](http://mths.be/he). * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't require escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. + * See [Mathias Bynens's article](http://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can break out + * of attribute values or HTML comments. See [#102](http://html5sec.org/#102), + * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of + * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. + * * When working with HTML you should always quote attribute values to reduce * XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping) * for more details. diff --git a/perf/asset/perf-ui.js b/perf/asset/perf-ui.js index d6ebe780e..6d0bf89a8 100644 --- a/perf/asset/perf-ui.js +++ b/perf/asset/perf-ui.js @@ -1,16 +1,16 @@ ;(function(window) { 'use strict'; - /** The base path of the builds */ + /** The base path of the Lo-Dash builds. */ var basePath = '../'; - /** The Lo-Dash build to load */ + /** The Lo-Dash build to load. */ var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]); - /** The other library to load */ + /** The other library to load. */ var other = (other = /other=([^&]+)/.exec(location.search)) && decodeURIComponent(other[1]); - /** The `ui` object */ + /** The `ui` object. */ var ui = {}; /*--------------------------------------------------------------------------*/ @@ -34,7 +34,7 @@ /*--------------------------------------------------------------------------*/ - // initialize controls + // Initialize controls. addListener(window, 'load', function() { function eventHandler(event) { var buildIndex = buildList.selectedIndex, @@ -112,7 +112,7 @@ addListener(otherList, 'change', eventHandler); }); - // expose Lo-Dash build file path + // The Lo-Dash build file path. ui.buildPath = (function() { var result; switch (build) { @@ -126,7 +126,7 @@ return basePath + result; }()); - // expose other library file path + // The other library file path. ui.otherPath = (function() { var result; switch (other) { @@ -142,13 +142,8 @@ return basePath + result; }()); - // expose `ui.urlParams` properties - ui.urlParams = { - 'build': build, - 'other': other - }; + ui.urlParams = { 'build': build, 'other': other }; - // expose `ui` window.ui = ui; }(this)); diff --git a/perf/perf.js b/perf/perf.js index d3231c795..410feeea8 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -1,15 +1,15 @@ ;(function() { - /** Used to access the Firebug Lite panel (set by `run`) */ + /** Used to access the Firebug Lite panel (set by `run`). */ var fbPanel; - /** Used as a safe reference for `undefined` in pre ES5 environments */ + /** Used as a safe reference for `undefined` in pre ES5 environments. */ var undefined; - /** Used as a reference to the global object */ + /** Used as a reference to the global object. */ var root = typeof global == 'object' && global || this; - /** Method and object shortcuts */ + /** Method and object shortcuts. */ var phantom = root.phantom, amd = root.define && define.amd, argv = root.process && process.argv, @@ -18,10 +18,10 @@ params = root.arguments, system = root.system; - /** Add `console.log()` support for Narwhal, Rhino, and RingoJS */ + /** Add `console.log()` support for Narwhal, Rhino, and RingoJS. */ var console = root.console || (root.console = { 'log': root.print }); - /** The file path of the Lo-Dash file to test */ + /** The file path of the Lo-Dash file to test. */ var filePath = (function() { var min = 0, result = []; @@ -52,51 +52,51 @@ return result; }()); - /** Used to match path separators */ + /** Used to match path separators. */ var rePathSeparator = /[\/\\]/; - /** Used to detect primitive types */ + /** Used to detect primitive types. */ var rePrimitive = /^(?:boolean|number|string|undefined)$/; - /** Used to match RegExp special characters */ + /** Used to match RegExp special characters. */ var reSpecialChars = /[.*+?^=!:${}()|[\]\/\\]/g; - /** The `ui` object */ + /** The `ui` object. */ var ui = root.ui || (root.ui = { 'buildPath': basename(filePath, '.js'), 'otherPath': 'underscore' }); - /** The Lo-Dash build basename */ + /** The Lo-Dash build basename. */ var buildName = root.buildName = basename(ui.buildPath, '.js'); - /** The other library basename */ + /** The other library basename. */ var otherName = root.otherName = (function() { var result = basename(ui.otherPath, '.js'); return result + (result == buildName ? ' (2)' : ''); }()); - /** Used to score performance */ + /** Used to score performance. */ var score = { 'a': [], 'b': [] }; - /** Used to queue benchmark suites */ + /** Used to queue benchmark suites. */ var suites = []; - /** Used to resolve a value's internal [[Class]] */ + /** Used to resolve a value's internal [[Class]]. */ var toString = Object.prototype.toString; - /** Detect if in a browser environment */ + /** Detect if in a browser environment. */ var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator'); - /** Detect if in a Java environment */ + /** Detect if in a Java environment. */ var isJava = !isBrowser && /Java/.test(toString.call(root.java)); - /** Use a single "load" function */ + /** Use a single "load" function. */ var load = (typeof require == 'function' && !amd) ? require : (isJava && root.load) || noop; - /** Load Lo-Dash */ + /** Load Lo-Dash. */ var lodash = root.lodash || (root.lodash = ( lodash = load(filePath) || root._, lodash = lodash._ || lodash, @@ -104,14 +104,14 @@ lodash.noConflict() )); - /** Load Benchmark.js */ + /** Load Benchmark.js. */ var Benchmark = root.Benchmark || (root.Benchmark = ( Benchmark = load('../vendor/benchmark.js/benchmark.js') || root.Benchmark, Benchmark = Benchmark.Benchmark || Benchmark, Benchmark.runInContext(lodash.extend({}, root, { '_': lodash })) )); - /** Load Underscore */ + /** Load Underscore. */ var _ = root._ || (root._ = ( _ = load('../vendor/underscore/underscore.js') || root._, _._ || _ @@ -189,7 +189,7 @@ function log(text) { console.log(text + ''); if (fbPanel) { - // scroll the Firebug Lite panel down + // Scroll the Firebug Lite panel down. fbPanel.scrollTop = fbPanel.scrollHeight; } } @@ -249,15 +249,15 @@ '% faster.' ); } - // add score adjusted for margin of error + // Add score adjusted for margin of error. score.a.push(aHz); score.b.push(bHz); } - // remove current suite from queue + // Remove current suite from queue. suites.shift(); if (suites.length) { - // run next suite + // Run next suite. suites[0].run({ 'async': !isJava }); } else { @@ -269,7 +269,7 @@ percentFaster = formatNumber(Math.round((xFaster - 1) * 100)), message = 'is ' + percentFaster + '% ' + (xFaster == 1 ? '' : '(' + formatNumber(xFaster.toFixed(2)) + 'x) ') + 'faster than'; - // report results + // Report results. if (aMeanHz >= bMeanHz) { log('\n' + buildName + ' ' + message + ' ' + otherName + '.'); } else { @@ -334,7 +334,7 @@ return /^_/.test(funcName);\ });\ \ - // potentially expensive\n\ + // Potentially expensive.\n\ for (index = 0; index < this.count; index++) {\ bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {\ object[funcName] = belt[funcName];\ @@ -974,7 +974,7 @@ ) ); - // avoid Underscore induced `OutOfMemoryError` in Rhino, Narwhal, and Ringo + // Avoid Underscore induced `OutOfMemoryError` in Rhino, Narwhal, and Ringo. if (!isJava) { suites.push( Benchmark.Suite('`_.find` with `properties`') @@ -2080,7 +2080,7 @@ if (Benchmark.platform + '') { log(Benchmark.platform); } - // in the browser, expose `run` to be called later + // Expose `run` to be called later when executing in a browser. if (document) { root.run = run; } else { diff --git a/test/asset/set.js b/test/asset/set.js index 256ee684a..d32d124ed 100644 --- a/test/asset/set.js +++ b/test/asset/set.js @@ -1,21 +1,21 @@ ;(function() { - /** Used to determine if values are of the language type Object */ + /** Used to determine if values are of the language type Object. */ var objectTypes = { 'function': true, 'object': true }; - /** Used as the `Set#toString` return value */ + /** Used as the `Set#toString` return value. */ var nativeString = String(Object.prototype.toString).replace(/toString/g, 'Set'); - /** Used as a reference to the global object */ + /** Used as a reference to the global object. */ var root = (objectTypes[typeof window] && window) || this; - /** Detect free variable `exports` */ + /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = objectTypes[typeof global] && global; if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { root = freeGlobal; diff --git a/test/asset/test-ui.js b/test/asset/test-ui.js index 7648ff366..c99dabc29 100644 --- a/test/asset/test-ui.js +++ b/test/asset/test-ui.js @@ -1,16 +1,16 @@ ;(function(window) { 'use strict'; - /** The base path of the builds */ + /** The base path of the Lo-Dash builds. */ var basePath = '../'; - /** The Lo-Dash build to load */ + /** The Lo-Dash build to load. */ var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]); - /** The module loader to use */ + /** The module loader to use. */ var loader = (loader = /loader=([^&]+)/.exec(location.search)) && decodeURIComponent(loader[1]); - /** The `ui` object */ + /** The `ui` object. */ var ui = {}; /*--------------------------------------------------------------------------*/ @@ -34,7 +34,7 @@ /*--------------------------------------------------------------------------*/ - // initialize controls + // Initialize controls. addListener(window, 'load', function() { function eventHandler(event) { var buildIndex = buildList.selectedIndex, @@ -124,19 +124,19 @@ init(); }); - // used to indicate that Lo-Dash is in strict mode + // Used to indicate that Lo-Dash is in strict mode. ui.isStrict = /\b(?:lodash-es6|transpiled)\b/.test([location.pathname, location.search]); - // used to indicate testing a foreign file + // Used to indicate testing a foreign file. ui.isForeign = RegExp('^(\\w+:)?//').test(build); - // used to indicate testing a modularized build + // Used to indicate testing a modularized build. ui.isModularize = /\b(?:commonjs|(index|main)\.js|lodash-(?:amd|es6|node)|modularize|npm|transpiled)\b/.test([location.pathname, location.search]); - // used to indicate testing in Sauce Labs' automated test cloud + // Used to indicate testing in Sauce Labs' automated test cloud. ui.isSauceLabs = location.port == '9001'; - // expose Lo-Dash build file path + // The Lo-Dash build file path. ui.buildPath = (function() { var result; switch (build) { @@ -152,7 +152,7 @@ return basePath + result; }()); - // expose module loader file path + // The module loader file path. ui.loaderPath = (function() { var result; switch (loader) { @@ -165,18 +165,9 @@ return basePath + result; }()); - // expose `ui.urlParams` properties - ui.urlParams = { - 'build': build, - 'loader': loader - }; + ui.urlParams = { 'build': build, 'loader': loader }; + ui.timing = { 'loadEventEnd': 0 }; - // expose page load timestamps - ui.timing = { - 'loadEventEnd': 0 - }; - - // expose `ui` window.ui = ui; }(this)); diff --git a/test/asset/weakmap.js b/test/asset/weakmap.js index 06040e664..7040876e6 100644 --- a/test/asset/weakmap.js +++ b/test/asset/weakmap.js @@ -1,21 +1,21 @@ ;(function() { - /** Used to determine if values are of the language type Object */ + /** Used to determine if values are of the language type Object. */ var objectTypes = { 'function': true, 'object': true }; - /** Used as the `WeakMap#toString` return value */ + /** Used as the `WeakMap#toString` return value. */ var nativeString = String(Object.prototype.toString).replace(/toString/g, 'WeakMap'); - /** Used as a reference to the global object */ + /** Used as a reference to the global object. */ var root = (objectTypes[typeof window] && window) || this; - /** Detect free variable `exports` */ + /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = objectTypes[typeof global] && global; if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { root = freeGlobal; @@ -35,7 +35,7 @@ * Creates a `WeakMap` object. */ function WeakMap() { - // no-op + // No operation performed. } /** diff --git a/test/saucelabs.js b/test/saucelabs.js index f1b2edf2f..971b9b26f 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -1,7 +1,7 @@ #!/usr/bin/env node 'use strict'; -/** Environment shortcut */ +/** Environment shortcut. */ var env = process.env; if (env.TRAVIS_SECURE_ENV_VARS == 'false') { @@ -9,35 +9,35 @@ if (env.TRAVIS_SECURE_ENV_VARS == 'false') { process.exit(0); } -/** Load Node.js modules */ +/** Load Node.js modules. */ var EventEmitter = require('events').EventEmitter, http = require('http'), path = require('path'), url = require('url'), util = require('util'); -/** Load other modules */ +/** Load other modules. */ var _ = require('../lodash.js'), chalk = require('chalk'), ecstatic = require('ecstatic'), request = require('request'), SauceTunnel = require('sauce-tunnel'); -/** Used for Sauce Labs credentials */ +/** Used for Sauce Labs credentials. */ var accessKey = env.SAUCE_ACCESS_KEY, username = env.SAUCE_USERNAME; -/** Used as the default maximum number of times to retry a job and tunnel */ +/** Used as the default maximum number of times to retry a job and tunnel. */ var maxJobRetries = 3, maxTunnelRetries = 3; -/** Used as the static file server middleware */ +/** Used as the static file server middleware. */ var mount = ecstatic({ 'cache': 'no-cache', 'root': process.cwd() }); -/** Used as the list of ports supported by Sauce Connect */ +/** Used as the list of ports supported by Sauce Connect. */ var ports = [ 80, 443, 888, 2000, 2001, 2020, 2109, 2222, 2310, 3000, 3001, 3030, 3210, 3333, 4000, 4001, 4040, 4321, 4502, 4503, 4567, 5000, 5001, 5050, 5555, 5432, @@ -46,19 +46,19 @@ var ports = [ 55001 ]; -/** Used by `logInline` to clear previously logged messages */ +/** Used by `logInline` to clear previously logged messages. */ var prevLine = ''; -/** Method shortcut */ +/** Method shortcut. */ var push = Array.prototype.push; -/** Used to detect error messages */ +/** Used to detect error messages. */ var reError = /(?:\be|E)rror\b/; -/** Used to detect valid job ids */ +/** Used to detect valid job ids. */ var reJobId = /^[a-z0-9]{32}$/; -/** Used to display the wait throbber */ +/** Used to display the wait throbber. */ var throbberDelay = 500, waitCount = -1; @@ -92,7 +92,7 @@ var advisor = getOption('advisor', false), tunnelTimeout = getOption('tunnelTimeout', 120), videoUploadOnPass = getOption('videoUploadOnPass', false); -/** Used to convert Sauce Labs browser identifiers to their formal names */ +/** Used to convert Sauce Labs browser identifiers to their formal names. */ var browserNameMap = { 'googlechrome': 'Chrome', 'iehta': 'Internet Explorer', @@ -100,7 +100,7 @@ var browserNameMap = { 'iphone': 'iPhone' }; -/** List of platforms to load the runner on */ +/** List of platforms to load the runner on. */ var platforms = [ //['Linux', 'android', '4.3'], //['Linux', 'android', '4.0'], @@ -125,12 +125,12 @@ var platforms = [ ['OS X 10.6', 'safari', '5'] ]; -/** Used to tailor the `platforms` array */ +/** Used to tailor the `platforms` array. */ var runnerQuery = url.parse(runner, true).query, isBackbone = /\bbackbone\b/i.test(runner), isModern = /\bmodern\b/i.test(runnerQuery.build); -// platforms to test IE compat mode +// The platforms to test IE compatibility modes. if (compatMode) { platforms = [ ['Windows 8.1', 'internet explorer', '11'], @@ -139,7 +139,7 @@ if (compatMode) { ['Windows 7', 'internet explorer', '8'] ]; } -// platforms for AMD tests +// The platforms for AMD tests. if (_.contains(tags, 'amd')) { platforms = _.filter(platforms, function(platform) { var browser = browserName(platform[1]), @@ -152,7 +152,7 @@ if (_.contains(tags, 'amd')) { return true; }); } -// platforms for Backbone tests +// The platforms for Backbone tests. if (isBackbone) { platforms = _.filter(platforms, function(platform) { var browser = browserName(platform[1]), @@ -166,7 +166,7 @@ if (isBackbone) { return true; }); } -// platforms for modern builds +// The platforms for modern builds. if (isModern) { platforms = _.filter(platforms, function(platform) { var browser = browserName(platform[1]), @@ -184,7 +184,7 @@ if (isModern) { }); } -/** Used as the default `Job` options object */ +/** Used as the default `Job` options object. */ var jobOptions = { 'build': build, 'command-timeout': commandTimeout, @@ -298,7 +298,7 @@ function logThrobber() { * @returns {Array} Returns the new converted array. */ function optionToArray(name, string) { - return _.compact(_.invoke((optionToValue(name, string) || '').split(/, */), 'trim')); + return _.compact(_.invoke((optionToValue(name, string) || '').split(/,. */), 'trim')); } /** @@ -742,7 +742,7 @@ function Tunnel(properties) { if (!_.contains(restarted, this)) { restarted.push(this); } - // restart tunnel if all active jobs have restarted + // Restart tunnel if all active jobs have restarted. var threshold = Math.min(all.length, _.isFinite(throttled) ? throttled : 3); if (tunnel.attempts < tunnel.retries && active.length >= threshold && _.isEmpty(_.difference(active, restarted))) { @@ -896,22 +896,22 @@ Tunnel.prototype.stop = function(callback) { /*----------------------------------------------------------------------------*/ -// cleanup any inline logs when exited via `ctrl+c` +// Cleanup any inline logs when exited via `ctrl+c`. process.on('SIGINT', function() { logInline(); process.exit(); }); -// create a web server for the current working directory +// Create a web server for the current working directory. http.createServer(function(req, res) { - // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx + // See http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx. if (compatMode && path.extname(url.parse(req.url).pathname) == '.html') { res.setHeader('X-UA-Compatible', 'IE=' + compatMode); } mount(req, res); }).listen(port); -// set up Sauce Connect so we can use this server from Sauce Labs +// Setup Sauce Connect so we can use this server from Sauce Labs. var tunnel = new Tunnel({ 'user': username, 'pass': accessKey, diff --git a/test/test.js b/test/test.js index d87fa879d..850d2d1c9 100644 --- a/test/test.js +++ b/test/test.js @@ -1,35 +1,35 @@ ;(function() { - /** Used as a safe reference for `undefined` in pre ES5 environments */ + /** Used as a safe reference for `undefined` in pre ES5 environments. */ var undefined; - /** Used to detect when a function becomes hot */ + /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150; - /** Used as the size to cover large array optimizations */ + /** Used as the size to cover large array optimizations. */ var LARGE_ARRAY_SIZE = 200; - /** Used as references for the max length and index of an array */ + /** Used as references for the max length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - /** Used as the maximum length an array-like object */ + /** Used as the maximum length an array-like object. */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - /** Used as a reference to the global object */ + /** Used as a reference to the global object. */ var root = (typeof global == 'object' && global) || this; - /** Used to store Lo-Dash to test for bad extensions/shims */ + /** Used to store Lo-Dash to test for bad extensions/shims. */ var lodashBizarro = root.lodashBizarro; - /** Used for native method references */ + /** Used for native method references. */ var arrayProto = Array.prototype, errorProto = Error.prototype, funcProto = Function.prototype, objectProto = Object.prototype, stringProto = String.prototype; - /** Method and object shortcuts */ + /** Method and object shortcuts. */ var phantom = root.phantom, amd = root.define && define.amd, argv = root.process && process.argv, @@ -49,7 +49,7 @@ toString = objectProto.toString, Uint8Array = root.Uint8Array; - /** Used to set property descriptors */ + /** Used to set property descriptors. */ var defineProperty = (function() { try { var o = {}, @@ -59,7 +59,7 @@ return result; }()); - /** The file path of the Lo-Dash file to test */ + /** The file path of the Lo-Dash file to test. */ var filePath = (function() { var min = 0, result = []; @@ -90,7 +90,7 @@ return result; }()); - /** The `ui` object */ + /** The `ui` object. */ var ui = root.ui || (root.ui = { 'buildPath': filePath, 'loaderPath': '', @@ -99,41 +99,41 @@ 'urlParams': {} }); - /** The basename of the Lo-Dash file to test */ + /** The basename of the Lo-Dash file to test. */ var basename = /[\w.-]+$/.exec(filePath)[0]; - /** Detect if in a Java environment */ + /** Detect if in a Java environment. */ var isJava = !document && !!root.java; - /** Used to indicate testing a modularized build */ + /** Used to indicate testing a modularized build. */ var isModularize = ui.isModularize; - /** Detect if testing `npm` modules */ + /** Detect if testing `npm` modules. */ var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); - /** Detect if running in PhantomJS */ + /** Detect if running in PhantomJS. */ var isPhantom = phantom || typeof callPhantom == 'function'; - /** Detect if running in Rhino */ + /** Detect if running in Rhino. */ var isRhino = isJava && typeof global == 'function' && global().Array === root.Array; - /** Detect if Lo-Dash is in strict mode */ + /** Detect if Lo-Dash is in strict mode. */ var isStrict = ui.isStrict; - /** Used to test Web Workers */ + /** Used to test Web Workers. */ var Worker = !(ui.isForeign || ui.isSauceLabs || isModularize) && document && root.Worker; - /** Used to test host objects in IE */ + /** Used to test host objects in IE. */ try { var xml = new ActiveXObject('Microsoft.XMLDOM'); } catch(e) {} - /** Use a single "load" function */ + /** Use a single "load" function. */ var load = (typeof require == 'function' && !amd) ? require : (isJava && root.load) || noop; - /** The unit testing framework */ + /** The unit testing framework. */ var QUnit = (function() { return root.QUnit || ( root.addEventListener || (root.addEventListener = noop), @@ -144,7 +144,7 @@ ); }()); - /** Load and install QUnit Extras and ES6 Set/WeakMap shims */ + /** Load and install QUnit Extras and ES6 Set/WeakMap shims. */ (function() { var paths = [ './asset/set.js', @@ -165,11 +165,11 @@ /*--------------------------------------------------------------------------*/ - // log params provided to `test.js` + // Log params provided to `test.js`. if (params) { console.log('test.js invoked with arguments: ' + JSON.stringify(slice.call(params))); } - // exit early if going to run tests in a PhantomJS web page + // Exit early if going to run tests in a PhantomJS web page. if (phantom && isModularize) { var page = require('webpage').create(); page.open(filePath, function(status) { @@ -211,14 +211,14 @@ /*--------------------------------------------------------------------------*/ - /** The `lodash` function to test */ + /** The `lodash` function to test. */ var _ = root._ || (root._ = ( _ = load(filePath) || root._, _ = _._ || (isStrict = ui.isStrict = isStrict || 'default' in _, _['default']) || _, (_.runInContext ? _.runInContext(root) : _) )); - /** List of latin-1 supplementary letters to basic latin letters */ + /** List of latin-1 supplementary letters to basic latin letters. */ var burredLetters = [ '\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf', '\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', @@ -226,7 +226,7 @@ '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' ]; - /** List of `burredLetters` translated to basic latin letters */ + /** List of `burredLetters` translated to basic latin letters. */ var deburredLetters = [ 'A', 'A', 'A', 'A', 'A', 'A', 'Ae', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'Th', @@ -234,13 +234,13 @@ 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y' ]; - /** Used to provide falsey values to methods */ + /** Used to provide falsey values to methods. */ var falsey = [, '', 0, false, NaN, null, undefined]; - /** Used to provide empty values to methods */ + /** Used to provide empty values to methods. */ var empties = [[], {}].concat(falsey.slice(1)); - /** Used to test error objects */ + /** Used to test error objects. */ var errors = [ new Error, new EvalError, @@ -251,7 +251,7 @@ new URIError ]; - /** Used to check problem JScript properties (a.k.a. the `[[DontEnum]]` bug) */ + /** Used to check problem JScript properties (a.k.a. the `[[DontEnum]]` bug). */ var shadowedProps = [ 'constructor', 'hasOwnProperty', @@ -262,10 +262,10 @@ 'valueOf' ]; - /** Used to check problem JScript properties too */ + /** Used to check problem JScript properties too. */ var shadowedObject = _.invert(shadowedProps); - /** Used to check whether methods support typed arrays */ + /** Used to check whether methods support typed arrays. */ var typedArrays = [ 'Float32Array', 'Float64Array', @@ -360,13 +360,13 @@ /*--------------------------------------------------------------------------*/ - // setup values for Node.js + // Setup values for Node.js. (function() { if (amd) { return; } try { - // add values from a different realm + // Add values from a different realm. _.extend(_, require('vm').runInNewContext([ '(function() {', ' var object = {', @@ -408,14 +408,14 @@ return _.constant(nativeString.replace(reToString, funcName)); } - // expose `baseEach` for better code coverage + // Expose `baseEach` for better code coverage. if (isModularize && !isNpm) { var path = require('path'), baseEach = require(path.join(path.dirname(filePath), 'internal', 'baseEach.js')); _._baseEach = baseEach.baseEach || baseEach['default'] || baseEach; } - // allow bypassing native checks + // Allow bypassing native checks. setProperty(funcProto, 'toString', function wrapper() { setProperty(funcProto, 'toString', fnToString); var result = _.has(this, 'toString') ? this.toString() : fnToString.call(this); @@ -423,10 +423,10 @@ return result; }); - // add extensions + // Add extensions. funcProto._method = _.noop; - // set bad shims + // Set bad shims. var _isArray = Array.isArray; setProperty(Array, 'isArray', _.noop); @@ -512,23 +512,23 @@ var _WeakMap = root.WeakMap; setProperty(root, 'WeakMap', _.noop); - // fake DOM + // Fake the DOM setProperty(root, 'window', {}); setProperty(root.window, 'document', {}); setProperty(root.window.document, 'createDocumentFragment', function() { return { 'nodeType': 11 }; }); - // fake `WinRTError` + // Fake `WinRTError`. setProperty(root, 'WinRTError', Error); - // clear cache so Lo-Dash can be reloaded + // Clear cache so Lo-Dash can be reloaded. emptyObject(require.cache); - // load Lo-Dash and expose it to the bad extensions/shims + // Load Lo-Dash and expose it to the bad extensions/shims. lodashBizarro = (lodashBizarro = require(filePath))._ || lodashBizarro['default'] || lodashBizarro; - // restore native methods + // Restore native methods. setProperty(Array, 'isArray', _isArray); setProperty(Date, 'now', _now); setProperty(Object, 'create', _create); @@ -568,7 +568,7 @@ delete funcProto._method; }()); - // add values from an iframe + // Add values from an iframe. (function() { if (_._object || !document) { return; @@ -607,7 +607,7 @@ idoc.close(); }()); - // add web worker + // Add a web worker. (function() { if (!Worker) { return; @@ -622,8 +622,8 @@ /*--------------------------------------------------------------------------*/ - // explicitly call `QUnit.module()` instead of `module()` - // in case we are in a CLI environment + // Explicitly call `QUnit.module()` instead of `module()` in case we are + // in a CLI environment. QUnit.module(basename); (function() { @@ -1813,7 +1813,7 @@ }); test('`_.' + methodName + '` should clone `lastIndex` regexp property', 1, function() { - // avoid a regexp literal for older Opera and use `exec` for older Safari + // Avoid a regexp literal for older Opera and use `exec` for older Safari. var regexp = RegExp('x', 'g'); regexp.exec('vwxyz'); @@ -4182,7 +4182,7 @@ }); test('should work with extremely large arrays', 3, function() { - // test in modern browsers + // Test in modern browsers only to avoid browser hangs. if (freeze) { var expected = Array(5e5); @@ -6234,7 +6234,7 @@ }); test('should return `true` for like-objects from different documents', 4, function() { - // ensure `_._object` is assigned (unassigned in Opera 10.00) + // Ensure `_._object` is assigned (unassigned in Opera 10.00). if (_._object) { strictEqual(_.isEqual({ 'a': 1, 'b': 2, 'c': 3 }, _._object), true); strictEqual(_.isEqual({ 'a': 1, 'b': 2, 'c': 2 }, _._object), false); @@ -6501,8 +6501,8 @@ test('should work using its fallback', 3, function() { if (!isModularize) { - // simulate native `Uint8Array` constructor with a `[[Class]]` - // of 'Function' and a `typeof` result of 'object' + // Simulate native `Uint8Array` constructor with a `[[Class]]` + // of 'Function' and a `typeof` result of 'object'. var lodash = _.runInContext({ 'Function': { 'prototype': { @@ -6542,8 +6542,8 @@ }); test('should work with host objects in IE 8 document mode (test in IE 11)', 2, function() { - // trigger Chakra bug - // https://github.com/jashkenas/underscore/issues/1621 + // Trigger a Chakra bug. + // See https://github.com/jashkenas/underscore/issues/1621. _.each([body, xml], function(object) { if (object) { _.times(100, _.isFunction); @@ -6824,14 +6824,14 @@ }); test('should avoid V8 bug #2291 (test in Chrome 19-20)', 1, function() { - // trigger V8 bug - // http://code.google.com/p/v8/issues/detail?id=2291 + // Trigger a V8 bug. + // See http://code.google.com/p/v8/issues/detail?id=2291. var object = {}; - // 1: Useless comparison statement, this is half the trigger + // 1: Useless comparison statement, this is half the trigger. object == object; - // 2: Initial check with object, this is the other half of the trigger + // 2: Initial check with object, this is the other half of the trigger. _.isObject(object); strictEqual(_.isObject('x'), false); @@ -7114,7 +7114,7 @@ deepEqual(func('abc').sort(), ['0', '1', '2']); if (!isKeys) { - // IE 9 doesn't box numbers in for-in loops + // IE 9 doesn't box numbers in for-in loops. Number.prototype.a = 1; deepEqual(func(0).sort(), ['a']); delete Number.prototype.a; @@ -10876,7 +10876,7 @@ array.length = length; - // avoid false fail in older Firefox + // Avoid false fails in older Firefox. if (array.length == length) { var actual = func(array, undefined, function() { steps++; }); strictEqual(steps, 33); @@ -11177,7 +11177,7 @@ }); test('should support single line comments in "evaluate" delimiters (test production builds)', 1, function() { - var compiled = _.template('<% // comment %><% if (value) { %>yap<% } else { %>nope<% } %>'), + var compiled = _.template('<% // A code comment. %><% if (value) { %>yap<% } else { %>nope<% } %>'), data = { 'value': true }; strictEqual(compiled(data), 'yap'); @@ -11304,7 +11304,7 @@ test('should work with templates containing newlines and comments', 1, function() { var compiled = _.template('<%\n\ - // comment\n\ + // A code comment.\n\ if (value) { value += 3; }\n\ %>

<%= value %>

' ); @@ -12177,7 +12177,7 @@ }); test('`_.' + methodName + '` should not remove non-whitespace characters', 1, function() { - // zero-width space (zws), next line character (nel), and non-character (bom) are not whitespace + // Zero-width space (zws), next line character (nel), and non-character (bom) are not whitespace. var problemChars = '\x85\u200b\ufffe', string = problemChars + 'a b c' + problemChars; @@ -13445,7 +13445,7 @@ ok(pass, '`_.' + methodName + '` accepts falsey arguments'); }); - // skip tests for missing methods of modularized builds + // Skip tests for missing methods of modularized builds. _.each(['chain', 'noConflict', 'runInContext'], function(methodName) { if (!_[methodName]) { skipTest();