wp/wp-includes/js/dist/shortcode.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 this["wp"] = this["wp"] || {}; this["wp"]["shortcode"] =
     1 /******/ (function() { // webpackBootstrap
     2 /******/ (function(modules) { // webpackBootstrap
     2 /******/ 	var __webpack_modules__ = ({
       
     3 
       
     4 /***/ 9756:
       
     5 /***/ (function(module) {
       
     6 
       
     7 /**
       
     8  * Memize options object.
       
     9  *
       
    10  * @typedef MemizeOptions
       
    11  *
       
    12  * @property {number} [maxSize] Maximum size of the cache.
       
    13  */
       
    14 
       
    15 /**
       
    16  * Internal cache entry.
       
    17  *
       
    18  * @typedef MemizeCacheNode
       
    19  *
       
    20  * @property {?MemizeCacheNode|undefined} [prev] Previous node.
       
    21  * @property {?MemizeCacheNode|undefined} [next] Next node.
       
    22  * @property {Array<*>}                   args   Function arguments for cache
       
    23  *                                               entry.
       
    24  * @property {*}                          val    Function result.
       
    25  */
       
    26 
       
    27 /**
       
    28  * Properties of the enhanced function for controlling cache.
       
    29  *
       
    30  * @typedef MemizeMemoizedFunction
       
    31  *
       
    32  * @property {()=>void} clear Clear the cache.
       
    33  */
       
    34 
       
    35 /**
       
    36  * Accepts a function to be memoized, and returns a new memoized function, with
       
    37  * optional options.
       
    38  *
       
    39  * @template {Function} F
       
    40  *
       
    41  * @param {F}             fn        Function to memoize.
       
    42  * @param {MemizeOptions} [options] Options object.
       
    43  *
       
    44  * @return {F & MemizeMemoizedFunction} Memoized function.
       
    45  */
       
    46 function memize( fn, options ) {
       
    47 	var size = 0;
       
    48 
       
    49 	/** @type {?MemizeCacheNode|undefined} */
       
    50 	var head;
       
    51 
       
    52 	/** @type {?MemizeCacheNode|undefined} */
       
    53 	var tail;
       
    54 
       
    55 	options = options || {};
       
    56 
       
    57 	function memoized( /* ...args */ ) {
       
    58 		var node = head,
       
    59 			len = arguments.length,
       
    60 			args, i;
       
    61 
       
    62 		searchCache: while ( node ) {
       
    63 			// Perform a shallow equality test to confirm that whether the node
       
    64 			// under test is a candidate for the arguments passed. Two arrays
       
    65 			// are shallowly equal if their length matches and each entry is
       
    66 			// strictly equal between the two sets. Avoid abstracting to a
       
    67 			// function which could incur an arguments leaking deoptimization.
       
    68 
       
    69 			// Check whether node arguments match arguments length
       
    70 			if ( node.args.length !== arguments.length ) {
       
    71 				node = node.next;
       
    72 				continue;
       
    73 			}
       
    74 
       
    75 			// Check whether node arguments match arguments values
       
    76 			for ( i = 0; i < len; i++ ) {
       
    77 				if ( node.args[ i ] !== arguments[ i ] ) {
       
    78 					node = node.next;
       
    79 					continue searchCache;
       
    80 				}
       
    81 			}
       
    82 
       
    83 			// At this point we can assume we've found a match
       
    84 
       
    85 			// Surface matched node to head if not already
       
    86 			if ( node !== head ) {
       
    87 				// As tail, shift to previous. Must only shift if not also
       
    88 				// head, since if both head and tail, there is no previous.
       
    89 				if ( node === tail ) {
       
    90 					tail = node.prev;
       
    91 				}
       
    92 
       
    93 				// Adjust siblings to point to each other. If node was tail,
       
    94 				// this also handles new tail's empty `next` assignment.
       
    95 				/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
       
    96 				if ( node.next ) {
       
    97 					node.next.prev = node.prev;
       
    98 				}
       
    99 
       
   100 				node.next = head;
       
   101 				node.prev = null;
       
   102 				/** @type {MemizeCacheNode} */ ( head ).prev = node;
       
   103 				head = node;
       
   104 			}
       
   105 
       
   106 			// Return immediately
       
   107 			return node.val;
       
   108 		}
       
   109 
       
   110 		// No cached value found. Continue to insertion phase:
       
   111 
       
   112 		// Create a copy of arguments (avoid leaking deoptimization)
       
   113 		args = new Array( len );
       
   114 		for ( i = 0; i < len; i++ ) {
       
   115 			args[ i ] = arguments[ i ];
       
   116 		}
       
   117 
       
   118 		node = {
       
   119 			args: args,
       
   120 
       
   121 			// Generate the result from original function
       
   122 			val: fn.apply( null, args ),
       
   123 		};
       
   124 
       
   125 		// Don't need to check whether node is already head, since it would
       
   126 		// have been returned above already if it was
       
   127 
       
   128 		// Shift existing head down list
       
   129 		if ( head ) {
       
   130 			head.prev = node;
       
   131 			node.next = head;
       
   132 		} else {
       
   133 			// If no head, follows that there's no tail (at initial or reset)
       
   134 			tail = node;
       
   135 		}
       
   136 
       
   137 		// Trim tail if we're reached max size and are pending cache insertion
       
   138 		if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
       
   139 			tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
       
   140 			/** @type {MemizeCacheNode} */ ( tail ).next = null;
       
   141 		} else {
       
   142 			size++;
       
   143 		}
       
   144 
       
   145 		head = node;
       
   146 
       
   147 		return node.val;
       
   148 	}
       
   149 
       
   150 	memoized.clear = function() {
       
   151 		head = null;
       
   152 		tail = null;
       
   153 		size = 0;
       
   154 	};
       
   155 
       
   156 	if ( false ) {}
       
   157 
       
   158 	// Ignore reason: There's not a clear solution to create an intersection of
       
   159 	// the function with additional properties, where the goal is to retain the
       
   160 	// function signature of the incoming argument and add control properties
       
   161 	// on the return value.
       
   162 
       
   163 	// @ts-ignore
       
   164 	return memoized;
       
   165 }
       
   166 
       
   167 module.exports = memize;
       
   168 
       
   169 
       
   170 /***/ })
       
   171 
       
   172 /******/ 	});
       
   173 /************************************************************************/
     3 /******/ 	// The module cache
   174 /******/ 	// The module cache
     4 /******/ 	var installedModules = {};
   175 /******/ 	var __webpack_module_cache__ = {};
     5 /******/
   176 /******/ 	
     6 /******/ 	// The require function
   177 /******/ 	// The require function
     7 /******/ 	function __webpack_require__(moduleId) {
   178 /******/ 	function __webpack_require__(moduleId) {
     8 /******/
       
     9 /******/ 		// Check if module is in cache
   179 /******/ 		// Check if module is in cache
    10 /******/ 		if(installedModules[moduleId]) {
   180 /******/ 		var cachedModule = __webpack_module_cache__[moduleId];
    11 /******/ 			return installedModules[moduleId].exports;
   181 /******/ 		if (cachedModule !== undefined) {
       
   182 /******/ 			return cachedModule.exports;
    12 /******/ 		}
   183 /******/ 		}
    13 /******/ 		// Create a new module (and put it into the cache)
   184 /******/ 		// Create a new module (and put it into the cache)
    14 /******/ 		var module = installedModules[moduleId] = {
   185 /******/ 		var module = __webpack_module_cache__[moduleId] = {
    15 /******/ 			i: moduleId,
   186 /******/ 			// no module.id needed
    16 /******/ 			l: false,
   187 /******/ 			// no module.loaded needed
    17 /******/ 			exports: {}
   188 /******/ 			exports: {}
    18 /******/ 		};
   189 /******/ 		};
    19 /******/
   190 /******/ 	
    20 /******/ 		// Execute the module function
   191 /******/ 		// Execute the module function
    21 /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
   192 /******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
    22 /******/
   193 /******/ 	
    23 /******/ 		// Flag the module as loaded
       
    24 /******/ 		module.l = true;
       
    25 /******/
       
    26 /******/ 		// Return the exports of the module
   194 /******/ 		// Return the exports of the module
    27 /******/ 		return module.exports;
   195 /******/ 		return module.exports;
    28 /******/ 	}
   196 /******/ 	}
    29 /******/
   197 /******/ 	
    30 /******/
       
    31 /******/ 	// expose the modules object (__webpack_modules__)
       
    32 /******/ 	__webpack_require__.m = modules;
       
    33 /******/
       
    34 /******/ 	// expose the module cache
       
    35 /******/ 	__webpack_require__.c = installedModules;
       
    36 /******/
       
    37 /******/ 	// define getter function for harmony exports
       
    38 /******/ 	__webpack_require__.d = function(exports, name, getter) {
       
    39 /******/ 		if(!__webpack_require__.o(exports, name)) {
       
    40 /******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
       
    41 /******/ 		}
       
    42 /******/ 	};
       
    43 /******/
       
    44 /******/ 	// define __esModule on exports
       
    45 /******/ 	__webpack_require__.r = function(exports) {
       
    46 /******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
       
    47 /******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
       
    48 /******/ 		}
       
    49 /******/ 		Object.defineProperty(exports, '__esModule', { value: true });
       
    50 /******/ 	};
       
    51 /******/
       
    52 /******/ 	// create a fake namespace object
       
    53 /******/ 	// mode & 1: value is a module id, require it
       
    54 /******/ 	// mode & 2: merge all properties of value into the ns
       
    55 /******/ 	// mode & 4: return value when already ns object
       
    56 /******/ 	// mode & 8|1: behave like require
       
    57 /******/ 	__webpack_require__.t = function(value, mode) {
       
    58 /******/ 		if(mode & 1) value = __webpack_require__(value);
       
    59 /******/ 		if(mode & 8) return value;
       
    60 /******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
       
    61 /******/ 		var ns = Object.create(null);
       
    62 /******/ 		__webpack_require__.r(ns);
       
    63 /******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
       
    64 /******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
       
    65 /******/ 		return ns;
       
    66 /******/ 	};
       
    67 /******/
       
    68 /******/ 	// getDefaultExport function for compatibility with non-harmony modules
       
    69 /******/ 	__webpack_require__.n = function(module) {
       
    70 /******/ 		var getter = module && module.__esModule ?
       
    71 /******/ 			function getDefault() { return module['default']; } :
       
    72 /******/ 			function getModuleExports() { return module; };
       
    73 /******/ 		__webpack_require__.d(getter, 'a', getter);
       
    74 /******/ 		return getter;
       
    75 /******/ 	};
       
    76 /******/
       
    77 /******/ 	// Object.prototype.hasOwnProperty.call
       
    78 /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
       
    79 /******/
       
    80 /******/ 	// __webpack_public_path__
       
    81 /******/ 	__webpack_require__.p = "";
       
    82 /******/
       
    83 /******/
       
    84 /******/ 	// Load entry module and return exports
       
    85 /******/ 	return __webpack_require__(__webpack_require__.s = "/2FX");
       
    86 /******/ })
       
    87 /************************************************************************/
   198 /************************************************************************/
    88 /******/ ({
   199 /******/ 	/* webpack/runtime/compat get default export */
    89 
   200 /******/ 	!function() {
    90 /***/ "/2FX":
   201 /******/ 		// getDefaultExport function for compatibility with non-harmony modules
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   202 /******/ 		__webpack_require__.n = function(module) {
    92 
   203 /******/ 			var getter = module && module.__esModule ?
       
   204 /******/ 				function() { return module['default']; } :
       
   205 /******/ 				function() { return module; };
       
   206 /******/ 			__webpack_require__.d(getter, { a: getter });
       
   207 /******/ 			return getter;
       
   208 /******/ 		};
       
   209 /******/ 	}();
       
   210 /******/ 	
       
   211 /******/ 	/* webpack/runtime/define property getters */
       
   212 /******/ 	!function() {
       
   213 /******/ 		// define getter functions for harmony exports
       
   214 /******/ 		__webpack_require__.d = function(exports, definition) {
       
   215 /******/ 			for(var key in definition) {
       
   216 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
       
   217 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
       
   218 /******/ 				}
       
   219 /******/ 			}
       
   220 /******/ 		};
       
   221 /******/ 	}();
       
   222 /******/ 	
       
   223 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
       
   224 /******/ 	!function() {
       
   225 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
       
   226 /******/ 	}();
       
   227 /******/ 	
       
   228 /************************************************************************/
       
   229 var __webpack_exports__ = {};
       
   230 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
       
   231 !function() {
    93 "use strict";
   232 "use strict";
    94 __webpack_require__.r(__webpack_exports__);
   233 
    95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "next", function() { return next; });
   234 // EXPORTS
    96 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replace", function() { return replace; });
   235 __webpack_require__.d(__webpack_exports__, {
    97 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "string", function() { return string; });
   236   "default": function() { return /* binding */ build_module; }
    98 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "regexp", function() { return regexp; });
   237 });
    99 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "attrs", function() { return attrs; });
   238 
   100 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMatch", function() { return fromMatch; });
   239 // UNUSED EXPORTS: attrs, fromMatch, next, regexp, replace, string
   101 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("YLtl");
   240 
   102 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);
   241 ;// CONCATENATED MODULE: external "lodash"
   103 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("4eJC");
   242 var external_lodash_namespaceObject = window["lodash"];
   104 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(memize__WEBPACK_IMPORTED_MODULE_1__);
   243 // EXTERNAL MODULE: ./node_modules/memize/index.js
       
   244 var memize = __webpack_require__(9756);
       
   245 var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
       
   246 ;// CONCATENATED MODULE: ./node_modules/@wordpress/shortcode/build-module/index.js
   105 /**
   247 /**
   106  * External dependencies
   248  * External dependencies
   107  */
   249  */
   108 
   250 
   109 
   251 
   144  * @param {number} index Index to start search from.
   286  * @param {number} index Index to start search from.
   145  *
   287  *
   146  * @return {?WPShortcodeMatch} Matched information.
   288  * @return {?WPShortcodeMatch} Matched information.
   147  */
   289  */
   148 
   290 
   149 function next(tag, text, index = 0) {
   291 function next(tag, text) {
       
   292   let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
   150   const re = regexp(tag);
   293   const re = regexp(tag);
   151   re.lastIndex = index;
   294   re.lastIndex = index;
   152   const match = re.exec(text);
   295   const match = re.exec(text);
   153 
   296 
   154   if (!match) {
   297   if (!match) {
   262  * @param {string} text Serialised shortcode attributes.
   405  * @param {string} text Serialised shortcode attributes.
   263  *
   406  *
   264  * @return {WPShortcodeAttrs} Parsed shortcode attributes.
   407  * @return {WPShortcodeAttrs} Parsed shortcode attributes.
   265  */
   408  */
   266 
   409 
   267 const attrs = memize__WEBPACK_IMPORTED_MODULE_1___default()(text => {
   410 const attrs = memize_default()(text => {
   268   const named = {};
   411   const named = {};
   269   const numeric = []; // This regular expression is reused from `shortcode_parse_atts()` in
   412   const numeric = []; // This regular expression is reused from `shortcode_parse_atts()` in
   270   // `wp-includes/shortcodes.php`.
   413   // `wp-includes/shortcodes.php`.
   271   //
   414   //
   272   // Capture groups:
   415   // Capture groups:
   348  * @param {Object} options Options as described.
   491  * @param {Object} options Options as described.
   349  *
   492  *
   350  * @return {WPShortcode} Shortcode instance.
   493  * @return {WPShortcode} Shortcode instance.
   351  */
   494  */
   352 
   495 
   353 const shortcode = Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(function (options) {
   496 const shortcode = (0,external_lodash_namespaceObject.extend)(function (options) {
   354   Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(this, Object(lodash__WEBPACK_IMPORTED_MODULE_0__["pick"])(options || {}, 'tag', 'attrs', 'type', 'content'));
   497   (0,external_lodash_namespaceObject.extend)(this, (0,external_lodash_namespaceObject.pick)(options || {}, 'tag', 'attrs', 'type', 'content'));
   355   const attributes = this.attrs; // Ensure we have a correctly formatted `attrs` object.
   498   const attributes = this.attrs; // Ensure we have a correctly formatted `attrs` object.
   356 
   499 
   357   this.attrs = {
   500   this.attrs = {
   358     named: {},
   501     named: {},
   359     numeric: []
   502     numeric: []
   362   if (!attributes) {
   505   if (!attributes) {
   363     return;
   506     return;
   364   } // Parse a string of attributes.
   507   } // Parse a string of attributes.
   365 
   508 
   366 
   509 
   367   if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isString"])(attributes)) {
   510   if ((0,external_lodash_namespaceObject.isString)(attributes)) {
   368     this.attrs = attrs(attributes); // Identify a correctly formatted `attrs` object.
   511     this.attrs = attrs(attributes); // Identify a correctly formatted `attrs` object.
   369   } else if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isEqual"])(Object.keys(attributes), ['named', 'numeric'])) {
   512   } else if ((0,external_lodash_namespaceObject.isEqual)(Object.keys(attributes), ['named', 'numeric'])) {
   370     this.attrs = attributes; // Handle a flat object of attributes.
   513     this.attrs = attributes; // Handle a flat object of attributes.
   371   } else {
   514   } else {
   372     Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(attributes, (value, key) => {
   515     (0,external_lodash_namespaceObject.forEach)(attributes, (value, key) => {
   373       this.set(key, value);
   516       this.set(key, value);
   374     });
   517     });
   375   }
   518   }
   376 }, {
   519 }, {
   377   next,
   520   next,
   379   string,
   522   string,
   380   regexp,
   523   regexp,
   381   attrs,
   524   attrs,
   382   fromMatch
   525   fromMatch
   383 });
   526 });
   384 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(shortcode.prototype, {
   527 (0,external_lodash_namespaceObject.extend)(shortcode.prototype, {
   385   /**
   528   /**
   386    * Get a shortcode attribute.
   529    * Get a shortcode attribute.
   387    *
   530    *
   388    * Automatically detects whether `attr` is named or numeric and routes it
   531    * Automatically detects whether `attr` is named or numeric and routes it
   389    * accordingly.
   532    * accordingly.
   391    * @param {(number|string)} attr Attribute key.
   534    * @param {(number|string)} attr Attribute key.
   392    *
   535    *
   393    * @return {string} Attribute value.
   536    * @return {string} Attribute value.
   394    */
   537    */
   395   get(attr) {
   538   get(attr) {
   396     return this.attrs[Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isNumber"])(attr) ? 'numeric' : 'named'][attr];
   539     return this.attrs[(0,external_lodash_namespaceObject.isNumber)(attr) ? 'numeric' : 'named'][attr];
   397   },
   540   },
   398 
   541 
   399   /**
   542   /**
   400    * Set a shortcode attribute.
   543    * Set a shortcode attribute.
   401    *
   544    *
   406    * @param {string}          value Attribute value.
   549    * @param {string}          value Attribute value.
   407    *
   550    *
   408    * @return {WPShortcode} Shortcode instance.
   551    * @return {WPShortcode} Shortcode instance.
   409    */
   552    */
   410   set(attr, value) {
   553   set(attr, value) {
   411     this.attrs[Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isNumber"])(attr) ? 'numeric' : 'named'][attr] = value;
   554     this.attrs[(0,external_lodash_namespaceObject.isNumber)(attr) ? 'numeric' : 'named'][attr] = value;
   412     return this;
   555     return this;
   413   },
   556   },
   414 
   557 
   415   /**
   558   /**
   416    * Transform the shortcode into a string.
   559    * Transform the shortcode into a string.
   417    *
   560    *
   418    * @return {string} String representation of the shortcode.
   561    * @return {string} String representation of the shortcode.
   419    */
   562    */
   420   string() {
   563   string() {
   421     let text = '[' + this.tag;
   564     let text = '[' + this.tag;
   422     Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.numeric, value => {
   565     (0,external_lodash_namespaceObject.forEach)(this.attrs.numeric, value => {
   423       if (/\s/.test(value)) {
   566       if (/\s/.test(value)) {
   424         text += ' "' + value + '"';
   567         text += ' "' + value + '"';
   425       } else {
   568       } else {
   426         text += ' ' + value;
   569         text += ' ' + value;
   427       }
   570       }
   428     });
   571     });
   429     Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.named, (value, name) => {
   572     (0,external_lodash_namespaceObject.forEach)(this.attrs.named, (value, name) => {
   430       text += ' ' + name + '="' + value + '"';
   573       text += ' ' + name + '="' + value + '"';
   431     }); // If the tag is marked as `single` or `self-closing`, close the tag and
   574     }); // If the tag is marked as `single` or `self-closing`, close the tag and
   432     // ignore any additional content.
   575     // ignore any additional content.
   433 
   576 
   434     if ('single' === this.type) {
   577     if ('single' === this.type) {
   447 
   590 
   448     return text + '[/' + this.tag + ']';
   591     return text + '[/' + this.tag + ']';
   449   }
   592   }
   450 
   593 
   451 });
   594 });
   452 /* harmony default export */ __webpack_exports__["default"] = (shortcode);
   595 /* harmony default export */ var build_module = (shortcode);
   453 
   596 
   454 
   597 }();
   455 /***/ }),
   598 (window.wp = window.wp || {}).shortcode = __webpack_exports__["default"];
   456 
   599 /******/ })()
   457 /***/ "4eJC":
   600 ;
   458 /***/ (function(module, exports, __webpack_require__) {
       
   459 
       
   460 /**
       
   461  * Memize options object.
       
   462  *
       
   463  * @typedef MemizeOptions
       
   464  *
       
   465  * @property {number} [maxSize] Maximum size of the cache.
       
   466  */
       
   467 
       
   468 /**
       
   469  * Internal cache entry.
       
   470  *
       
   471  * @typedef MemizeCacheNode
       
   472  *
       
   473  * @property {?MemizeCacheNode|undefined} [prev] Previous node.
       
   474  * @property {?MemizeCacheNode|undefined} [next] Next node.
       
   475  * @property {Array<*>}                   args   Function arguments for cache
       
   476  *                                               entry.
       
   477  * @property {*}                          val    Function result.
       
   478  */
       
   479 
       
   480 /**
       
   481  * Properties of the enhanced function for controlling cache.
       
   482  *
       
   483  * @typedef MemizeMemoizedFunction
       
   484  *
       
   485  * @property {()=>void} clear Clear the cache.
       
   486  */
       
   487 
       
   488 /**
       
   489  * Accepts a function to be memoized, and returns a new memoized function, with
       
   490  * optional options.
       
   491  *
       
   492  * @template {Function} F
       
   493  *
       
   494  * @param {F}             fn        Function to memoize.
       
   495  * @param {MemizeOptions} [options] Options object.
       
   496  *
       
   497  * @return {F & MemizeMemoizedFunction} Memoized function.
       
   498  */
       
   499 function memize( fn, options ) {
       
   500 	var size = 0;
       
   501 
       
   502 	/** @type {?MemizeCacheNode|undefined} */
       
   503 	var head;
       
   504 
       
   505 	/** @type {?MemizeCacheNode|undefined} */
       
   506 	var tail;
       
   507 
       
   508 	options = options || {};
       
   509 
       
   510 	function memoized( /* ...args */ ) {
       
   511 		var node = head,
       
   512 			len = arguments.length,
       
   513 			args, i;
       
   514 
       
   515 		searchCache: while ( node ) {
       
   516 			// Perform a shallow equality test to confirm that whether the node
       
   517 			// under test is a candidate for the arguments passed. Two arrays
       
   518 			// are shallowly equal if their length matches and each entry is
       
   519 			// strictly equal between the two sets. Avoid abstracting to a
       
   520 			// function which could incur an arguments leaking deoptimization.
       
   521 
       
   522 			// Check whether node arguments match arguments length
       
   523 			if ( node.args.length !== arguments.length ) {
       
   524 				node = node.next;
       
   525 				continue;
       
   526 			}
       
   527 
       
   528 			// Check whether node arguments match arguments values
       
   529 			for ( i = 0; i < len; i++ ) {
       
   530 				if ( node.args[ i ] !== arguments[ i ] ) {
       
   531 					node = node.next;
       
   532 					continue searchCache;
       
   533 				}
       
   534 			}
       
   535 
       
   536 			// At this point we can assume we've found a match
       
   537 
       
   538 			// Surface matched node to head if not already
       
   539 			if ( node !== head ) {
       
   540 				// As tail, shift to previous. Must only shift if not also
       
   541 				// head, since if both head and tail, there is no previous.
       
   542 				if ( node === tail ) {
       
   543 					tail = node.prev;
       
   544 				}
       
   545 
       
   546 				// Adjust siblings to point to each other. If node was tail,
       
   547 				// this also handles new tail's empty `next` assignment.
       
   548 				/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
       
   549 				if ( node.next ) {
       
   550 					node.next.prev = node.prev;
       
   551 				}
       
   552 
       
   553 				node.next = head;
       
   554 				node.prev = null;
       
   555 				/** @type {MemizeCacheNode} */ ( head ).prev = node;
       
   556 				head = node;
       
   557 			}
       
   558 
       
   559 			// Return immediately
       
   560 			return node.val;
       
   561 		}
       
   562 
       
   563 		// No cached value found. Continue to insertion phase:
       
   564 
       
   565 		// Create a copy of arguments (avoid leaking deoptimization)
       
   566 		args = new Array( len );
       
   567 		for ( i = 0; i < len; i++ ) {
       
   568 			args[ i ] = arguments[ i ];
       
   569 		}
       
   570 
       
   571 		node = {
       
   572 			args: args,
       
   573 
       
   574 			// Generate the result from original function
       
   575 			val: fn.apply( null, args ),
       
   576 		};
       
   577 
       
   578 		// Don't need to check whether node is already head, since it would
       
   579 		// have been returned above already if it was
       
   580 
       
   581 		// Shift existing head down list
       
   582 		if ( head ) {
       
   583 			head.prev = node;
       
   584 			node.next = head;
       
   585 		} else {
       
   586 			// If no head, follows that there's no tail (at initial or reset)
       
   587 			tail = node;
       
   588 		}
       
   589 
       
   590 		// Trim tail if we're reached max size and are pending cache insertion
       
   591 		if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
       
   592 			tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
       
   593 			/** @type {MemizeCacheNode} */ ( tail ).next = null;
       
   594 		} else {
       
   595 			size++;
       
   596 		}
       
   597 
       
   598 		head = node;
       
   599 
       
   600 		return node.val;
       
   601 	}
       
   602 
       
   603 	memoized.clear = function() {
       
   604 		head = null;
       
   605 		tail = null;
       
   606 		size = 0;
       
   607 	};
       
   608 
       
   609 	if ( false ) {}
       
   610 
       
   611 	// Ignore reason: There's not a clear solution to create an intersection of
       
   612 	// the function with additional properties, where the goal is to retain the
       
   613 	// function signature of the incoming argument and add control properties
       
   614 	// on the return value.
       
   615 
       
   616 	// @ts-ignore
       
   617 	return memoized;
       
   618 }
       
   619 
       
   620 module.exports = memize;
       
   621 
       
   622 
       
   623 /***/ }),
       
   624 
       
   625 /***/ "YLtl":
       
   626 /***/ (function(module, exports) {
       
   627 
       
   628 (function() { module.exports = window["lodash"]; }());
       
   629 
       
   630 /***/ })
       
   631 
       
   632 /******/ })["default"];