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

100% Statements 3/3
100% Branches 3/3
100% Functions 2/2
100% Lines 3/3

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 19 20 21 22 23 24 254x                             5x             4x    
let enabledFeatures = []
 
/**
 * @param {string} key
 * @param {boolean} [defaut=false] The value to return when `false` if plugin not initialized (list is `null`)
 * @return {boolean} `true` or `false` if feature `key` is enabled (inside list of enabled features)
 * @example
 * import { isEnabled } from 'vue-feature-flipping'
 * function sample() {
 *     if (isEnabled('XXXXX')) {
 *         console.log('...')
 *     }
 * }
 */
export function isEnabled (key, defaut = false) {
  return enabledFeatures === null ? defaut : enabledFeatures.includes(key)
}
 
/**
 * @param {Array.string|null} features
 */
export function setEnabledFeatures (features) {
  enabledFeatures = features
}