index.js
function processBreakpoint(root, breakpointOption) {
  if (breakpointOption && breakpointOption !== Object(breakpointOption)) {
    throw new Error('Breakpoint must be of type Object.');
  }

  const processedBreakpoint = Object.assign({}, breakpointOption);

  let atRule;
  /* search current rules to see if one exists */
  root.walkAtRules('media', rule => {
    if (rule.params !== processedBreakpoint.mediaQuery) return;
    atRule = rule;
  });

  /* if no rules exist, create a new one */
  if (!atRule) {
    atRule = postcss.atRule({
      name: 'media',
      params: processedBreakpoint.mediaQuery,
    });
  }

  processedBreakpoint.atRule = atRule;
  return processedBreakpoint;
}
function processBreakpoint(root, breakpointOption) {
  if (breakpointOption && breakpointOption !== Object(breakpointOption)) {
    throw new Error('Breakpoint must be of type Object.');
  }

  const processedBreakpoint = Object.assign({}, breakpointOption);

  let atRule;
  /* search current rules to see if one exists */
  root.walkAtRules('media', rule => {
    if (rule.params !== processedBreakpoint.mediaQuery) return;
    atRule = rule;
  });

  /* if no rules exist, create a new one */
  if (!atRule) {
    atRule = postcss.atRule({
      name: 'media',
      params: processedBreakpoint.mediaQuery,
    });
  }

  processedBreakpoint.atRule = atRule;
  return processedBreakpoint;
}
function processBreakpoint ( root , breakpointOption ) { if ( breakpointOption && breakpointOption !== Object ( breakpointOption ) ) { throw new Error ( 'Breakpoint must be of type Object.' ) ; } const processedBreakpoint = Object . assign ( { } , breakpointOption ) ; let atRule ; /* search current rules to see if one exists */ root . walkAtRules ( 'media' , rule => { if ( rule . params !== processedBreakpoint . mediaQuery ) return ; atRule = rule ; } ) ; /* if no rules exist, create a new one */ if ( ! atRule ) { atRule = postcss . atRule ( { name : 'media' , params : processedBreakpoint . mediaQuery , } ) ; } processedBreakpoint . atRule = atRule ; return processedBreakpoint ; }
Processes a breakpoint option by creating a PostCSS @media atRule from the options
@param {Object} root Root postcss node
@param {Object} breakpointOption
@param {String} breakpointOption.name
@param {String} breakpointOption.mediaQuery
@return {Object} Processed breakpoint option
Processes a breakpoint option by creating a PostCSS