Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
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 })
}
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 }
}
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
}
const removeDatum = function(obj) {
if (!isObject(obj)) {
return obj
}
return filterObj(obj, hasNoData)
}
const filterTransforms = function({ condition, transforms, ...rest }) {
if (condition === undefined) {
return transforms
}
const transformsA = filterObj(transforms, attrName =>
filterTransform({ condition, attrName, ...rest }),
)
return transformsA
}
const reduceFields = function(opts, fields, mapper) {
const fieldsA = mapValues(fields, mapField.bind(null, { opts, mapper }))
return filterObj(fieldsA, hasValue)
}
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 }
}
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
}