;(function() { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150; /** Used as the size to cover large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** 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. */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; /** `Object#toString` result references. */ var funcTag = '[object Function]', numberTag = '[object Number]', objectTag = '[object Object]'; /** Used as a reference to the global object. */ var root = (typeof global == 'object' && global) || this; /** Used to store lodash to test for bad extensions/shims. */ var lodashBizarro = root.lodashBizarro; /** 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. */ var phantom = root.phantom, amd = root.define && define.amd, argv = root.process && process.argv, ArrayBuffer = root.ArrayBuffer, document = !phantom && root.document, body = root.document && root.document.body, create = Object.create, fnToString = funcProto.toString, freeze = Object.freeze, hasOwnProperty = objectProto.hasOwnProperty, JSON = root.JSON, noop = function() {}, objToString = objectProto.toString, params = root.arguments, push = arrayProto.push, slice = arrayProto.slice, system = root.system, Uint8Array = root.Uint8Array; /** Used to set property descriptors. */ var defineProperty = (function() { try { var o = {}, func = Object.defineProperty, result = func(o, o, o) && func; } catch(e) {} return result; }()); /** The file path of the lodash file to test. */ var filePath = (function() { var min = 0, result = []; if (phantom) { result = params = phantom.args; } else if (system) { min = 1; result = params = system.args; } else if (argv) { min = 2; result = params = argv; } else if (params) { result = params; } var last = result[result.length - 1]; result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.src.js'; if (!amd) { try { result = require('fs').realpathSync(result); } catch(e) {} try { result = require.resolve(result); } catch(e) {} } return result; }()); /** The `ui` object. */ var ui = root.ui || (root.ui = { 'buildPath': filePath, 'loaderPath': '', 'isModularize': /\b(?:amd|commonjs|es6?|node|npm|(index|main)\.js)\b/.test(filePath), 'isStrict': /\bes6?\b/.test(filePath), 'urlParams': {} }); /** The basename of the lodash file to test. */ var basename = /[\w.-]+$/.exec(filePath)[0]; /** Detect if in a Java environment. */ var isJava = !document && !!root.java; /** Used to indicate testing a modularized build. */ var isModularize = ui.isModularize; /** Detect if testing `npm` modules. */ var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); /** Detect if running in PhantomJS. */ var isPhantom = phantom || typeof callPhantom == 'function'; /** Detect if running in Rhino. */ var isRhino = isJava && typeof global == 'function' && global().Array === root.Array; /** Detect if lodash is in strict mode. */ var isStrict = ui.isStrict; /** Used to test Web Workers. */ var Worker = !(ui.isForeign || ui.isSauceLabs || isModularize) && document && root.Worker; /** Used to test host objects in IE. */ try { var xml = new ActiveXObject('Microsoft.XMLDOM'); } catch(e) {} /** Use a single "load" function. */ var load = (typeof require == 'function' && !amd) ? require : (isJava ? root.load : noop); /** The unit testing framework. */ var QUnit = root.QUnit || (root.QUnit = ( QUnit = load('../node_modules/qunitjs/qunit/qunit.js') || root.QUnit, QUnit = QUnit.QUnit || QUnit )); /** Load and install QUnit Extras and ES6 Set/WeakMap shims. */ (function() { var paths = [ './asset/set.js', './asset/weakmap.js', '../node_modules/qunit-extras/qunit-extras.js' ]; var index = -1, length = paths.length; while (++index < length) { var object = load(paths[index]); if (object) { object.runInContext(root); } } }()); /*--------------------------------------------------------------------------*/ // 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. if (phantom && isModularize) { var page = require('webpage').create(); page.open(filePath, function(status) { if (status != 'success') { console.log('PhantomJS failed to load page: ' + filePath); phantom.exit(1); } }); page.onCallback = function(details) { var coverage = details.coverage; if (coverage) { var fs = require('fs'), cwd = fs.workingDirectory, sep = fs.separator; fs.write([cwd, 'coverage', 'coverage.json'].join(sep), JSON.stringify(coverage)); } phantom.exit(details.failed ? 1 : 0); }; page.onConsoleMessage = function(message) { console.log(message); }; page.onInitialized = function() { page.evaluate(function() { document.addEventListener('DOMContentLoaded', function() { QUnit.done(function(details) { details.coverage = window.__coverage__; callPhantom(details); }); }); }); }; return; } /*--------------------------------------------------------------------------*/ /** 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. */ 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', '\xdf', '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' ]; /** 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', 'ss', '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', 'y' ]; /** Used to provide falsey values to methods. */ var falsey = [, '', 0, false, NaN, null, undefined]; /** Used to provide empty values to methods. */ var empties = [[], {}].concat(falsey.slice(1)); /** Used to test error objects. */ var errors = [ new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError ]; /** Used to check problem JScript properties (a.k.a. the `[[DontEnum]]` bug). */ var shadowProps = [ 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf' ]; /** Used to check problem JScript properties too. */ var shadowObject = _.invert(shadowProps); /** Used to check whether methods support typed arrays. */ var typedArrays = [ 'Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array' ]; /** * Used to check for problems removing whitespace. For a whitespace reference * see V8's unit test https://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/whitespaces.js. */ var whitespace = ' \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'; /** * Extracts the unwrapped value from its wrapper. * * @private * @param {Object} wrapper The wrapper to unwrap. * @returns {*} Returns the unwrapped value. */ function getUnwrappedValue(wrapper) { var index = -1, actions = wrapper.__actions__, length = actions.length, result = wrapper.__wrapped__; while (++index < length) { var args = [result], action = actions[index]; push.apply(args, action.args); result = action.func.apply(action.thisArg, args); } return result; } /** * Removes all own enumerable properties from a given object. * * @private * @param {Object} object The object to empty. */ function emptyObject(object) { _.forOwn(object, function(value, key, object) { delete object[key]; }); } /** * Sets a non-enumerable property value on `object`. * * Note: This function is used to avoid a bug in older versions of V8 where * overwriting non-enumerable built-ins makes them enumerable. * See https://code.google.com/p/v8/issues/detail?id=1623 * * @private * @param {Object} object The object augment. * @param {string} key The name of the property to set. * @param {*} value The property value. */ function setProperty(object, key, value) { try { defineProperty(object, key, { 'configurable': true, 'enumerable': false, 'writable': true, 'value': value }); } catch(e) { object[key] = value; } } /** * Skips a given number of tests with a passing result. * * @private * @param {number} [count=1] The number of tests to skip. */ function skipTest(count) { count || (count = 1); while (count--) { ok(true, 'test skipped'); } } /*--------------------------------------------------------------------------*/ // Setup values for Node.js. (function() { if (amd) { return; } try { // Add values from a different realm. _.extend(_, require('vm').runInNewContext([ '(function() {', ' var object = {', " '_arguments': (function() { return arguments; }(1, 2, 3)),", " '_array': [1, 2, 3],", " '_boolean': Object(false),", " '_date': new Date,", " '_errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", " '_function': function() {},", " '_nan': NaN,", " '_null': null,", " '_number': Object(0),", " '_object': { 'a': 1, 'b': 2, 'c': 3 },", " '_regexp': /x/,", " '_string': Object('a'),", " '_undefined': undefined", ' };', '', " ['" + typedArrays.join("', '") + "'].forEach(function(type) {", " var Ctor = Function('return typeof ' + type + \" != 'undefined' && \" + type)()", ' if (Ctor) {', " object['_' + type.toLowerCase()] = new Ctor(new ArrayBuffer(24));", ' }', " });", '', ' return object;', '}())' ].join('\n'))); } catch(e) { if (!phantom) { return; } } var nativeString = fnToString.call(toString), reToString = /toString/g; function createToString(funcName) { return _.constant(nativeString.replace(reToString, funcName)); } // Expose internal modules for better code coverage. if (isModularize && !isNpm) { _.each(['baseEach', 'isIndex', 'isIterateeCall', 'isLength'], function(funcName) { var path = require('path'), func = require(path.join(path.dirname(filePath), 'internal', 'baseEach.js')); _['_' + funcName] = func[funcName] || func['default'] || func; }); } // Allow bypassing native checks. setProperty(funcProto, 'toString', function wrapper() { setProperty(funcProto, 'toString', fnToString); var result = _.has(this, 'toString') ? this.toString() : fnToString.call(this); setProperty(funcProto, 'toString', wrapper); return result; }); // Add built-in prototype extensions. funcProto._method = _.noop; // Set bad shims. var _isArray = Array.isArray; setProperty(Array, 'isArray', _.noop); var _now = Date.now; setProperty(Date, 'now', _.noop); var _getPrototypeOf = Object.getPrototypeOf; setProperty(Object, 'getPrototypeOf', _.noop); var _keys = Object.keys; setProperty(Object, 'keys', _.noop); var _propertyIsEnumerable = objectProto.propertyIsEnumerable; setProperty(objectProto, 'propertyIsEnumerable', function(key) { if (key == '1' && _.isArguments(this) && _.isEqual(_.values(this), [0, 0])) { throw new Error; } return _.has(this, key); }); var _isFinite = Number.isFinite; setProperty(Number, 'isFinite', _.noop); var _ArrayBuffer = ArrayBuffer; setProperty(root, 'ArrayBuffer', (function() { function ArrayBuffer(byteLength) { var buffer = new _ArrayBuffer(byteLength); if (!byteLength) { setProperty(buffer, 'slice', buffer.slice ? null : bufferSlice); } return buffer; } function bufferSlice() { var newBuffer = new _ArrayBuffer(this.byteLength), view = new Uint8Array(newBuffer); view.set(new Uint8Array(this)); return newBuffer; } setProperty(ArrayBuffer, 'toString', createToString('ArrayBuffer')); setProperty(bufferSlice, 'toString', createToString('slice')); return ArrayBuffer; }())); if (!root.Float64Array) { setProperty(root, 'Float64Array', (function() { function Float64Array(buffer, byteOffset, length) { return arguments.length == 1 ? new Uint8Array(buffer) : new Uint8Array(buffer, byteOffset || 0, length || buffer.byteLength); } setProperty(Float64Array, 'BYTES_PER_ELEMENT', 8); setProperty(Float64Array, 'toString', createToString('Float64Array')); return Float64Array; }())); } var _parseInt = parseInt; setProperty(root, 'parseInt', (function() { var checkStr = whitespace + '08', isFaked = _parseInt(checkStr) != 8, reHexPrefix = /^0[xX]/, reTrim = RegExp('^[' + whitespace + ']+|[' + whitespace + ']+$'); return function(value, radix) { if (value == checkStr && !isFaked) { isFaked = true; return 0; } value = String(value == null ? '' : value).replace(reTrim, ''); return _parseInt(value, +radix || (reHexPrefix.test(value) ? 16 : 10)); }; }())); var _Set = root.Set; setProperty(root, 'Set', _.noop); var _WeakMap = root.WeakMap; setProperty(root, 'WeakMap', _.noop); // Fake the DOM. setProperty(root, 'window', {}); setProperty(root.window, 'document', {}); setProperty(root.window.document, 'createDocumentFragment', function() { return { 'nodeType': 11 }; }); // Fake `WinRTError`. setProperty(root, 'WinRTError', Error); // Clear cache so lodash can be reloaded. emptyObject(require.cache); // Load lodash and expose it to the bad extensions/shims. lodashBizarro = (lodashBizarro = require(filePath))._ || lodashBizarro['default'] || lodashBizarro; // Restore built-in methods. setProperty(Array, 'isArray', _isArray); setProperty(Date, 'now', _now); setProperty(Object, 'getPrototypeOf', _getPrototypeOf); setProperty(Object, 'keys', _keys); setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable); setProperty(root, 'parseInt', _parseInt); if (_isFinite) { setProperty(Number, 'isFinite', _isFinite); } else { delete Number.isFinite; } if (_ArrayBuffer) { setProperty(root, 'ArrayBuffer', _ArrayBuffer); } else { delete root.ArrayBuffer; } if (_Set) { setProperty(root, 'Set', Set); } else { delete root.Set; } if (_WeakMap) { setProperty(root, 'WeakMap', WeakMap); } else { delete root.WeakMap; } delete root.WinRTError; delete root.window; delete funcProto._method; }()); // Add values from an iframe. (function() { if (_._object || !document) { return; } var iframe = document.createElement('iframe'); iframe.frameBorder = iframe.height = iframe.width = 0; body.appendChild(iframe); var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; idoc.write([ '