How to use the filter-obj function in filter-obj

To help you get started, we’ve selected a few filter-obj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ehmicky / autoserver / src / errors / standard.js View on Github external
export const getStandardError = function({ error, mInput }) {
  if (!error) {
    return
  }

  const errorA = normalizeError({ error })

  const errorB = fillError({ error: errorA, mInput })

  // Do not expose undefined values
  const errorC = filterObj(errorB, isDefined)
  return errorC
}
github ehmicky / gulp-execa / src / options / main.js View on Github external
const validateOpts = function({ opts, defaultOpts, forcedOpts }) {
  const exampleConfig = filterObj(
    { ...EXAMPLE_OPTS, ...defaultOpts },
    key => !hasOwnProperty.call(forcedOpts, key),
  )

  try {
    validate(opts, { exampleConfig, recursiveBlacklist: ['env'] })
  } catch (error) {
    // `jest-validate` `error.stack` just repeats `error.message`
    throwError(error, { showStack: false })
  }

  validateCustom({ opts })
}
github ehmicky / nve / src / path.js View on Github external
export const fixPath = function({
  nodePath,
  spawnOptions,
  spawnOptions: { env, cwd },
}) {
  const npmRunPathOpts = filterObj({ env, cwd, execPath: nodePath }, isDefined)
  const envA = npmRunPath.env(npmRunPathOpts)
  return { ...spawnOptions, env: envA, preferLocal: false }
}
github ehmicky / log-process-errors / src / options / main.js View on Github external
export const getOptions = function({ opts = {} }) {
  const optsA = filterObj(opts, isDefined)

  validate(optsA, { exampleConfig: EXAMPLE_OPTS })
  validateOptions(optsA)

  const optsB = applyTesting({ opts: optsA })
  const level = applyDefaultLevels({ opts: optsB })
  const optsC = { ...DEFAULT_OPTS, ...optsB, level }

  const optsD = addChalk({ opts: optsC })
  return optsD
}
github ehmicky / autoserver / src / config / reducers / syntax / main.js View on Github external
const removeDatum = function(obj) {
  if (!isObject(obj)) {
    return obj
  }

  return filterObj(obj, hasNoData)
}
github ehmicky / autoserver / src / middleware / request_response / transform / common.js View on Github external
const filterTransforms = function({ condition, transforms, ...rest }) {
  if (condition === undefined) {
    return transforms
  }

  const transformsA = filterObj(transforms, attrName =>
    filterTransform({ condition, attrName, ...rest }),
  )
  return transformsA
}
github ehmicky / autoserver / src / rpc / adapters / graphql / load / types / object / fields.js View on Github external
const reduceFields = function(opts, fields, mapper) {
  const fieldsA = mapValues(fields, mapField.bind(null, { opts, mapper }))
  return filterObj(fieldsA, hasValue)
}
github ehmicky / log-process-errors / src / level.js View on Github external
export const applyDefaultLevels = function({
  opts: { level: { default: defaultLevel, ...level } = {} },
}) {
  const levelA = filterObj(level, isDefined)

  if (defaultLevel === undefined) {
    return { ...DEFAULT_LEVEL, ...levelA }
  }

  const defaultLevels = mapValues(DEFAULT_LEVEL, () => defaultLevel)
  return { ...defaultLevels, ...levelA }
}
github ehmicky / log-process-errors / src / handle / event.js View on Github external
export const getEvent = async function({
  name,
  promise,
  value,
  nextRejected,
  nextValue,
}) {
  const { rejected, value: valueA } = await parsePromise({
    name,
    promise,
    value,
  })

  const event = { rejected, value: valueA, nextRejected, nextValue }

  const eventA = filterObj(event, isDefined)
  return eventA
}

filter-obj

Filter object keys and values into a new object

MIT
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis

Popular filter-obj functions