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 5.0.5 to 5.1.0-beta.1

dist/are-inputs-equal.d.ts

67

dist/memoize-one.cjs.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function areInputsEqual(newInputs, lastInputs) {
if (newInputs.length !== lastInputs.length) {
return false;
}
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
if (newInputs.length !== lastInputs.length) {
return false;
}
}
return true;
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
}
}
return true;
}
function memoizeOne(resultFn, isEqual) {
if (isEqual === void 0) {
isEqual = areInputsEqual;
}
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
var result = function memoized() {
for (var _len = arguments.length, newArgs = new Array(_len), _key = 0; _key < _len; _key++) {
newArgs[_key] = arguments[_key];
if (isEqual === void 0) { isEqual = areInputsEqual; }
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
function memoized() {
var newArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
newArgs[_i] = arguments[_i];
}
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
}
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
};
return result;
return memoized;
}
module.exports = memoizeOne;
exports.default = memoizeOne;
exports.memoizeOne = memoizeOne;
function areInputsEqual(newInputs, lastInputs) {
if (newInputs.length !== lastInputs.length) {
return false;
}
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
if (newInputs.length !== lastInputs.length) {
return false;
}
}
return true;
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
}
}
return true;
}
function memoizeOne(resultFn, isEqual) {
if (isEqual === void 0) {
isEqual = areInputsEqual;
}
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
var result = function memoized() {
for (var _len = arguments.length, newArgs = new Array(_len), _key = 0; _key < _len; _key++) {
newArgs[_key] = arguments[_key];
if (isEqual === void 0) { isEqual = areInputsEqual; }
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
function memoized() {
var newArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
newArgs[_i] = arguments[_i];
}
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
}
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
};
return result;
return memoized;
}
export default memoizeOne;
export { memoizeOne };
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.memoizeOne = factory());
}(this, function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.memoizeOne = {}));
}(this, function (exports) { 'use strict';
function areInputsEqual(newInputs, lastInputs) {
if (newInputs.length !== lastInputs.length) {
return false;
}
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
if (newInputs.length !== lastInputs.length) {
return false;
}
}
return true;
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
}
}
return true;
}
function memoizeOne(resultFn, isEqual) {
if (isEqual === void 0) {
isEqual = areInputsEqual;
}
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
var result = function memoized() {
for (var _len = arguments.length, newArgs = new Array(_len), _key = 0; _key < _len; _key++) {
newArgs[_key] = arguments[_key];
if (isEqual === void 0) { isEqual = areInputsEqual; }
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
function memoized() {
var newArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
newArgs[_i] = arguments[_i];
}
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
}
return memoized;
}
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
exports.default = memoizeOne;
exports.memoizeOne = memoizeOne;
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
};
Object.defineProperty(exports, '__esModule', { value: true });
return result;
}
return memoizeOne;
}));

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

!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";function e(e,n){if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}return function(r,i){var f;void 0===i&&(i=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&&f===this&&i(n,u)||(o=r.apply(this,n),d=!0,f=this,u=n),o}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).memoizeOne={})}(this,function(e){"use strict";function t(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function n(n,r){var i;void 0===r&&(r=t);var o,f=[],u=!1;return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return u&&i===this&&r(e,f)||(o=n.apply(this,e),u=!0,i=this,f=e),o}}e.default=n,e.memoizeOne=n,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "memoize-one",
"version": "5.0.5",
"version": "5.1.0-beta.1",
"description": "A memoization library which only remembers the latest invocation",
"main": "dist/memoize-one.cjs.js",
"types": "dist/memoize-one.d.ts",
"module": "dist/memoize-one.esm.js",

@@ -26,44 +27,46 @@ "sideEffects": false,

"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.2",
"@babel/preset-flow": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "10.0.2",
"babel-jest": "^24.8.0",
"@types/jest": "^24.0.18",
"@types/lodash.isequal": "^4.5.5",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"benchmark": "^2.1.4",
"cross-env": "^5.2.0",
"eslint": "6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-flowtype": "^3.11.1",
"eslint-plugin-jest": "^22.7.2",
"eslint": "6.2.0",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-jest": "^22.15.1",
"eslint-plugin-prettier": "^3.1.0",
"flow-bin": "0.102.0",
"jest": "^24.8.0",
"flow-bin": "^0.105.2",
"jest": "^24.9.0",
"lodash.isequal": "^4.5.0",
"prettier": "1.18.2",
"rimraf": "2.6.3",
"rollup": "^1.16.6",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.1",
"rimraf": "3.0.0",
"rollup": "^1.19.4",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2"
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-uglify": "^6.0.2",
"ts-jest": "^24.0.2",
"ts-node": "^8.3.0",
"tslib": "^1.10.0",
"typescript": "^3.5.3"
},
"config": {
"prettier_target": "*.{js,jsx,md,json} src/**/*.{js,jsx,md,json} test/**/*.{js,jsx,md,json}"
"prettier_target": "src/**/*.{ts,js,jsx,md,json} test/**/*.{ts,js,jsx,md,json}"
},
"scripts": {
"validate": "yarn run lint && yarn run typecheck",
"test": "cross-env NODE_ENV=test jest",
"typecheck": "flow check",
"validate": "yarn lint && yarn typecheck",
"test": "yarn jest",
"typecheck": "yarn tsc --noEmit",
"prettier:check": "yarn prettier --debug-check $npm_package_config_prettier_target",
"prettier:write": "yarn prettier --write $npm_package_config_prettier_target",
"lint:eslint": "eslint src test",
"lint:eslint": "eslint $npm_package_config_prettier_target",
"lint": "yarn lint:eslint && yarn prettier:check",
"build": "yarn run build:clean && yarn run build:dist && yarn run build:flow",
"build": "yarn build:clean && yarn build:dist && yarn build:typescript && yarn build:flow",
"build:clean": "rimraf dist",
"build:dist": "rollup -c",
"build:flow": "echo \"// @flow\n\nexport * from '../src';\" > dist/memoize-one.cjs.js.flow",
"perf": "node ./benchmarks/shallowEqual.js",
"prepublish": "yarn run build"
"build:typescript": "tsc ./src/memoize-one.ts --emitDeclarationOnly --declaration --outDir ./dist",
"build:flow": "cp src/memoize-one.js.flow dist/memoize-one.cjs.js.flow",
"perf": "ts-node ./benchmarks/shallow-equal.ts",
"prepublishOnly": "yarn build"
}
}

@@ -83,10 +83,5 @@ # memoize-one

```js
const simpleIsEqual: EqualityFn = (
newArgs: mixed[],
lastArgs: mixed[],
): boolean =>
const simpleIsEqual: EqualityFn = (newArgs: mixed[], lastArgs: mixed[]): boolean =>
newArgs.length === lastArgs.length &&
newArgs.every((newArg: mixed, index: number): boolean =>
shallowEqual(newArg, lastArgs[index]),
);
newArgs.every((newArg: mixed, index: number): boolean => shallowEqual(newArg, lastArgs[index]));
```

@@ -93,0 +88,0 @@

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