all files / lib/helpers/ utils.js

100% Statements 34/34
91.67% Branches 11/12
100% Functions 4/4
100% Lines 14/14
1 statement, 3 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                              28× 28×   28×     28×    
'use strict';
 
import * as util from 'util';
import * as configs from '../configs/default';
 
const MAGIC_SELECTORS = [
  'hover',
  'active',
  'target',
  'focus'
];
const MAGIC_SELECTOR_DIVIDER = '_';
 
const DEFAULT_LAYOUT = 'smart';
const LAYOUT = {
  vertical: 'top-down',
  horizontal: 'left-right',
  diagonal: 'diagonal',
  smart: 'binary-tree',
  default: DEFAULT_LAYOUT
};
 
export var SPRITE_LAYOUT = LAYOUT;
 
export { default as logger } from './Logger';
 
export function isTruthy(value) {
  return ((value || '').toString().toLowerCase() === 'true');
}
 
export function computeSelector(input) {
  let selector = input.split(MAGIC_SELECTOR_DIVIDER);
  let matches = MAGIC_SELECTORS.indexOf(selector[1]) > -1;
 
  if (matches) {
    input = selector.join(':');
  }
 
  return input.replace(configs.CLASSNAME_REGEX, '');
}