Skip to content

Commit

Permalink
chore(linter): fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Dec 4, 2019
1 parent 8d8efde commit 9e7880b
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const applyDiffWithCreateQueriesFromPatch = (
*/
export const applyFlatConfigToState = (
config: MappedConfig,
queryValues: {readonly [index: string]:any},
queryValues: { readonly [index: string]: any },
ns: string,
state: object,
initialState: object
Expand Down Expand Up @@ -142,32 +142,37 @@ export const applyFlatConfigToState = (
* that can be used to generate a query string.
* @return a key/value object with the object containing the defined parameters as key.
*/
export const flattenConfig =
(config: Config, path: readonly string[] = []): MappedConfig => {
return Object.keys(config).reduce((next: {readonly [index: string]:any}, key) => {
const v = config[key]
const nextPath: ReadonlyArray<string> = [...path, key]
if (typeof v === 'function') {
const { name, ...rest } = v()
if (next[name] !== undefined) {
throw new Error(
`Config invalid: Multiple definitions found for ${name}.`
)
}
return {
...next,
[name]: {
path: nextPath,
...rest
export const flattenConfig = (
config: Config,
path: readonly string[] = []
): MappedConfig => {
return Object.keys(config).reduce(
(next: { readonly [index: string]: any }, key) => {
const v = config[key]
const nextPath: ReadonlyArray<string> = [...path, key]
if (typeof v === 'function') {
const { name, ...rest } = v()
if (next[name] !== undefined) {
throw new Error(
`Config invalid: Multiple definitions found for ${name}.`
)
}
return {
...next,
[name]: {
path: nextPath,
...rest
}
}
}
}
if (typeof v === 'object') {
return {
...next,
...flattenConfig(v, nextPath)
if (typeof v === 'object') {
return {
...next,
...flattenConfig(v, nextPath)
}
}
}
return next
}, {})
return next
},
{}
)
}

0 comments on commit 9e7880b

Please sign in to comment.