All files / src resolveKey.js

100% Statements 4/4
100% Branches 5/5
100% Functions 4/4
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15                  13x 3x   7x    
/**
 * Returns a function for handling key resolver pairs
 * @param {Object} input object
 */
export default function resolveKey(
  input,
  context = {},
  { isSync = false } = {}
) {
  return isSync === true
    ? ({ key, fn }) => ({ key, value: fn(input, context) })
    : ({ key, fn }) =>
        Promise.resolve(fn(input, context)).then(value => ({ key, value }));
}