Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 20, 2022
1 parent 1271134 commit 5b9486c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
27 changes: 27 additions & 0 deletions src/config/normalize/lib/wild_wild_path/reduce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { list } from './get.js'

// Modify a target object multiple times for each matched property.
export const reduceParents = function ({
target,
query,
setFunc,
missing,
leaves,
classes,
inherited,
}) {
const entries = list(target, query, {
childFirst: false,
roots: !leaves,
leaves,
sort: false,
missing,
entries: true,
classes,
inherited,
})
return entries.reduce(
(targetA, { path }) => setFunc(targetA, path, 0),
target,
)
}
3 changes: 2 additions & 1 deletion src/config/normalize/lib/wild_wild_path/remove.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { reduceParents, setValue } from './set.js'
import { reduceParents } from './reduce.js'
import { setValue } from './set.js'
import { validateClasses } from './validate.js'

// Same as `set()` but removing a value
Expand Down
28 changes: 1 addition & 27 deletions src/config/normalize/lib/wild_wild_path/set.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { list } from './get.js'
import { getMissingValue } from './iterate/missing.js'
import { reduceParents } from './reduce.js'
import { validateClasses } from './validate.js'

// Set a value to one or multiple properties in `target` using a query string.
Expand All @@ -26,32 +26,6 @@ export const set = function (
})
}

// Modify a target object multiple times for each matched property.
export const reduceParents = function ({
target,
query,
setFunc,
missing,
leaves,
classes,
inherited,
}) {
const entries = list(target, query, {
childFirst: false,
roots: !leaves,
leaves,
sort: false,
missing,
entries: true,
classes,
inherited,
})
return entries.reduce(
(targetA, { path }) => setFunc(targetA, path, 0),
target,
)
}

// Use positional arguments for performance
// eslint-disable-next-line max-params
const setEntry = function (
Expand Down

0 comments on commit 5b9486c

Please sign in to comment.