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

fast-memoize

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-memoize - npm Package Compare versions

Comparing version 2.5.1 to 2.5.2

2

CHANGELOG.md

@@ -7,3 +7,3 @@ # Changelog

## [2.4.1] - 2018-06-28
## [2.5.1] - 2018-06-28
### Fixed

@@ -10,0 +10,0 @@ - Publish TypeScript annotations to npm package

{
"name": "fast-memoize",
"version": "2.5.1",
"version": "2.5.2",
"description": "Fastest memoization lib that supports N arguments",

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

@@ -106,9 +106,9 @@ <img src="http://rawgit.com/caiogondim/fast-memoize/master/img/icon.svg" width="100%" />

#### Spread arguments
#### Rest & Default Parameters
We check for `function.length` to get upfront the expected number of arguments
in order to use the fastest strategy. But with spread arguments we don't receive
the right number.
in order to use the fastest strategy. But when rest & default parameters are being used, we don't receive the right number of arguments ([see details](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length#Description)).
```js
// Rest parameter example
function multiply (multiplier, ...theArgs) {

@@ -120,5 +120,11 @@ return theArgs.map(function (element) {

multiply.length // => 1
// Default parameter example
function divide (element, divisor = 1) {
return divisor * element
}
divide.length // => 1
```
So if you use spread arguments, explicitly set the strategy to variadic.
So if you use [rest](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) & [default](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) parameters, explicitly set the strategy to variadic.

@@ -125,0 +131,0 @@ ```js

type Func = (...args: any[]) => any;
export interface Cache<K, V> {
get(key: K): V;
set(key: K, value: V): void;
has(key: K): boolean;
create: CacheCreateFunc<K, V>
}
interface CacheCreateFunc<K, V> {
(): {
get(key: K): V;
set(key: K, value: V): void;
has(key: K): boolean;
}
}
export type Serializer = (args: any[]) => string;

@@ -10,0 +16,0 @@

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