Skip to content

Commit

Permalink
Fix filter-obj
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jul 23, 2022
1 parent f3770dc commit 956a32b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/bin/parse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import filterObj from 'filter-obj'
import { excludeKeys } from 'filter-obj'
import { map } from 'wild-wild-utils'

import { mapValues } from '../utils/map.js'
Expand All @@ -15,7 +15,7 @@ export const parseCliFlags = function (yargs) {
_: [command = DEFAULT_COMMAND],
...configFlags
} = yargs.parse()
const configFlagsA = filterObj(configFlags, isUserProp)
const configFlagsA = excludeKeys(configFlags, isInternalProp)
const configFlagsB = mapValues(configFlagsA, handleEmptyArr)
const configFlagsC = transtypeCliFlags(configFlagsB)
return { command, configFlags: configFlagsC }
Expand All @@ -26,8 +26,8 @@ const DEFAULT_COMMAND = 'run'
// Remove `yargs`-specific properties and shortcuts.
// We do not remove dasherized properties because user-defined identifiers can
// use dashes and we disable yargs' `camel-case-expansion`.
const isUserProp = function (key, value) {
return value !== undefined && !INTERNAL_KEYS.has(key) && key.length !== 1
const isInternalProp = function (key, value) {
return value === undefined || INTERNAL_KEYS.has(key) || key.length === 1
}

const INTERNAL_KEYS = new Set(['help', 'version', '_', '$0'])
Expand Down
8 changes: 4 additions & 4 deletions src/config/normalize/lib/options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inspect } from 'util'

import filterObj from 'filter-obj'
import { excludeKeys } from 'filter-obj'
import isPlainObj from 'is-plain-obj'

import { DefinitionError } from './error.js'
Expand Down Expand Up @@ -44,7 +44,7 @@ const normalizeAll = function (all, ruleProps, sync) {
)
}

const allA = filterObj(all, isDefined)
const allA = excludeKeys(all, isUndefined)
validateRuleProps({
definitions: allA,
ruleProps,
Expand All @@ -54,6 +54,6 @@ const normalizeAll = function (all, ruleProps, sync) {
return allA
}

const isDefined = function (key, value) {
return value !== undefined
const isUndefined = function (key, value) {
return value === undefined
}
7 changes: 3 additions & 4 deletions src/top/omit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { includeKeys } from 'filter-obj'
import omit from 'omit.js'

import { pick } from '../utils/pick.js'

// We only expose specific properties to reporters.
// For example, we do not expose subId.
export const pickTopProps = function (result) {
return pick(result, REPORTED_TOP_PROPS)
return includeKeys(result, REPORTED_TOP_PROPS)
}

const REPORTED_TOP_PROPS = [
Expand All @@ -20,7 +19,7 @@ const REPORTED_TOP_PROPS = [
// Same as `pickToProps()` but for combinations
export const pickCombProps = function (result) {
const combinations = result.combinations.map((combination) =>
pick(combination, REPORTED_COMB_PROPS),
includeKeys(combination, REPORTED_COMB_PROPS),
)
return { ...result, combinations }
}
Expand Down
4 changes: 2 additions & 2 deletions src/top/system/merge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import filterObj from 'filter-obj'
import { includeKeys } from 'filter-obj'

import { hasPrefix, removePrefix } from '../../combination/prefix.js'
import { groupBy } from '../../utils/group.js'
Expand All @@ -25,7 +25,7 @@ export const mergeSystems = function ({ combinations }) {
}

const getCombinationSystem = function ({ dimensions, system, versions }) {
const dimensionsA = filterObj(dimensions, isSystemDimension)
const dimensionsA = includeKeys(dimensions, isSystemDimension)
const dimensionsB = mapKeys(dimensionsA, removeSystemPrefix)
const dimensionsC = mapValues(dimensionsB, useDimensionId)
return { ...system, versions, dimensions: dimensionsC }
Expand Down
6 changes: 0 additions & 6 deletions src/utils/pick.js

This file was deleted.

0 comments on commit 956a32b

Please sign in to comment.