fast-memoize
Advanced tools
Comparing version 2.5.1 to 2.5.2
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
143
172
0
12400
6