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

memoize-one

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memoize-one - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

13

esm/index.js

@@ -7,10 +7,2 @@

var defineProperty = function defineProperty(target, property, value) {
return Object.defineProperty(target, property, {
writable: false,
configurable: true,
value: value
});
};
export default function (resultFn) {

@@ -44,8 +36,3 @@ var isEqual = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : simpleIsEqual;

defineProperty(result, 'length', resultFn.length);
var name = 'memoized_' + (resultFn.name || 'fn');
defineProperty(result, 'name', name);
return result;
}

15

lib/index.js

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

'use strict';
"use strict";

@@ -35,7 +35,2 @@ Object.defineProperty(exports, "__esModule", {

defineProperty(result, 'length', resultFn.length);
var name = 'memoized_' + (resultFn.name || 'fn');
defineProperty(result, 'name', name);
return result;

@@ -46,10 +41,2 @@ };

return a === b;
};
var defineProperty = function defineProperty(target, property, value) {
return Object.defineProperty(target, property, {
writable: false,
configurable: true,
value: value
});
};

2

package.json
{
"name": "memoize-one",
"version": "3.1.0",
"version": "3.1.1",
"description": "A memoization library which only remembers the latest invocation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -81,33 +81,2 @@ # memoizeOne

### Dynamic properties
The result function will have the same [`.length` property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) as the provided function.
```js
const add = (a, b) => a + b;
const memoizedAdd = memoizeOne(add);
memoizedAdd.length === 2; // true
```
- For debug purposes we add a [`.name` property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name) to the result function. If provided function has a name then the name will be `memoized_${yourFunction.name}`. Otherwise it will be `memoized_fn`. This assists in debugging memoized functions.
```js
// function has a name
const add = (a, b) => a + b;
// the original name is 'add'
add.name === 'add'; // true
// our new memoizedAdd function has a prefixed name
const memoizedAdd = memoizeOne(add);
memoizedAdd.name === 'memoized_add'; // true
```
```js
// function does not have a name
const memoizedInline = memoizeOne((a, b) => a + b);
memoizedInline.name === 'memoized_fn';
```
## Installation

@@ -114,0 +83,0 @@

@@ -6,9 +6,2 @@ // @flow

const defineProperty = (target: Object, property: string, value: mixed) =>
Object.defineProperty(target, property, {
writable: false,
configurable: true,
value: value,
});
// <ResultFn: (...Array<any>) => mixed>

@@ -44,13 +37,4 @@ // The purpose of this typing is to ensure that the returned memoized

// Adding a length property
// This is useful for some memoization checks that inspect the length of the function arguments
defineProperty(result, 'length', resultFn.length);
// Giving a useful name to the resulting function
// This is helpful for debug purposes
const name: string = `memoized_${resultFn.name || 'fn'}`;
defineProperty(result, 'name', name);
// telling flow to ignore the type of `result` as we know it is `ResultFn`
return (result: any);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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