All files / vue-feature-flipping/src utils.js

80% Statements 4/5
75% Branches 3/4
100% Functions 1/1
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                  13x 4x 9x 9x          
/**
 * @param {(string|{key: string, default: boolean})} obj
 * @return {[string, boolean]}
 * @example
 * parseParameter('XXXXX') // ['XXXXX', undefined]
 * parseParameter({ key: 'XXXXX' }) // ['XXXXX', undefined]
 * parseParameter({ key: 'XXXXX', default: true }) // ['XXXXX', true]
 */
export function parseParameter (obj) {
  if (typeof obj === 'string') {
    return [obj, undefined]
  } else Eif (obj instanceof Object) {
    return [obj.key, obj.default]
  } else {
    throw TypeError(`Unsupported parameter type: ${typeof obj}`)
  }
}