UNPKG

78.7 kBJavaScriptView Raw
1/*!
2 * @nuxt/cli v2.12.0 (c) 2016-2020
3
4 * - All the amazing contributors
5 * Released under the MIT License.
6 * Website: https://nuxtjs.org
7*/
8'use strict';
9
10function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
11
12function _interopNamespace(e) {
13 if (e && e.__esModule) { return e; } else {
14 var n = {};
15 if (e) {
16 Object.keys(e).forEach(function (k) {
17 var d = Object.getOwnPropertyDescriptor(e, k);
18 Object.defineProperty(n, k, d.get ? d : {
19 enumerable: true,
20 get: function () {
21 return e[k];
22 }
23 });
24 });
25 }
26 n['default'] = e;
27 return n;
28 }
29}
30
31const path = _interopDefault(require('path'));
32const config = require('@nuxt/config');
33const exit = _interopDefault(require('exit'));
34const utils = require('@nuxt/utils');
35const chalk = _interopDefault(require('chalk'));
36const env = _interopDefault(require('std-env'));
37const wrapAnsi = _interopDefault(require('wrap-ansi'));
38const boxen = _interopDefault(require('boxen'));
39const consola = _interopDefault(require('consola'));
40const minimist = _interopDefault(require('minimist'));
41const Hookable = _interopDefault(require('hable'));
42const fs = _interopDefault(require('fs'));
43const execa = _interopDefault(require('execa'));
44
45const commands = {
46 start: () => new Promise(function (resolve) { resolve(require('./cli-start.js')); }),
47 dev: () => new Promise(function (resolve) { resolve(require('./cli-dev.js')); }),
48 build: () => new Promise(function (resolve) { resolve(require('./cli-build.js')); }),
49 generate: () => new Promise(function (resolve) { resolve(require('./cli-generate.js')); }),
50 webpack: () => new Promise(function (resolve) { resolve(require('./cli-webpack.js')); }),
51 help: () => new Promise(function (resolve) { resolve(require('./cli-help.js')); })
52};
53
54function getCommand (name) {
55 if (!commands[name]) {
56 return Promise.resolve(null)
57 }
58 return commands[name]().then(m => m.default)
59}
60
61const index = /*#__PURE__*/Object.freeze({
62 __proto__: null,
63 'default': getCommand
64});
65
66const localNodeModules = path.resolve(process.cwd(), 'node_modules');
67
68// Prefer importing modules from local node_modules (for NPX and global bin)
69async function _import (modulePath) {
70 for (const mp of [
71 path.resolve(localNodeModules, modulePath),
72 modulePath
73 ]) {
74 try {
75 return await new Promise(function (resolve) { resolve(_interopNamespace(require(mp))); })
76 } catch (e) {
77 if (e.code !== 'MODULE_NOT_FOUND') {
78 throw e
79 }
80 }
81 }
82
83 const error = new Error(`Cannot import module '${modulePath}'`);
84 error.code = 'MODULE_NOT_FOUND';
85 throw error
86}
87
88const builder = () => _import('@nuxt/builder');
89const webpack = () => _import('@nuxt/webpack');
90const generator = () => _import('@nuxt/generator');
91const core = () => _import('@nuxt/core');
92
93const importModule = _import;
94
95const imports = /*#__PURE__*/Object.freeze({
96 __proto__: null,
97 builder: builder,
98 webpack: webpack,
99 generator: generator,
100 core: core,
101 importModule: importModule
102});
103
104const forceExitTimeout = 5;
105
106const startSpaces = 2;
107const optionSpaces = 2;
108
109// 80% of terminal column width
110// this is a fn because console width can have changed since startup
111const maxCharsPerLine = () => (process.stdout.columns || 100) * 80 / 100;
112
113function indent (count, chr = ' ') {
114 return chr.repeat(count)
115}
116
117function indentLines (string, spaces, firstLineSpaces) {
118 const lines = Array.isArray(string) ? string : string.split('\n');
119 let s = '';
120 if (lines.length) {
121 const i0 = indent(firstLineSpaces === undefined ? spaces : firstLineSpaces);
122 s = i0 + lines.shift();
123 }
124 if (lines.length) {
125 const i = indent(spaces);
126 s += '\n' + lines.map(l => i + l).join('\n');
127 }
128 return s
129}
130
131function foldLines (string, spaces, firstLineSpaces, charsPerLine = maxCharsPerLine()) {
132 return indentLines(wrapAnsi(string, charsPerLine), spaces, firstLineSpaces)
133}
134
135function colorize (text) {
136 return text
137 .replace(/\[[^ ]+]/g, m => chalk.grey(m))
138 .replace(/<[^ ]+>/g, m => chalk.green(m))
139 .replace(/ (-[-\w,]+)/g, m => chalk.bold(m))
140 .replace(/`([^`]+)`/g, (_, m) => chalk.bold.cyan(m))
141}
142
143function box (message, title, options) {
144 return boxen([
145 title || chalk.white('Nuxt Message'),
146 '',
147 chalk.white(foldLines(message, 0, 0, maxCharsPerLine()))
148 ].join('\n'), Object.assign({
149 borderColor: 'white',
150 borderStyle: 'round',
151 padding: 1,
152 margin: 1
153 }, options)) + '\n'
154}
155
156function successBox (message, title) {
157 return box(message, title || chalk.green('✔ Nuxt Success'), {
158 borderColor: 'green'
159 })
160}
161
162function warningBox (message, title) {
163 return box(message, title || chalk.yellow('⚠ Nuxt Warning'), {
164 borderColor: 'yellow'
165 })
166}
167
168function errorBox (message, title) {
169 return box(message, title || chalk.red('✖ Nuxt Error'), {
170 borderColor: 'red'
171 })
172}
173
174function fatalBox (message, title) {
175 return errorBox(message, title || chalk.red('✖ Nuxt Fatal Error'))
176}
177
178const eventsMapping = {
179 add: { icon: '+', color: 'green', action: 'Created' },
180 change: { icon: env.windows ? '»' : '↻', color: 'blue', action: 'Updated' },
181 unlink: { icon: '-', color: 'red', action: 'Removed' }
182};
183
184function formatPath (filePath) {
185 if (!filePath) {
186 return
187 }
188 return filePath.replace(process.cwd() + path.sep, '')
189}
190
191/**
192 * Normalize string argument in command
193 *
194 * @export
195 * @param {String} argument
196 * @param {*} defaultValue
197 * @returns formatted argument
198 */
199function normalizeArg (arg, defaultValue) {
200 switch (arg) {
201 case 'true': arg = true; break
202 case '': arg = true; break
203 case 'false': arg = false; break
204 case undefined: arg = defaultValue; break
205 }
206 return arg
207}
208
209function forceExit (cmdName, timeout) {
210 if (timeout !== false) {
211 const exitTimeout = setTimeout(() => {
212 const msg = `The command 'nuxt ${cmdName}' finished but did not exit after ${timeout}s
213This is most likely not caused by a bug in Nuxt.js
214Make sure to cleanup all timers and listeners you or your plugins/modules start.
215Nuxt.js will now force exit
216
217${chalk.bold('DeprecationWarning: Starting with Nuxt version 3 this will be a fatal error')}`;
218
219 // TODO: Change this to a fatal error in v3
220 process.stderr.write(warningBox(msg));
221 exit(0);
222 }, timeout * 1000);
223 exitTimeout.unref();
224 } else {
225 exit(0);
226 }
227}
228
229// An immediate export throws an error when mocking with jest
230// TypeError: Cannot set property createLock of #<Object> which has only a getter
231function createLock (...args) {
232 return utils.lock(...args)
233}
234
235const common = {
236 spa: {
237 alias: 's',
238 type: 'boolean',
239 description: 'Launch in SPA mode'
240 },
241 universal: {
242 alias: 'u',
243 type: 'boolean',
244 description: 'Launch in Universal mode (default)'
245 },
246 'config-file': {
247 alias: 'c',
248 type: 'string',
249 default: config.defaultNuxtConfigFile,
250 description: `Path to Nuxt.js config file (default: \`${config.defaultNuxtConfigFile}\`)`
251 },
252 modern: {
253 alias: 'm',
254 type: 'string',
255 description: 'Build/Start app for modern browsers, e.g. server, client and false',
256 prepare (cmd, options, argv) {
257 if (argv.modern !== undefined) {
258 options.modern = normalizeArg(argv.modern);
259 }
260 }
261 },
262 'force-exit': {
263 type: 'boolean',
264 default (cmd) {
265 return ['build', 'generate'].includes(cmd.name)
266 },
267 description: 'Whether Nuxt.js should force exit after the command has finished'
268 },
269 version: {
270 alias: 'v',
271 type: 'boolean',
272 description: 'Display the Nuxt version'
273 },
274 help: {
275 alias: 'h',
276 type: 'boolean',
277 description: 'Display this message'
278 }
279};
280
281const server = {
282 port: {
283 alias: 'p',
284 type: 'string',
285 description: 'Port number on which to start the application',
286 prepare (cmd, options, argv) {
287 if (argv.port) {
288 options.server.port = +argv.port;
289 }
290 }
291 },
292 hostname: {
293 alias: 'H',
294 type: 'string',
295 description: 'Hostname on which to start the application',
296 prepare (cmd, options, argv) {
297 if (argv.hostname === '') {
298 consola.fatal('Provided hostname argument has no value');
299 }
300 }
301 },
302 'unix-socket': {
303 alias: 'n',
304 type: 'string',
305 description: 'Path to a UNIX socket'
306 }
307};
308
309const locking = {
310 lock: {
311 type: 'boolean',
312 default: true,
313 description: 'Do not set a lock on the project when building'
314 }
315};
316
317
318
319const index$1 = /*#__PURE__*/Object.freeze({
320 __proto__: null,
321 common: common,
322 server: server,
323 locking: locking
324});
325
326var name = "@nuxt/cli";
327var version = "2.12.0";
328
329/**
330 * A faster alternative to `Function#apply`, this function invokes `func`
331 * with the `this` binding of `thisArg` and the arguments of `args`.
332 *
333 * @private
334 * @param {Function} func The function to invoke.
335 * @param {*} thisArg The `this` binding of `func`.
336 * @param {Array} args The arguments to invoke `func` with.
337 * @returns {*} Returns the result of `func`.
338 */
339function apply(func, thisArg, args) {
340 switch (args.length) {
341 case 0: return func.call(thisArg);
342 case 1: return func.call(thisArg, args[0]);
343 case 2: return func.call(thisArg, args[0], args[1]);
344 case 3: return func.call(thisArg, args[0], args[1], args[2]);
345 }
346 return func.apply(thisArg, args);
347}
348
349var _apply = apply;
350
351/**
352 * This method returns the first argument it receives.
353 *
354 * @static
355 * @since 0.1.0
356 * @memberOf _
357 * @category Util
358 * @param {*} value Any value.
359 * @returns {*} Returns `value`.
360 * @example
361 *
362 * var object = { 'a': 1 };
363 *
364 * console.log(_.identity(object) === object);
365 * // => true
366 */
367function identity(value) {
368 return value;
369}
370
371var identity_1 = identity;
372
373/* Built-in method references for those with the same name as other `lodash` methods. */
374var nativeMax = Math.max;
375
376/**
377 * A specialized version of `baseRest` which transforms the rest array.
378 *
379 * @private
380 * @param {Function} func The function to apply a rest parameter to.
381 * @param {number} [start=func.length-1] The start position of the rest parameter.
382 * @param {Function} transform The rest array transform.
383 * @returns {Function} Returns the new function.
384 */
385function overRest(func, start, transform) {
386 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
387 return function() {
388 var args = arguments,
389 index = -1,
390 length = nativeMax(args.length - start, 0),
391 array = Array(length);
392
393 while (++index < length) {
394 array[index] = args[start + index];
395 }
396 index = -1;
397 var otherArgs = Array(start + 1);
398 while (++index < start) {
399 otherArgs[index] = args[index];
400 }
401 otherArgs[start] = transform(array);
402 return _apply(func, this, otherArgs);
403 };
404}
405
406var _overRest = overRest;
407
408/**
409 * Creates a function that returns `value`.
410 *
411 * @static
412 * @memberOf _
413 * @since 2.4.0
414 * @category Util
415 * @param {*} value The value to return from the new function.
416 * @returns {Function} Returns the new constant function.
417 * @example
418 *
419 * var objects = _.times(2, _.constant({ 'a': 1 }));
420 *
421 * console.log(objects);
422 * // => [{ 'a': 1 }, { 'a': 1 }]
423 *
424 * console.log(objects[0] === objects[1]);
425 * // => true
426 */
427function constant(value) {
428 return function() {
429 return value;
430 };
431}
432
433var constant_1 = constant;
434
435var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
436
437function createCommonjsModule(fn, module) {
438 return module = { exports: {} }, fn(module, module.exports), module.exports;
439}
440
441/** Detect free variable `global` from Node.js. */
442var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
443
444var _freeGlobal = freeGlobal;
445
446/** Detect free variable `self`. */
447var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
448
449/** Used as a reference to the global object. */
450var root = _freeGlobal || freeSelf || Function('return this')();
451
452var _root = root;
453
454/** Built-in value references. */
455var Symbol = _root.Symbol;
456
457var _Symbol = Symbol;
458
459/** Used for built-in method references. */
460var objectProto = Object.prototype;
461
462/** Used to check objects for own properties. */
463var hasOwnProperty = objectProto.hasOwnProperty;
464
465/**
466 * Used to resolve the
467 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
468 * of values.
469 */
470var nativeObjectToString = objectProto.toString;
471
472/** Built-in value references. */
473var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
474
475/**
476 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
477 *
478 * @private
479 * @param {*} value The value to query.
480 * @returns {string} Returns the raw `toStringTag`.
481 */
482function getRawTag(value) {
483 var isOwn = hasOwnProperty.call(value, symToStringTag),
484 tag = value[symToStringTag];
485
486 try {
487 value[symToStringTag] = undefined;
488 var unmasked = true;
489 } catch (e) {}
490
491 var result = nativeObjectToString.call(value);
492 if (unmasked) {
493 if (isOwn) {
494 value[symToStringTag] = tag;
495 } else {
496 delete value[symToStringTag];
497 }
498 }
499 return result;
500}
501
502var _getRawTag = getRawTag;
503
504/** Used for built-in method references. */
505var objectProto$1 = Object.prototype;
506
507/**
508 * Used to resolve the
509 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
510 * of values.
511 */
512var nativeObjectToString$1 = objectProto$1.toString;
513
514/**
515 * Converts `value` to a string using `Object.prototype.toString`.
516 *
517 * @private
518 * @param {*} value The value to convert.
519 * @returns {string} Returns the converted string.
520 */
521function objectToString(value) {
522 return nativeObjectToString$1.call(value);
523}
524
525var _objectToString = objectToString;
526
527/** `Object#toString` result references. */
528var nullTag = '[object Null]',
529 undefinedTag = '[object Undefined]';
530
531/** Built-in value references. */
532var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
533
534/**
535 * The base implementation of `getTag` without fallbacks for buggy environments.
536 *
537 * @private
538 * @param {*} value The value to query.
539 * @returns {string} Returns the `toStringTag`.
540 */
541function baseGetTag(value) {
542 if (value == null) {
543 return value === undefined ? undefinedTag : nullTag;
544 }
545 return (symToStringTag$1 && symToStringTag$1 in Object(value))
546 ? _getRawTag(value)
547 : _objectToString(value);
548}
549
550var _baseGetTag = baseGetTag;
551
552/**
553 * Checks if `value` is the
554 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
555 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
556 *
557 * @static
558 * @memberOf _
559 * @since 0.1.0
560 * @category Lang
561 * @param {*} value The value to check.
562 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
563 * @example
564 *
565 * _.isObject({});
566 * // => true
567 *
568 * _.isObject([1, 2, 3]);
569 * // => true
570 *
571 * _.isObject(_.noop);
572 * // => true
573 *
574 * _.isObject(null);
575 * // => false
576 */
577function isObject(value) {
578 var type = typeof value;
579 return value != null && (type == 'object' || type == 'function');
580}
581
582var isObject_1 = isObject;
583
584/** `Object#toString` result references. */
585var asyncTag = '[object AsyncFunction]',
586 funcTag = '[object Function]',
587 genTag = '[object GeneratorFunction]',
588 proxyTag = '[object Proxy]';
589
590/**
591 * Checks if `value` is classified as a `Function` object.
592 *
593 * @static
594 * @memberOf _
595 * @since 0.1.0
596 * @category Lang
597 * @param {*} value The value to check.
598 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
599 * @example
600 *
601 * _.isFunction(_);
602 * // => true
603 *
604 * _.isFunction(/abc/);
605 * // => false
606 */
607function isFunction(value) {
608 if (!isObject_1(value)) {
609 return false;
610 }
611 // The use of `Object#toString` avoids issues with the `typeof` operator
612 // in Safari 9 which returns 'object' for typed arrays and other constructors.
613 var tag = _baseGetTag(value);
614 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
615}
616
617var isFunction_1 = isFunction;
618
619/** Used to detect overreaching core-js shims. */
620var coreJsData = _root['__core-js_shared__'];
621
622var _coreJsData = coreJsData;
623
624/** Used to detect methods masquerading as native. */
625var maskSrcKey = (function() {
626 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
627 return uid ? ('Symbol(src)_1.' + uid) : '';
628}());
629
630/**
631 * Checks if `func` has its source masked.
632 *
633 * @private
634 * @param {Function} func The function to check.
635 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
636 */
637function isMasked(func) {
638 return !!maskSrcKey && (maskSrcKey in func);
639}
640
641var _isMasked = isMasked;
642
643/** Used for built-in method references. */
644var funcProto = Function.prototype;
645
646/** Used to resolve the decompiled source of functions. */
647var funcToString = funcProto.toString;
648
649/**
650 * Converts `func` to its source code.
651 *
652 * @private
653 * @param {Function} func The function to convert.
654 * @returns {string} Returns the source code.
655 */
656function toSource(func) {
657 if (func != null) {
658 try {
659 return funcToString.call(func);
660 } catch (e) {}
661 try {
662 return (func + '');
663 } catch (e) {}
664 }
665 return '';
666}
667
668var _toSource = toSource;
669
670/**
671 * Used to match `RegExp`
672 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
673 */
674var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
675
676/** Used to detect host constructors (Safari). */
677var reIsHostCtor = /^\[object .+?Constructor\]$/;
678
679/** Used for built-in method references. */
680var funcProto$1 = Function.prototype,
681 objectProto$2 = Object.prototype;
682
683/** Used to resolve the decompiled source of functions. */
684var funcToString$1 = funcProto$1.toString;
685
686/** Used to check objects for own properties. */
687var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
688
689/** Used to detect if a method is native. */
690var reIsNative = RegExp('^' +
691 funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
692 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
693);
694
695/**
696 * The base implementation of `_.isNative` without bad shim checks.
697 *
698 * @private
699 * @param {*} value The value to check.
700 * @returns {boolean} Returns `true` if `value` is a native function,
701 * else `false`.
702 */
703function baseIsNative(value) {
704 if (!isObject_1(value) || _isMasked(value)) {
705 return false;
706 }
707 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
708 return pattern.test(_toSource(value));
709}
710
711var _baseIsNative = baseIsNative;
712
713/**
714 * Gets the value at `key` of `object`.
715 *
716 * @private
717 * @param {Object} [object] The object to query.
718 * @param {string} key The key of the property to get.
719 * @returns {*} Returns the property value.
720 */
721function getValue(object, key) {
722 return object == null ? undefined : object[key];
723}
724
725var _getValue = getValue;
726
727/**
728 * Gets the native function at `key` of `object`.
729 *
730 * @private
731 * @param {Object} object The object to query.
732 * @param {string} key The key of the method to get.
733 * @returns {*} Returns the function if it's native, else `undefined`.
734 */
735function getNative(object, key) {
736 var value = _getValue(object, key);
737 return _baseIsNative(value) ? value : undefined;
738}
739
740var _getNative = getNative;
741
742var defineProperty = (function() {
743 try {
744 var func = _getNative(Object, 'defineProperty');
745 func({}, '', {});
746 return func;
747 } catch (e) {}
748}());
749
750var _defineProperty = defineProperty;
751
752/**
753 * The base implementation of `setToString` without support for hot loop shorting.
754 *
755 * @private
756 * @param {Function} func The function to modify.
757 * @param {Function} string The `toString` result.
758 * @returns {Function} Returns `func`.
759 */
760var baseSetToString = !_defineProperty ? identity_1 : function(func, string) {
761 return _defineProperty(func, 'toString', {
762 'configurable': true,
763 'enumerable': false,
764 'value': constant_1(string),
765 'writable': true
766 });
767};
768
769var _baseSetToString = baseSetToString;
770
771/** Used to detect hot functions by number of calls within a span of milliseconds. */
772var HOT_COUNT = 800,
773 HOT_SPAN = 16;
774
775/* Built-in method references for those with the same name as other `lodash` methods. */
776var nativeNow = Date.now;
777
778/**
779 * Creates a function that'll short out and invoke `identity` instead
780 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
781 * milliseconds.
782 *
783 * @private
784 * @param {Function} func The function to restrict.
785 * @returns {Function} Returns the new shortable function.
786 */
787function shortOut(func) {
788 var count = 0,
789 lastCalled = 0;
790
791 return function() {
792 var stamp = nativeNow(),
793 remaining = HOT_SPAN - (stamp - lastCalled);
794
795 lastCalled = stamp;
796 if (remaining > 0) {
797 if (++count >= HOT_COUNT) {
798 return arguments[0];
799 }
800 } else {
801 count = 0;
802 }
803 return func.apply(undefined, arguments);
804 };
805}
806
807var _shortOut = shortOut;
808
809/**
810 * Sets the `toString` method of `func` to return `string`.
811 *
812 * @private
813 * @param {Function} func The function to modify.
814 * @param {Function} string The `toString` result.
815 * @returns {Function} Returns `func`.
816 */
817var setToString = _shortOut(_baseSetToString);
818
819var _setToString = setToString;
820
821/**
822 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
823 *
824 * @private
825 * @param {Function} func The function to apply a rest parameter to.
826 * @param {number} [start=func.length-1] The start position of the rest parameter.
827 * @returns {Function} Returns the new function.
828 */
829function baseRest(func, start) {
830 return _setToString(_overRest(func, start, identity_1), func + '');
831}
832
833var _baseRest = baseRest;
834
835/**
836 * Removes all key-value entries from the list cache.
837 *
838 * @private
839 * @name clear
840 * @memberOf ListCache
841 */
842function listCacheClear() {
843 this.__data__ = [];
844 this.size = 0;
845}
846
847var _listCacheClear = listCacheClear;
848
849/**
850 * Performs a
851 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
852 * comparison between two values to determine if they are equivalent.
853 *
854 * @static
855 * @memberOf _
856 * @since 4.0.0
857 * @category Lang
858 * @param {*} value The value to compare.
859 * @param {*} other The other value to compare.
860 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
861 * @example
862 *
863 * var object = { 'a': 1 };
864 * var other = { 'a': 1 };
865 *
866 * _.eq(object, object);
867 * // => true
868 *
869 * _.eq(object, other);
870 * // => false
871 *
872 * _.eq('a', 'a');
873 * // => true
874 *
875 * _.eq('a', Object('a'));
876 * // => false
877 *
878 * _.eq(NaN, NaN);
879 * // => true
880 */
881function eq(value, other) {
882 return value === other || (value !== value && other !== other);
883}
884
885var eq_1 = eq;
886
887/**
888 * Gets the index at which the `key` is found in `array` of key-value pairs.
889 *
890 * @private
891 * @param {Array} array The array to inspect.
892 * @param {*} key The key to search for.
893 * @returns {number} Returns the index of the matched value, else `-1`.
894 */
895function assocIndexOf(array, key) {
896 var length = array.length;
897 while (length--) {
898 if (eq_1(array[length][0], key)) {
899 return length;
900 }
901 }
902 return -1;
903}
904
905var _assocIndexOf = assocIndexOf;
906
907/** Used for built-in method references. */
908var arrayProto = Array.prototype;
909
910/** Built-in value references. */
911var splice = arrayProto.splice;
912
913/**
914 * Removes `key` and its value from the list cache.
915 *
916 * @private
917 * @name delete
918 * @memberOf ListCache
919 * @param {string} key The key of the value to remove.
920 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
921 */
922function listCacheDelete(key) {
923 var data = this.__data__,
924 index = _assocIndexOf(data, key);
925
926 if (index < 0) {
927 return false;
928 }
929 var lastIndex = data.length - 1;
930 if (index == lastIndex) {
931 data.pop();
932 } else {
933 splice.call(data, index, 1);
934 }
935 --this.size;
936 return true;
937}
938
939var _listCacheDelete = listCacheDelete;
940
941/**
942 * Gets the list cache value for `key`.
943 *
944 * @private
945 * @name get
946 * @memberOf ListCache
947 * @param {string} key The key of the value to get.
948 * @returns {*} Returns the entry value.
949 */
950function listCacheGet(key) {
951 var data = this.__data__,
952 index = _assocIndexOf(data, key);
953
954 return index < 0 ? undefined : data[index][1];
955}
956
957var _listCacheGet = listCacheGet;
958
959/**
960 * Checks if a list cache value for `key` exists.
961 *
962 * @private
963 * @name has
964 * @memberOf ListCache
965 * @param {string} key The key of the entry to check.
966 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
967 */
968function listCacheHas(key) {
969 return _assocIndexOf(this.__data__, key) > -1;
970}
971
972var _listCacheHas = listCacheHas;
973
974/**
975 * Sets the list cache `key` to `value`.
976 *
977 * @private
978 * @name set
979 * @memberOf ListCache
980 * @param {string} key The key of the value to set.
981 * @param {*} value The value to set.
982 * @returns {Object} Returns the list cache instance.
983 */
984function listCacheSet(key, value) {
985 var data = this.__data__,
986 index = _assocIndexOf(data, key);
987
988 if (index < 0) {
989 ++this.size;
990 data.push([key, value]);
991 } else {
992 data[index][1] = value;
993 }
994 return this;
995}
996
997var _listCacheSet = listCacheSet;
998
999/**
1000 * Creates an list cache object.
1001 *
1002 * @private
1003 * @constructor
1004 * @param {Array} [entries] The key-value pairs to cache.
1005 */
1006function ListCache(entries) {
1007 var index = -1,
1008 length = entries == null ? 0 : entries.length;
1009
1010 this.clear();
1011 while (++index < length) {
1012 var entry = entries[index];
1013 this.set(entry[0], entry[1]);
1014 }
1015}
1016
1017// Add methods to `ListCache`.
1018ListCache.prototype.clear = _listCacheClear;
1019ListCache.prototype['delete'] = _listCacheDelete;
1020ListCache.prototype.get = _listCacheGet;
1021ListCache.prototype.has = _listCacheHas;
1022ListCache.prototype.set = _listCacheSet;
1023
1024var _ListCache = ListCache;
1025
1026/**
1027 * Removes all key-value entries from the stack.
1028 *
1029 * @private
1030 * @name clear
1031 * @memberOf Stack
1032 */
1033function stackClear() {
1034 this.__data__ = new _ListCache;
1035 this.size = 0;
1036}
1037
1038var _stackClear = stackClear;
1039
1040/**
1041 * Removes `key` and its value from the stack.
1042 *
1043 * @private
1044 * @name delete
1045 * @memberOf Stack
1046 * @param {string} key The key of the value to remove.
1047 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1048 */
1049function stackDelete(key) {
1050 var data = this.__data__,
1051 result = data['delete'](key);
1052
1053 this.size = data.size;
1054 return result;
1055}
1056
1057var _stackDelete = stackDelete;
1058
1059/**
1060 * Gets the stack value for `key`.
1061 *
1062 * @private
1063 * @name get
1064 * @memberOf Stack
1065 * @param {string} key The key of the value to get.
1066 * @returns {*} Returns the entry value.
1067 */
1068function stackGet(key) {
1069 return this.__data__.get(key);
1070}
1071
1072var _stackGet = stackGet;
1073
1074/**
1075 * Checks if a stack value for `key` exists.
1076 *
1077 * @private
1078 * @name has
1079 * @memberOf Stack
1080 * @param {string} key The key of the entry to check.
1081 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1082 */
1083function stackHas(key) {
1084 return this.__data__.has(key);
1085}
1086
1087var _stackHas = stackHas;
1088
1089/* Built-in method references that are verified to be native. */
1090var Map = _getNative(_root, 'Map');
1091
1092var _Map = Map;
1093
1094/* Built-in method references that are verified to be native. */
1095var nativeCreate = _getNative(Object, 'create');
1096
1097var _nativeCreate = nativeCreate;
1098
1099/**
1100 * Removes all key-value entries from the hash.
1101 *
1102 * @private
1103 * @name clear
1104 * @memberOf Hash
1105 */
1106function hashClear() {
1107 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
1108 this.size = 0;
1109}
1110
1111var _hashClear = hashClear;
1112
1113/**
1114 * Removes `key` and its value from the hash.
1115 *
1116 * @private
1117 * @name delete
1118 * @memberOf Hash
1119 * @param {Object} hash The hash to modify.
1120 * @param {string} key The key of the value to remove.
1121 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1122 */
1123function hashDelete(key) {
1124 var result = this.has(key) && delete this.__data__[key];
1125 this.size -= result ? 1 : 0;
1126 return result;
1127}
1128
1129var _hashDelete = hashDelete;
1130
1131/** Used to stand-in for `undefined` hash values. */
1132var HASH_UNDEFINED = '__lodash_hash_undefined__';
1133
1134/** Used for built-in method references. */
1135var objectProto$3 = Object.prototype;
1136
1137/** Used to check objects for own properties. */
1138var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
1139
1140/**
1141 * Gets the hash value for `key`.
1142 *
1143 * @private
1144 * @name get
1145 * @memberOf Hash
1146 * @param {string} key The key of the value to get.
1147 * @returns {*} Returns the entry value.
1148 */
1149function hashGet(key) {
1150 var data = this.__data__;
1151 if (_nativeCreate) {
1152 var result = data[key];
1153 return result === HASH_UNDEFINED ? undefined : result;
1154 }
1155 return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
1156}
1157
1158var _hashGet = hashGet;
1159
1160/** Used for built-in method references. */
1161var objectProto$4 = Object.prototype;
1162
1163/** Used to check objects for own properties. */
1164var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
1165
1166/**
1167 * Checks if a hash value for `key` exists.
1168 *
1169 * @private
1170 * @name has
1171 * @memberOf Hash
1172 * @param {string} key The key of the entry to check.
1173 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1174 */
1175function hashHas(key) {
1176 var data = this.__data__;
1177 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
1178}
1179
1180var _hashHas = hashHas;
1181
1182/** Used to stand-in for `undefined` hash values. */
1183var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1184
1185/**
1186 * Sets the hash `key` to `value`.
1187 *
1188 * @private
1189 * @name set
1190 * @memberOf Hash
1191 * @param {string} key The key of the value to set.
1192 * @param {*} value The value to set.
1193 * @returns {Object} Returns the hash instance.
1194 */
1195function hashSet(key, value) {
1196 var data = this.__data__;
1197 this.size += this.has(key) ? 0 : 1;
1198 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
1199 return this;
1200}
1201
1202var _hashSet = hashSet;
1203
1204/**
1205 * Creates a hash object.
1206 *
1207 * @private
1208 * @constructor
1209 * @param {Array} [entries] The key-value pairs to cache.
1210 */
1211function Hash(entries) {
1212 var index = -1,
1213 length = entries == null ? 0 : entries.length;
1214
1215 this.clear();
1216 while (++index < length) {
1217 var entry = entries[index];
1218 this.set(entry[0], entry[1]);
1219 }
1220}
1221
1222// Add methods to `Hash`.
1223Hash.prototype.clear = _hashClear;
1224Hash.prototype['delete'] = _hashDelete;
1225Hash.prototype.get = _hashGet;
1226Hash.prototype.has = _hashHas;
1227Hash.prototype.set = _hashSet;
1228
1229var _Hash = Hash;
1230
1231/**
1232 * Removes all key-value entries from the map.
1233 *
1234 * @private
1235 * @name clear
1236 * @memberOf MapCache
1237 */
1238function mapCacheClear() {
1239 this.size = 0;
1240 this.__data__ = {
1241 'hash': new _Hash,
1242 'map': new (_Map || _ListCache),
1243 'string': new _Hash
1244 };
1245}
1246
1247var _mapCacheClear = mapCacheClear;
1248
1249/**
1250 * Checks if `value` is suitable for use as unique object key.
1251 *
1252 * @private
1253 * @param {*} value The value to check.
1254 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1255 */
1256function isKeyable(value) {
1257 var type = typeof value;
1258 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1259 ? (value !== '__proto__')
1260 : (value === null);
1261}
1262
1263var _isKeyable = isKeyable;
1264
1265/**
1266 * Gets the data for `map`.
1267 *
1268 * @private
1269 * @param {Object} map The map to query.
1270 * @param {string} key The reference key.
1271 * @returns {*} Returns the map data.
1272 */
1273function getMapData(map, key) {
1274 var data = map.__data__;
1275 return _isKeyable(key)
1276 ? data[typeof key == 'string' ? 'string' : 'hash']
1277 : data.map;
1278}
1279
1280var _getMapData = getMapData;
1281
1282/**
1283 * Removes `key` and its value from the map.
1284 *
1285 * @private
1286 * @name delete
1287 * @memberOf MapCache
1288 * @param {string} key The key of the value to remove.
1289 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1290 */
1291function mapCacheDelete(key) {
1292 var result = _getMapData(this, key)['delete'](key);
1293 this.size -= result ? 1 : 0;
1294 return result;
1295}
1296
1297var _mapCacheDelete = mapCacheDelete;
1298
1299/**
1300 * Gets the map value for `key`.
1301 *
1302 * @private
1303 * @name get
1304 * @memberOf MapCache
1305 * @param {string} key The key of the value to get.
1306 * @returns {*} Returns the entry value.
1307 */
1308function mapCacheGet(key) {
1309 return _getMapData(this, key).get(key);
1310}
1311
1312var _mapCacheGet = mapCacheGet;
1313
1314/**
1315 * Checks if a map value for `key` exists.
1316 *
1317 * @private
1318 * @name has
1319 * @memberOf MapCache
1320 * @param {string} key The key of the entry to check.
1321 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1322 */
1323function mapCacheHas(key) {
1324 return _getMapData(this, key).has(key);
1325}
1326
1327var _mapCacheHas = mapCacheHas;
1328
1329/**
1330 * Sets the map `key` to `value`.
1331 *
1332 * @private
1333 * @name set
1334 * @memberOf MapCache
1335 * @param {string} key The key of the value to set.
1336 * @param {*} value The value to set.
1337 * @returns {Object} Returns the map cache instance.
1338 */
1339function mapCacheSet(key, value) {
1340 var data = _getMapData(this, key),
1341 size = data.size;
1342
1343 data.set(key, value);
1344 this.size += data.size == size ? 0 : 1;
1345 return this;
1346}
1347
1348var _mapCacheSet = mapCacheSet;
1349
1350/**
1351 * Creates a map cache object to store key-value pairs.
1352 *
1353 * @private
1354 * @constructor
1355 * @param {Array} [entries] The key-value pairs to cache.
1356 */
1357function MapCache(entries) {
1358 var index = -1,
1359 length = entries == null ? 0 : entries.length;
1360
1361 this.clear();
1362 while (++index < length) {
1363 var entry = entries[index];
1364 this.set(entry[0], entry[1]);
1365 }
1366}
1367
1368// Add methods to `MapCache`.
1369MapCache.prototype.clear = _mapCacheClear;
1370MapCache.prototype['delete'] = _mapCacheDelete;
1371MapCache.prototype.get = _mapCacheGet;
1372MapCache.prototype.has = _mapCacheHas;
1373MapCache.prototype.set = _mapCacheSet;
1374
1375var _MapCache = MapCache;
1376
1377/** Used as the size to enable large array optimizations. */
1378var LARGE_ARRAY_SIZE = 200;
1379
1380/**
1381 * Sets the stack `key` to `value`.
1382 *
1383 * @private
1384 * @name set
1385 * @memberOf Stack
1386 * @param {string} key The key of the value to set.
1387 * @param {*} value The value to set.
1388 * @returns {Object} Returns the stack cache instance.
1389 */
1390function stackSet(key, value) {
1391 var data = this.__data__;
1392 if (data instanceof _ListCache) {
1393 var pairs = data.__data__;
1394 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1395 pairs.push([key, value]);
1396 this.size = ++data.size;
1397 return this;
1398 }
1399 data = this.__data__ = new _MapCache(pairs);
1400 }
1401 data.set(key, value);
1402 this.size = data.size;
1403 return this;
1404}
1405
1406var _stackSet = stackSet;
1407
1408/**
1409 * Creates a stack cache object to store key-value pairs.
1410 *
1411 * @private
1412 * @constructor
1413 * @param {Array} [entries] The key-value pairs to cache.
1414 */
1415function Stack(entries) {
1416 var data = this.__data__ = new _ListCache(entries);
1417 this.size = data.size;
1418}
1419
1420// Add methods to `Stack`.
1421Stack.prototype.clear = _stackClear;
1422Stack.prototype['delete'] = _stackDelete;
1423Stack.prototype.get = _stackGet;
1424Stack.prototype.has = _stackHas;
1425Stack.prototype.set = _stackSet;
1426
1427var _Stack = Stack;
1428
1429/**
1430 * The base implementation of `assignValue` and `assignMergeValue` without
1431 * value checks.
1432 *
1433 * @private
1434 * @param {Object} object The object to modify.
1435 * @param {string} key The key of the property to assign.
1436 * @param {*} value The value to assign.
1437 */
1438function baseAssignValue(object, key, value) {
1439 if (key == '__proto__' && _defineProperty) {
1440 _defineProperty(object, key, {
1441 'configurable': true,
1442 'enumerable': true,
1443 'value': value,
1444 'writable': true
1445 });
1446 } else {
1447 object[key] = value;
1448 }
1449}
1450
1451var _baseAssignValue = baseAssignValue;
1452
1453/**
1454 * This function is like `assignValue` except that it doesn't assign
1455 * `undefined` values.
1456 *
1457 * @private
1458 * @param {Object} object The object to modify.
1459 * @param {string} key The key of the property to assign.
1460 * @param {*} value The value to assign.
1461 */
1462function assignMergeValue(object, key, value) {
1463 if ((value !== undefined && !eq_1(object[key], value)) ||
1464 (value === undefined && !(key in object))) {
1465 _baseAssignValue(object, key, value);
1466 }
1467}
1468
1469var _assignMergeValue = assignMergeValue;
1470
1471/**
1472 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1473 *
1474 * @private
1475 * @param {boolean} [fromRight] Specify iterating from right to left.
1476 * @returns {Function} Returns the new base function.
1477 */
1478function createBaseFor(fromRight) {
1479 return function(object, iteratee, keysFunc) {
1480 var index = -1,
1481 iterable = Object(object),
1482 props = keysFunc(object),
1483 length = props.length;
1484
1485 while (length--) {
1486 var key = props[fromRight ? length : ++index];
1487 if (iteratee(iterable[key], key, iterable) === false) {
1488 break;
1489 }
1490 }
1491 return object;
1492 };
1493}
1494
1495var _createBaseFor = createBaseFor;
1496
1497/**
1498 * The base implementation of `baseForOwn` which iterates over `object`
1499 * properties returned by `keysFunc` and invokes `iteratee` for each property.
1500 * Iteratee functions may exit iteration early by explicitly returning `false`.
1501 *
1502 * @private
1503 * @param {Object} object The object to iterate over.
1504 * @param {Function} iteratee The function invoked per iteration.
1505 * @param {Function} keysFunc The function to get the keys of `object`.
1506 * @returns {Object} Returns `object`.
1507 */
1508var baseFor = _createBaseFor();
1509
1510var _baseFor = baseFor;
1511
1512var _cloneBuffer = createCommonjsModule(function (module, exports) {
1513/** Detect free variable `exports`. */
1514var freeExports = exports && !exports.nodeType && exports;
1515
1516/** Detect free variable `module`. */
1517var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1518
1519/** Detect the popular CommonJS extension `module.exports`. */
1520var moduleExports = freeModule && freeModule.exports === freeExports;
1521
1522/** Built-in value references. */
1523var Buffer = moduleExports ? _root.Buffer : undefined,
1524 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
1525
1526/**
1527 * Creates a clone of `buffer`.
1528 *
1529 * @private
1530 * @param {Buffer} buffer The buffer to clone.
1531 * @param {boolean} [isDeep] Specify a deep clone.
1532 * @returns {Buffer} Returns the cloned buffer.
1533 */
1534function cloneBuffer(buffer, isDeep) {
1535 if (isDeep) {
1536 return buffer.slice();
1537 }
1538 var length = buffer.length,
1539 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
1540
1541 buffer.copy(result);
1542 return result;
1543}
1544
1545module.exports = cloneBuffer;
1546});
1547
1548/** Built-in value references. */
1549var Uint8Array = _root.Uint8Array;
1550
1551var _Uint8Array = Uint8Array;
1552
1553/**
1554 * Creates a clone of `arrayBuffer`.
1555 *
1556 * @private
1557 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1558 * @returns {ArrayBuffer} Returns the cloned array buffer.
1559 */
1560function cloneArrayBuffer(arrayBuffer) {
1561 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1562 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
1563 return result;
1564}
1565
1566var _cloneArrayBuffer = cloneArrayBuffer;
1567
1568/**
1569 * Creates a clone of `typedArray`.
1570 *
1571 * @private
1572 * @param {Object} typedArray The typed array to clone.
1573 * @param {boolean} [isDeep] Specify a deep clone.
1574 * @returns {Object} Returns the cloned typed array.
1575 */
1576function cloneTypedArray(typedArray, isDeep) {
1577 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1578 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1579}
1580
1581var _cloneTypedArray = cloneTypedArray;
1582
1583/**
1584 * Copies the values of `source` to `array`.
1585 *
1586 * @private
1587 * @param {Array} source The array to copy values from.
1588 * @param {Array} [array=[]] The array to copy values to.
1589 * @returns {Array} Returns `array`.
1590 */
1591function copyArray(source, array) {
1592 var index = -1,
1593 length = source.length;
1594
1595 array || (array = Array(length));
1596 while (++index < length) {
1597 array[index] = source[index];
1598 }
1599 return array;
1600}
1601
1602var _copyArray = copyArray;
1603
1604/** Built-in value references. */
1605var objectCreate = Object.create;
1606
1607/**
1608 * The base implementation of `_.create` without support for assigning
1609 * properties to the created object.
1610 *
1611 * @private
1612 * @param {Object} proto The object to inherit from.
1613 * @returns {Object} Returns the new object.
1614 */
1615var baseCreate = (function() {
1616 function object() {}
1617 return function(proto) {
1618 if (!isObject_1(proto)) {
1619 return {};
1620 }
1621 if (objectCreate) {
1622 return objectCreate(proto);
1623 }
1624 object.prototype = proto;
1625 var result = new object;
1626 object.prototype = undefined;
1627 return result;
1628 };
1629}());
1630
1631var _baseCreate = baseCreate;
1632
1633/**
1634 * Creates a unary function that invokes `func` with its argument transformed.
1635 *
1636 * @private
1637 * @param {Function} func The function to wrap.
1638 * @param {Function} transform The argument transform.
1639 * @returns {Function} Returns the new function.
1640 */
1641function overArg(func, transform) {
1642 return function(arg) {
1643 return func(transform(arg));
1644 };
1645}
1646
1647var _overArg = overArg;
1648
1649/** Built-in value references. */
1650var getPrototype = _overArg(Object.getPrototypeOf, Object);
1651
1652var _getPrototype = getPrototype;
1653
1654/** Used for built-in method references. */
1655var objectProto$5 = Object.prototype;
1656
1657/**
1658 * Checks if `value` is likely a prototype object.
1659 *
1660 * @private
1661 * @param {*} value The value to check.
1662 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1663 */
1664function isPrototype(value) {
1665 var Ctor = value && value.constructor,
1666 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
1667
1668 return value === proto;
1669}
1670
1671var _isPrototype = isPrototype;
1672
1673/**
1674 * Initializes an object clone.
1675 *
1676 * @private
1677 * @param {Object} object The object to clone.
1678 * @returns {Object} Returns the initialized clone.
1679 */
1680function initCloneObject(object) {
1681 return (typeof object.constructor == 'function' && !_isPrototype(object))
1682 ? _baseCreate(_getPrototype(object))
1683 : {};
1684}
1685
1686var _initCloneObject = initCloneObject;
1687
1688/**
1689 * Checks if `value` is object-like. A value is object-like if it's not `null`
1690 * and has a `typeof` result of "object".
1691 *
1692 * @static
1693 * @memberOf _
1694 * @since 4.0.0
1695 * @category Lang
1696 * @param {*} value The value to check.
1697 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1698 * @example
1699 *
1700 * _.isObjectLike({});
1701 * // => true
1702 *
1703 * _.isObjectLike([1, 2, 3]);
1704 * // => true
1705 *
1706 * _.isObjectLike(_.noop);
1707 * // => false
1708 *
1709 * _.isObjectLike(null);
1710 * // => false
1711 */
1712function isObjectLike(value) {
1713 return value != null && typeof value == 'object';
1714}
1715
1716var isObjectLike_1 = isObjectLike;
1717
1718/** `Object#toString` result references. */
1719var argsTag = '[object Arguments]';
1720
1721/**
1722 * The base implementation of `_.isArguments`.
1723 *
1724 * @private
1725 * @param {*} value The value to check.
1726 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1727 */
1728function baseIsArguments(value) {
1729 return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
1730}
1731
1732var _baseIsArguments = baseIsArguments;
1733
1734/** Used for built-in method references. */
1735var objectProto$6 = Object.prototype;
1736
1737/** Used to check objects for own properties. */
1738var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
1739
1740/** Built-in value references. */
1741var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
1742
1743/**
1744 * Checks if `value` is likely an `arguments` object.
1745 *
1746 * @static
1747 * @memberOf _
1748 * @since 0.1.0
1749 * @category Lang
1750 * @param {*} value The value to check.
1751 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1752 * else `false`.
1753 * @example
1754 *
1755 * _.isArguments(function() { return arguments; }());
1756 * // => true
1757 *
1758 * _.isArguments([1, 2, 3]);
1759 * // => false
1760 */
1761var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
1762 return isObjectLike_1(value) && hasOwnProperty$4.call(value, 'callee') &&
1763 !propertyIsEnumerable.call(value, 'callee');
1764};
1765
1766var isArguments_1 = isArguments;
1767
1768/**
1769 * Checks if `value` is classified as an `Array` object.
1770 *
1771 * @static
1772 * @memberOf _
1773 * @since 0.1.0
1774 * @category Lang
1775 * @param {*} value The value to check.
1776 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1777 * @example
1778 *
1779 * _.isArray([1, 2, 3]);
1780 * // => true
1781 *
1782 * _.isArray(document.body.children);
1783 * // => false
1784 *
1785 * _.isArray('abc');
1786 * // => false
1787 *
1788 * _.isArray(_.noop);
1789 * // => false
1790 */
1791var isArray = Array.isArray;
1792
1793var isArray_1 = isArray;
1794
1795/** Used as references for various `Number` constants. */
1796var MAX_SAFE_INTEGER = 9007199254740991;
1797
1798/**
1799 * Checks if `value` is a valid array-like length.
1800 *
1801 * **Note:** This method is loosely based on
1802 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1803 *
1804 * @static
1805 * @memberOf _
1806 * @since 4.0.0
1807 * @category Lang
1808 * @param {*} value The value to check.
1809 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1810 * @example
1811 *
1812 * _.isLength(3);
1813 * // => true
1814 *
1815 * _.isLength(Number.MIN_VALUE);
1816 * // => false
1817 *
1818 * _.isLength(Infinity);
1819 * // => false
1820 *
1821 * _.isLength('3');
1822 * // => false
1823 */
1824function isLength(value) {
1825 return typeof value == 'number' &&
1826 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1827}
1828
1829var isLength_1 = isLength;
1830
1831/**
1832 * Checks if `value` is array-like. A value is considered array-like if it's
1833 * not a function and has a `value.length` that's an integer greater than or
1834 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1835 *
1836 * @static
1837 * @memberOf _
1838 * @since 4.0.0
1839 * @category Lang
1840 * @param {*} value The value to check.
1841 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1842 * @example
1843 *
1844 * _.isArrayLike([1, 2, 3]);
1845 * // => true
1846 *
1847 * _.isArrayLike(document.body.children);
1848 * // => true
1849 *
1850 * _.isArrayLike('abc');
1851 * // => true
1852 *
1853 * _.isArrayLike(_.noop);
1854 * // => false
1855 */
1856function isArrayLike(value) {
1857 return value != null && isLength_1(value.length) && !isFunction_1(value);
1858}
1859
1860var isArrayLike_1 = isArrayLike;
1861
1862/**
1863 * This method is like `_.isArrayLike` except that it also checks if `value`
1864 * is an object.
1865 *
1866 * @static
1867 * @memberOf _
1868 * @since 4.0.0
1869 * @category Lang
1870 * @param {*} value The value to check.
1871 * @returns {boolean} Returns `true` if `value` is an array-like object,
1872 * else `false`.
1873 * @example
1874 *
1875 * _.isArrayLikeObject([1, 2, 3]);
1876 * // => true
1877 *
1878 * _.isArrayLikeObject(document.body.children);
1879 * // => true
1880 *
1881 * _.isArrayLikeObject('abc');
1882 * // => false
1883 *
1884 * _.isArrayLikeObject(_.noop);
1885 * // => false
1886 */
1887function isArrayLikeObject(value) {
1888 return isObjectLike_1(value) && isArrayLike_1(value);
1889}
1890
1891var isArrayLikeObject_1 = isArrayLikeObject;
1892
1893/**
1894 * This method returns `false`.
1895 *
1896 * @static
1897 * @memberOf _
1898 * @since 4.13.0
1899 * @category Util
1900 * @returns {boolean} Returns `false`.
1901 * @example
1902 *
1903 * _.times(2, _.stubFalse);
1904 * // => [false, false]
1905 */
1906function stubFalse() {
1907 return false;
1908}
1909
1910var stubFalse_1 = stubFalse;
1911
1912var isBuffer_1 = createCommonjsModule(function (module, exports) {
1913/** Detect free variable `exports`. */
1914var freeExports = exports && !exports.nodeType && exports;
1915
1916/** Detect free variable `module`. */
1917var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1918
1919/** Detect the popular CommonJS extension `module.exports`. */
1920var moduleExports = freeModule && freeModule.exports === freeExports;
1921
1922/** Built-in value references. */
1923var Buffer = moduleExports ? _root.Buffer : undefined;
1924
1925/* Built-in method references for those with the same name as other `lodash` methods. */
1926var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1927
1928/**
1929 * Checks if `value` is a buffer.
1930 *
1931 * @static
1932 * @memberOf _
1933 * @since 4.3.0
1934 * @category Lang
1935 * @param {*} value The value to check.
1936 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1937 * @example
1938 *
1939 * _.isBuffer(new Buffer(2));
1940 * // => true
1941 *
1942 * _.isBuffer(new Uint8Array(2));
1943 * // => false
1944 */
1945var isBuffer = nativeIsBuffer || stubFalse_1;
1946
1947module.exports = isBuffer;
1948});
1949
1950/** `Object#toString` result references. */
1951var objectTag = '[object Object]';
1952
1953/** Used for built-in method references. */
1954var funcProto$2 = Function.prototype,
1955 objectProto$7 = Object.prototype;
1956
1957/** Used to resolve the decompiled source of functions. */
1958var funcToString$2 = funcProto$2.toString;
1959
1960/** Used to check objects for own properties. */
1961var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
1962
1963/** Used to infer the `Object` constructor. */
1964var objectCtorString = funcToString$2.call(Object);
1965
1966/**
1967 * Checks if `value` is a plain object, that is, an object created by the
1968 * `Object` constructor or one with a `[[Prototype]]` of `null`.
1969 *
1970 * @static
1971 * @memberOf _
1972 * @since 0.8.0
1973 * @category Lang
1974 * @param {*} value The value to check.
1975 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1976 * @example
1977 *
1978 * function Foo() {
1979 * this.a = 1;
1980 * }
1981 *
1982 * _.isPlainObject(new Foo);
1983 * // => false
1984 *
1985 * _.isPlainObject([1, 2, 3]);
1986 * // => false
1987 *
1988 * _.isPlainObject({ 'x': 0, 'y': 0 });
1989 * // => true
1990 *
1991 * _.isPlainObject(Object.create(null));
1992 * // => true
1993 */
1994function isPlainObject(value) {
1995 if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
1996 return false;
1997 }
1998 var proto = _getPrototype(value);
1999 if (proto === null) {
2000 return true;
2001 }
2002 var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor;
2003 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
2004 funcToString$2.call(Ctor) == objectCtorString;
2005}
2006
2007var isPlainObject_1 = isPlainObject;
2008
2009/** `Object#toString` result references. */
2010var argsTag$1 = '[object Arguments]',
2011 arrayTag = '[object Array]',
2012 boolTag = '[object Boolean]',
2013 dateTag = '[object Date]',
2014 errorTag = '[object Error]',
2015 funcTag$1 = '[object Function]',
2016 mapTag = '[object Map]',
2017 numberTag = '[object Number]',
2018 objectTag$1 = '[object Object]',
2019 regexpTag = '[object RegExp]',
2020 setTag = '[object Set]',
2021 stringTag = '[object String]',
2022 weakMapTag = '[object WeakMap]';
2023
2024var arrayBufferTag = '[object ArrayBuffer]',
2025 dataViewTag = '[object DataView]',
2026 float32Tag = '[object Float32Array]',
2027 float64Tag = '[object Float64Array]',
2028 int8Tag = '[object Int8Array]',
2029 int16Tag = '[object Int16Array]',
2030 int32Tag = '[object Int32Array]',
2031 uint8Tag = '[object Uint8Array]',
2032 uint8ClampedTag = '[object Uint8ClampedArray]',
2033 uint16Tag = '[object Uint16Array]',
2034 uint32Tag = '[object Uint32Array]';
2035
2036/** Used to identify `toStringTag` values of typed arrays. */
2037var typedArrayTags = {};
2038typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
2039typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
2040typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
2041typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
2042typedArrayTags[uint32Tag] = true;
2043typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
2044typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
2045typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
2046typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
2047typedArrayTags[mapTag] = typedArrayTags[numberTag] =
2048typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
2049typedArrayTags[setTag] = typedArrayTags[stringTag] =
2050typedArrayTags[weakMapTag] = false;
2051
2052/**
2053 * The base implementation of `_.isTypedArray` without Node.js optimizations.
2054 *
2055 * @private
2056 * @param {*} value The value to check.
2057 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2058 */
2059function baseIsTypedArray(value) {
2060 return isObjectLike_1(value) &&
2061 isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
2062}
2063
2064var _baseIsTypedArray = baseIsTypedArray;
2065
2066/**
2067 * The base implementation of `_.unary` without support for storing metadata.
2068 *
2069 * @private
2070 * @param {Function} func The function to cap arguments for.
2071 * @returns {Function} Returns the new capped function.
2072 */
2073function baseUnary(func) {
2074 return function(value) {
2075 return func(value);
2076 };
2077}
2078
2079var _baseUnary = baseUnary;
2080
2081var _nodeUtil = createCommonjsModule(function (module, exports) {
2082/** Detect free variable `exports`. */
2083var freeExports = exports && !exports.nodeType && exports;
2084
2085/** Detect free variable `module`. */
2086var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
2087
2088/** Detect the popular CommonJS extension `module.exports`. */
2089var moduleExports = freeModule && freeModule.exports === freeExports;
2090
2091/** Detect free variable `process` from Node.js. */
2092var freeProcess = moduleExports && _freeGlobal.process;
2093
2094/** Used to access faster Node.js helpers. */
2095var nodeUtil = (function() {
2096 try {
2097 // Use `util.types` for Node.js 10+.
2098 var types = freeModule && freeModule.require && freeModule.require('util').types;
2099
2100 if (types) {
2101 return types;
2102 }
2103
2104 // Legacy `process.binding('util')` for Node.js < 10.
2105 return freeProcess && freeProcess.binding && freeProcess.binding('util');
2106 } catch (e) {}
2107}());
2108
2109module.exports = nodeUtil;
2110});
2111
2112/* Node.js helper references. */
2113var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
2114
2115/**
2116 * Checks if `value` is classified as a typed array.
2117 *
2118 * @static
2119 * @memberOf _
2120 * @since 3.0.0
2121 * @category Lang
2122 * @param {*} value The value to check.
2123 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2124 * @example
2125 *
2126 * _.isTypedArray(new Uint8Array);
2127 * // => true
2128 *
2129 * _.isTypedArray([]);
2130 * // => false
2131 */
2132var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
2133
2134var isTypedArray_1 = isTypedArray;
2135
2136/**
2137 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
2138 *
2139 * @private
2140 * @param {Object} object The object to query.
2141 * @param {string} key The key of the property to get.
2142 * @returns {*} Returns the property value.
2143 */
2144function safeGet(object, key) {
2145 if (key === 'constructor' && typeof object[key] === 'function') {
2146 return;
2147 }
2148
2149 if (key == '__proto__') {
2150 return;
2151 }
2152
2153 return object[key];
2154}
2155
2156var _safeGet = safeGet;
2157
2158/** Used for built-in method references. */
2159var objectProto$8 = Object.prototype;
2160
2161/** Used to check objects for own properties. */
2162var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
2163
2164/**
2165 * Assigns `value` to `key` of `object` if the existing value is not equivalent
2166 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2167 * for equality comparisons.
2168 *
2169 * @private
2170 * @param {Object} object The object to modify.
2171 * @param {string} key The key of the property to assign.
2172 * @param {*} value The value to assign.
2173 */
2174function assignValue(object, key, value) {
2175 var objValue = object[key];
2176 if (!(hasOwnProperty$6.call(object, key) && eq_1(objValue, value)) ||
2177 (value === undefined && !(key in object))) {
2178 _baseAssignValue(object, key, value);
2179 }
2180}
2181
2182var _assignValue = assignValue;
2183
2184/**
2185 * Copies properties of `source` to `object`.
2186 *
2187 * @private
2188 * @param {Object} source The object to copy properties from.
2189 * @param {Array} props The property identifiers to copy.
2190 * @param {Object} [object={}] The object to copy properties to.
2191 * @param {Function} [customizer] The function to customize copied values.
2192 * @returns {Object} Returns `object`.
2193 */
2194function copyObject(source, props, object, customizer) {
2195 var isNew = !object;
2196 object || (object = {});
2197
2198 var index = -1,
2199 length = props.length;
2200
2201 while (++index < length) {
2202 var key = props[index];
2203
2204 var newValue = customizer
2205 ? customizer(object[key], source[key], key, object, source)
2206 : undefined;
2207
2208 if (newValue === undefined) {
2209 newValue = source[key];
2210 }
2211 if (isNew) {
2212 _baseAssignValue(object, key, newValue);
2213 } else {
2214 _assignValue(object, key, newValue);
2215 }
2216 }
2217 return object;
2218}
2219
2220var _copyObject = copyObject;
2221
2222/**
2223 * The base implementation of `_.times` without support for iteratee shorthands
2224 * or max array length checks.
2225 *
2226 * @private
2227 * @param {number} n The number of times to invoke `iteratee`.
2228 * @param {Function} iteratee The function invoked per iteration.
2229 * @returns {Array} Returns the array of results.
2230 */
2231function baseTimes(n, iteratee) {
2232 var index = -1,
2233 result = Array(n);
2234
2235 while (++index < n) {
2236 result[index] = iteratee(index);
2237 }
2238 return result;
2239}
2240
2241var _baseTimes = baseTimes;
2242
2243/** Used as references for various `Number` constants. */
2244var MAX_SAFE_INTEGER$1 = 9007199254740991;
2245
2246/** Used to detect unsigned integer values. */
2247var reIsUint = /^(?:0|[1-9]\d*)$/;
2248
2249/**
2250 * Checks if `value` is a valid array-like index.
2251 *
2252 * @private
2253 * @param {*} value The value to check.
2254 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
2255 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
2256 */
2257function isIndex(value, length) {
2258 var type = typeof value;
2259 length = length == null ? MAX_SAFE_INTEGER$1 : length;
2260
2261 return !!length &&
2262 (type == 'number' ||
2263 (type != 'symbol' && reIsUint.test(value))) &&
2264 (value > -1 && value % 1 == 0 && value < length);
2265}
2266
2267var _isIndex = isIndex;
2268
2269/** Used for built-in method references. */
2270var objectProto$9 = Object.prototype;
2271
2272/** Used to check objects for own properties. */
2273var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
2274
2275/**
2276 * Creates an array of the enumerable property names of the array-like `value`.
2277 *
2278 * @private
2279 * @param {*} value The value to query.
2280 * @param {boolean} inherited Specify returning inherited property names.
2281 * @returns {Array} Returns the array of property names.
2282 */
2283function arrayLikeKeys(value, inherited) {
2284 var isArr = isArray_1(value),
2285 isArg = !isArr && isArguments_1(value),
2286 isBuff = !isArr && !isArg && isBuffer_1(value),
2287 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
2288 skipIndexes = isArr || isArg || isBuff || isType,
2289 result = skipIndexes ? _baseTimes(value.length, String) : [],
2290 length = result.length;
2291
2292 for (var key in value) {
2293 if ((inherited || hasOwnProperty$7.call(value, key)) &&
2294 !(skipIndexes && (
2295 // Safari 9 has enumerable `arguments.length` in strict mode.
2296 key == 'length' ||
2297 // Node.js 0.10 has enumerable non-index properties on buffers.
2298 (isBuff && (key == 'offset' || key == 'parent')) ||
2299 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2300 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2301 // Skip index properties.
2302 _isIndex(key, length)
2303 ))) {
2304 result.push(key);
2305 }
2306 }
2307 return result;
2308}
2309
2310var _arrayLikeKeys = arrayLikeKeys;
2311
2312/**
2313 * This function is like
2314 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2315 * except that it includes inherited enumerable properties.
2316 *
2317 * @private
2318 * @param {Object} object The object to query.
2319 * @returns {Array} Returns the array of property names.
2320 */
2321function nativeKeysIn(object) {
2322 var result = [];
2323 if (object != null) {
2324 for (var key in Object(object)) {
2325 result.push(key);
2326 }
2327 }
2328 return result;
2329}
2330
2331var _nativeKeysIn = nativeKeysIn;
2332
2333/** Used for built-in method references. */
2334var objectProto$a = Object.prototype;
2335
2336/** Used to check objects for own properties. */
2337var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
2338
2339/**
2340 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
2341 *
2342 * @private
2343 * @param {Object} object The object to query.
2344 * @returns {Array} Returns the array of property names.
2345 */
2346function baseKeysIn(object) {
2347 if (!isObject_1(object)) {
2348 return _nativeKeysIn(object);
2349 }
2350 var isProto = _isPrototype(object),
2351 result = [];
2352
2353 for (var key in object) {
2354 if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
2355 result.push(key);
2356 }
2357 }
2358 return result;
2359}
2360
2361var _baseKeysIn = baseKeysIn;
2362
2363/**
2364 * Creates an array of the own and inherited enumerable property names of `object`.
2365 *
2366 * **Note:** Non-object values are coerced to objects.
2367 *
2368 * @static
2369 * @memberOf _
2370 * @since 3.0.0
2371 * @category Object
2372 * @param {Object} object The object to query.
2373 * @returns {Array} Returns the array of property names.
2374 * @example
2375 *
2376 * function Foo() {
2377 * this.a = 1;
2378 * this.b = 2;
2379 * }
2380 *
2381 * Foo.prototype.c = 3;
2382 *
2383 * _.keysIn(new Foo);
2384 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
2385 */
2386function keysIn(object) {
2387 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
2388}
2389
2390var keysIn_1 = keysIn;
2391
2392/**
2393 * Converts `value` to a plain object flattening inherited enumerable string
2394 * keyed properties of `value` to own properties of the plain object.
2395 *
2396 * @static
2397 * @memberOf _
2398 * @since 3.0.0
2399 * @category Lang
2400 * @param {*} value The value to convert.
2401 * @returns {Object} Returns the converted plain object.
2402 * @example
2403 *
2404 * function Foo() {
2405 * this.b = 2;
2406 * }
2407 *
2408 * Foo.prototype.c = 3;
2409 *
2410 * _.assign({ 'a': 1 }, new Foo);
2411 * // => { 'a': 1, 'b': 2 }
2412 *
2413 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
2414 * // => { 'a': 1, 'b': 2, 'c': 3 }
2415 */
2416function toPlainObject(value) {
2417 return _copyObject(value, keysIn_1(value));
2418}
2419
2420var toPlainObject_1 = toPlainObject;
2421
2422/**
2423 * A specialized version of `baseMerge` for arrays and objects which performs
2424 * deep merges and tracks traversed objects enabling objects with circular
2425 * references to be merged.
2426 *
2427 * @private
2428 * @param {Object} object The destination object.
2429 * @param {Object} source The source object.
2430 * @param {string} key The key of the value to merge.
2431 * @param {number} srcIndex The index of `source`.
2432 * @param {Function} mergeFunc The function to merge values.
2433 * @param {Function} [customizer] The function to customize assigned values.
2434 * @param {Object} [stack] Tracks traversed source values and their merged
2435 * counterparts.
2436 */
2437function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
2438 var objValue = _safeGet(object, key),
2439 srcValue = _safeGet(source, key),
2440 stacked = stack.get(srcValue);
2441
2442 if (stacked) {
2443 _assignMergeValue(object, key, stacked);
2444 return;
2445 }
2446 var newValue = customizer
2447 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
2448 : undefined;
2449
2450 var isCommon = newValue === undefined;
2451
2452 if (isCommon) {
2453 var isArr = isArray_1(srcValue),
2454 isBuff = !isArr && isBuffer_1(srcValue),
2455 isTyped = !isArr && !isBuff && isTypedArray_1(srcValue);
2456
2457 newValue = srcValue;
2458 if (isArr || isBuff || isTyped) {
2459 if (isArray_1(objValue)) {
2460 newValue = objValue;
2461 }
2462 else if (isArrayLikeObject_1(objValue)) {
2463 newValue = _copyArray(objValue);
2464 }
2465 else if (isBuff) {
2466 isCommon = false;
2467 newValue = _cloneBuffer(srcValue, true);
2468 }
2469 else if (isTyped) {
2470 isCommon = false;
2471 newValue = _cloneTypedArray(srcValue, true);
2472 }
2473 else {
2474 newValue = [];
2475 }
2476 }
2477 else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) {
2478 newValue = objValue;
2479 if (isArguments_1(objValue)) {
2480 newValue = toPlainObject_1(objValue);
2481 }
2482 else if (!isObject_1(objValue) || isFunction_1(objValue)) {
2483 newValue = _initCloneObject(srcValue);
2484 }
2485 }
2486 else {
2487 isCommon = false;
2488 }
2489 }
2490 if (isCommon) {
2491 // Recursively merge objects and arrays (susceptible to call stack limits).
2492 stack.set(srcValue, newValue);
2493 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
2494 stack['delete'](srcValue);
2495 }
2496 _assignMergeValue(object, key, newValue);
2497}
2498
2499var _baseMergeDeep = baseMergeDeep;
2500
2501/**
2502 * The base implementation of `_.merge` without support for multiple sources.
2503 *
2504 * @private
2505 * @param {Object} object The destination object.
2506 * @param {Object} source The source object.
2507 * @param {number} srcIndex The index of `source`.
2508 * @param {Function} [customizer] The function to customize merged values.
2509 * @param {Object} [stack] Tracks traversed source values and their merged
2510 * counterparts.
2511 */
2512function baseMerge(object, source, srcIndex, customizer, stack) {
2513 if (object === source) {
2514 return;
2515 }
2516 _baseFor(source, function(srcValue, key) {
2517 stack || (stack = new _Stack);
2518 if (isObject_1(srcValue)) {
2519 _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
2520 }
2521 else {
2522 var newValue = customizer
2523 ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
2524 : undefined;
2525
2526 if (newValue === undefined) {
2527 newValue = srcValue;
2528 }
2529 _assignMergeValue(object, key, newValue);
2530 }
2531 }, keysIn_1);
2532}
2533
2534var _baseMerge = baseMerge;
2535
2536/**
2537 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
2538 * objects into destination objects that are passed thru.
2539 *
2540 * @private
2541 * @param {*} objValue The destination value.
2542 * @param {*} srcValue The source value.
2543 * @param {string} key The key of the property to merge.
2544 * @param {Object} object The parent object of `objValue`.
2545 * @param {Object} source The parent object of `srcValue`.
2546 * @param {Object} [stack] Tracks traversed source values and their merged
2547 * counterparts.
2548 * @returns {*} Returns the value to assign.
2549 */
2550function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
2551 if (isObject_1(objValue) && isObject_1(srcValue)) {
2552 // Recursively merge objects and arrays (susceptible to call stack limits).
2553 stack.set(srcValue, objValue);
2554 _baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
2555 stack['delete'](srcValue);
2556 }
2557 return objValue;
2558}
2559
2560var _customDefaultsMerge = customDefaultsMerge;
2561
2562/**
2563 * Checks if the given arguments are from an iteratee call.
2564 *
2565 * @private
2566 * @param {*} value The potential iteratee value argument.
2567 * @param {*} index The potential iteratee index or key argument.
2568 * @param {*} object The potential iteratee object argument.
2569 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
2570 * else `false`.
2571 */
2572function isIterateeCall(value, index, object) {
2573 if (!isObject_1(object)) {
2574 return false;
2575 }
2576 var type = typeof index;
2577 if (type == 'number'
2578 ? (isArrayLike_1(object) && _isIndex(index, object.length))
2579 : (type == 'string' && index in object)
2580 ) {
2581 return eq_1(object[index], value);
2582 }
2583 return false;
2584}
2585
2586var _isIterateeCall = isIterateeCall;
2587
2588/**
2589 * Creates a function like `_.assign`.
2590 *
2591 * @private
2592 * @param {Function} assigner The function to assign values.
2593 * @returns {Function} Returns the new assigner function.
2594 */
2595function createAssigner(assigner) {
2596 return _baseRest(function(object, sources) {
2597 var index = -1,
2598 length = sources.length,
2599 customizer = length > 1 ? sources[length - 1] : undefined,
2600 guard = length > 2 ? sources[2] : undefined;
2601
2602 customizer = (assigner.length > 3 && typeof customizer == 'function')
2603 ? (length--, customizer)
2604 : undefined;
2605
2606 if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
2607 customizer = length < 3 ? undefined : customizer;
2608 length = 1;
2609 }
2610 object = Object(object);
2611 while (++index < length) {
2612 var source = sources[index];
2613 if (source) {
2614 assigner(object, source, index, customizer);
2615 }
2616 }
2617 return object;
2618 });
2619}
2620
2621var _createAssigner = createAssigner;
2622
2623/**
2624 * This method is like `_.merge` except that it accepts `customizer` which
2625 * is invoked to produce the merged values of the destination and source
2626 * properties. If `customizer` returns `undefined`, merging is handled by the
2627 * method instead. The `customizer` is invoked with six arguments:
2628 * (objValue, srcValue, key, object, source, stack).
2629 *
2630 * **Note:** This method mutates `object`.
2631 *
2632 * @static
2633 * @memberOf _
2634 * @since 4.0.0
2635 * @category Object
2636 * @param {Object} object The destination object.
2637 * @param {...Object} sources The source objects.
2638 * @param {Function} customizer The function to customize assigned values.
2639 * @returns {Object} Returns `object`.
2640 * @example
2641 *
2642 * function customizer(objValue, srcValue) {
2643 * if (_.isArray(objValue)) {
2644 * return objValue.concat(srcValue);
2645 * }
2646 * }
2647 *
2648 * var object = { 'a': [1], 'b': [2] };
2649 * var other = { 'a': [3], 'b': [4] };
2650 *
2651 * _.mergeWith(object, other, customizer);
2652 * // => { 'a': [1, 3], 'b': [2, 4] }
2653 */
2654var mergeWith = _createAssigner(function(object, source, srcIndex, customizer) {
2655 _baseMerge(object, source, srcIndex, customizer);
2656});
2657
2658var mergeWith_1 = mergeWith;
2659
2660/**
2661 * This method is like `_.defaults` except that it recursively assigns
2662 * default properties.
2663 *
2664 * **Note:** This method mutates `object`.
2665 *
2666 * @static
2667 * @memberOf _
2668 * @since 3.10.0
2669 * @category Object
2670 * @param {Object} object The destination object.
2671 * @param {...Object} [sources] The source objects.
2672 * @returns {Object} Returns `object`.
2673 * @see _.defaults
2674 * @example
2675 *
2676 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
2677 * // => { 'a': { 'b': 2, 'c': 3 } }
2678 */
2679var defaultsDeep = _baseRest(function(args) {
2680 args.push(undefined, _customDefaultsMerge);
2681 return _apply(mergeWith_1, undefined, args);
2682});
2683
2684var defaultsDeep_1 = defaultsDeep;
2685
2686async function loadNuxtConfig (argv, configContext) {
2687 const rootDir = path.resolve(argv._[0] || '.');
2688 const configFile = argv['config-file'];
2689
2690 // Load config
2691 const options = await config.loadNuxtConfig({
2692 rootDir,
2693 configFile,
2694 configContext
2695 });
2696
2697 // Nuxt Mode
2698 options.mode = (argv.spa && 'spa') || (argv.universal && 'universal') || options.mode;
2699
2700 // Server options
2701 options.server = defaultsDeep_1({
2702 port: argv.port || undefined,
2703 host: argv.hostname || undefined,
2704 socket: argv['unix-socket'] || undefined
2705 }, options.server || {}, config.getDefaultNuxtConfig().server);
2706
2707 return options
2708}
2709
2710class NuxtCommand extends Hookable {
2711 constructor (cmd = { name: '', usage: '', description: '' }, argv = process.argv.slice(2), hooks = {}) {
2712 super(consola);
2713 this.addHooks(hooks);
2714
2715 if (!cmd.options) {
2716 cmd.options = {};
2717 }
2718 this.cmd = cmd;
2719
2720 this._argv = Array.from(argv);
2721 this._parsedArgv = null; // Lazy evaluate
2722 }
2723
2724 static run (cmd, argv, hooks) {
2725 return NuxtCommand.from(cmd, argv, hooks).run()
2726 }
2727
2728 static from (cmd, argv, hooks) {
2729 if (cmd instanceof NuxtCommand) {
2730 return cmd
2731 }
2732 return new NuxtCommand(cmd, argv, hooks)
2733 }
2734
2735 async run () {
2736 await this.callHook('run:before', {
2737 argv: this._argv,
2738 cmd: this.cmd,
2739 rootDir: path.resolve(this.argv._[0] || '.')
2740 });
2741
2742 if (this.argv.help) {
2743 this.showHelp();
2744 return
2745 }
2746
2747 if (this.argv.version) {
2748 this.showVersion();
2749 return
2750 }
2751
2752 if (typeof this.cmd.run !== 'function') {
2753 throw new TypeError('Invalid command! Commands should at least implement run() function.')
2754 }
2755
2756 let cmdError;
2757
2758 try {
2759 await this.cmd.run(this);
2760 } catch (e) {
2761 cmdError = e;
2762 }
2763
2764 if (this.argv.lock) {
2765 await this.releaseLock();
2766 }
2767
2768 if (this.argv['force-exit']) {
2769 const forceExitByUser = this.isUserSuppliedArg('force-exit');
2770 if (cmdError) {
2771 consola.fatal(cmdError);
2772 }
2773 forceExit(this.cmd.name, forceExitByUser ? false : forceExitTimeout);
2774 if (forceExitByUser) {
2775 return
2776 }
2777 }
2778
2779 if (cmdError) {
2780 throw cmdError
2781 }
2782 }
2783
2784 showVersion () {
2785 process.stdout.write(`${name} v${version}\n`);
2786 }
2787
2788 showHelp () {
2789 process.stdout.write(this._getHelp());
2790 }
2791
2792 get argv () {
2793 if (!this._parsedArgv) {
2794 const minimistOptions = this._getMinimistOptions();
2795 this._parsedArgv = minimist(this._argv, minimistOptions);
2796 }
2797 return this._parsedArgv
2798 }
2799
2800 async getNuxtConfig (extraOptions = {}) {
2801 // Flag to indicate nuxt is running with CLI (not programmatic)
2802 extraOptions._cli = true;
2803
2804 const context = {
2805 command: this.cmd.name,
2806 dev: !!extraOptions.dev
2807 };
2808
2809 const config = await loadNuxtConfig(this.argv, context);
2810 const options = Object.assign(config, extraOptions);
2811
2812 for (const name of Object.keys(this.cmd.options)) {
2813 this.cmd.options[name].prepare && this.cmd.options[name].prepare(this, options, this.argv);
2814 }
2815
2816 await this.callHook('config', options);
2817
2818 return options
2819 }
2820
2821 async getNuxt (options) {
2822 const { Nuxt } = await core();
2823
2824 const nuxt = new Nuxt(options);
2825 await nuxt.ready();
2826
2827 return nuxt
2828 }
2829
2830 async getBuilder (nuxt) {
2831 const { Builder } = await builder();
2832 const { BundleBuilder } = await webpack();
2833 return new Builder(nuxt, BundleBuilder)
2834 }
2835
2836 async getGenerator (nuxt) {
2837 const { Generator } = await generator();
2838 const builder = await this.getBuilder(nuxt);
2839 return new Generator(nuxt, builder)
2840 }
2841
2842 async setLock (lockRelease) {
2843 if (lockRelease) {
2844 if (this._lockRelease) {
2845 consola.warn(`A previous unreleased lock was found, this shouldn't happen and is probably an error in 'nuxt ${this.cmd.name}' command. The lock will be removed but be aware of potential strange results`);
2846
2847 await this.releaseLock();
2848 this._lockRelease = lockRelease;
2849 } else {
2850 this._lockRelease = lockRelease;
2851 }
2852 }
2853 }
2854
2855 async releaseLock () {
2856 if (this._lockRelease) {
2857 await this._lockRelease();
2858 this._lockRelease = undefined;
2859 }
2860 }
2861
2862 isUserSuppliedArg (option) {
2863 return this._argv.includes(`--${option}`) || this._argv.includes(`--no-${option}`)
2864 }
2865
2866 _getDefaultOptionValue (option) {
2867 return typeof option.default === 'function' ? option.default(this.cmd) : option.default
2868 }
2869
2870 _getMinimistOptions () {
2871 const minimistOptions = {
2872 alias: {},
2873 boolean: [],
2874 string: [],
2875 default: {}
2876 };
2877
2878 for (const name of Object.keys(this.cmd.options)) {
2879 const option = this.cmd.options[name];
2880
2881 if (option.alias) {
2882 minimistOptions.alias[option.alias] = name;
2883 }
2884 if (option.type) {
2885 minimistOptions[option.type].push(option.alias || name);
2886 }
2887 if (option.default) {
2888 minimistOptions.default[option.alias || name] = this._getDefaultOptionValue(option);
2889 }
2890 }
2891
2892 return minimistOptions
2893 }
2894
2895 _getHelp () {
2896 const options = [];
2897 let maxOptionLength = 0;
2898
2899 for (const name in this.cmd.options) {
2900 const option = this.cmd.options[name];
2901
2902 let optionHelp = '--';
2903 optionHelp += option.type === 'boolean' && this._getDefaultOptionValue(option) ? 'no-' : '';
2904 optionHelp += name;
2905 if (option.alias) {
2906 optionHelp += `, -${option.alias}`;
2907 }
2908
2909 maxOptionLength = Math.max(maxOptionLength, optionHelp.length);
2910 options.push([optionHelp, option.description]);
2911 }
2912
2913 const _opts = options.map(([option, description]) => {
2914 const i = indent(maxOptionLength + optionSpaces - option.length);
2915 return foldLines(
2916 option + i + description,
2917 startSpaces + maxOptionLength + optionSpaces * 2,
2918 startSpaces + optionSpaces
2919 )
2920 }).join('\n');
2921
2922 const usage = foldLines(`Usage: nuxt ${this.cmd.usage} [options]`, startSpaces);
2923 const description = foldLines(this.cmd.description, startSpaces);
2924 const opts = foldLines('Options:', startSpaces) + '\n\n' + _opts;
2925
2926 let helpText = colorize(`${usage}\n\n`);
2927 if (this.cmd.description) {
2928 helpText += colorize(`${description}\n\n`);
2929 }
2930 if (options.length) {
2931 helpText += colorize(`${opts}\n\n`);
2932 }
2933
2934 return helpText
2935 }
2936}
2937
2938let _setup = false;
2939
2940function setup ({ dev }) {
2941 // Apply default NODE_ENV if not provided
2942 if (!process.env.NODE_ENV) {
2943 process.env.NODE_ENV = dev ? 'development' : 'production';
2944 }
2945
2946 if (_setup) {
2947 return
2948 }
2949 _setup = true;
2950
2951 // Global error handler
2952 /* istanbul ignore next */
2953 process.on('unhandledRejection', (err) => {
2954 consola.error(err);
2955 });
2956
2957 // Exit process on fatal errors
2958 /* istanbul ignore next */
2959 consola.addReporter({
2960 log (logObj) {
2961 if (logObj.type === 'fatal') {
2962 const errorMessage = String(logObj.args[0]);
2963 process.stderr.write(fatalBox(errorMessage));
2964 exit(1);
2965 }
2966 }
2967 });
2968
2969 // Wrap all console logs with consola for better DX
2970 consola.wrapConsole();
2971}
2972
2973function packageExists (name) {
2974 try {
2975 require.resolve(name);
2976 return true
2977 } catch (e) {
2978 return false
2979 }
2980}
2981
2982async function run (_argv, hooks = {}) {
2983 // Check for not installing both nuxt and nuxt-edge
2984 const dupPkg = '@nuxt/' + ( 'cli-edge');
2985 if (packageExists(dupPkg)) {
2986 throw new Error('Both `nuxt` and `nuxt-edge` dependencies are installed! This is unsupported, please choose one and remove the other one from dependencies.')
2987 }
2988
2989 // Read from process.argv
2990 const argv = _argv ? Array.from(_argv) : process.argv.slice(2);
2991
2992 // Check for internal command
2993 let cmd = await getCommand(argv[0]);
2994
2995 // Matching `nuxt` or `nuxt [dir]` or `nuxt -*` for `nuxt dev` shortcut
2996 if (!cmd && (!argv[0] || argv[0][0] === '-' || fs.existsSync(argv[0]))) {
2997 argv.unshift('dev');
2998 cmd = await getCommand('dev');
2999 }
3000
3001 // Check for dev
3002 const dev = argv[0] === 'dev';
3003
3004 // Setup env
3005 setup({ dev });
3006
3007 // Try internal command
3008 if (cmd) {
3009 return NuxtCommand.run(cmd, argv.slice(1), hooks)
3010 }
3011
3012 // Try external command
3013 try {
3014 await execa(`nuxt-${argv[0]}`, argv.slice(1), {
3015 stdout: process.stdout,
3016 stderr: process.stderr,
3017 stdin: process.stdin
3018 });
3019 } catch (error) {
3020 if (error.exitCode === 2) {
3021 throw String(`Command not found: nuxt-${argv[0]}`)
3022 }
3023 throw String(`Failed to run command \`nuxt-${argv[0]}\`:\n${error}`)
3024 }
3025}
3026
3027async function getWebpackConfig (name = 'client', loadOptions = {}) {
3028 const { loadNuxt } = await core();
3029 const { getBuilder } = await builder();
3030
3031 const nuxt = await loadNuxt(loadOptions);
3032 const builder$1 = await getBuilder(nuxt);
3033 const { bundleBuilder } = builder$1;
3034 return bundleBuilder.getWebpackConfig(name)
3035}
3036
3037exports.MapCache = _MapCache;
3038exports.NuxtCommand = NuxtCommand;
3039exports.Symbol = _Symbol;
3040exports.baseGetTag = _baseGetTag;
3041exports.colorize = colorize;
3042exports.common = common;
3043exports.createLock = createLock;
3044exports.eventsMapping = eventsMapping;
3045exports.foldLines = foldLines;
3046exports.formatPath = formatPath;
3047exports.getCommand = getCommand;
3048exports.getWebpackConfig = getWebpackConfig;
3049exports.imports = imports;
3050exports.indent = indent;
3051exports.index = index;
3052exports.index$1 = index$1;
3053exports.isArray = isArray_1;
3054exports.isObjectLike = isObjectLike_1;
3055exports.loadNuxtConfig = loadNuxtConfig;
3056exports.locking = locking;
3057exports.normalizeArg = normalizeArg;
3058exports.optionSpaces = optionSpaces;
3059exports.run = run;
3060exports.server = server;
3061exports.setup = setup;
3062exports.startSpaces = startSpaces;
3063exports.successBox = successBox;