all files / lib/utils/ helpers.js

100% Statements 6/6
100% Branches 0/0
100% Functions 3/3
100% Lines 3/3
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                        170×                         85×                       83×  
/**
 * Check if a string begins with the characters of a specified string.
 * @param {string} str - Original string.
 * @param {string} searchString - Characters to be searched.
 * @returns {boolean} true if str starts with searchString
 * @example
 * // returns true
 * startsWith('Hello World', 'Hell')
 * @example
 * // returns false
 * startsWith('Hello World', 'Heaven')
 */
export const startsWith = (str, searchString) => str.indexOf(searchString) === 0
 
/**
 * Check if the given string is a pseudo selector/class
 * @param {string} str - String to be tested.
 * @return {boolean} true if str is a pseudo selector/class
 * @example
 * // returns true
 * isPseudoSelector(':after')
 * @example
 * // returns false
 * isPseudoSelector('borderRadius')
 */
export const isPseudoSelector = str => startsWith(str, ':')
 
/**
 * Check if the given string is a media querie.
 * @param {string} str - String to be tested.
 * @return {boolean} true if str is a media querie
 * @example
 * // returns true
 * isMediaQuerie('@media (min-width: 700px)')
 * // returns false
 * isMediaQuerie('borderRadius')
 */
export const isMediaQuery = str => startsWith(str, '@media')