UNPKG

fluxcapacitor

Version:

A bunch of tools to implement apps the Flux way

1,471 lines (1,275 loc) 2.79 MB
(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<r.length;o++)s(r[o]);return s})({"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/actions/TodoActions.js":[function(require,module,exports){ var FluxCapacitor = require('fluxcapacitor'); module.exports = FluxCapacitor.createActions([ 'destroyCompleted', 'destroy', 'toggleCompleteAll', 'toggleComplete', 'updateText', 'create' ]); },{"fluxcapacitor":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/fluxcapacitor/src/fluxcapacitor.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/app.js":[function(require,module,exports){ /** * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ var React = require('react'); var TodoApp = require('./components/TodoApp.react'); React.render( React.createElement(TodoApp, null), document.getElementById('todoapp') ); },{"./components/TodoApp.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoApp.react.js","react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/Footer.react.js":[function(require,module,exports){ /** * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ var React = require('react'); var ReactPropTypes = React.PropTypes; var TodoActions = require('../actions/TodoActions'); var Footer = React.createClass({displayName: "Footer", propTypes: { allTodos: ReactPropTypes.object.isRequired }, /** * @return {object} */ render: function() { var allTodos = this.props.allTodos; var total = Object.keys(allTodos).length; if (total === 0) { return null; } var completed = 0; for (var key in allTodos) { if (allTodos[key].complete) { completed++; } } var itemsLeft = total - completed; var itemsLeftPhrase = itemsLeft === 1 ? ' item ' : ' items '; itemsLeftPhrase += 'left'; // Undefined and thus not rendered if no completed items are left. var clearCompletedButton; if (completed) { clearCompletedButton = React.createElement("button", { id: "clear-completed", onClick: this._onClearCompletedClick}, "Clear completed (", completed, ")" ); } return ( React.createElement("footer", {id: "footer"}, React.createElement("span", {id: "todo-count"}, React.createElement("strong", null, itemsLeft ), itemsLeftPhrase ), clearCompletedButton ) ); }, /** * Event handler to delete all completed TODOs */ _onClearCompletedClick: function() { TodoActions.destroyCompleted(); } }); module.exports = Footer; },{"../actions/TodoActions":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/actions/TodoActions.js","react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/Header.react.js":[function(require,module,exports){ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ var React = require('react'); var TodoActions = require('../actions/TodoActions'); var TodoTextInput = require('./TodoTextInput.react'); var Header = React.createClass({displayName: "Header", /** * @return {object} */ render: function() { return ( React.createElement("header", {id: "header"}, React.createElement("h1", null, "todos"), React.createElement(TodoTextInput, { id: "new-todo", placeholder: "What needs to be done?", onSave: this._onSave} ) ) ); }, /** * Event handler called within TodoTextInput. * Defining this here allows TodoTextInput to be used in multiple places * in different ways. * @param {string} text */ _onSave: function(text) { if (text.trim()){ TodoActions.create({ text: text }); } } }); module.exports = Header; },{"../actions/TodoActions":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/actions/TodoActions.js","./TodoTextInput.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoTextInput.react.js","react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/MainSection.react.js":[function(require,module,exports){ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ var React = require('react'); var ReactPropTypes = React.PropTypes; var TodoActions = require('../actions/TodoActions'); var TodoItem = require('./TodoItem.react'); var MainSection = React.createClass({displayName: "MainSection", propTypes: { allTodos: ReactPropTypes.object.isRequired, areAllComplete: ReactPropTypes.bool.isRequired }, /** * @return {object} */ render: function() { // This section should be hidden by default // and shown when there are todos. if (Object.keys(this.props.allTodos).length < 1) { return null; } var allTodos = this.props.allTodos; var todos = []; for (var key in allTodos) { todos.push(React.createElement(TodoItem, {key: key, todo: allTodos[key]})); } return ( React.createElement("section", {id: "main"}, React.createElement("input", { id: "toggle-all", type: "checkbox", onChange: this._onToggleCompleteAll, checked: this.props.areAllComplete ? 'checked' : ''} ), React.createElement("label", {htmlFor: "toggle-all"}, "Mark all as complete"), React.createElement("ul", {id: "todo-list"}, todos) ) ); }, /** * Event handler to mark all TODOs as complete */ _onToggleCompleteAll: function() { TodoActions.toggleCompleteAll(); } }); module.exports = MainSection; },{"../actions/TodoActions":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/actions/TodoActions.js","./TodoItem.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoItem.react.js","react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoApp.react.js":[function(require,module,exports){ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ /** * This component operates as a "Controller-View". It listens for changes in * the TodoStore and passes the new data to its children. */ var Footer = require('./Footer.react'); var Header = require('./Header.react'); var MainSection = require('./MainSection.react'); var React = require('react'); var TodoStore = require('../stores/TodoStore'); /** * Retrieve the current TODO data from the TodoStore */ function getTodoState() { return { allTodos: TodoStore.getAll(), areAllComplete: TodoStore.areAllComplete() }; } var TodoApp = React.createClass({displayName: "TodoApp", getInitialState: function() { return getTodoState(); }, componentDidMount: function() { TodoStore.events.change.listen(this._onChange); }, componentWillUnmount: function() { TodoStore.events.change.off(this._onChange); }, /** * @return {object} */ render: function() { return ( React.createElement("div", null, React.createElement(Header, null), React.createElement(MainSection, { allTodos: this.state.allTodos, areAllComplete: this.state.areAllComplete} ), React.createElement(Footer, {allTodos: this.state.allTodos}) ) ); }, /** * Event handler for 'change' events coming from the TodoStore */ _onChange: function() { this.setState(getTodoState()); } }); module.exports = TodoApp; },{"../stores/TodoStore":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/stores/TodoStore.js","./Footer.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/Footer.react.js","./Header.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/Header.react.js","./MainSection.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/MainSection.react.js","react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoItem.react.js":[function(require,module,exports){ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ var React = require('react'); var ReactPropTypes = React.PropTypes; var TodoActions = require('../actions/TodoActions'); var TodoTextInput = require('./TodoTextInput.react'); var cx = require('react/lib/cx'); var TodoItem = React.createClass({displayName: "TodoItem", propTypes: { todo: ReactPropTypes.object.isRequired }, getInitialState: function() { return { isEditing: false }; }, /** * @return {object} */ render: function() { var todo = this.props.todo; var input; if (this.state.isEditing) { input = React.createElement(TodoTextInput, { className: "edit", onSave: this._onSave, value: todo.text} ); } // List items should get the class 'editing' when editing // and 'completed' when marked as completed. // Note that 'completed' is a classification while 'complete' is a state. // This differentiation between classification and state becomes important // in the naming of view actions toggleComplete() vs. destroyCompleted(). return ( React.createElement("li", { className: cx({ 'completed': todo.complete, 'editing': this.state.isEditing }), key: todo.id}, React.createElement("div", {className: "view"}, React.createElement("input", { className: "toggle", type: "checkbox", checked: todo.complete, onChange: this._onToggleComplete} ), React.createElement("label", {onDoubleClick: this._onDoubleClick}, todo.text ), React.createElement("button", {className: "destroy", onClick: this._onDestroyClick}) ), input ) ); }, _onToggleComplete: function() { TodoActions.toggleComplete(this.props.todo); }, _onDoubleClick: function() { this.setState({isEditing: true}); }, /** * Event handler called within TodoTextInput. * Defining this here allows TodoTextInput to be used in multiple places * in different ways. * @param {string} text */ _onSave: function(text) { TodoActions.updateText({ id: this.props.todo.id, text: text }); this.setState({isEditing: false}); }, _onDestroyClick: function() { TodoActions.destroy({ id: this.props.todo.id }); } }); module.exports = TodoItem; },{"../actions/TodoActions":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/actions/TodoActions.js","./TodoTextInput.react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoTextInput.react.js","react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js","react/lib/cx":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/lib/cx.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/components/TodoTextInput.react.js":[function(require,module,exports){ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ var React = require('react'); var ReactPropTypes = React.PropTypes; var ENTER_KEY_CODE = 13; var TodoTextInput = React.createClass({displayName: "TodoTextInput", propTypes: { className: ReactPropTypes.string, id: ReactPropTypes.string, placeholder: ReactPropTypes.string, onSave: ReactPropTypes.func.isRequired, value: ReactPropTypes.string }, getInitialState: function() { return { value: this.props.value || '' }; }, /** * @return {object} */ render: function() /*object*/ { return ( React.createElement("input", { className: this.props.className, id: this.props.id, placeholder: this.props.placeholder, onBlur: this._save, onChange: this._onChange, onKeyDown: this._onKeyDown, value: this.state.value, autoFocus: true} ) ); }, /** * Invokes the callback passed in as onSave, allowing this component to be * used in different ways. */ _save: function() { this.props.onSave(this.state.value); this.setState({ value: '' }); }, /** * @param {object} event */ _onChange: function(/*object*/ event) { this.setState({ value: event.target.value }); }, /** * @param {object} event */ _onKeyDown: function(event) { if (event.keyCode === ENTER_KEY_CODE) { this._save(); } } }); module.exports = TodoTextInput; },{"react":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/react/react.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/stores/TodoStore.js":[function(require,module,exports){ var FluxCapacitor = require('fluxcapacitor'); var TodoActions = require('../actions/TodoActions'); var assign = require('object-assign'); var TodoStore = FluxCapacitor.createStore([TodoActions], { events: FluxCapacitor.createEvents(['change']), text: '', todos: {}, onCreate: function(action) { if (action.text !== '') { this.create(action.text); } this.events.change(); }, onToggleCompleteAll: function() { if (this.areAllComplete()) { this.updateAll({complete: false}); } else { this.updateAll({complete: true}); } this.events.change(); }, onDestroyCompleted: function() { this.destroyCompleted(); this.events.change(); }, onDestroy: function(action) { this.destroy(action.id); this.events.change(); }, onToggleComplete: function(action) { this.update(action.id, { complete: !action.complete }); this.events.change(); }, onUpdateText: function(action) { text = action.text.trim(); if (text !== '') { this.update(action.id, {text: text}); } this.events.change(); }, create: function(text) { var id = (+new Date() + Math.floor(Math.random() * 999999)).toString(36); this.todos[id] = { id: id, complete: false, text: text }; }, update: function(id, updates) { this.todos[id] = assign({}, this.todos[id], updates); }, updateAll: function(updates) { for (var id in this.todos) { this.update(id, updates); } }, destroy: function(id) { delete this.todos[id]; }, destroyCompleted: function() { for (var id in this.todos) { if (this.todos[id].complete) { this.destroy(id); } } }, areAllComplete: function() { for (var id in this.todos) { if (!this.todos[id].complete) { return false; } } return true; }, getAll: function() { return this.todos; } }); module.exports = TodoStore; },{"../actions/TodoActions":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/js/actions/TodoActions.js","fluxcapacitor":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/fluxcapacitor/src/fluxcapacitor.js","object-assign":"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/object-assign/index.js"}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/browserify/node_modules/process/browser.js":[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; var queue = []; var draining = false; function drainQueue() { if (draining) { return; } draining = true; var currentQueue; var len = queue.length; while(len) { currentQueue = queue; queue = []; var i = -1; while (++i < len) { currentQueue[i](); } len = queue.length; } draining = false; } process.nextTick = function (fun) { queue.push(fun); if (!draining) { setTimeout(drainQueue, 0); } }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.binding = function (name) { throw new Error('process.binding is not supported'); }; // TODO(shtylman) process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; },{}],"/home/mathieuancelin/Dropbox/current-projects/fluxcapacitor/example/todo/node_modules/fluxcapacitor/node_modules/lodash/index.js":[function(require,module,exports){ (function (global){ /** * @license * lodash 3.3.1 (Custom Build) <https://lodash.com/> * Build: `lodash modern -d -o ./index.js` * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <https://lodash.com/license> */ ;(function() { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; /** Used as the semantic version number. */ var VERSION = '3.3.1'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_BOUND_FLAG = 4, CURRY_FLAG = 8, CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, REARG_FLAG = 128, ARY_FLAG = 256; /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = '...'; /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150, HOT_SPAN = 16; /** Used to indicate the type of lazy iteratees. */ var LAZY_FILTER_FLAG = 0, LAZY_MAP_FLAG = 1, LAZY_WHILE_FLAG = 2; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** Used as the internal argument placeholder. */ var PLACEHOLDER = '__lodash_placeholder__'; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', 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 empty string literals in compiled template source. */ var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; /** Used to match HTML entities and HTML characters. */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g, reHasEscapedHtml = RegExp(reEscapedHtml.source), reHasUnescapedHtml = RegExp(reUnescapedHtml.source); /** Used to match template delimiters. */ var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; /** * Used to match ES template delimiters. * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components) * for more details. */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; /** Used to detect named functions. */ var reFuncName = /^\s*function[ \n\r\t]+\w/; /** Used to detect hexadecimal string values. */ var reHexPrefix = /^0[xX]/; /** Used to detect host constructors (Safari > 5). */ var reHostCtor = /^\[object .+?Constructor\]$/; /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; /** Used to ensure capturing order of template delimiters. */ var reNoMatch = /($^)/; /** * Used to match `RegExp` special characters. * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) * for more details. */ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, reHasRegExpChars = RegExp(reRegExpChars.source); /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; /** Used to match unescaped characters in compiled string literals. */ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; /** Used to match words to create compound words. */ var reWords = (function() { var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); /** Used to detect and test for whitespace. */ var whitespace = ( // Basic whitespace characters. ' \t\x0b\f\xa0\ufeff' + // Line terminators. '\n\r\u2028\u2029' + // Unicode category "Zs" space separators. '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' ); /** Used to assign default `context` object properties. */ var contextProps = [ 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 'window', 'WinRTError' ]; /** Used to make template sourceURLs easier to identify. */ var templateCounter = -1; /** 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[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; /** Used to identify `toStringTag` values supported by `_.clone`. */ var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[stringTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[mapTag] = cloneableTags[setTag] = cloneableTags[weakMapTag] = false; /** Used as an internal `_.debounce` options object by `_.throttle`. */ var debounceOptions = { 'leading': false, 'maxWait': 0, 'trailing': false }; /** Used to map latin-1 supplementary letters to basic latin letters. */ var deburredLetters = { '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', '\xc7': 'C', '\xe7': 'c', '\xd0': 'D', '\xf0': 'd', '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', '\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', '\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', '\xd1': 'N', '\xf1': 'n', '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', '\xc6': 'Ae', '\xe6': 'ae', '\xde': 'Th', '\xfe': 'th', '\xdf': 'ss' }; /** Used to map characters to HTML entities. */ var htmlEscapes = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;', '`': '&#96;' }; /** Used to map HTML entities to characters. */ var htmlUnescapes = { '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&#39;': "'", '&#96;': '`' }; /** Used to determine if values are of the language type `Object`. */ var objectTypes = { 'function': true, 'object': true }; /** Used to escape characters for inclusion in compiled string literals. */ var stringEscapes = { '\\': '\\', "'": "'", '\n': 'n', '\r': 'r', '\u2028': 'u2028', '\u2029': 'u2029' }; /** * Used as a reference to the global object. * * The `this` value is used if it is the global object to avoid Greasemonkey's * restricted `window` object, otherwise the `window` object is used. */ var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this; /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { root = freeGlobal; } /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /*--------------------------------------------------------------------------*/ /** * The base implementation of `compareAscending` which compares values and * sorts them in ascending order without guaranteeing a stable sort. * * @private * @param {*} value The value to compare to `other`. * @param {*} other The value to compare to `value`. * @returns {number} Returns the sort order indicator for `value`. */ function baseCompareAscending(value, other) { if (value !== other) { var valIsReflexive = value === value, othIsReflexive = other === other; if (value > other || !valIsReflexive || (typeof value == 'undefined' && othIsReflexive)) { return 1; } if (value < other || !othIsReflexive || (typeof other == 'undefined' && valIsReflexive)) { return -1; } } return 0; } /** * The base implementation of `_.indexOf` without support for binary searches. * * @private * @param {Array} array The array to search. * @param {*} value The value to search for. * @param {number} [fromIndex=0] The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { if (value !== value) { return indexOfNaN(array, fromIndex); } var index = (fromIndex || 0) - 1, length = array.length; while (++index < length) { if (array[index] === value) { return index; } } return -1; } /** * The base implementation of `_.isFunction` without support for environments * with incorrect `typeof` results. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. */ function baseIsFunction(value) { // Avoid a Chakra JIT bug in compatibility modes of IE 11. // See https://github.com/jashkenas/underscore/issues/1621 for more details. return typeof value == 'function' || false; } /** * The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer` * to define the sort order of `array` and replaces criteria objects with their * corresponding values. * * @private * @param {Array} array The array to sort. * @param {Function} comparer The function to define sort order. * @returns {Array} Returns `array`. */ function baseSortBy(array, comparer) { var length = array.length; array.sort(comparer); while (length--) { array[length] = array[length].value; } return array; } /** * Converts `value` to a string if it is not one. An empty string is returned * for `null` or `undefined` values. * * @private * @param {*} value The value to process. * @returns {string} Returns the string. */ function baseToString(value) { if (typeof value == 'string') { return value; } return value == null ? '' : (value + ''); } /** * Used by `_.max` and `_.min` as the default callback for string values. * * @private * @param {string} string The string to inspect. * @returns {number} Returns the code unit of the first character of the string. */ function charAtCallback(string) { return string.charCodeAt(0); } /** * Used by `_.trim` and `_.trimLeft` to get the index of the first character * of `string` that is not found in `chars`. * * @private * @param {string} string The string to inspect. * @param {string} chars The characters to find. * @returns {number} Returns the index of the first character not found in `chars`. */ function charsLeftIndex(string, chars) { var index = -1, length = string.length; while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} return index; } /** * Used by `_.trim` and `_.trimRight` to get the index of the last character * of `string` that is not found in `chars`. * * @private * @param {string} string The string to inspect. * @param {string} chars The characters to find. * @returns {number} Returns the index of the last character not found in `chars`. */ function charsRightIndex(string, chars) { var index = string.length; while (index-- && chars.indexOf(string.charAt(index)) > -1) {} return index; } /** * Used by `_.sortBy` to compare transformed elements of a collection and stable * sort them in ascending order. * * @private * @param {Object} object The object to compare to `other`. * @param {Object} other The object to compare to `object`. * @returns {number} Returns the sort order indicator for `object`. */ function compareAscending(object, other) { return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index); } /** * Used by `_.sortByAll` to compare multiple properties of each element * in a collection and stable sort them in ascending order. * * @private * @param {Object} object The object to compare to `other`. * @param {Object} other The object to compare to `object`. * @returns {number} Returns the sort order indicator for `object`. */ function compareMultipleAscending(object, other) { var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length; while (++index < length) { var result = baseCompareAscending(objCriteria[index], othCriteria[index]); if (result) { return result; } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications // that causes it, under certain circumstances, to provide the same value for // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 // for more details. // // This also ensures a stable sort in V8 and other engines. // See https://code.google.com/p/v8/issues/detail?id=90 for more details. return object.index - other.index; } /** * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * * @private * @param {string} letter The matched letter to deburr. * @returns {string} Returns the deburred letter. */ function deburrLetter(letter) { return deburredLetters[letter]; } /** * Used by `_.escape` to convert characters to HTML entities. * * @private * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ function escapeHtmlChar(chr) { return htmlEscapes[chr]; } /** * 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]; } /** * Gets the index at which the first occurrence of `NaN` is found in `array`. * If `fromRight` is provided elements of `array` are iterated from right to left. * * @private * @param {Array} array The array to search. * @param {number} [fromIndex] The index to search from. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched `NaN`, else `-1`. */ function indexOfNaN(array, fromIndex, fromRight) { var length = array.length, index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); while ((fromRight ? index-- : ++index < length)) { var other = array[index]; if (other !== other) { return index; } } return -1; } /** * Checks if `value` is object-like. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. */ function isObjectLike(value) { return (value && typeof value == 'object') || false; } /** * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a * character code is whitespace. * * @private * @param {number} charCode The character code to inspect. * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`. */ function isSpace(charCode) { return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 || (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279))); } /** * Replaces all `placeholder` elements in `array` with an internal placeholder * and returns an array of their indexes. * * @private * @param {Array} array The array to modify. * @param {*} placeholder The placeholder to replace. * @returns {Array} Returns the new array of placeholder indexes. */ function replaceHolders(array, placeholder) { var index = -1, length = array.length, resIndex = -1, result = []; while (++index < length) { if (array[index] === placeholder) { array[index] = PLACEHOLDER; result[++resIndex] = index; } } return result; } /** * An implementation of `_.uniq` optimized for sorted arrays without support * for callback shorthands and `this` binding. * * @private * @param {Array} array The array to inspect. * @param {Function} [iteratee] The function invoked per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ function sortedUniq(array, iteratee) { var seen, index = -1, length = array.length, resIndex = -1, result = []; while (++index < length) { var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; if (!index || seen !== computed) { seen = computed; result[++resIndex] = value; } } return result; } /** * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace * character of `string`. * * @private * @param {string} string The string to inspect. * @returns {number} Returns the index of the first non-whitespace character. */ function trimmedLeftIndex(string) { var index = -1, length = string.length; while (++index < length && isSpace(string.charCodeAt(index))) {} return index; } /** * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace * character of `string`. * * @private * @param {string} string The string to inspect. * @returns {number} Returns the index of the last non-whitespace character. */ function trimmedRightIndex(string) { var index = string.length; while (index-- && isSpace(string.charCodeAt(index))) {} return index; } /** * Used by `_.unescape` to convert HTML entities to characters. * * @private * @param {string} chr The matched character to unescape. * @returns {string} Returns the unescaped character. */ function unescapeHtmlChar(chr) { return htmlUnescapes[chr]; } /*--------------------------------------------------------------------------*/ /** * Create a new pristine `lodash` function using the given `context` object. * * @static * @memberOf _ * @category Utility * @param {Object} [context=root] The context object. * @returns {Function} Returns a new `lodash` function. * @example * * _.mixin({ 'add': function(a, b) { return a + b; } }); * * var lodash = _.runInContext(); * lodash.mixin({ 'sub': function(a, b) { return a - b; } }); * * _.isFunction(_.add); * // => true * _.isFunction(_.sub); * // => false * * lodash.isFunction(lodash.add); * // => false * lodash.isFunction(lodash.sub); * // => true * * // using `context` to mock `Date#getTime` use in `_.now` * var mock = _.runInContext({ * 'Date': function() { * return { 'getTime': getTimeMock }; * } * }); * * // or creating a suped-up `defer` in Node.js * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; */ function runInContext(context) { // Avoid issues with some ES3 environments that attempt to use values, named // after built-in constructors like `Object`, for the creation of literals. // ES5 clears this up by stating that literals must use built-in constructors. // See https://es5.github.io/#x11.1.5 for more details. context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; /** Native constructor references. */ var Array = context.Array, Date = context.Date, Error = context.Error, Function = context.Function, Math = context.Math, Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, TypeError = context.TypeError; /** Used for native method references. */ var arrayProto = Array.prototype, objectProto = Object.prototype; /** Used to detect DOM support. */ var document = (document = context.window) && document.document; /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; /** Used to the length of n-tuples for `_.unzip`. */ var getLength = baseProperty('length'); /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to generate unique IDs. */ var idCounter = 0; /** * Used to resolve the `toStringTag` of values. * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) * for more details. */ var objToString = objectProto.toString; /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = context._; /** Used to detect if a method is native. */ var reNative = RegExp('^' + escapeRegExp(objToString) .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** Native method references. */ var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, ceil = Math.ceil, clearTimeout = context.clearTimeout, floor = Math.floor, getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, push = arrayProto.push, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = isNative(Set = context.Set) && Set, setTimeout = context.setTimeout, splice = arrayProto.splice, Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; /** Used to clone array buffers. */ var Float64Array = (function() { // Safari 5 errors when using an array buffer to initialize a typed array // where the array buffer's `byteLength` is not a multiple of the typed // array's `BYTES_PER_ELEMENT`. try { var func = isNative(func = context.Float64Array) && func, result = new func(new ArrayBuffer(10), 0, 1) && func; } catch(e) {} return result; }()); /* Native method references for those with the same name as other `lodash` methods. */ var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, nativeMin = Math.min, nativeNow = isNative(nativeNow = Date.now) && nativeNow, nativeNumIsFinite = isNative(nativeNumIsFinite = Number.isFinite) && nativeNumIsFinite, nativeParseInt = context.parseInt, nativeRandom = Math.random; /** Used as references for `-Infinity` and `Infinity`. */ var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; /** Used as references for the maximum length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; /** Used as the size, in bytes, of each `Float64Array` element. */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** * Used as the maximum length of an array-like value. * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) * for more details. */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; /*------------------------------------------------------------------------*/ /** * Creates a `lodash` object which wraps `value` to enable implicit chaining. * Methods that operate on and return arrays, collections, and functions can * be chained together. Methods that return a boolean or single value will * automatically end the chain returning the unwrapped value. Explicit chaining * may be enabled using `_.chain`. The execution of chained methods is lazy, * that is, execution is deferred until `_#value` is implicitly or explicitly * called. * * Lazy evaluation allows several methods to support shortcut fusion. Shortcut * fusion is an optimization that merges iteratees to avoid creating intermediate * arrays and reduce the number of iteratee executions. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build. * * In addition to lodash methods, wrappers also have the following `Array` methods: * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, * and `unshift` * * The wrapper methods that support shortcut fusion are: * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, * and `where` * * The chainable wrapper methods are: * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, * `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`, * `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`, * `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, * `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, * `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, * `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`, * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, * `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, * `zip`, and `zipObject` * * The wrapper methods that are **not** chainable by default are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey