From f49ae026e748e873cd3509761efcfbee793c35fb Mon Sep 17 00:00:00 2001 From: mapsam Date: Thu, 17 Nov 2016 11:16:29 -0800 Subject: [PATCH 01/17] require mapboxgl --- dist/mapbox-gl-directions.js | 596 +++++++++++++++++++++-------------- example/index.html | 25 -- example/index.js | 30 +- package.json | 7 +- src/directions.js | 39 +-- index.js => src/index.js | 8 +- 6 files changed, 405 insertions(+), 300 deletions(-) delete mode 100644 example/index.html rename index.js => src/index.js (90%) diff --git a/dist/mapbox-gl-directions.js b/dist/mapbox-gl-directions.js index d2533d1..3a383b0 100644 --- a/dist/mapbox-gl-directions.js +++ b/dist/mapbox-gl-directions.js @@ -37,7 +37,7 @@ if (window.mapboxgl) { * @return {Directions} `this` */ -},{"./src/directions":36}],2:[function(require,module,exports){ +},{"./src/directions":42}],2:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -3996,13 +3996,13 @@ exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -exports["default"] = applyMiddleware; +exports['default'] = applyMiddleware; var _compose = require('./compose'); var _compose2 = _interopRequireDefault(_compose); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /** * Creates a store enhancer that applies middleware to the dispatch method @@ -4026,8 +4026,8 @@ function applyMiddleware() { } return function (createStore) { - return function (reducer, initialState, enhancer) { - var store = createStore(reducer, initialState, enhancer); + return function (reducer, preloadedState, enhancer) { + var store = createStore(reducer, preloadedState, enhancer); var _dispatch = store.dispatch; var chain = []; @@ -4040,7 +4040,7 @@ function applyMiddleware() { chain = middlewares.map(function (middleware) { return middleware(middlewareAPI); }); - _dispatch = _compose2["default"].apply(undefined, chain)(store.dispatch); + _dispatch = _compose2['default'].apply(undefined, chain)(store.dispatch); return _extends({}, store, { dispatch: _dispatch @@ -4052,7 +4052,7 @@ function applyMiddleware() { 'use strict'; exports.__esModule = true; -exports["default"] = bindActionCreators; +exports['default'] = bindActionCreators; function bindActionCreator(actionCreator, dispatch) { return function () { return dispatch(actionCreator.apply(undefined, arguments)); @@ -4104,7 +4104,7 @@ function bindActionCreators(actionCreators, dispatch) { 'use strict'; exports.__esModule = true; -exports["default"] = combineReducers; +exports['default'] = combineReducers; var _createStore = require('./createStore'); @@ -4116,7 +4116,7 @@ var _warning = require('./utils/warning'); var _warning2 = _interopRequireDefault(_warning); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function getUndefinedStateErrorMessage(key, action) { var actionType = action && action.type; @@ -4125,20 +4125,24 @@ function getUndefinedStateErrorMessage(key, action) { return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state.'; } -function getUnexpectedStateShapeWarningMessage(inputState, reducers, action) { +function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { var reducerKeys = Object.keys(reducers); - var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'initialState argument passed to createStore' : 'previous state received by the reducer'; + var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; if (reducerKeys.length === 0) { return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; } - if (!(0, _isPlainObject2["default"])(inputState)) { + if (!(0, _isPlainObject2['default'])(inputState)) { return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"'); } var unexpectedKeys = Object.keys(inputState).filter(function (key) { - return !reducers.hasOwnProperty(key); + return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; + }); + + unexpectedKeys.forEach(function (key) { + unexpectedKeyCache[key] = true; }); if (unexpectedKeys.length > 0) { @@ -4183,12 +4187,23 @@ function combineReducers(reducers) { var finalReducers = {}; for (var i = 0; i < reducerKeys.length; i++) { var key = reducerKeys[i]; + + if ("production" !== 'production') { + if (typeof reducers[key] === 'undefined') { + (0, _warning2['default'])('No reducer provided for key "' + key + '"'); + } + } + if (typeof reducers[key] === 'function') { finalReducers[key] = reducers[key]; } } var finalReducerKeys = Object.keys(finalReducers); + if ("production" !== 'production') { + var unexpectedKeyCache = {}; + } + var sanityError; try { assertReducerSanity(finalReducers); @@ -4205,9 +4220,9 @@ function combineReducers(reducers) { } if ("production" !== 'production') { - var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action); + var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache); if (warningMessage) { - (0, _warning2["default"])(warningMessage); + (0, _warning2['default'])(warningMessage); } } @@ -4228,7 +4243,7 @@ function combineReducers(reducers) { return hasChanged ? nextState : state; }; } -},{"./createStore":14,"./utils/warning":16,"lodash/isPlainObject":21}],13:[function(require,module,exports){ +},{"./createStore":14,"./utils/warning":16,"lodash/isPlainObject":26}],13:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -4253,28 +4268,26 @@ function compose() { return function (arg) { return arg; }; - } else { - var _ret = function () { - var last = funcs[funcs.length - 1]; - var rest = funcs.slice(0, -1); - return { - v: function v() { - return rest.reduceRight(function (composed, f) { - return f(composed); - }, last.apply(undefined, arguments)); - } - }; - }(); + } - if (typeof _ret === "object") return _ret.v; + if (funcs.length === 1) { + return funcs[0]; } + + var last = funcs[funcs.length - 1]; + var rest = funcs.slice(0, -1); + return function () { + return rest.reduceRight(function (composed, f) { + return f(composed); + }, last.apply(undefined, arguments)); + }; } },{}],14:[function(require,module,exports){ 'use strict'; exports.__esModule = true; exports.ActionTypes = undefined; -exports["default"] = createStore; +exports['default'] = createStore; var _isPlainObject = require('lodash/isPlainObject'); @@ -4284,7 +4297,7 @@ var _symbolObservable = require('symbol-observable'); var _symbolObservable2 = _interopRequireDefault(_symbolObservable); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /** * These are private action types reserved by Redux. @@ -4307,7 +4320,7 @@ var ActionTypes = exports.ActionTypes = { * @param {Function} reducer A function that returns the next state tree, given * the current state tree and the action to handle. * - * @param {any} [initialState] The initial state. You may optionally specify it + * @param {any} [preloadedState] The initial state. You may optionally specify it * to hydrate the state from the server in universal apps, or to restore a * previously serialized user session. * If you use `combineReducers` to produce the root reducer function, this must be @@ -4321,12 +4334,12 @@ var ActionTypes = exports.ActionTypes = { * @returns {Store} A Redux store that lets you read the state, dispatch actions * and subscribe to changes. */ -function createStore(reducer, initialState, enhancer) { +function createStore(reducer, preloadedState, enhancer) { var _ref2; - if (typeof initialState === 'function' && typeof enhancer === 'undefined') { - enhancer = initialState; - initialState = undefined; + if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { + enhancer = preloadedState; + preloadedState = undefined; } if (typeof enhancer !== 'undefined') { @@ -4334,7 +4347,7 @@ function createStore(reducer, initialState, enhancer) { throw new Error('Expected the enhancer to be a function.'); } - return enhancer(createStore)(reducer, initialState); + return enhancer(createStore)(reducer, preloadedState); } if (typeof reducer !== 'function') { @@ -4342,7 +4355,7 @@ function createStore(reducer, initialState, enhancer) { } var currentReducer = reducer; - var currentState = initialState; + var currentState = preloadedState; var currentListeners = []; var nextListeners = currentListeners; var isDispatching = false; @@ -4434,7 +4447,7 @@ function createStore(reducer, initialState, enhancer) { * return something else (for example, a Promise you can await). */ function dispatch(action) { - if (!(0, _isPlainObject2["default"])(action)) { + if (!(0, _isPlainObject2['default'])(action)) { throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); } @@ -4499,7 +4512,6 @@ function createStore(reducer, initialState, enhancer) { * be used to unsubscribe the observable from the store, and prevent further * emission of values from the observable. */ - subscribe: function subscribe(observer) { if (typeof observer !== 'object') { throw new TypeError('Expected the observer to be an object.'); @@ -4515,7 +4527,7 @@ function createStore(reducer, initialState, enhancer) { var unsubscribe = outerSubscribe(observeState); return { unsubscribe: unsubscribe }; } - }, _ref[_symbolObservable2["default"]] = function () { + }, _ref[_symbolObservable2['default']] = function () { return this; }, _ref; } @@ -4530,9 +4542,9 @@ function createStore(reducer, initialState, enhancer) { subscribe: subscribe, getState: getState, replaceReducer: replaceReducer - }, _ref2[_symbolObservable2["default"]] = observable, _ref2; + }, _ref2[_symbolObservable2['default']] = observable, _ref2; } -},{"lodash/isPlainObject":21,"symbol-observable":22}],15:[function(require,module,exports){ +},{"lodash/isPlainObject":26,"symbol-observable":27}],15:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4562,7 +4574,7 @@ var _warning = require('./utils/warning'); var _warning2 = _interopRequireDefault(_warning); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /* * This is a dummy function to check if the function name has been altered by minification. @@ -4571,19 +4583,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d function isCrushed() {} if ("production" !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') { - (0, _warning2["default"])('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.'); + (0, _warning2['default'])('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.'); } -exports.createStore = _createStore2["default"]; -exports.combineReducers = _combineReducers2["default"]; -exports.bindActionCreators = _bindActionCreators2["default"]; -exports.applyMiddleware = _applyMiddleware2["default"]; -exports.compose = _compose2["default"]; +exports.createStore = _createStore2['default']; +exports.combineReducers = _combineReducers2['default']; +exports.bindActionCreators = _bindActionCreators2['default']; +exports.applyMiddleware = _applyMiddleware2['default']; +exports.compose = _compose2['default']; },{"./applyMiddleware":10,"./bindActionCreators":11,"./combineReducers":12,"./compose":13,"./createStore":14,"./utils/warning":16}],16:[function(require,module,exports){ 'use strict'; exports.__esModule = true; -exports["default"] = warning; +exports['default'] = warning; /** * Prints a warning in the console if it exists. * @@ -4606,6 +4618,53 @@ function warning(message) { /* eslint-enable no-empty */ } },{}],17:[function(require,module,exports){ +var root = require('./_root'); + +/** Built-in value references. */ +var Symbol = root.Symbol; + +module.exports = Symbol; + +},{"./_root":24}],18:[function(require,module,exports){ +var Symbol = require('./_Symbol'), + getRawTag = require('./_getRawTag'), + objectToString = require('./_objectToString'); + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + value = Object(value); + return (symToStringTag && symToStringTag in value) + ? getRawTag(value) + : objectToString(value); +} + +module.exports = baseGetTag; + +},{"./_Symbol":17,"./_getRawTag":21,"./_objectToString":22}],19:[function(require,module,exports){ +(function (global){ +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +module.exports = freeGlobal; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],20:[function(require,module,exports){ var overArg = require('./_overArg'); /** Built-in value references. */ @@ -4613,29 +4672,79 @@ var getPrototype = overArg(Object.getPrototypeOf, Object); module.exports = getPrototype; -},{"./_overArg":19}],18:[function(require,module,exports){ +},{"./_overArg":23}],21:[function(require,module,exports){ +var Symbol = require('./_Symbol'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + /** - * Checks if `value` is a host object in IE < 9. + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } } return result; } -module.exports = isHostObject; +module.exports = getRawTag; + +},{"./_Symbol":17}],22:[function(require,module,exports){ +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +module.exports = objectToString; -},{}],19:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ /** * Creates a unary function that invokes `func` with its argument transformed. * @@ -4652,7 +4761,18 @@ function overArg(func, transform) { module.exports = overArg; -},{}],20:[function(require,module,exports){ +},{}],24:[function(require,module,exports){ +var freeGlobal = require('./_freeGlobal'); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + +},{"./_freeGlobal":19}],25:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". @@ -4678,14 +4798,14 @@ module.exports = overArg; * // => false */ function isObjectLike(value) { - return !!value && typeof value == 'object'; + return value != null && typeof value == 'object'; } module.exports = isObjectLike; -},{}],21:[function(require,module,exports){ -var getPrototype = require('./_getPrototype'), - isHostObject = require('./_isHostObject'), +},{}],26:[function(require,module,exports){ +var baseGetTag = require('./_baseGetTag'), + getPrototype = require('./_getPrototype'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ @@ -4704,13 +4824,6 @@ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to infer the `Object` constructor. */ var objectCtorString = funcToString.call(Object); -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - /** * Checks if `value` is a plain object, that is, an object created by the * `Object` constructor or one with a `[[Prototype]]` of `null`. @@ -4740,8 +4853,7 @@ var objectToString = objectProto.toString; * // => true */ function isPlainObject(value) { - if (!isObjectLike(value) || - objectToString.call(value) != objectTag || isHostObject(value)) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag) { return false; } var proto = getPrototype(value); @@ -4749,33 +4861,64 @@ function isPlainObject(value) { return true; } var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; - return (typeof Ctor == 'function' && - Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; } module.exports = isPlainObject; -},{"./_getPrototype":17,"./_isHostObject":18,"./isObjectLike":20}],22:[function(require,module,exports){ +},{"./_baseGetTag":18,"./_getPrototype":20,"./isObjectLike":25}],27:[function(require,module,exports){ +module.exports = require('./lib/index'); + +},{"./lib/index":28}],28:[function(require,module,exports){ (function (global){ -/* global window */ 'use strict'; -module.exports = require('./ponyfill')(global || window || this); +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _ponyfill = require('./ponyfill'); +var _ponyfill2 = _interopRequireDefault(_ponyfill); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var root; /* global window */ + + +if (typeof self !== 'undefined') { + root = self; +} else if (typeof window !== 'undefined') { + root = window; +} else if (typeof global !== 'undefined') { + root = global; +} else if (typeof module !== 'undefined') { + root = module; +} else { + root = Function('return this')(); +} + +var result = (0, _ponyfill2['default'])(root); +exports['default'] = result; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./ponyfill":23}],23:[function(require,module,exports){ +},{"./ponyfill":29}],29:[function(require,module,exports){ 'use strict'; -module.exports = function symbolObservablePonyfill(root) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = symbolObservablePonyfill; +function symbolObservablePonyfill(root) { var result; - var Symbol = root.Symbol; + var _Symbol = root.Symbol; - if (typeof Symbol === 'function') { - if (Symbol.observable) { - result = Symbol.observable; + if (typeof _Symbol === 'function') { + if (_Symbol.observable) { + result = _Symbol.observable; } else { - result = Symbol('observable'); - Symbol.observable = result; + result = _Symbol('observable'); + _Symbol.observable = result; } } else { result = '@@observable'; @@ -4783,8 +4926,7 @@ module.exports = function symbolObservablePonyfill(root) { return result; }; - -},{}],24:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ 'use strict'; /** @@ -4843,7 +4985,7 @@ module.exports = function symbolObservablePonyfill(root) { var Suggestions = require('./src/suggestions'); window.Suggestions = module.exports = Suggestions; -},{"./src/suggestions":27}],25:[function(require,module,exports){ +},{"./src/suggestions":33}],31:[function(require,module,exports){ /* * Fuzzy * https://github.com/myork/fuzzy @@ -4868,23 +5010,23 @@ if (typeof exports !== 'undefined') { // Return all elements of `array` that have a fuzzy // match against `pattern`. fuzzy.simpleFilter = function(pattern, array) { - return array.filter(function(string) { - return fuzzy.test(pattern, string); + return array.filter(function(str) { + return fuzzy.test(pattern, str); }); }; -// Does `pattern` fuzzy match `string`? -fuzzy.test = function(pattern, string) { - return fuzzy.match(pattern, string) !== null; +// Does `pattern` fuzzy match `str`? +fuzzy.test = function(pattern, str) { + return fuzzy.match(pattern, str) !== null; }; -// If `pattern` matches `string`, wrap each matching character +// If `pattern` matches `str`, wrap each matching character // in `opts.pre` and `opts.post`. If no match, return null -fuzzy.match = function(pattern, string, opts) { +fuzzy.match = function(pattern, str, opts) { opts = opts || {}; var patternIdx = 0 , result = [] - , len = string.length + , len = str.length , totalScore = 0 , currScore = 0 // prefix @@ -4893,15 +5035,15 @@ fuzzy.match = function(pattern, string, opts) { , post = opts.post || '' // String to compare against. This might be a lowercase version of the // raw string - , compareString = opts.caseSensitive && string || string.toLowerCase() - , ch, compareChar; + , compareString = opts.caseSensitive && str || str.toLowerCase() + , ch; pattern = opts.caseSensitive && pattern || pattern.toLowerCase(); // For each character in the string, either add it to the result // or wrap in template if it's the next string in the pattern for(var idx = 0; idx < len; idx++) { - ch = string[idx]; + ch = str[idx]; if(compareString[idx] === pattern[patternIdx]) { ch = pre + ch + post; patternIdx += 1; @@ -4917,6 +5059,8 @@ fuzzy.match = function(pattern, string, opts) { // return rendered string if we have a match for every char if(patternIdx === pattern.length) { + // if the string is an exact match with pattern, totalScore should be maxed + totalScore = (compareString === pattern) ? Infinity : totalScore; return {rendered: result.join(''), score: totalScore}; } @@ -4948,6 +5092,12 @@ fuzzy.match = function(pattern, string, opts) { // , extract: function(arg) { return arg.crying; } // } fuzzy.filter = function(pattern, arr, opts) { + if(!arr || arr.length === 0) { + return []; + } + if (typeof pattern !== 'string') { + return arr; + } opts = opts || {}; return arr .reduce(function(prev, element, idx, arr) { @@ -4981,7 +5131,7 @@ fuzzy.filter = function(pattern, arr, opts) { }()); -},{}],26:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ 'Use strict'; var List = function(component) { @@ -5068,7 +5218,7 @@ List.prototype.next = function() { module.exports = List; -},{}],27:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ 'use strict'; var extend = require('xtend'); @@ -5258,7 +5408,7 @@ Suggestions.prototype.getItemValue = function(item) { module.exports = Suggestions; -},{"./list":26,"fuzzy":25,"xtend":30}],28:[function(require,module,exports){ +},{"./list":32,"fuzzy":31,"xtend":36}],34:[function(require,module,exports){ var each = require('turf-meta').coordEach; /** @@ -5328,7 +5478,7 @@ module.exports = function(layer) { return extent; }; -},{"turf-meta":29}],29:[function(require,module,exports){ +},{"turf-meta":35}],35:[function(require,module,exports){ /** * Lazily iterate over coordinates in any GeoJSON object, similar to * Array.forEach. @@ -5468,7 +5618,7 @@ function propReduce(layer, callback, memo) { } module.exports.propReduce = propReduce; -},{}],30:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ module.exports = extend var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -5489,7 +5639,7 @@ function extend() { return target } -},{}],31:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -5580,12 +5730,11 @@ function setHoverMarker(feature) { function fetchDirections() { return function (dispatch, getState) { - var _getState = getState(); - - var api = _getState.api; - var accessToken = _getState.accessToken; - var routeIndex = _getState.routeIndex; - var profile = _getState.profile; + var _getState = getState(), + api = _getState.api, + accessToken = _getState.accessToken, + routeIndex = _getState.routeIndex, + profile = _getState.profile; var query = buildDirectionsQuery(getState); @@ -5638,12 +5787,10 @@ function fetchDirections() { * @param {Function} state */ function buildDirectionsQuery(state) { - var _state = state(); - - var origin = _state.origin; - var destination = _state.destination; - var waypoints = _state.waypoints; - + var _state = state(), + origin = _state.origin, + destination = _state.destination, + waypoints = _state.waypoints; var query = []; query = query.concat(origin.geometry.coordinates); @@ -5749,9 +5896,8 @@ function setRouteIndex(routeIndex) { function createOrigin(coordinates) { return function (dispatch, getState) { - var _getState2 = getState(); - - var destination = _getState2.destination; + var _getState2 = getState(), + destination = _getState2.destination; dispatch(originPoint(coordinates)); if (destination.geometry) dispatch(fetchDirections()); @@ -5760,9 +5906,8 @@ function createOrigin(coordinates) { function createDestination(coordinates) { return function (dispatch, getState) { - var _getState3 = getState(); - - var origin = _getState3.origin; + var _getState3 = getState(), + origin = _getState3.origin; dispatch(destinationPoint(coordinates)); if (origin.geometry) dispatch(fetchDirections()); @@ -5771,10 +5916,9 @@ function createDestination(coordinates) { function setProfile(profile) { return function (dispatch, getState) { - var _getState4 = getState(); - - var origin = _getState4.origin; - var destination = _getState4.destination; + var _getState4 = getState(), + origin = _getState4.origin, + destination = _getState4.destination; dispatch({ type: types.DIRECTIONS_PROFILE, profile: profile }); dispatch(eventEmit('profile', { profile: profile })); @@ -5821,10 +5965,9 @@ function setDestinationFromCoordinates(coords) { function addWaypoint(index, waypoint) { return function (dispatch, getState) { - var _getState5 = getState(); - - var destination = _getState5.destination; - var waypoints = _getState5.waypoints; + var _getState5 = getState(), + destination = _getState5.destination, + waypoints = _getState5.waypoints; waypoints.splice(index, 0, normalizeWaypoint(waypoint)); dispatch(updateWaypoints(waypoints)); @@ -5834,10 +5977,9 @@ function addWaypoint(index, waypoint) { function setWaypoint(index, waypoint) { return function (dispatch, getState) { - var _getState6 = getState(); - - var destination = _getState6.destination; - var waypoints = _getState6.waypoints; + var _getState6 = getState(), + destination = _getState6.destination, + waypoints = _getState6.waypoints; waypoints[index] = normalizeWaypoint(waypoint); dispatch(updateWaypoints(waypoints)); @@ -5847,10 +5989,9 @@ function setWaypoint(index, waypoint) { function removeWaypoint(waypoint) { return function (dispatch, getState) { - var _getState7 = getState(); - - var destination = _getState7.destination; - var waypoints = _getState7.waypoints; + var _getState7 = getState(), + destination = _getState7.destination, + waypoints = _getState7.waypoints; waypoints = waypoints.filter(function (way) { return !_utils2.default.coordinateMatch(way, waypoint); @@ -5863,9 +6004,8 @@ function removeWaypoint(waypoint) { function eventSubscribe(type, fn) { return function (dispatch, getState) { - var _getState8 = getState(); - - var events = _getState8.events; + var _getState8 = getState(), + events = _getState8.events; events[type] = events[type] || []; events[type].push(fn); @@ -5880,10 +6020,8 @@ function eventEmit(type, data) { var _this = this; return function (dispatch, getState) { - var _getState9 = getState(); - - var events = _getState9.events; - + var _getState9 = getState(), + events = _getState9.events; if (!events[type]) { return { @@ -5900,7 +6038,7 @@ function eventEmit(type, data) { }; } -},{"../constants/action_types":32,"../utils":39}],32:[function(require,module,exports){ +},{"../constants/action_types":38,"../utils":45}],38:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -5923,10 +6061,10 @@ var ROUTE_INDEX = exports.ROUTE_INDEX = 'ROUTE_INDEX'; var SET_OPTIONS = exports.SET_OPTIONS = 'SET_OPTIONS'; var WAYPOINTS = exports.WAYPOINTS = 'WAYPOINTS'; -},{}],33:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ 'use strict'; -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var Typeahead = require('suggestions'); var debounce = require('lodash.debounce'); @@ -6231,7 +6369,7 @@ Geocoder.prototype = { module.exports = Geocoder; -},{"events":2,"lodash.debounce":3,"suggestions":24,"xtend":30}],34:[function(require,module,exports){ +},{"events":2,"lodash.debounce":3,"suggestions":30,"xtend":36}],40:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6277,12 +6415,10 @@ var Inputs = function () { function Inputs(el, store, actions, map) { _classCallCheck(this, Inputs); - var _store$getState = store.getState(); - - var originQuery = _store$getState.originQuery; - var destinationQuery = _store$getState.destinationQuery; - var profile = _store$getState.profile; - + var _store$getState = store.getState(), + originQuery = _store$getState.originQuery, + destinationQuery = _store$getState.destinationQuery, + profile = _store$getState.profile; el.innerHTML = tmpl({ originQuery: originQuery, @@ -6302,11 +6438,9 @@ var Inputs = function () { _createClass(Inputs, [{ key: 'animateToCoordinates', value: function animateToCoordinates(mode, coords) { - var _store$getState2 = this.store.getState(); - - var origin = _store$getState2.origin; - var destination = _store$getState2.destination; - + var _store$getState2 = this.store.getState(), + origin = _store$getState2.origin, + destination = _store$getState2.destination; if (origin.geometry && destination.geometry && !(0, _lodash4.default)(origin.geometry, destination.geometry)) { @@ -6326,18 +6460,16 @@ var Inputs = function () { value: function onAdd() { var _this = this; - var _actions = this.actions; - var clearOrigin = _actions.clearOrigin; - var clearDestination = _actions.clearDestination; - var createOrigin = _actions.createOrigin; - var createDestination = _actions.createDestination; - var setProfile = _actions.setProfile; - var reverse = _actions.reverse; - - var _store$getState3 = this.store.getState(); - - var geocoder = _store$getState3.geocoder; + var _actions = this.actions, + clearOrigin = _actions.clearOrigin, + clearDestination = _actions.clearDestination, + createOrigin = _actions.createOrigin, + createDestination = _actions.createDestination, + setProfile = _actions.setProfile, + reverse = _actions.reverse; + var _store$getState3 = this.store.getState(), + geocoder = _store$getState3.geocoder; this.originInput = new _geocoder2.default(Object.assign({}, { flyTo: false, @@ -6381,10 +6513,9 @@ var Inputs = function () { // Reversing Origin / Destination this.container.querySelector('.js-reverse-inputs').addEventListener('click', function () { - var _store$getState4 = _this.store.getState(); - - var origin = _store$getState4.origin; - var destination = _store$getState4.destination; + var _store$getState4 = _this.store.getState(), + origin = _store$getState4.origin, + destination = _store$getState4.destination; if (origin) _this.actions.queryDestination(origin.geometry.coordinates); if (destination) _this.actions.queryOrigin(destination.geometry.coordinates); @@ -6397,13 +6528,11 @@ var Inputs = function () { var _this2 = this; this.store.subscribe(function () { - var _store$getState5 = _this2.store.getState(); - - var originQuery = _store$getState5.originQuery; - var destinationQuery = _store$getState5.destinationQuery; - var originQueryCoordinates = _store$getState5.originQueryCoordinates; - var destinationQueryCoordinates = _store$getState5.destinationQueryCoordinates; - + var _store$getState5 = _this2.store.getState(), + originQuery = _store$getState5.originQuery, + destinationQuery = _store$getState5.destinationQuery, + originQueryCoordinates = _store$getState5.originQueryCoordinates, + destinationQueryCoordinates = _store$getState5.destinationQueryCoordinates; if (originQuery) { _this2.originInput.query(originQuery); @@ -6435,7 +6564,7 @@ var Inputs = function () { exports.default = Inputs; -},{"./geocoder":33,"lodash.isequal":4,"lodash.template":5,"turf-extent":28}],35:[function(require,module,exports){ +},{"./geocoder":39,"lodash.isequal":4,"lodash.template":5,"turf-extent":34}],41:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6492,16 +6621,15 @@ var Instructions = function () { var _this = this; this.store.subscribe(function () { - var _actions = _this.actions; - var hoverMarker = _actions.hoverMarker; - var setRouteIndex = _actions.setRouteIndex; - - var _store$getState = _this.store.getState(); + var _actions = _this.actions, + hoverMarker = _actions.hoverMarker, + setRouteIndex = _actions.setRouteIndex; - var routeIndex = _store$getState.routeIndex; - var unit = _store$getState.unit; - var directions = _store$getState.directions; - var error = _store$getState.error; + var _store$getState = _this.store.getState(), + routeIndex = _store$getState.routeIndex, + unit = _store$getState.unit, + directions = _store$getState.directions, + error = _store$getState.error; var shouldRender = !(0, _lodash4.default)(directions[routeIndex], _this.directions); @@ -6561,7 +6689,7 @@ var Instructions = function () { exports.default = Instructions; -},{"../utils":39,"lodash.isequal":4,"lodash.template":5}],36:[function(require,module,exports){ +},{"../utils":45,"lodash.isequal":4,"lodash.template":5}],42:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6655,11 +6783,9 @@ var Directions = function () { this._map = map; - var _store$getState = store.getState(); - - var container = _store$getState.container; - var controls = _store$getState.controls; - + var _store$getState = store.getState(), + container = _store$getState.container, + controls = _store$getState.controls; this.container = container ? typeof container === 'string' ? document.getElementById(container) : container : this._map.getContainer(); @@ -6703,14 +6829,14 @@ var Directions = function () { value: function mapState() { var _this2 = this; - var _store$getState2 = store.getState(); - - var profile = _store$getState2.profile; - var styles = _store$getState2.styles; - var interactive = _store$getState2.interactive; + var _store$getState2 = store.getState(), + profile = _store$getState2.profile, + styles = _store$getState2.styles, + interactive = _store$getState2.interactive; // Emit any default or option set config + this.actions.eventEmit('profile', { profile: profile }); var geojson = { @@ -6748,14 +6874,12 @@ var Directions = function () { var _this3 = this; store.subscribe(function () { - var _store$getState3 = store.getState(); - - var origin = _store$getState3.origin; - var destination = _store$getState3.destination; - var hoverMarker = _store$getState3.hoverMarker; - var directions = _store$getState3.directions; - var routeIndex = _store$getState3.routeIndex; - + var _store$getState3 = store.getState(), + origin = _store$getState3.origin, + destination = _store$getState3.destination, + hoverMarker = _store$getState3.hoverMarker, + directions = _store$getState3.directions, + routeIndex = _store$getState3.routeIndex; var geojson = { type: 'FeatureCollection', @@ -6809,9 +6933,8 @@ var Directions = function () { value: function _onClick(e) { var _this4 = this; - var _store$getState4 = store.getState(); - - var origin = _store$getState4.origin; + var _store$getState4 = store.getState(), + origin = _store$getState4.origin; var coords = [e.lngLat.lng, e.lngLat.lat]; @@ -6847,10 +6970,8 @@ var Directions = function () { value: function _move(e) { var _this5 = this; - var _store$getState5 = store.getState(); - - var hoverMarker = _store$getState5.hoverMarker; - + var _store$getState5 = store.getState(), + hoverMarker = _store$getState5.hoverMarker; var features = this._map.queryRenderedFeatures(e.point, { layers: ['directions-route-line-alt', 'directions-route-line', 'directions-origin-point', 'directions-destination-point', 'directions-hover-point'] @@ -6911,12 +7032,10 @@ var Directions = function () { value: function _onDragUp() { if (!this.isDragging) return; - var _store$getState6 = store.getState(); - - var hoverMarker = _store$getState6.hoverMarker; - var origin = _store$getState6.origin; - var destination = _store$getState6.destination; - + var _store$getState6 = store.getState(), + hoverMarker = _store$getState6.hoverMarker, + origin = _store$getState6.origin, + destination = _store$getState6.destination; switch (this.isDragging.layer.id) { case 'directions-origin-point': @@ -7088,9 +7207,8 @@ var Directions = function () { }, { key: 'removeWaypoint', value: function removeWaypoint(index) { - var _store$getState7 = store.getState(); - - var waypoints = _store$getState7.waypoints; + var _store$getState7 = store.getState(), + waypoints = _store$getState7.waypoints; this.actions.removeWaypoint(waypoints[index]); return this; @@ -7135,7 +7253,7 @@ var Directions = function () { exports.default = Directions; -},{"./actions":31,"./controls/inputs":34,"./controls/instructions":35,"./directions_style":37,"./reducers":38,"./utils":39,"polyline":8,"redux":15,"redux-thunk":9}],37:[function(require,module,exports){ +},{"./actions":37,"./controls/inputs":40,"./controls/instructions":41,"./directions_style":43,"./reducers":44,"./utils":45,"polyline":8,"redux":15,"redux-thunk":9}],43:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -7251,7 +7369,7 @@ var style = [{ exports.default = style; -},{}],38:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -7304,7 +7422,7 @@ var initialState = { }; function data() { - var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0]; + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments[1]; switch (action.type) { @@ -7396,7 +7514,7 @@ function data() { exports.default = data; -},{"../constants/action_types.js":32}],39:[function(require,module,exports){ +},{"../constants/action_types.js":38}],45:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { diff --git a/example/index.html b/example/index.html deleted file mode 100644 index e3c3855..0000000 --- a/example/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - -
-
- - - - diff --git a/example/index.js b/example/index.js index b4adb37..1655d94 100644 --- a/example/index.js +++ b/example/index.js @@ -1,26 +1,38 @@ 'use strict'; -/* global mapboxgl */ - -var Directions = require('../index'); - +var mapboxgl = require('mapbox-gl'); +var MapboxGeocoder = require('../src/index'); +var insertCss = require('insert-css'); +var fs = require('fs'); mapboxgl.accessToken = window.localStorage.getItem('MapboxAccessToken'); +insertCss(fs.readFileSync('./node_modules/mapbox-gl/dist/mapbox-gl.css', 'utf8')); +var mapDiv = document.body.appendChild(document.createElement('div')); +mapDiv.style = 'position:absolute;top:0;right:0;left:0;bottom:0;'; + var map = new mapboxgl.Map({ hash: true, - container: 'map', + container: mapDiv, style: 'mapbox://styles/mapbox/streets-v9', center: [-79.4512, 43.6568], zoom: 13 }); -var directions = new mapboxgl.Directions({ +// ui +// var button = document.body.appendChild(document.createElement('button')); +// button.style = 'position:absolute;top:10px;left:10px;z-index:10;'; +var button = document.createElement('button'); +button.style = 'z-index:10;'; +button.textContent = 'click me'; + +// directions +var MapboxDirections = require('../src/index'); +var directions = new MapboxDirections({ + accessToken: window.localStorage.getItem('MapboxAccessToken'), unit: 'metric', profile: 'cycling', container: 'directions' }); - -var button = document.createElement('button'); -button.textContent = 'click me'; +window.directions = directions; map.getContainer().querySelector('.mapboxgl-ctrl-bottom-left').appendChild(button); map.addControl(directions); diff --git a/package.json b/package.json index 717abcc..0e2ff7d 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,10 @@ "scripts": { "prepublish": "npm run build", "start": "NODE_ENV=development budo example/index.js:example/bundle.js --live", - "build": "NODE_ENV=production browserify -s mapboxDirections index.js > dist/mapbox-gl-directions.js", + "build": "NODE_ENV=production browserify -s MapboxDirections lib/index.js > dist/mapbox-gl-directions.js", "test": "NODE_ENV=test npm run lint && browserify test/index.js | smokestack -b firefox | tap-status", "docs": "documentation build --format=md > API.md", - "lint": "eslint --no-eslintrc -c .eslintrc index.js src" + "lint": "eslint --no-eslintrc -c .eslintrc src" }, "repository": { "type": "git", @@ -45,9 +45,10 @@ "budo": "^8.3.0", "documentation": "^4.0.0-beta5", "eslint": "^2.13.1", + "insert-css": "^2.0.0", "json-loader": "0.5.4", "lodash.once": "^4.0.0", - "mapbox-gl": "^0.22.1", + "mapbox-gl": "^0.27.0", "smokestack": "^3.3.1", "tap-status": "^1.0.1", "tape": "^4.6.0", diff --git a/src/directions.js b/src/directions.js index 14a6a3d..7ab7f9c 100644 --- a/src/directions.js +++ b/src/directions.js @@ -20,38 +20,41 @@ export default class Directions { constructor(options) { this.actions = bindActionCreators(actions, store.dispatch); this.actions.setOptions(options || {}); + this.options = options || {}; this.onDragDown = this._onDragDown.bind(this); this.onDragMove = this._onDragMove.bind(this); this.onDragUp = this._onDragUp.bind(this); this.move = this._move.bind(this); this.onClick = this._onClick.bind(this); - } - - addTo(map) { - this._map = map; - var container = this._container = this.onAdd(map); - if (this.options && this.options.position) { - var pos = this.options.position; - var corner = map._controlCorners[pos]; - container.className += ' mapboxgl-ctrl'; - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } - } - return this; + console.log('main constructor', this); } + // addTo(map) { + // this._map = map; + // var container = this._container = this.onAdd(map); + // if (this.options && this.options.position) { + // var pos = this.options.position; + // var corner = map._controlCorners[pos]; + // container.className += ' mapboxgl-ctrl'; + // if (pos.indexOf('bottom') !== -1) { + // corner.insertBefore(container, corner.firstChild); + // } else { + // corner.appendChild(container); + // } + // } + + // return this; + // } + onAdd(map) { this._map = map; const { container, controls } = store.getState(); - this.container = container ? typeof container === 'string' ? - document.getElementById(container) : container : this._map.getContainer(); + // this.container = container ? typeof container === 'string' ? + // document.getElementById(container) : container : this._map.getContainer(); // Add controls to the page const inputEl = document.createElement('div'); diff --git a/index.js b/src/index.js similarity index 90% rename from index.js rename to src/index.js index a4ffc7a..39b89e3 100644 --- a/index.js +++ b/src/index.js @@ -23,10 +23,6 @@ * map.addControl(directions); * @return {Directions} `this` */ -import Directions from './src/directions'; +import MapboxDirections from './directions'; -if (window.mapboxgl) { - mapboxgl.Directions = Directions; -} else if (typeof module !== 'undefined') { - module.exports = Directions; -} +module.exports = MapboxDirections; \ No newline at end of file From f11514e48fb2715c1dc71d7af2f7b9598df893d9 Mon Sep 17 00:00:00 2001 From: mapsam Date: Thu, 17 Nov 2016 13:36:30 -0800 Subject: [PATCH 02/17] remove container --- example/index.js | 11 +++++++---- src/actions/index.js | 1 + src/controls/geocoder.js | 32 ++++++++++---------------------- src/controls/inputs.js | 8 ++++++-- src/directions.js | 16 +++++++++------- test/index.js | 2 +- 6 files changed, 34 insertions(+), 36 deletions(-) diff --git a/example/index.js b/example/index.js index 1655d94..b853fec 100644 --- a/example/index.js +++ b/example/index.js @@ -5,11 +5,15 @@ var insertCss = require('insert-css'); var fs = require('fs'); mapboxgl.accessToken = window.localStorage.getItem('MapboxAccessToken'); +// var directionsDiv = document.body.appendChild(document.createElement('div')); +// directionsDiv.id = 'directions'; + +insertCss(fs.readFileSync('./dist/mapbox-gl-directions.css', 'utf8')); insertCss(fs.readFileSync('./node_modules/mapbox-gl/dist/mapbox-gl.css', 'utf8')); var mapDiv = document.body.appendChild(document.createElement('div')); mapDiv.style = 'position:absolute;top:0;right:0;left:0;bottom:0;'; -var map = new mapboxgl.Map({ +var map = window.map = new mapboxgl.Map({ hash: true, container: mapDiv, style: 'mapbox://styles/mapbox/streets-v9', @@ -18,8 +22,6 @@ var map = new mapboxgl.Map({ }); // ui -// var button = document.body.appendChild(document.createElement('button')); -// button.style = 'position:absolute;top:10px;left:10px;z-index:10;'; var button = document.createElement('button'); button.style = 'z-index:10;'; button.textContent = 'click me'; @@ -30,7 +32,8 @@ var directions = new MapboxDirections({ accessToken: window.localStorage.getItem('MapboxAccessToken'), unit: 'metric', profile: 'cycling', - container: 'directions' + container: 'directions', + instructions: false }); window.directions = directions; diff --git a/src/actions/index.js b/src/actions/index.js index f55f960..9bd50cc 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -142,6 +142,7 @@ function setError(error) { } export function queryOrigin(query) { + console.log('querying origin'); return { type: types.ORIGIN_QUERY, query diff --git a/src/controls/geocoder.js b/src/controls/geocoder.js index 5adfa4e..9c31031 100644 --- a/src/controls/geocoder.js +++ b/src/controls/geocoder.js @@ -5,6 +5,8 @@ var debounce = require('lodash.debounce'); var extend = require('xtend'); var EventEmitter = require('events').EventEmitter; +import utils from '../utils' + // Mapbox Geocoder version var API = 'https://api.mapbox.com/geocoding/v5/mapbox.places/'; @@ -36,30 +38,14 @@ function Geocoder(options) { Geocoder.prototype = { options: { - position: 'top-left', placeholder: 'Search', zoom: 16, flyTo: true }, - addTo: function (map) { - this._map = map; - var container = this._container = this.onAdd(map); - if (this.options && this.options.position) { - var pos = this.options.position; - var corner = map._controlCorners[pos]; - container.className += ' mapboxgl-ctrl'; - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } - } - - return this; - }, - onAdd: function(map) { + this._map = map; + this.request = new XMLHttpRequest(); this.container = this.options.container ? @@ -141,6 +127,8 @@ Geocoder.prototype = { this._loadingEl.classList.add('active'); this.fire('loading'); + console.log('geocoder this', this); + var options = []; if (this.options.proximity) options.push('proximity=' + this.options.proximity.join()); if (this.options.bbox) options.push('bbox=' + this.options.bbox.join()); @@ -199,8 +187,8 @@ Geocoder.prototype = { if (!input) return; if (typeof input === 'object' && input.length) { input = [ - mapboxgl.util.wrap(input[0], -180, 180), - mapboxgl.util.wrap(input[1], -180, 180) + utils.wrap(input[0]), + utils.wrap(input[1]) ].join(); } @@ -218,8 +206,8 @@ Geocoder.prototype = { if (!input) return; if (typeof input === 'object' && input.length) { input = [ - mapboxgl.util.wrap(input[0], -180, 180), - mapboxgl.util.wrap(input[1], -180, 180) + utils.wrap(input[0]), + utils.wrap(input[1]) ].join(); } diff --git a/src/controls/inputs.js b/src/controls/inputs.js index ba6aa0e..7a79b51 100644 --- a/src/controls/inputs.js +++ b/src/controls/inputs.js @@ -65,10 +65,13 @@ export default class Inputs { const { geocoder } = this.store.getState(); + console.log('geocoder from state', geocoder); + this.originInput = new Geocoder(Object.assign({}, { flyTo: false, placeholder: 'Choose a starting place', - container: this.container.querySelector('#mapbox-directions-origin-input') + container: this.container.querySelector('#mapbox-directions-origin-input'), + accessToken: this.accessToken }, geocoder)); this._map.addControl(this.originInput); @@ -76,7 +79,8 @@ export default class Inputs { this.destinationInput = new Geocoder(Object.assign({}, { flyTo: false, placeholder: 'Choose destination', - container: this.container.querySelector('#mapbox-directions-destination-input') + container: this.container.querySelector('#mapbox-directions-destination-input'), + accessToken: this.accessToken }, geocoder)); this._map.addControl(this.destinationInput); diff --git a/src/directions.js b/src/directions.js index 7ab7f9c..9c2f75d 100644 --- a/src/directions.js +++ b/src/directions.js @@ -27,8 +27,6 @@ export default class Directions { this.onDragUp = this._onDragUp.bind(this); this.move = this._move.bind(this); this.onClick = this._onClick.bind(this); - - console.log('main constructor', this); } // addTo(map) { @@ -50,11 +48,12 @@ export default class Directions { onAdd(map) { this._map = map; + console.log(this._map); - const { container, controls } = store.getState(); + const { controls } = store.getState(); - // this.container = container ? typeof container === 'string' ? - // document.getElementById(container) : container : this._map.getContainer(); + var el = document.createElement('div'); + el.className = 'mapboxgl-ctrl-directions mapboxgl-ctrl'; // Add controls to the page const inputEl = document.createElement('div'); @@ -69,12 +68,14 @@ export default class Directions { setRouteIndex: this.actions.setRouteIndex }, this._map); - if (controls.inputs) this.container.appendChild(inputEl); - if (controls.instructions) this.container.appendChild(directionsEl); + if (controls.inputs) el.appendChild(inputEl); + if (controls.instructions) el.appendChild(directionsEl); this.subscribedActions(); if (this._map.loaded()) this.mapState() else this._map.on('load', () => this.mapState()); + + return el; } /** @@ -357,6 +358,7 @@ export default class Directions { */ setOrigin(query) { if (typeof query === 'string') { + console.log('this is a query'); this.actions.queryOrigin(query); } else { this.actions.setOriginFromCoordinates(query); diff --git a/test/index.js b/test/index.js index f0a0c4c..e790dcd 100644 --- a/test/index.js +++ b/test/index.js @@ -2,7 +2,7 @@ const test = require('tape'); window.mapboxgl = require('mapbox-gl'); -require('../index'); +require('../src/index'); mapboxgl.accessToken = process.env.MapboxAccessToken; From 01f32c26c28ef6c2cac0c8e3fb1dfc5e6c11ba60 Mon Sep 17 00:00:00 2001 From: mapsam Date: Thu, 17 Nov 2016 15:48:51 -0800 Subject: [PATCH 03/17] make 0.27.0 work --- .gitignore | 1 + dist/mapbox-gl-directions.js | 251 ++++++++++++------------- example/index.js | 12 +- package.json | 5 +- src/controls/geocoder.js | 10 - src/controls/inputs.js | 16 +- src/directions.js | 21 +-- src/index.js | 1 - {dist => src}/mapbox-gl-directions.css | 19 +- src/templates/instructions.html | 48 ++--- test/test.directions.js | 2 + test/test.inputs.js | 3 +- test/test.instructions.js | 3 +- test/test.options.js | 3 +- 14 files changed, 183 insertions(+), 212 deletions(-) rename {dist => src}/mapbox-gl-directions.css (98%) diff --git a/.gitignore b/.gitignore index 4f19409..09b5414 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ env.test.sh node_modules/ +dist/ \ No newline at end of file diff --git a/dist/mapbox-gl-directions.js b/dist/mapbox-gl-directions.js index 3a383b0..22c8611 100644 --- a/dist/mapbox-gl-directions.js +++ b/dist/mapbox-gl-directions.js @@ -1,43 +1,4 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mapboxDirections = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o @@ -722,7 +683,7 @@ function toNumber(value) { module.exports = debounce; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],4:[function(require,module,exports){ +},{}],3:[function(require,module,exports){ (function (global){ /** * lodash (Custom Build) @@ -2375,7 +2336,7 @@ function keys(object) { module.exports = isEqual; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],5:[function(require,module,exports){ +},{}],4:[function(require,module,exports){ (function (global){ /** * lodash (Custom Build) @@ -3511,7 +3472,7 @@ var attempt = baseRest(function(func, args) { module.exports = template; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"lodash._reinterpolate":6,"lodash.templatesettings":7}],6:[function(require,module,exports){ +},{"lodash._reinterpolate":5,"lodash.templatesettings":6}],5:[function(require,module,exports){ /** * lodash 3.0.0 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -3526,7 +3487,7 @@ var reInterpolate = /<%=([\s\S]+?)%>/g; module.exports = reInterpolate; -},{}],7:[function(require,module,exports){ +},{}],6:[function(require,module,exports){ (function (global){ /** * lodash (Custom Build) @@ -3810,7 +3771,7 @@ function escape(string) { module.exports = templateSettings; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"lodash._reinterpolate":6}],8:[function(require,module,exports){ +},{"lodash._reinterpolate":5}],7:[function(require,module,exports){ 'use strict'; /** @@ -3965,7 +3926,7 @@ if (typeof module === 'object' && module.exports) { module.exports = polyline; } -},{}],9:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -3989,7 +3950,7 @@ var thunk = createThunkMiddleware(); thunk.withExtraArgument = createThunkMiddleware; exports['default'] = thunk; -},{}],10:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4048,7 +4009,7 @@ function applyMiddleware() { }; }; } -},{"./compose":13}],11:[function(require,module,exports){ +},{"./compose":12}],10:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4100,7 +4061,7 @@ function bindActionCreators(actionCreators, dispatch) { } return boundActionCreators; } -},{}],12:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4243,7 +4204,7 @@ function combineReducers(reducers) { return hasChanged ? nextState : state; }; } -},{"./createStore":14,"./utils/warning":16,"lodash/isPlainObject":26}],13:[function(require,module,exports){ +},{"./createStore":13,"./utils/warning":15,"lodash/isPlainObject":25}],12:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -4282,7 +4243,7 @@ function compose() { }, last.apply(undefined, arguments)); }; } -},{}],14:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4544,7 +4505,7 @@ function createStore(reducer, preloadedState, enhancer) { replaceReducer: replaceReducer }, _ref2[_symbolObservable2['default']] = observable, _ref2; } -},{"lodash/isPlainObject":26,"symbol-observable":27}],15:[function(require,module,exports){ +},{"lodash/isPlainObject":25,"symbol-observable":26}],14:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4591,7 +4552,7 @@ exports.combineReducers = _combineReducers2['default']; exports.bindActionCreators = _bindActionCreators2['default']; exports.applyMiddleware = _applyMiddleware2['default']; exports.compose = _compose2['default']; -},{"./applyMiddleware":10,"./bindActionCreators":11,"./combineReducers":12,"./compose":13,"./createStore":14,"./utils/warning":16}],16:[function(require,module,exports){ +},{"./applyMiddleware":9,"./bindActionCreators":10,"./combineReducers":11,"./compose":12,"./createStore":13,"./utils/warning":15}],15:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4617,7 +4578,7 @@ function warning(message) { } catch (e) {} /* eslint-enable no-empty */ } -},{}],17:[function(require,module,exports){ +},{}],16:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ @@ -4625,7 +4586,7 @@ var Symbol = root.Symbol; module.exports = Symbol; -},{"./_root":24}],18:[function(require,module,exports){ +},{"./_root":23}],17:[function(require,module,exports){ var Symbol = require('./_Symbol'), getRawTag = require('./_getRawTag'), objectToString = require('./_objectToString'); @@ -4656,7 +4617,7 @@ function baseGetTag(value) { module.exports = baseGetTag; -},{"./_Symbol":17,"./_getRawTag":21,"./_objectToString":22}],19:[function(require,module,exports){ +},{"./_Symbol":16,"./_getRawTag":20,"./_objectToString":21}],18:[function(require,module,exports){ (function (global){ /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; @@ -4664,7 +4625,7 @@ var freeGlobal = typeof global == 'object' && global && global.Object === Object module.exports = freeGlobal; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],20:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ var overArg = require('./_overArg'); /** Built-in value references. */ @@ -4672,7 +4633,7 @@ var getPrototype = overArg(Object.getPrototypeOf, Object); module.exports = getPrototype; -},{"./_overArg":23}],21:[function(require,module,exports){ +},{"./_overArg":22}],20:[function(require,module,exports){ var Symbol = require('./_Symbol'); /** Used for built-in method references. */ @@ -4720,7 +4681,7 @@ function getRawTag(value) { module.exports = getRawTag; -},{"./_Symbol":17}],22:[function(require,module,exports){ +},{"./_Symbol":16}],21:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -4744,7 +4705,7 @@ function objectToString(value) { module.exports = objectToString; -},{}],23:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ /** * Creates a unary function that invokes `func` with its argument transformed. * @@ -4761,7 +4722,7 @@ function overArg(func, transform) { module.exports = overArg; -},{}],24:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `self`. */ @@ -4772,7 +4733,7 @@ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; -},{"./_freeGlobal":19}],25:[function(require,module,exports){ +},{"./_freeGlobal":18}],24:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". @@ -4803,7 +4764,7 @@ function isObjectLike(value) { module.exports = isObjectLike; -},{}],26:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), getPrototype = require('./_getPrototype'), isObjectLike = require('./isObjectLike'); @@ -4867,10 +4828,10 @@ function isPlainObject(value) { module.exports = isPlainObject; -},{"./_baseGetTag":18,"./_getPrototype":20,"./isObjectLike":25}],27:[function(require,module,exports){ +},{"./_baseGetTag":17,"./_getPrototype":19,"./isObjectLike":24}],26:[function(require,module,exports){ module.exports = require('./lib/index'); -},{"./lib/index":28}],28:[function(require,module,exports){ +},{"./lib/index":27}],27:[function(require,module,exports){ (function (global){ 'use strict'; @@ -4902,7 +4863,7 @@ if (typeof self !== 'undefined') { var result = (0, _ponyfill2['default'])(root); exports['default'] = result; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./ponyfill":29}],29:[function(require,module,exports){ +},{"./ponyfill":28}],28:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -4926,7 +4887,7 @@ function symbolObservablePonyfill(root) { return result; }; -},{}],30:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ 'use strict'; /** @@ -4985,7 +4946,7 @@ function symbolObservablePonyfill(root) { var Suggestions = require('./src/suggestions'); window.Suggestions = module.exports = Suggestions; -},{"./src/suggestions":33}],31:[function(require,module,exports){ +},{"./src/suggestions":32}],30:[function(require,module,exports){ /* * Fuzzy * https://github.com/myork/fuzzy @@ -5131,7 +5092,7 @@ fuzzy.filter = function(pattern, arr, opts) { }()); -},{}],32:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ 'Use strict'; var List = function(component) { @@ -5218,7 +5179,7 @@ List.prototype.next = function() { module.exports = List; -},{}],33:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ 'use strict'; var extend = require('xtend'); @@ -5408,7 +5369,7 @@ Suggestions.prototype.getItemValue = function(item) { module.exports = Suggestions; -},{"./list":32,"fuzzy":31,"xtend":36}],34:[function(require,module,exports){ +},{"./list":31,"fuzzy":30,"xtend":35}],33:[function(require,module,exports){ var each = require('turf-meta').coordEach; /** @@ -5478,7 +5439,7 @@ module.exports = function(layer) { return extent; }; -},{"turf-meta":35}],35:[function(require,module,exports){ +},{"turf-meta":34}],34:[function(require,module,exports){ /** * Lazily iterate over coordinates in any GeoJSON object, similar to * Array.forEach. @@ -5618,7 +5579,7 @@ function propReduce(layer, callback, memo) { } module.exports.propReduce = propReduce; -},{}],36:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ module.exports = extend var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -5639,7 +5600,7 @@ function extend() { return target } -},{}],37:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -5826,6 +5787,7 @@ function setError(error) { } function queryOrigin(query) { + console.log('querying origin'); return { type: types.ORIGIN_QUERY, query: query @@ -6038,7 +6000,7 @@ function eventEmit(type, data) { }; } -},{"../constants/action_types":38,"../utils":45}],38:[function(require,module,exports){ +},{"../constants/action_types":37,"../utils":45}],37:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6061,11 +6023,17 @@ var ROUTE_INDEX = exports.ROUTE_INDEX = 'ROUTE_INDEX'; var SET_OPTIONS = exports.SET_OPTIONS = 'SET_OPTIONS'; var WAYPOINTS = exports.WAYPOINTS = 'WAYPOINTS'; -},{}],39:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ 'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +var _utils = require('../utils'); + +var _utils2 = _interopRequireDefault(_utils); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + var Typeahead = require('suggestions'); var debounce = require('lodash.debounce'); var extend = require('xtend'); @@ -6102,30 +6070,14 @@ function Geocoder(options) { Geocoder.prototype = { options: { - position: 'top-left', placeholder: 'Search', zoom: 16, flyTo: true }, - addTo: function addTo(map) { + onAdd: function onAdd(map) { this._map = map; - var container = this._container = this.onAdd(map); - if (this.options && this.options.position) { - var pos = this.options.position; - var corner = map._controlCorners[pos]; - container.className += ' mapboxgl-ctrl'; - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } - } - - return this; - }, - onAdd: function onAdd(map) { this.request = new XMLHttpRequest(); this.container = this.options.container ? typeof this.options.container === 'string' ? document.getElementById(this.options.container) : this.options.container : map.getContainer(); @@ -6204,6 +6156,8 @@ Geocoder.prototype = { this._loadingEl.classList.add('active'); this.fire('loading'); + console.log('geocoder this', this); + var options = []; if (this.options.proximity) options.push('proximity=' + this.options.proximity.join()); if (this.options.bbox) options.push('bbox=' + this.options.bbox.join()); @@ -6261,7 +6215,7 @@ Geocoder.prototype = { _query: function _query(input) { if (!input) return; if ((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && input.length) { - input = [mapboxgl.util.wrap(input[0], -180, 180), mapboxgl.util.wrap(input[1], -180, 180)].join(); + input = [_utils2.default.wrap(input[0]), _utils2.default.wrap(input[1])].join(); } this._geocode(input, function (results) { @@ -6277,7 +6231,7 @@ Geocoder.prototype = { _setInput: function _setInput(input) { if (!input) return; if ((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && input.length) { - input = [mapboxgl.util.wrap(input[0], -180, 180), mapboxgl.util.wrap(input[1], -180, 180)].join(); + input = [_utils2.default.wrap(input[0]), _utils2.default.wrap(input[1])].join(); } // Set input value to passed value and clear everything else. @@ -6369,7 +6323,7 @@ Geocoder.prototype = { module.exports = Geocoder; -},{"events":2,"lodash.debounce":3,"suggestions":30,"xtend":36}],40:[function(require,module,exports){ +},{"../utils":45,"events":1,"lodash.debounce":2,"suggestions":29,"xtend":35}],39:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6471,10 +6425,13 @@ var Inputs = function () { var _store$getState3 = this.store.getState(), geocoder = _store$getState3.geocoder; + console.log('geocoder from state', geocoder); + this.originInput = new _geocoder2.default(Object.assign({}, { flyTo: false, placeholder: 'Choose a starting place', - container: this.container.querySelector('#mapbox-directions-origin-input') + container: this.container.querySelector('#mapbox-directions-origin-input'), + accessToken: this.accessToken }, geocoder)); this._map.addControl(this.originInput); @@ -6482,7 +6439,8 @@ var Inputs = function () { this.destinationInput = new _geocoder2.default(Object.assign({}, { flyTo: false, placeholder: 'Choose destination', - container: this.container.querySelector('#mapbox-directions-destination-input') + container: this.container.querySelector('#mapbox-directions-destination-input'), + accessToken: this.accessToken }, geocoder)); this._map.addControl(this.destinationInput); @@ -6564,7 +6522,7 @@ var Inputs = function () { exports.default = Inputs; -},{"./geocoder":39,"lodash.isequal":4,"lodash.template":5,"turf-extent":34}],41:[function(require,module,exports){ +},{"./geocoder":38,"lodash.isequal":3,"lodash.template":4,"turf-extent":33}],40:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6689,7 +6647,7 @@ var Instructions = function () { exports.default = Instructions; -},{"../utils":45,"lodash.isequal":4,"lodash.template":5}],42:[function(require,module,exports){ +},{"../utils":45,"lodash.isequal":3,"lodash.template":4}],41:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -6750,6 +6708,7 @@ var Directions = function () { this.actions = (0, _redux.bindActionCreators)(actions, store.dispatch); this.actions.setOptions(options || {}); + this.options = options || {}; this.onDragDown = this._onDragDown.bind(this); this.onDragMove = this._onDragMove.bind(this); @@ -6758,36 +6717,36 @@ var Directions = function () { this.onClick = this._onClick.bind(this); } - _createClass(Directions, [{ - key: 'addTo', - value: function addTo(map) { - this._map = map; - var container = this._container = this.onAdd(map); - if (this.options && this.options.position) { - var pos = this.options.position; - var corner = map._controlCorners[pos]; - container.className += ' mapboxgl-ctrl'; - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } - } + // addTo(map) { + // this._map = map; + // var container = this._container = this.onAdd(map); + // if (this.options && this.options.position) { + // var pos = this.options.position; + // var corner = map._controlCorners[pos]; + // container.className += ' mapboxgl-ctrl'; + // if (pos.indexOf('bottom') !== -1) { + // corner.insertBefore(container, corner.firstChild); + // } else { + // corner.appendChild(container); + // } + // } + + // return this; + // } - return this; - } - }, { + _createClass(Directions, [{ key: 'onAdd', value: function onAdd(map) { var _this = this; this._map = map; + console.log(this._map); var _store$getState = store.getState(), - container = _store$getState.container, controls = _store$getState.controls; - this.container = container ? typeof container === 'string' ? document.getElementById(container) : container : this._map.getContainer(); + var el = document.createElement('div'); + el.className = 'mapboxgl-ctrl-directions mapboxgl-ctrl'; // Add controls to the page var inputEl = document.createElement('div'); @@ -6802,13 +6761,15 @@ var Directions = function () { setRouteIndex: this.actions.setRouteIndex }, this._map); - if (controls.inputs) this.container.appendChild(inputEl); - if (controls.instructions) this.container.appendChild(directionsEl); + if (controls.inputs) el.appendChild(inputEl); + if (controls.instructions) el.appendChild(directionsEl); this.subscribedActions(); if (this._map.loaded()) this.mapState();else this._map.on('load', function () { return _this.mapState(); }); + + return el; } /** @@ -7115,6 +7076,7 @@ var Directions = function () { key: 'setOrigin', value: function setOrigin(query) { if (typeof query === 'string') { + console.log('this is a query'); this.actions.queryOrigin(query); } else { this.actions.setOriginFromCoordinates(query); @@ -7253,7 +7215,7 @@ var Directions = function () { exports.default = Directions; -},{"./actions":37,"./controls/inputs":40,"./controls/instructions":41,"./directions_style":43,"./reducers":44,"./utils":45,"polyline":8,"redux":15,"redux-thunk":9}],43:[function(require,module,exports){ +},{"./actions":36,"./controls/inputs":39,"./controls/instructions":40,"./directions_style":42,"./reducers":44,"./utils":45,"polyline":7,"redux":14,"redux-thunk":8}],42:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -7369,7 +7331,42 @@ var style = [{ exports.default = style; -},{}],44:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ +'use strict'; + +var _directions = require('./directions'); + +var _directions2 = _interopRequireDefault(_directions); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +module.exports = _directions2.default; /** + * A directions component using Mapbox Directions APi + * @class mapboxgl.Directions + * + * @param {Object} options + * @param {Array} [options.styles] Override default layer properties of the [directions source](https://github.com/mapbox/mapbox-gl-directions/blob/master/src/directions_style.js). Documentation for each property are specified in the [Mapbox GL Style Reference](https://www.mapbox.com/mapbox-gl-style-spec/). + * @param {String} [options.accessToken=null] Required unless `mapboxgl.accessToken` is set globally + * @param {Boolean} [options.interactive=true] Enable/Disable mouse or touch interactivity from the plugin + * @param {String} [options.profile="driving"] Routing profile to use. Options: `driving`, `walking`, `cycling` + * @param {String} [options.unit="imperial"] Measurement system to be used in navigation instructions. Options: `imperial`, `metric` + * @param {string|Element} options.container HTML element to initialize the map in (or element id as string). If no container is passed map.getContainer() is used instead. + * @param {Object} [options.geocoder] Pass options available to mapbox-gl-geocoder as [documented here](https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxglgeocoder). + * @param {Object} [options.controls] + * @param {Boolean} [options.controls.inputs=true] Hide or display the inputs control. + * @param {Boolean} [options.controls.instructions=true] Hide or display the instructions control. + * @example + * var directions = new mapboxgl.Directions({ + * container: 'directions', + * unit: 'metric', + * profile: 'walking' + * }); + * + * map.addControl(directions); + * @return {Directions} `this` + */ + +},{"./directions":41}],44:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -7514,7 +7511,7 @@ function data() { exports.default = data; -},{"../constants/action_types.js":38}],45:[function(require,module,exports){ +},{"../constants/action_types.js":37}],45:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -7574,5 +7571,5 @@ var format = { exports.default = { format: format, coordinateMatch: coordinateMatch, createPoint: createPoint, validCoords: validCoords, wrap: wrap }; -},{}]},{},[1])(1) +},{}]},{},[43])(43) }); \ No newline at end of file diff --git a/example/index.js b/example/index.js index b853fec..334d2bd 100644 --- a/example/index.js +++ b/example/index.js @@ -1,6 +1,5 @@ 'use strict'; var mapboxgl = require('mapbox-gl'); -var MapboxGeocoder = require('../src/index'); var insertCss = require('insert-css'); var fs = require('fs'); mapboxgl.accessToken = window.localStorage.getItem('MapboxAccessToken'); @@ -23,7 +22,6 @@ var map = window.map = new mapboxgl.Map({ // ui var button = document.createElement('button'); -button.style = 'z-index:10;'; button.textContent = 'click me'; // directions @@ -31,18 +29,16 @@ var MapboxDirections = require('../src/index'); var directions = new MapboxDirections({ accessToken: window.localStorage.getItem('MapboxAccessToken'), unit: 'metric', - profile: 'cycling', - container: 'directions', - instructions: false + profile: 'cycling' }); window.directions = directions; -map.getContainer().querySelector('.mapboxgl-ctrl-bottom-left').appendChild(button); -map.addControl(directions); +map.getContainer().querySelector('.mapboxgl-ctrl-top-right').appendChild(button); +map.addControl(directions, 'top-left'); map.on('load', () => { button.addEventListener('click', function() { directions.setOrigin([-79.4512, 43.6568]); directions.setDestination('Montreal Quebec'); }); -}); +}); \ No newline at end of file diff --git a/package.json b/package.json index 0e2ff7d..9f0fba8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "mapbox-gl-directions", "version": "2.2.0", "description": "A mapboxgl plugin for the Mapbox Directions API", - "main": "dist/mapbox-gl-directions.js", + "main": "./src/index.js", "browserify": { "transform": [ "babelify", @@ -12,7 +12,7 @@ "scripts": { "prepublish": "npm run build", "start": "NODE_ENV=development budo example/index.js:example/bundle.js --live", - "build": "NODE_ENV=production browserify -s MapboxDirections lib/index.js > dist/mapbox-gl-directions.js", + "build": "NODE_ENV=production browserify -s MapboxDirections src/index.js > dist/mapbox-gl-directions.js", "test": "NODE_ENV=test npm run lint && browserify test/index.js | smokestack -b firefox | tap-status", "docs": "documentation build --format=md > API.md", "lint": "eslint --no-eslintrc -c .eslintrc src" @@ -60,6 +60,7 @@ "lodash.debounce": "^4.0.6", "lodash.isequal": "^4.2.0", "lodash.template": "^4.2.5", + "mapbox-gl-geocoder": "^2.0.0", "polyline": "^0.2.0", "redux": "^3.5.2", "redux-thunk": "^2.1.0", diff --git a/src/controls/geocoder.js b/src/controls/geocoder.js index 9c31031..24aa4c4 100644 --- a/src/controls/geocoder.js +++ b/src/controls/geocoder.js @@ -48,12 +48,6 @@ Geocoder.prototype = { this.request = new XMLHttpRequest(); - this.container = this.options.container ? - typeof this.options.container === 'string' ? - document.getElementById(this.options.container) : - this.options.container : - map.getContainer(); - // Template var el = document.createElement('div'); el.className = 'mapboxgl-ctrl-geocoder'; @@ -112,8 +106,6 @@ Geocoder.prototype = { el.appendChild(input); el.appendChild(actions); - this.container.appendChild(el); - // Override the control being added to control containers if (this.options.container) this.options.position = false; @@ -127,8 +119,6 @@ Geocoder.prototype = { this._loadingEl.classList.add('active'); this.fire('loading'); - console.log('geocoder this', this); - var options = []; if (this.options.proximity) options.push('proximity=' + this.options.proximity.join()); if (this.options.bbox) options.push('bbox=' + this.options.bbox.join()); diff --git a/src/controls/inputs.js b/src/controls/inputs.js index 7a79b51..c7cc44b 100644 --- a/src/controls/inputs.js +++ b/src/controls/inputs.js @@ -65,25 +65,25 @@ export default class Inputs { const { geocoder } = this.store.getState(); - console.log('geocoder from state', geocoder); - this.originInput = new Geocoder(Object.assign({}, { flyTo: false, placeholder: 'Choose a starting place', - container: this.container.querySelector('#mapbox-directions-origin-input'), - accessToken: this.accessToken + accessToken: 'waka' }, geocoder)); - this._map.addControl(this.originInput); + var originEl = this.originInput.onAdd(); + var originContainerEl = this.container.querySelector('#mapbox-directions-origin-input'); + originContainerEl.appendChild(originEl); this.destinationInput = new Geocoder(Object.assign({}, { flyTo: false, placeholder: 'Choose destination', - container: this.container.querySelector('#mapbox-directions-destination-input'), - accessToken: this.accessToken + accessToken: 'waka' }, geocoder)); - this._map.addControl(this.destinationInput); + var destinationEl = this.destinationInput.onAdd(); + this.container.querySelector('#mapbox-directions-destination-input').appendChild(destinationEl); + this.originInput.on('result', (e) => { const coords = e.result.center; diff --git a/src/directions.js b/src/directions.js index 9c2f75d..0e34586 100644 --- a/src/directions.js +++ b/src/directions.js @@ -29,26 +29,8 @@ export default class Directions { this.onClick = this._onClick.bind(this); } - // addTo(map) { - // this._map = map; - // var container = this._container = this.onAdd(map); - // if (this.options && this.options.position) { - // var pos = this.options.position; - // var corner = map._controlCorners[pos]; - // container.className += ' mapboxgl-ctrl'; - // if (pos.indexOf('bottom') !== -1) { - // corner.insertBefore(container, corner.firstChild); - // } else { - // corner.appendChild(container); - // } - // } - - // return this; - // } - onAdd(map) { this._map = map; - console.log(this._map); const { controls } = store.getState(); @@ -69,7 +51,7 @@ export default class Directions { }, this._map); if (controls.inputs) el.appendChild(inputEl); - if (controls.instructions) el.appendChild(directionsEl); + el.appendChild(directionsEl); this.subscribedActions(); if (this._map.loaded()) this.mapState() @@ -358,7 +340,6 @@ export default class Directions { */ setOrigin(query) { if (typeof query === 'string') { - console.log('this is a query'); this.actions.queryOrigin(query); } else { this.actions.setOriginFromCoordinates(query); diff --git a/src/index.js b/src/index.js index 39b89e3..14f3cd2 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,6 @@ * @param {Boolean} [options.interactive=true] Enable/Disable mouse or touch interactivity from the plugin * @param {String} [options.profile="driving"] Routing profile to use. Options: `driving`, `walking`, `cycling` * @param {String} [options.unit="imperial"] Measurement system to be used in navigation instructions. Options: `imperial`, `metric` - * @param {string|Element} options.container HTML element to initialize the map in (or element id as string). If no container is passed map.getContainer() is used instead. * @param {Object} [options.geocoder] Pass options available to mapbox-gl-geocoder as [documented here](https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxglgeocoder). * @param {Object} [options.controls] * @param {Boolean} [options.controls.inputs=true] Hide or display the inputs control. diff --git a/dist/mapbox-gl-directions.css b/src/mapbox-gl-directions.css similarity index 98% rename from dist/mapbox-gl-directions.css rename to src/mapbox-gl-directions.css index 33262e3..8c7e212 100644 --- a/dist/mapbox-gl-directions.css +++ b/src/mapbox-gl-directions.css @@ -160,14 +160,14 @@ /* Layout containers */ .directions-control { - position:absolute; width:33.3333%; max-width:300px; - min-width:200px; + min-width:250px; z-index:1; } .directions-control.directions-control-directions { background:rgba(0,0,0,0.75); + margin: 7px 0 0; color:#fff; top:0; right:0; @@ -211,7 +211,7 @@ z-index:10; background:white; left:50px; - top:30px; + top:40px; cursor:pointer; } @@ -295,7 +295,7 @@ /* Route Summary */ .mapbox-directions-route-summary { - position:fixed; + position: relative; z-index:1; width:100%; min-height:50px; @@ -306,7 +306,6 @@ line-height:28px; } .mapbox-directions-route-summary + .mapbox-directions-instructions { - padding-top:50px; } .mapbox-directions-route-summary h1 { font-weight:500; @@ -321,11 +320,11 @@ } /* Alt route selection */ - .mapbox-directions-multiple { - min-height:75px; + .mapbox-directions-instructions { + overflow: scroll; } - .mapbox-directions-multiple + .mapbox-directions-instructions { - padding-top:75px; + .mapbox-directions-instructions-wrapper { + max-height: 500px; } .mapbox-directions-routes { margin:0 0 10px; @@ -431,7 +430,7 @@ .mapbox-directions-routes { float:right; margin-right:10px; } .directions-control.directions-control-directions { top:auto; max-height:40%; } .mapbox-directions-multiple { min-height:50px; } -.mapbox-directions-multiple + .mapbox-directions-instructions { padding-top:50px; } + } @-webkit-keyframes rotate { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } diff --git a/src/templates/instructions.html b/src/templates/instructions.html index 2daeada..1ac7bc7 100644 --- a/src/templates/instructions.html +++ b/src/templates/instructions.html @@ -13,29 +13,31 @@

<%- duration %>

-
    - <% steps.forEach(function(step) { %> - <% - var distance = step.distance ? format(step.distance) : false; - var icon = step.maneuver.type.replace(/\s+/g, '-').toLowerCase(); - var lng = step.maneuver.location.coordinates[0]; - var lat = step.maneuver.location.coordinates[1]; - %> -
  1. - -
    - <%= step.maneuver.instruction %> -
    - <% if (step.distance) { %> -
    - <%= distance %> +
    +
      + <% steps.forEach(function(step) { %> + <% + var distance = step.distance ? format(step.distance) : false; + var icon = step.maneuver.type.replace(/\s+/g, '-').toLowerCase(); + var lng = step.maneuver.location.coordinates[0]; + var lat = step.maneuver.location.coordinates[1]; + %> +
    1. + +
      + <%= step.maneuver.instruction %>
      - <% } %> -
    2. - <% }); %> -
    + <% if (step.distance) { %> +
    + <%= distance %> +
    + <% } %> +
  2. + <% }); %> +
+
diff --git a/test/test.directions.js b/test/test.directions.js index 8dc8a15..d5f2c12 100644 --- a/test/test.directions.js +++ b/test/test.directions.js @@ -10,6 +10,8 @@ test('directions', (tt) => { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); directions = new mapboxgl.Directions(opts); + var MapboxDirections = require('..'); + var directions = new MapboxDirections(opts); map.addControl(directions); } diff --git a/test/test.inputs.js b/test/test.inputs.js index 154d852..81eaad5 100644 --- a/test/test.inputs.js +++ b/test/test.inputs.js @@ -15,7 +15,8 @@ test('Directions#inputControl', tt => { function setup(opts) { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); - directions = new mapboxgl.Directions(opts); + var MapboxDirections = require('..'); + var directions = new MapboxDirections(opts); map.addControl(directions); } diff --git a/test/test.instructions.js b/test/test.instructions.js index 90413aa..213dd3f 100644 --- a/test/test.instructions.js +++ b/test/test.instructions.js @@ -9,7 +9,8 @@ test('Directions#instructionControl', tt => { function setup(opts) { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); - directions = new mapboxgl.Directions(opts); + var MapboxDirections = require('..'); + var directions = new MapboxDirections(opts); map.addControl(directions); } diff --git a/test/test.options.js b/test/test.options.js index d34194e..bc0ed9f 100644 --- a/test/test.options.js +++ b/test/test.options.js @@ -9,7 +9,8 @@ test('Directions#option', tt => { function setup(opts) { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); - directions = new mapboxgl.Directions(opts); + var MapboxDirections = require('..'); + var directions = new MapboxDirections(opts); map.addControl(directions); } From aa9e3e7b2db3a744e8e855ca1df219710625d1b1 Mon Sep 17 00:00:00 2001 From: mapsam Date: Fri, 18 Nov 2016 09:14:50 -0800 Subject: [PATCH 04/17] no more require, get tests running --- example/index.js | 2 +- package.json | 2 +- src/controls/geocoder.js | 9 ++++----- src/controls/inputs.js | 4 ++-- test/test.directions.js | 5 ++--- test/test.inputs.js | 2 +- test/test.instructions.js | 2 +- test/test.options.js | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/example/index.js b/example/index.js index 334d2bd..50730aa 100644 --- a/example/index.js +++ b/example/index.js @@ -7,7 +7,7 @@ mapboxgl.accessToken = window.localStorage.getItem('MapboxAccessToken'); // var directionsDiv = document.body.appendChild(document.createElement('div')); // directionsDiv.id = 'directions'; -insertCss(fs.readFileSync('./dist/mapbox-gl-directions.css', 'utf8')); +insertCss(fs.readFileSync('./src/mapbox-gl-directions.css', 'utf8')); insertCss(fs.readFileSync('./node_modules/mapbox-gl/dist/mapbox-gl.css', 'utf8')); var mapDiv = document.body.appendChild(document.createElement('div')); mapDiv.style = 'position:absolute;top:0;right:0;left:0;bottom:0;'; diff --git a/package.json b/package.json index 9f0fba8..edc54cd 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "prepublish": "npm run build", "start": "NODE_ENV=development budo example/index.js:example/bundle.js --live", - "build": "NODE_ENV=production browserify -s MapboxDirections src/index.js > dist/mapbox-gl-directions.js", + "build": "NODE_ENV=production mkdir -p dist && browserify -s MapboxDirections src/index.js > dist/mapbox-gl-directions.js", "test": "NODE_ENV=test npm run lint && browserify test/index.js | smokestack -b firefox | tap-status", "docs": "documentation build --format=md > API.md", "lint": "eslint --no-eslintrc -c .eslintrc src" diff --git a/src/controls/geocoder.js b/src/controls/geocoder.js index 24aa4c4..a292b6d 100644 --- a/src/controls/geocoder.js +++ b/src/controls/geocoder.js @@ -1,10 +1,9 @@ 'use strict'; -var Typeahead = require('suggestions'); -var debounce = require('lodash.debounce'); -var extend = require('xtend'); -var EventEmitter = require('events').EventEmitter; - +import Typeahead from 'suggestions'; +import debounce from 'lodash.debounce'; +import extend from 'xtend'; +import { EventEmitter } from 'events'; import utils from '../utils' // Mapbox Geocoder version diff --git a/src/controls/inputs.js b/src/controls/inputs.js index c7cc44b..6fe3ed0 100644 --- a/src/controls/inputs.js +++ b/src/controls/inputs.js @@ -68,7 +68,7 @@ export default class Inputs { this.originInput = new Geocoder(Object.assign({}, { flyTo: false, placeholder: 'Choose a starting place', - accessToken: 'waka' + accessToken: 'pk.eyJ1IjoibWFwc2FtIiwiYSI6ImNpaWR1MXlxcDAxMTJ1M2tzYWUyeTdpY24ifQ.QG1jCTgj-WYwJa2y1W0wMw' }, geocoder)); var originEl = this.originInput.onAdd(); @@ -78,7 +78,7 @@ export default class Inputs { this.destinationInput = new Geocoder(Object.assign({}, { flyTo: false, placeholder: 'Choose destination', - accessToken: 'waka' + accessToken: 'pk.eyJ1IjoibWFwc2FtIiwiYSI6ImNpaWR1MXlxcDAxMTJ1M2tzYWUyeTdpY24ifQ.QG1jCTgj-WYwJa2y1W0wMw' }, geocoder)); var destinationEl = this.destinationInput.onAdd(); diff --git a/test/test.directions.js b/test/test.directions.js index d5f2c12..cf99f7e 100644 --- a/test/test.directions.js +++ b/test/test.directions.js @@ -9,9 +9,8 @@ test('directions', (tt) => { function setup(opts) { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); - directions = new mapboxgl.Directions(opts); - var MapboxDirections = require('..'); - var directions = new MapboxDirections(opts); + const MapboxDirections = require('..'); + directions = new MapboxDirections(opts); map.addControl(directions); } diff --git a/test/test.inputs.js b/test/test.inputs.js index 81eaad5..ff6dde7 100644 --- a/test/test.inputs.js +++ b/test/test.inputs.js @@ -16,7 +16,7 @@ test('Directions#inputControl', tt => { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); var MapboxDirections = require('..'); - var directions = new MapboxDirections(opts); + directions = new MapboxDirections(opts); map.addControl(directions); } diff --git a/test/test.instructions.js b/test/test.instructions.js index 213dd3f..f230416 100644 --- a/test/test.instructions.js +++ b/test/test.instructions.js @@ -10,7 +10,7 @@ test('Directions#instructionControl', tt => { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); var MapboxDirections = require('..'); - var directions = new MapboxDirections(opts); + directions = new MapboxDirections(opts); map.addControl(directions); } diff --git a/test/test.options.js b/test/test.options.js index bc0ed9f..3c5c9c1 100644 --- a/test/test.options.js +++ b/test/test.options.js @@ -10,7 +10,7 @@ test('Directions#option', tt => { container = document.createElement('div'); map = new mapboxgl.Map({ container: container }); var MapboxDirections = require('..'); - var directions = new MapboxDirections(opts); + directions = new MapboxDirections(opts); map.addControl(directions); } From fc59fc7ceb6901901461160aee11f00d87a1cc8e Mon Sep 17 00:00:00 2001 From: mapsam Date: Fri, 18 Nov 2016 09:16:17 -0800 Subject: [PATCH 05/17] remove dist --- dist/mapbox-gl-directions.js | 7575 ---------------------- {dist => src}/icons/arrive.svg | 0 {dist => src}/icons/bear-left.svg | 0 {dist => src}/icons/bear-right.svg | 0 {dist => src}/icons/continue.svg | 0 {dist => src}/icons/depart.svg | 0 {dist => src}/icons/enter-roundabout.svg | 0 {dist => src}/icons/error.svg | 0 {dist => src}/icons/reverse.svg | 0 {dist => src}/icons/sharp-left.svg | 0 {dist => src}/icons/sharp-right.svg | 0 {dist => src}/icons/turn-left.svg | 0 {dist => src}/icons/turn-right.svg | 0 {dist => src}/icons/u-turn.svg | 0 {dist => src}/icons/waypoint.svg | 0 15 files changed, 7575 deletions(-) delete mode 100644 dist/mapbox-gl-directions.js rename {dist => src}/icons/arrive.svg (100%) rename {dist => src}/icons/bear-left.svg (100%) rename {dist => src}/icons/bear-right.svg (100%) rename {dist => src}/icons/continue.svg (100%) rename {dist => src}/icons/depart.svg (100%) rename {dist => src}/icons/enter-roundabout.svg (100%) rename {dist => src}/icons/error.svg (100%) rename {dist => src}/icons/reverse.svg (100%) rename {dist => src}/icons/sharp-left.svg (100%) rename {dist => src}/icons/sharp-right.svg (100%) rename {dist => src}/icons/turn-left.svg (100%) rename {dist => src}/icons/turn-right.svg (100%) rename {dist => src}/icons/u-turn.svg (100%) rename {dist => src}/icons/waypoint.svg (100%) diff --git a/dist/mapbox-gl-directions.js b/dist/mapbox-gl-directions.js deleted file mode 100644 index 22c8611..0000000 --- a/dist/mapbox-gl-directions.js +++ /dev/null @@ -1,7575 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MapboxDirections = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - -},{}],2:[function(require,module,exports){ -(function (global){ -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** Used as references for various `Number` constants. */ -var NAN = 0 / 0; - -/** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; - -/** Used to match leading and trailing whitespace. */ -var reTrim = /^\s+|\s+$/g; - -/** Used to detect bad signed hexadecimal string values. */ -var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - -/** Used to detect binary string values. */ -var reIsBinary = /^0b[01]+$/i; - -/** Used to detect octal string values. */ -var reIsOctal = /^0o[0-7]+$/i; - -/** Built-in method references without a dependency on `root`. */ -var freeParseInt = parseInt; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max, - nativeMin = Math.min; - -/** - * Gets the timestamp of the number of milliseconds that have elapsed since - * the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Date - * @returns {number} Returns the timestamp. - * @example - * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => Logs the number of milliseconds it took for the deferred invocation. - */ -var now = function() { - return root.Date.now(); -}; - -/** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide `options` to indicate whether `func` should be invoked on the - * leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent - * calls to the debounced function return the result of the last `func` - * invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the debounced function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.debounce` and `_.throttle`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=false] - * Specify invoking on the leading edge of the timeout. - * @param {number} [options.maxWait] - * The maximum time `func` is allowed to be delayed before it's invoked. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // Avoid costly calculations while the window size is in flux. - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); - * - * // Invoke `sendMail` when clicked, debouncing subsequent calls. - * jQuery(element).on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); - * - * // Ensure `batchLog` is invoked once after 1 second of debounced calls. - * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); - * var source = new EventSource('/stream'); - * jQuery(source).on('message', debounced); - * - * // Cancel the trailing debounced invocation. - * jQuery(window).on('popstate', debounced.cancel); - */ -function debounce(func, wait, options) { - var lastArgs, - lastThis, - maxWait, - result, - timerId, - lastCallTime, - lastInvokeTime = 0, - leading = false, - maxing = false, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = toNumber(wait) || 0; - if (isObject(options)) { - leading = !!options.leading; - maxing = 'maxWait' in options; - maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - - function invokeFunc(time) { - var args = lastArgs, - thisArg = lastThis; - - lastArgs = lastThis = undefined; - lastInvokeTime = time; - result = func.apply(thisArg, args); - return result; - } - - function leadingEdge(time) { - // Reset any `maxWait` timer. - lastInvokeTime = time; - // Start the timer for the trailing edge. - timerId = setTimeout(timerExpired, wait); - // Invoke the leading edge. - return leading ? invokeFunc(time) : result; - } - - function remainingWait(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; - - return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; - } - - function shouldInvoke(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime; - - // Either this is the first call, activity has stopped and we're at the - // trailing edge, the system time has gone backwards and we're treating - // it as the trailing edge, or we've hit the `maxWait` limit. - return (lastCallTime === undefined || (timeSinceLastCall >= wait) || - (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); - } - - function timerExpired() { - var time = now(); - if (shouldInvoke(time)) { - return trailingEdge(time); - } - // Restart the timer. - timerId = setTimeout(timerExpired, remainingWait(time)); - } - - function trailingEdge(time) { - timerId = undefined; - - // Only invoke if we have `lastArgs` which means `func` has been - // debounced at least once. - if (trailing && lastArgs) { - return invokeFunc(time); - } - lastArgs = lastThis = undefined; - return result; - } - - function cancel() { - if (timerId !== undefined) { - clearTimeout(timerId); - } - lastInvokeTime = 0; - lastArgs = lastCallTime = lastThis = timerId = undefined; - } - - function flush() { - return timerId === undefined ? result : trailingEdge(now()); - } - - function debounced() { - var time = now(), - isInvoking = shouldInvoke(time); - - lastArgs = arguments; - lastThis = this; - lastCallTime = time; - - if (isInvoking) { - if (timerId === undefined) { - return leadingEdge(lastCallTime); - } - if (maxing) { - // Handle invocations in a tight loop. - timerId = setTimeout(timerExpired, wait); - return invokeFunc(lastCallTime); - } - } - if (timerId === undefined) { - timerId = setTimeout(timerExpired, wait); - } - return result; - } - debounced.cancel = cancel; - debounced.flush = flush; - return debounced; -} - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); -} - -/** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3.2); - * // => 3.2 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity - * - * _.toNumber('3.2'); - * // => 3.2 - */ -function toNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == 'function' ? value.valueOf() : value; - value = isObject(other) ? (other + '') : other; - } - if (typeof value != 'string') { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ''); - var isBinary = reIsBinary.test(value); - return (isBinary || reIsOctal.test(value)) - ? freeParseInt(value.slice(2), isBinary ? 2 : 8) - : (reIsBadHex.test(value) ? NAN : +value); -} - -module.exports = debounce; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],3:[function(require,module,exports){ -(function (global){ -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used to compose bitmasks for comparison styles. */ -var UNORDERED_COMPARE_FLAG = 1, - PARTIAL_COMPARE_FLAG = 2; - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = -typedArrayTags[errorTag] = typedArrayTags[funcTag] = -typedArrayTags[mapTag] = typedArrayTags[numberTag] = -typedArrayTags[objectTag] = typedArrayTags[regexpTag] = -typedArrayTags[setTag] = typedArrayTags[stringTag] = -typedArrayTags[weakMapTag] = false; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Detect free variable `process` from Node.js. */ -var freeProcess = moduleExports && freeGlobal.process; - -/** Used to access faster Node.js helpers. */ -var nodeUtil = (function() { - try { - return freeProcess && freeProcess.binding('util'); - } catch (e) {} -}()); - -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - -/** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ -function arraySome(array, predicate) { - var index = -1, - length = array ? array.length : 0; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; -} - -/** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; -} - -/** - * The base implementation of `_.unary` without support for storing metadata. - * - * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - */ -function baseUnary(func) { - return function(value) { - return func(value); - }; -} - -/** - * Gets the value at `key` of `object`. - * - * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ -function getValue(object, key) { - return object == null ? undefined : object[key]; -} - -/** - * Checks if `value` is a host object in IE < 9. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. - */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} - } - return result; -} - -/** - * Converts `map` to its key-value pairs. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. - */ -function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; -} - -/** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; -} - -/** - * Converts `set` to an array of its values. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. - */ -function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; - }); - return result; -} - -/** Used for built-in method references. */ -var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype; - -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; - -/** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** Built-in value references. */ -var Symbol = root.Symbol, - Uint8Array = root.Uint8Array, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - splice = arrayProto.splice; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object); - -/* Built-in method references that are verified to be native. */ -var DataView = getNative(root, 'DataView'), - Map = getNative(root, 'Map'), - Promise = getNative(root, 'Promise'), - Set = getNative(root, 'Set'), - WeakMap = getNative(root, 'WeakMap'), - nativeCreate = getNative(Object, 'create'); - -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; - -/** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Hash(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the hash. - * - * @private - * @name clear - * @memberOf Hash - */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; -} - -/** - * Removes `key` and its value from the hash. - * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(key) { - return this.has(key) && delete this.__data__[key]; -} - -/** - * Gets the hash value for `key`. - * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; -} - -/** - * Checks if a hash value for `key` exists. - * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); -} - -/** - * Sets the hash `key` to `value`. - * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ -function hashSet(key, value) { - var data = this.__data__; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; - return this; -} - -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; - -/** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function ListCache(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the list cache. - * - * @private - * @name clear - * @memberOf ListCache - */ -function listCacheClear() { - this.__data__ = []; -} - -/** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - return true; -} - -/** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - return index < 0 ? undefined : data[index][1]; -} - -/** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; -} - -/** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; -} - -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; - -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function MapCache(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapCacheClear() { - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; -} - -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapCacheDelete(key) { - return getMapData(this, key)['delete'](key); -} - -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); -} - -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); -} - -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapCacheSet(key, value) { - getMapData(this, key).set(key, value); - return this; -} - -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - -/** - * - * Creates an array cache object to store unique values. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ -function SetCache(values) { - var index = -1, - length = values ? values.length : 0; - - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); - } -} - -/** - * Adds `value` to the array cache. - * - * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. - */ -function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; -} - -/** - * Checks if `value` is in the array cache. - * - * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. - */ -function setCacheHas(value) { - return this.__data__.has(value); -} - -// Add methods to `SetCache`. -SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; -SetCache.prototype.has = setCacheHas; - -/** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Stack(entries) { - this.__data__ = new ListCache(entries); -} - -/** - * Removes all key-value entries from the stack. - * - * @private - * @name clear - * @memberOf Stack - */ -function stackClear() { - this.__data__ = new ListCache; -} - -/** - * Removes `key` and its value from the stack. - * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function stackDelete(key) { - return this.__data__['delete'](key); -} - -/** - * Gets the stack value for `key`. - * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function stackGet(key) { - return this.__data__.get(key); -} - -/** - * Checks if a stack value for `key` exists. - * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function stackHas(key) { - return this.__data__.has(key); -} - -/** - * Sets the stack `key` to `value`. - * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. - */ -function stackSet(key, value) { - var cache = this.__data__; - if (cache instanceof ListCache) { - var pairs = cache.__data__; - if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { - pairs.push([key, value]); - return this; - } - cache = this.__data__ = new MapCache(pairs); - } - cache.set(key, value); - return this; -} - -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; - -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -function arrayLikeKeys(value, inherited) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - // Safari 9 makes `arguments.length` enumerable in strict mode. - var result = (isArray(value) || isArguments(value)) - ? baseTimes(value.length, String) - : []; - - var length = result.length, - skipIndexes = !!length; - - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && (key == 'length' || isIndex(key, length)))) { - result.push(key); - } - } - return result; -} - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -/** - * The base implementation of `getTag`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - return objectToString.call(value); -} - -/** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @param {boolean} [bitmask] The bitmask of comparison flags. - * The bitmask may be composed of the following flags: - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, customizer, bitmask, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack); -} - -/** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparisons. - * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; - - if (!objIsArr) { - objTag = getTag(object); - objTag = objTag == argsTag ? objectTag : objTag; - } - if (!othIsArr) { - othTag = getTag(other); - othTag = othTag == argsTag ? objectTag : othTag; - } - var objIsObj = objTag == objectTag && !isHostObject(object), - othIsObj = othTag == objectTag && !isHostObject(other), - isSameTag = objTag == othTag; - - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) - : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); - } - if (!(bitmask & PARTIAL_COMPARE_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; - - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, equalFunc, customizer, bitmask, stack); -} - -/** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ -function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); -} - -/** - * The base implementation of `_.isTypedArray` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - */ -function baseIsTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; -} - -/** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; -} - -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { - var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, - result = true, - seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined; - - stack.set(array, other); - stack.set(other, array); - - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!seen.has(othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { - return seen.add(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, customizer, bitmask, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; -} - -/** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; - - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - - case errorTag: - return object.name == other.name && object.message == other.message; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); - - case mapTag: - var convert = mapToArray; - - case setTag: - var isPartial = bitmask & PARTIAL_COMPARE_FLAG; - convert || (convert = setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= UNORDERED_COMPARE_FLAG; - - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); - stack['delete'](object); - return result; - - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; -} - -/** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { - var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - objProps = keys(object), - objLength = objProps.length, - othProps = keys(other), - othLength = othProps.length; - - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); - - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } - } - stack['delete'](object); - stack['delete'](other); - return result; -} - -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; -} - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; -} - -/** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -var getTag = baseGetTag; - -// Fallback for data views, maps, sets, and weak maps in IE 11, -// for data views in Edge < 14, and promises in Node.js. -if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = objectToString.call(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : undefined; - - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; -} - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); -} - -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); -} - -/** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ -function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); -} - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to process. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} - } - return ''; -} - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} - -/** - * Performs a deep comparison between two values to determine if they are - * equivalent. - * - * **Note:** This method supports comparing arrays, array buffers, booleans, - * date objects, error objects, maps, numbers, `Object` objects, regexes, - * sets, strings, symbols, and typed arrays. `Object` objects are compared - * by their own, not inherited, enumerable properties. Functions and DOM - * nodes are **not** supported. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.isEqual(object, other); - * // => true - * - * object === other; - * // => false - */ -function isEqual(value, other) { - return baseIsEqual(value, other); -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8-9 which returns 'object' for typed array and other constructors. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); -} - -module.exports = isEqual; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],4:[function(require,module,exports){ -(function (global){ -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -var reInterpolate = require('lodash._reinterpolate'), - templateSettings = require('lodash.templatesettings'); - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0, - MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - symbolTag = '[object Symbol]'; - -/** Used to match empty string literals in compiled template source. */ -var reEmptyStringLeading = /\b__p \+= '';/g, - reEmptyStringMiddle = /\b(__p \+=) '' \+/g, - reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - -/** - * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). - */ -var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** Used to ensure capturing order of template delimiters. */ -var reNoMatch = /($^)/; - -/** Used to match unescaped characters in compiled string literals. */ -var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - -/** Used to escape characters for inclusion in compiled string literals. */ -var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\u2028': 'u2028', - '\u2029': 'u2029' -}; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ -function apply(func, thisArg, args) { - switch (args.length) { - case 0: return func.call(thisArg); - case 1: return func.call(thisArg, args[0]); - case 2: return func.call(thisArg, args[0], args[1]); - case 3: return func.call(thisArg, args[0], args[1], args[2]); - } - return func.apply(thisArg, args); -} - -/** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function arrayMap(array, iteratee) { - var index = -1, - length = array ? array.length : 0, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} - -/** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; -} - -/** - * The base implementation of `_.values` and `_.valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. - */ -function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); -} - -/** - * Used by `_.template` to escape characters for inclusion in compiled string literals. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ -function escapeStringChar(chr) { - return '\\' + stringEscapes[chr]; -} - -/** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; -} - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Built-in value references. */ -var Symbol = root.Symbol, - propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object), - nativeMax = Math.max; - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; - -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -function arrayLikeKeys(value, inherited) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - // Safari 9 makes `arguments.length` enumerable in strict mode. - var result = (isArray(value) || isArguments(value)) - ? baseTimes(value.length, String) - : []; - - var length = result.length, - skipIndexes = !!length; - - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && (key == 'length' || isIndex(key, length)))) { - result.push(key); - } - } - return result; -} - -/** - * Used by `_.defaults` to customize its `_.assignIn` use. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to assign. - * @param {Object} object The parent object of `objValue`. - * @returns {*} Returns the value to assign. - */ -function assignInDefaults(objValue, srcValue, key, object) { - if (objValue === undefined || - (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { - return srcValue; - } - return objValue; -} - -/** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { - object[key] = value; - } -} - -/** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; -} - -/** - * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeysIn(object) { - if (!isObject(object)) { - return nativeKeysIn(object); - } - var isProto = isPrototype(object), - result = []; - - for (var key in object) { - if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; -} - -/** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - */ -function baseRest(func, start) { - start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); - - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = array; - return apply(func, this, otherArgs); - }; -} - -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ -function copyObject(source, props, object, customizer) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - - var newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; - - assignValue(object, key, newValue === undefined ? source[key] : newValue); - } - return object; -} - -/** - * Creates a function like `_.assign`. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ -function createAssigner(assigner) { - return baseRest(function(object, sources) { - var index = -1, - length = sources.length, - customizer = length > 1 ? sources[length - 1] : undefined, - guard = length > 2 ? sources[2] : undefined; - - customizer = (assigner.length > 3 && typeof customizer == 'function') - ? (length--, customizer) - : undefined; - - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }); -} - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); -} - -/** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ -function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object) - ) { - return eq(object[index], value); - } - return false; -} - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - -/** - * This function is like - * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * except that it includes inherited enumerable properties. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function nativeKeysIn(object) { - var result = []; - if (object != null) { - for (var key in Object(object)) { - result.push(key); - } - } - return result; -} - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} - -/** - * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, - * `SyntaxError`, `TypeError`, or `URIError` object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. - * @example - * - * _.isError(new Error); - * // => true - * - * _.isError(Error); - * // => false - */ -function isError(value) { - if (!isObjectLike(value)) { - return false; - } - return (objectToString.call(value) == errorTag) || - (typeof value.message == 'string' && typeof value.name == 'string'); -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8-9 which returns 'object' for typed array and other constructors. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); -} - -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString(value) { - return value == null ? '' : baseToString(value); -} - -/** - * This method is like `_.assignIn` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extendWith - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignInWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ -var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { - copyObject(source, keysIn(source), object, customizer); -}); - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); -} - -/** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ -function keysIn(object) { - return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); -} - -/** - * Creates a compiled template function that can interpolate data properties - * in "interpolate" delimiters, HTML-escape interpolated data properties in - * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data - * properties may be accessed as free variables in the template. If a setting - * object is given, it takes precedence over `_.templateSettings` values. - * - * **Note:** In the development build `_.template` utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for easier debugging. - * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). - * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category String - * @param {string} [string=''] The template string. - * @param {Object} [options={}] The options object. - * @param {RegExp} [options.escape=_.templateSettings.escape] - * The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] - * The "evaluate" delimiter. - * @param {Object} [options.imports=_.templateSettings.imports] - * An object to import into the template as free variables. - * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] - * The "interpolate" delimiter. - * @param {string} [options.sourceURL='templateSources[n]'] - * The sourceURL of the compiled template. - * @param {string} [options.variable='obj'] - * The data object variable name. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the compiled template function. - * @example - * - * // Use the "interpolate" delimiter to create a compiled template. - * var compiled = _.template('hello <%= user %>!'); - * compiled({ 'user': 'fred' }); - * // => 'hello fred!' - * - * // Use the HTML "escape" delimiter to escape data property values. - * var compiled = _.template('<%- value %>'); - * compiled({ 'value': '