Skip to content

Commit 2a18415

Browse files
committed
Simplify parameter normalizing
1 parent c44e445 commit 2a18415

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import arrayToObject from './lib/array-to-object';
22

33
function normalizeNamespace(fn) {
4-
return (namespace, map, getterType, mutationType) => {
5-
/* eslint-disable no-param-reassign */
6-
if (typeof namespace !== `string`) {
7-
mutationType = getterType;
8-
getterType = map;
9-
map = namespace;
10-
namespace = ``;
11-
} else if (namespace.charAt(namespace.length - 1) !== `/`) {
4+
return (...params) => {
5+
// eslint-disable-next-line prefer-const
6+
let [namespace, map, getterType, mutationType] =
7+
typeof params[0] === `string` ? [...params] : [``, ...params];
8+
9+
if (namespace.length && namespace.charAt(namespace.length - 1) !== `/`) {
1210
namespace += `/`;
1311
}
1412

1513
getterType = `${namespace}${getterType || `getField`}`;
1614
mutationType = `${namespace}${mutationType || `updateField`}`;
17-
/* eslint-enable */
1815

1916
return fn(namespace, map, getterType, mutationType);
2017
};

0 commit comments

Comments
 (0)