memoize-one
Advanced tools
Comparing version 5.0.0 to 5.0.1
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
global.memoizeOne = factory(); | ||
}(typeof self !== 'undefined' ? self : this, function () { 'use strict'; | ||
(global = global || self, global.memoizeOne = factory()); | ||
}(this, function () { 'use strict'; | ||
@@ -7,0 +7,0 @@ var shallowEqual = function shallowEqual(newValue, oldValue) { |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.memoizeOne=n()}("undefined"!=typeof self?self:this,function(){"use strict";var e=function(e,f){return e.length===f.length&&e.every(function(e,n){return t=e,r=f[n],t===r;var t,r})};return function(r,f){var i;void 0===f&&(f=e);var o,u=[],d=!1;return function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return d&&i===this&&f(n,u)||(o=r.apply(this,n),d=!0,i=this,u=n),o}}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).memoizeOne=n()}(this,function(){"use strict";var e=function(e,i){return e.length===i.length&&e.every(function(e,n){return t=e,r=i[n],t===r;var t,r})};return function(r,i){var o;void 0===i&&(i=e);var f,u=[],c=!1;return function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return c&&o===this&&i(n,u)||(f=r.apply(this,n),c=!0,o=this,u=n),f}}}); |
{ | ||
"name": "memoize-one", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "A memoization library which only remembers the latest invocation", | ||
@@ -26,24 +26,24 @@ "main": "dist/memoize-one.cjs.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/preset-env": "^7.2.0", | ||
"@babel/core": "^7.4.0", | ||
"@babel/preset-env": "^7.4.2", | ||
"@babel/preset-flow": "^7.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "10.0.1", | ||
"babel-jest": "^23.6.0", | ||
"babel-jest": "^24.5.0", | ||
"cross-env": "^5.2.0", | ||
"eslint": "5.10.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-plugin-flowtype": "^3.2.0", | ||
"eslint-plugin-jest": "^22.1.2", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"flow-bin": "0.89.0", | ||
"jest": "^23.6.0", | ||
"eslint": "5.15.3", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-flowtype": "^3.4.2", | ||
"eslint-plugin-jest": "^22.4.1", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"flow-bin": "0.95.1", | ||
"jest": "^24.5.0", | ||
"lodash.isequal": "^4.5.0", | ||
"prettier": "1.15.3", | ||
"rimraf": "2.6.2", | ||
"rollup": "^0.68.0", | ||
"rollup-plugin-babel": "^4.1.0", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-replace": "^2.1.0", | ||
"rollup-plugin-uglify": "^6.0.0" | ||
"prettier": "1.16.4", | ||
"rimraf": "2.6.3", | ||
"rollup": "^1.7.3", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^9.2.2", | ||
"rollup-plugin-replace": "^2.1.1", | ||
"rollup-plugin-uglify": "^6.0.2" | ||
}, | ||
@@ -50,0 +50,0 @@ "config": { |
@@ -80,3 +80,3 @@ # memoize-one | ||
The default equality function is a shallow equal check of all arguments (each argument is compared with `===`). The default equality function also does not check anything if the length of the arguments changes. You are welcome to decide if you want to return `false` if the `length` of the arguments is not equal | ||
The default equality function is a shallow equal check of all arguments (each argument is compared with `===`). If the `length` of arguments change, then the default equality function makes no shallow equality checks. You are welcome to decide if you want to return `false` if the `length` of the arguments is not equal | ||
@@ -83,0 +83,0 @@ ```js |
@@ -17,9 +17,9 @@ // @flow | ||
// <ResultFn: (...Array<any>) => mixed> | ||
// <ResultFn: (...any[]) => mixed> | ||
// The purpose of this typing is to ensure that the returned memoized | ||
// function has the same type as the provided function (`resultFn`). | ||
// ResultFn: Generic type (which is the same as the resultFn). | ||
// (...Array<any>): Accepts any length of arguments - and they are not checked | ||
// (...any[]): Accepts any length of arguments - and they are not checked | ||
// mixed: The result can be anything but needs to be checked before usage | ||
export default function<ResultFn: (...Array<any>) => mixed>( | ||
export default function<ResultFn: (...any[]) => mixed>( | ||
resultFn: ResultFn, | ||
@@ -29,3 +29,3 @@ isEqual?: EqualityFn = simpleIsEqual, | ||
let lastThis: mixed; | ||
let lastArgs: Array<mixed> = []; | ||
let lastArgs: mixed[] = []; | ||
let lastResult: mixed; | ||
@@ -35,3 +35,4 @@ let calledOnce: boolean = false; | ||
// breaking cache when context (this) or arguments change | ||
const result = function(...newArgs: Array<mixed>) { | ||
// $ExpectError - faking the type of ResultFn | ||
const result: ResultFn = function(...newArgs: mixed[]) { | ||
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) { | ||
@@ -51,4 +52,3 @@ return lastResult; | ||
// telling flow to ignore the type of `result` as we know it is `ResultFn` | ||
return (result: any); | ||
return result; | ||
} |
Sorry, the diff of this file is not supported yet
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
17455
149