Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bumping deps. naming functions #68

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ const simpleIsEqual: EqualityFn = (
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]),
);
```

Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
],
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"@babel/preset-flow": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "^24.7.1",
"babel-eslint": "10.0.2",
"babel-jest": "^24.8.0",
"benchmark": "^2.1.4",
"cross-env": "^5.2.0",
"eslint": "5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-flowtype": "^3.5.1",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-prettier": "^3.0.1",
"flow-bin": "0.96.0",
"jest": "^24.7.1",
"eslint": "6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-flowtype": "^3.11.1",
"eslint-plugin-jest": "^22.7.2",
"eslint-plugin-prettier": "^3.1.0",
"flow-bin": "0.102.0",
"jest": "^24.8.0",
"lodash.isequal": "^4.5.0",
"prettier": "1.16.4",
"prettier": "1.18.2",
"rimraf": "2.6.3",
"rollup": "^1.9.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-replace": "^2.1.1",
"rollup": "^1.16.6",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2"
},
"config": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type EqualityFn = (newArgs: mixed[], lastArgs: mixed[]) => boolean;
// ResultFn: Generic type (which is the same as the resultFn).
// (...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: (...any[]) => mixed>(
export default function memoizeOne<ResultFn: (...any[]) => mixed>(
resultFn: ResultFn,
isEqual?: EqualityFn = areInputsEqual,
): ResultFn {
Expand All @@ -19,7 +19,7 @@ export default function<ResultFn: (...any[]) => mixed>(
let calledOnce: boolean = false;

// breaking cache when context (this) or arguments change
const result = function(...newArgs: mixed[]) {
const result = function memoized(...newArgs: mixed[]) {
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
return lastResult;
}
Expand Down
5 changes: 2 additions & 3 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,8 @@ describe('memoizeOne', () => {

const addAges = jest
.fn()
.mockImplementation(
(...people: Person[]): number =>
people.reduce((sum: number, person: Person) => sum + person.age, 0),
.mockImplementation((...people: Person[]): number =>
people.reduce((sum: number, person: Person) => sum + person.age, 0),
);
const memoized = memoizeOne(addAges, isDeepEqual);

Expand Down
Loading