Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.memoize

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.memoize - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

LICENSE.txt

135

index.js

@@ -1,10 +0,2 @@

/**
* lodash 3.1.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var MapCache = require('lodash._mapcache');
/** Used as the `TypeError` message for "Functions" methods. */

@@ -14,8 +6,83 @@ /** Used as the `TypeError` message for "Functions" methods. */

/** Used for native method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates a cache object to store key/value pairs.
*
* @private
* @static
* @name Cache
* @memberOf _.memoize
*/
function MapCache() {
this.__data__ = {};
}
/**
* Removes `key` and its value from the cache.
*
* @private
* @name delete
* @memberOf _.memoize.Cache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed successfully, else `false`.
*/
function mapDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the cached value for `key`.
*
* @private
* @name get
* @memberOf _.memoize.Cache
* @param {string} key The key of the value to get.
* @returns {*} Returns the cached value.
*/
function mapGet(key) {
return key == '__proto__' ? undefined : this.__data__[key];
}
/**
* Checks if a cached value for `key` exists.
*
* @private
* @name has
* @memberOf _.memoize.Cache
* @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) {
return key != '__proto__' && hasOwnProperty.call(this.__data__, key);
}
/**
* Sets `value` to `key` of the cache.
*
* @private
* @name set
* @memberOf _.memoize.Cache
* @param {string} key The key of the value to cache.
* @param {*} value The value to cache.
* @returns {Object} Returns the cache object.
*/
function mapSet(key, value) {
if (key != '__proto__') {
this.__data__[key] = value;
}
return this;
}
/**
* 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.
* provided to the memoized function is coerced to a string and used as the
* cache key. The `func` is invoked with the `this` binding of the memoized
* function.
*

@@ -25,3 +92,3 @@ * **Note:** The cache is exposed as the `cache` property on the memoized

* 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`.
* method interface of `get`, `has`, and `set`.
*

@@ -36,23 +103,31 @@ * @static

*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
* var upperCase = _.memoize(function(string) {
* return string.toUpperCase();
* });
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
* upperCase('fred');
* // => 'FRED'
*
* values(other);
* // => [3, 4]
* // modifying the result cache
* upperCase.cache.set('fred', 'BARNEY');
* upperCase('fred');
* // => 'BARNEY'
*
* object.a = 2;
* values(object);
* // => [1, 2]
* // replacing `_.memoize.Cache`
* var object = { 'user': 'fred' };
* var other = { 'user': 'barney' };
* var identity = _.memoize(_.identity);
*
* // modifying the result cache
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
* identity(object);
* // => { 'user': 'fred' }
* identity(other);
* // => { 'user': 'fred' }
*
* // replacing `_.memoize.Cache`
* _.memoize.Cache = WeakMap;
* var identity = _.memoize(_.identity);
*
* identity(object);
* // => { 'user': 'fred' }
* identity(other);
* // => { 'user': 'barney' }
*/

@@ -79,2 +154,8 @@ function memoize(func, resolver) {

// Add functions to the `Map` cache.
MapCache.prototype['delete'] = mapDelete;
MapCache.prototype.get = mapGet;
MapCache.prototype.has = mapHas;
MapCache.prototype.set = mapSet;
// Assign cache to `_.memoize`.

@@ -81,0 +162,0 @@ memoize.Cache = MapCache;

15

package.json
{
"name": "lodash.memoize",
"version": "3.1.0",
"description": "The lodash method `_.memoize` exported as a module.",
"version": "3.1.1",
"description": "The modern build of lodash’s `_.memoize` as a module.",
"homepage": "https://lodash.com/",
"icon": "https://lodash.com/icon.svg",
"license": "MIT",
"keywords": "lodash, lodash-modularized, stdlib, util, memoize",
"keywords": "lodash, lodash-modularized, stdlib, util",
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
"contributors": [
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
"Blaine Bublitz <blaine@iceddev.com> (https://github.com/phated)",
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)",
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)",
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)",
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
],
"repository": "lodash/lodash",
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" },
"dependencies": {
"lodash._mapcache": "^3.0.0"
}
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }
}

@@ -1,4 +0,4 @@

# lodash.memoize v3.1.0
# lodash.memoize v3.1.1
The [lodash](https://lodash.com/) method `_.memoize` exported as a [Node.js](https://nodejs.org/) module.
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.memoize` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.

@@ -8,2 +8,3 @@ ## Installation

Using npm:
```bash

@@ -14,3 +15,4 @@ $ {sudo -H} npm i -g npm

In Node.js:
In Node.js/io.js:
```js

@@ -20,2 +22,2 @@ var memoize = require('lodash.memoize');

See the [documentation](https://lodash.com/docs#memoize) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.memoize) for more details.
See the [documentation](https://lodash.com/docs#memoize) or [package source](https://github.com/lodash/lodash/blob/3.1.1-npm-packages/lodash.memoize) for more details.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc