Skip to content

Commit 4927ff2

Browse files
committed
Add Prettier config file and format index
1 parent 6770550 commit 4927ff2

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "none",
6+
"arrowParens": "avoid"
7+
}

src/index.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ function getDependencies(funcs) {
3737
const dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs
3838

3939
if (!dependencies.every(dep => typeof dep === 'function')) {
40-
const dependencyTypes = dependencies.map(
41-
dep => typeof dep
42-
).join(', ')
40+
const dependencyTypes = dependencies.map(dep => typeof dep).join(', ')
4341
throw new Error(
4442
'Selector creators expect all input-selectors to be functions, ' +
45-
`instead received the following types: [${dependencyTypes}]`
43+
`instead received the following types: [${dependencyTypes}]`
4644
)
4745
}
4846

@@ -55,14 +53,11 @@ export function createSelectorCreator(memoize, ...memoizeOptions) {
5553
const resultFunc = funcs.pop()
5654
const dependencies = getDependencies(funcs)
5755

58-
const memoizedResultFunc = memoize(
59-
function () {
60-
recomputations++
61-
// apply arguments instead of spreading for performance.
62-
return resultFunc.apply(null, arguments)
63-
},
64-
...memoizeOptions
65-
)
56+
const memoizedResultFunc = memoize(function () {
57+
recomputations++
58+
// apply arguments instead of spreading for performance.
59+
return resultFunc.apply(null, arguments)
60+
}, ...memoizeOptions)
6661

6762
// If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
6863
const selector = memoize(function () {
@@ -81,18 +76,22 @@ export function createSelectorCreator(memoize, ...memoizeOptions) {
8176
selector.resultFunc = resultFunc
8277
selector.dependencies = dependencies
8378
selector.recomputations = () => recomputations
84-
selector.resetRecomputations = () => recomputations = 0
79+
selector.resetRecomputations = () => (recomputations = 0)
8580
return selector
8681
}
8782
}
8883

89-
export const createSelector = /* #__PURE__ */ createSelectorCreator(defaultMemoize)
84+
export const createSelector =
85+
/* #__PURE__ */ createSelectorCreator(defaultMemoize)
9086

91-
export function createStructuredSelector(selectors, selectorCreator = createSelector) {
87+
export function createStructuredSelector(
88+
selectors,
89+
selectorCreator = createSelector
90+
) {
9291
if (typeof selectors !== 'object') {
9392
throw new Error(
9493
'createStructuredSelector expects first argument to be an object ' +
95-
`where each property is a selector, instead received a ${typeof selectors}`
94+
`where each property is a selector, instead received a ${typeof selectors}`
9695
)
9796
}
9897
const objectKeys = Object.keys(selectors)

0 commit comments

Comments
 (0)