Skip to content

Instantly share code, notes, and snippets.

@ryan-roemer
Last active February 24, 2016 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-roemer/12dcf16efe85f3a28588 to your computer and use it in GitHub Desktop.
Save ryan-roemer/12dcf16efe85f3a28588 to your computer and use it in GitHub Desktop.
Simple JS file with lodash memoize.
// Here is the output bundle with filepaths included to see what _also_
// comes in with memoize.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
"use strict";
var _memoize = __webpack_require__(/*! lodash/memoize */ 1);
var _memoize2 = _interopRequireDefault(_memoize);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var foo = (0, _memoize2.default)(function (x) {
return "foo";
});
foo();
foo();
/***/ },
/* 1 */
/*!*****************************!*\
!*** ./~/lodash/memoize.js ***!
\*****************************/
/***/ function(module, exports, __webpack_require__) {
var MapCache = __webpack_require__(/*! ./_MapCache */ 2);
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoizing function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result);
return result;
};
memoized.cache = new memoize.Cache;
return memoized;
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
module.exports = memoize;
/***/ },
/* 2 */
/*!*******************************!*\
!*** ./~/lodash/_MapCache.js ***!
\*******************************/
/***/ function(module, exports, __webpack_require__) {
var mapClear = __webpack_require__(/*! ./_mapClear */ 3),
mapDelete = __webpack_require__(/*! ./_mapDelete */ 16),
mapGet = __webpack_require__(/*! ./_mapGet */ 23),
mapHas = __webpack_require__(/*! ./_mapHas */ 26),
mapSet = __webpack_require__(/*! ./_mapSet */ 28);
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function MapCache(values) {
var index = -1,
length = values ? values.length : 0;
this.clear();
while (++index < length) {
var entry = values[index];
this.set(entry[0], entry[1]);
}
}
// Add functions to the `MapCache`.
MapCache.prototype.clear = mapClear;
MapCache.prototype['delete'] = mapDelete;
MapCache.prototype.get = mapGet;
MapCache.prototype.has = mapHas;
MapCache.prototype.set = mapSet;
module.exports = MapCache;
/***/ },
/* 3 */
/*!*******************************!*\
!*** ./~/lodash/_mapClear.js ***!
\*******************************/
/***/ function(module, exports, __webpack_require__) {
var Hash = __webpack_require__(/*! ./_Hash */ 4),
Map = __webpack_require__(/*! ./_Map */ 12);
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapClear() {
this.__data__ = {
'hash': new Hash,
'map': Map ? new Map : [],
'string': new Hash
};
}
module.exports = mapClear;
/***/ },
/* 4 */
/*!***************************!*\
!*** ./~/lodash/_Hash.js ***!
\***************************/
/***/ function(module, exports, __webpack_require__) {
var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ 5);
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Creates an hash object.
*
* @private
* @constructor
* @returns {Object} Returns the new hash object.
*/
function Hash() {}
// Avoid inheriting from `Object.prototype` when possible.
Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto;
module.exports = Hash;
/***/ },
/* 5 */
/*!***********************************!*\
!*** ./~/lodash/_nativeCreate.js ***!
\***********************************/
/***/ function(module, exports, __webpack_require__) {
var getNative = __webpack_require__(/*! ./_getNative */ 6);
/* Built-in method references that are verified to be native. */
var nativeCreate = getNative(Object, 'create');
module.exports = nativeCreate;
/***/ },
/* 6 */
/*!********************************!*\
!*** ./~/lodash/_getNative.js ***!
\********************************/
/***/ function(module, exports, __webpack_require__) {
var isNative = __webpack_require__(/*! ./isNative */ 7);
/**
* 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 = object == null ? undefined : object[key];
return isNative(value) ? value : undefined;
}
module.exports = getNative;
/***/ },
/* 7 */
/*!******************************!*\
!*** ./~/lodash/isNative.js ***!
\******************************/
/***/ function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(/*! ./isFunction */ 8),
isHostObject = __webpack_require__(/*! ./_isHostObject */ 10),
isObjectLike = __webpack_require__(/*! ./isObjectLike */ 11);
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari > 5). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = Function.prototype.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/**
* Checks if `value` is a native function.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function, else `false`.
* @example
*
* _.isNative(Array.prototype.push);
* // => true
*
* _.isNative(_);
* // => false
*/
function isNative(value) {
if (value == null) {
return false;
}
if (isFunction(value)) {
return reIsNative.test(funcToString.call(value));
}
return isObjectLike(value) &&
(isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
}
module.exports = isNative;
/***/ },
/* 8 */
/*!********************************!*\
!*** ./~/lodash/isFunction.js ***!
\********************************/
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(/*! ./isObject */ 9);
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, 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 which returns 'object' for typed array constructors, and
// PhantomJS 1.9 which returns 'function' for `NodeList` instances.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
}
module.exports = isFunction;
/***/ },
/* 9 */
/*!******************************!*\
!*** ./~/lodash/isObject.js ***!
\******************************/
/***/ function(module, exports) {
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @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');
}
module.exports = isObject;
/***/ },
/* 10 */
/*!***********************************!*\
!*** ./~/lodash/_isHostObject.js ***!
\***********************************/
/***/ function(module, exports) {
/**
* 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;
}
module.exports = isHostObject;
/***/ },
/* 11 */
/*!**********************************!*\
!*** ./~/lodash/isObjectLike.js ***!
\**********************************/
/***/ function(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".
*
* @static
* @memberOf _
* @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';
}
module.exports = isObjectLike;
/***/ },
/* 12 */
/*!**************************!*\
!*** ./~/lodash/_Map.js ***!
\**************************/
/***/ function(module, exports, __webpack_require__) {
var getNative = __webpack_require__(/*! ./_getNative */ 6),
root = __webpack_require__(/*! ./_root */ 13);
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map');
module.exports = Map;
/***/ },
/* 13 */
/*!***************************!*\
!*** ./~/lodash/_root.js ***!
\***************************/
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module, global) {var checkGlobal = __webpack_require__(/*! ./_checkGlobal */ 15);
/** Used to determine if values are of the language type `Object`. */
var objectTypes = {
'function': true,
'object': true
};
/** Detect free variable `exports`. */
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
? exports
: undefined;
/** Detect free variable `module`. */
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
? module
: undefined;
/** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
/** Detect free variable `self`. */
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
/** Detect free variable `window`. */
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
/** Detect `this` as the global object. */
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
/**
* Used as a reference to the global object.
*
* The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
var root = freeGlobal ||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
freeSelf || thisGlobal || Function('return this')();
module.exports = root;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(/*! ./../webpack/buildin/module.js */ 14)(module), (function() { return this; }())))
/***/ },
/* 14 */
/*!***********************************!*\
!*** (webpack)/buildin/module.js ***!
\***********************************/
/***/ function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
/***/ },
/* 15 */
/*!**********************************!*\
!*** ./~/lodash/_checkGlobal.js ***!
\**********************************/
/***/ function(module, exports) {
/**
* Checks if `value` is a global object.
*
* @private
* @param {*} value The value to check.
* @returns {null|Object} Returns `value` if it's a global object, else `null`.
*/
function checkGlobal(value) {
return (value && value.Object === Object) ? value : null;
}
module.exports = checkGlobal;
/***/ },
/* 16 */
/*!********************************!*\
!*** ./~/lodash/_mapDelete.js ***!
\********************************/
/***/ function(module, exports, __webpack_require__) {
var Map = __webpack_require__(/*! ./_Map */ 12),
assocDelete = __webpack_require__(/*! ./_assocDelete */ 17),
hashDelete = __webpack_require__(/*! ./_hashDelete */ 20),
isKeyable = __webpack_require__(/*! ./_isKeyable */ 22);
/**
* 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 mapDelete(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashDelete(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map['delete'](key) : assocDelete(data.map, key);
}
module.exports = mapDelete;
/***/ },
/* 17 */
/*!**********************************!*\
!*** ./~/lodash/_assocDelete.js ***!
\**********************************/
/***/ function(module, exports, __webpack_require__) {
var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ 18);
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* Removes `key` and its value from the associative array.
*
* @private
* @param {Array} array The array to query.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function assocDelete(array, key) {
var index = assocIndexOf(array, key);
if (index < 0) {
return false;
}
var lastIndex = array.length - 1;
if (index == lastIndex) {
array.pop();
} else {
splice.call(array, index, 1);
}
return true;
}
module.exports = assocDelete;
/***/ },
/* 18 */
/*!***********************************!*\
!*** ./~/lodash/_assocIndexOf.js ***!
\***********************************/
/***/ function(module, exports, __webpack_require__) {
var eq = __webpack_require__(/*! ./eq */ 19);
/**
* Gets the index at which the first occurrence of `key` is found in `array`
* of key-value pairs.
*
* @private
* @param {Array} array The array to search.
* @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;
}
module.exports = assocIndexOf;
/***/ },
/* 19 */
/*!************************!*\
!*** ./~/lodash/eq.js ***!
\************************/
/***/ function(module, exports) {
/**
* Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @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 = { 'user': 'fred' };
* var other = { 'user': 'fred' };
*
* _.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);
}
module.exports = eq;
/***/ },
/* 20 */
/*!*********************************!*\
!*** ./~/lodash/_hashDelete.js ***!
\*********************************/
/***/ function(module, exports, __webpack_require__) {
var hashHas = __webpack_require__(/*! ./_hashHas */ 21);
/**
* Removes `key` and its value from the hash.
*
* @private
* @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(hash, key) {
return hashHas(hash, key) && delete hash[key];
}
module.exports = hashDelete;
/***/ },
/* 21 */
/*!******************************!*\
!*** ./~/lodash/_hashHas.js ***!
\******************************/
/***/ function(module, exports, __webpack_require__) {
var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ 5);
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Checks if a hash value for `key` exists.
*
* @private
* @param {Object} hash The hash to query.
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(hash, key) {
return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key);
}
module.exports = hashHas;
/***/ },
/* 22 */
/*!********************************!*\
!*** ./~/lodash/_isKeyable.js ***!
\********************************/
/***/ function(module, exports) {
/**
* 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 == 'number' || type == 'boolean' ||
(type == 'string' && value != '__proto__') || value == null;
}
module.exports = isKeyable;
/***/ },
/* 23 */
/*!*****************************!*\
!*** ./~/lodash/_mapGet.js ***!
\*****************************/
/***/ function(module, exports, __webpack_require__) {
var Map = __webpack_require__(/*! ./_Map */ 12),
assocGet = __webpack_require__(/*! ./_assocGet */ 24),
hashGet = __webpack_require__(/*! ./_hashGet */ 25),
isKeyable = __webpack_require__(/*! ./_isKeyable */ 22);
/**
* 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 mapGet(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashGet(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map.get(key) : assocGet(data.map, key);
}
module.exports = mapGet;
/***/ },
/* 24 */
/*!*******************************!*\
!*** ./~/lodash/_assocGet.js ***!
\*******************************/
/***/ function(module, exports, __webpack_require__) {
var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ 18);
/**
* Gets the associative array value for `key`.
*
* @private
* @param {Array} array The array to query.
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function assocGet(array, key) {
var index = assocIndexOf(array, key);
return index < 0 ? undefined : array[index][1];
}
module.exports = assocGet;
/***/ },
/* 25 */
/*!******************************!*\
!*** ./~/lodash/_hashGet.js ***!
\******************************/
/***/ function(module, exports, __webpack_require__) {
var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ 5);
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Gets the hash value for `key`.
*
* @private
* @param {Object} hash The hash to query.
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(hash, key) {
if (nativeCreate) {
var result = hash[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(hash, key) ? hash[key] : undefined;
}
module.exports = hashGet;
/***/ },
/* 26 */
/*!*****************************!*\
!*** ./~/lodash/_mapHas.js ***!
\*****************************/
/***/ function(module, exports, __webpack_require__) {
var Map = __webpack_require__(/*! ./_Map */ 12),
assocHas = __webpack_require__(/*! ./_assocHas */ 27),
hashHas = __webpack_require__(/*! ./_hashHas */ 21),
isKeyable = __webpack_require__(/*! ./_isKeyable */ 22);
/**
* 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 mapHas(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashHas(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map.has(key) : assocHas(data.map, key);
}
module.exports = mapHas;
/***/ },
/* 27 */
/*!*******************************!*\
!*** ./~/lodash/_assocHas.js ***!
\*******************************/
/***/ function(module, exports, __webpack_require__) {
var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ 18);
/**
* Checks if an associative array value for `key` exists.
*
* @private
* @param {Array} array The array to query.
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function assocHas(array, key) {
return assocIndexOf(array, key) > -1;
}
module.exports = assocHas;
/***/ },
/* 28 */
/*!*****************************!*\
!*** ./~/lodash/_mapSet.js ***!
\*****************************/
/***/ function(module, exports, __webpack_require__) {
var Map = __webpack_require__(/*! ./_Map */ 12),
assocSet = __webpack_require__(/*! ./_assocSet */ 29),
hashSet = __webpack_require__(/*! ./_hashSet */ 30),
isKeyable = __webpack_require__(/*! ./_isKeyable */ 22);
/**
* 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 object.
*/
function mapSet(key, value) {
var data = this.__data__;
if (isKeyable(key)) {
hashSet(typeof key == 'string' ? data.string : data.hash, key, value);
} else if (Map) {
data.map.set(key, value);
} else {
assocSet(data.map, key, value);
}
return this;
}
module.exports = mapSet;
/***/ },
/* 29 */
/*!*******************************!*\
!*** ./~/lodash/_assocSet.js ***!
\*******************************/
/***/ function(module, exports, __webpack_require__) {
var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ 18);
/**
* Sets the associative array `key` to `value`.
*
* @private
* @param {Array} array The array to modify.
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
*/
function assocSet(array, key, value) {
var index = assocIndexOf(array, key);
if (index < 0) {
array.push([key, value]);
} else {
array[index][1] = value;
}
}
module.exports = assocSet;
/***/ },
/* 30 */
/*!******************************!*\
!*** ./~/lodash/_hashSet.js ***!
\******************************/
/***/ function(module, exports, __webpack_require__) {
var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ 5);
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Sets the hash `key` to `value`.
*
* @private
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
*/
function hashSet(hash, key, value) {
hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
}
module.exports = hashSet;
/***/ }
/******/ ]);
// Here's a simple file, just using `memoize`.
import memoize from "lodash/memoize";
const foo = memoize((x) => "foo");
foo();
foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment