function transform (opts) {
  var contents = opts.contents;

  var $ = cheerio.load(contents);

  var cssTransforms = opts.fetcher.transforms.css.map((tf) => tf({
    fetcher: opts.fetcher,
    index: opts.index
  }));

  // start parallel processing streams, one for each style tag
  var tasks = [].concat(
    // style attributes
    $('[style]').toArray().map((el) => transformDOMText({
      filePath: opts.filePath,
      getText: getAttrText, // get from attribute
      el$: $(el),
      setText: setAttrText, // set attribute
      transforms: cssTransforms
    })),
    // style tags
    $('style').toArray().map((el) => transformDOMText({
      filePath: opts.filePath,
      getText: getTagText, // get from textContent
      el$: $(el),
      setText: setTagText, // set textContent
      transforms: cssTransforms
    }))
  );
  return Promise.all(tasks)
    // all styles have been processed, output correct HTML
    .then(() => $.html());
}
function transform (opts) {
  var contents = opts.contents;

  var $ = cheerio.load(contents);

  var cssTransforms = opts.fetcher.transforms.css.map((tf) => tf({
    fetcher: opts.fetcher,
    index: opts.index
  }));

  
  var tasks = [].concat(
    
    $('[style]').toArray().map((el) => transformDOMText({
      filePath: opts.filePath,
      getText: getAttrText, 
      el$: $(el),
      setText: setAttrText, 
      transforms: cssTransforms
    })),
    
    $('style').toArray().map((el) => transformDOMText({
      filePath: opts.filePath,
      getText: getTagText, 
      el$: $(el),
      setText: setTagText, 
      transforms: cssTransforms
    }))
  );
  return Promise.all(tasks)
    
    .then(() => $.html());
}
function transform ( opts ) { var contents = opts . contents ; var $ = cheerio . load ( contents ) ; var cssTransforms = opts . fetcher . transforms . css . map ( ( tf ) => tf ( { fetcher : opts . fetcher , index : opts . index } ) ) ; // start parallel processing streams, one for each style tag var tasks = [ ] . concat ( // style attributes $ ( '[style]' ) . toArray ( ) . map ( ( el ) => transformDOMText ( { filePath : opts . filePath , getText : getAttrText , // get from attribute el$ : $ ( el ) , setText : setAttrText , // set attribute transforms : cssTransforms } ) ) , // style tags $ ( 'style' ) . toArray ( ) . map ( ( el ) => transformDOMText ( { filePath : opts . filePath , getText : getTagText , // get from textContent el$ : $ ( el ) , setText : setTagText , // set textContent transforms : cssTransforms } ) ) ) ; return Promise . all ( tasks ) // all styles have been processed, output correct HTML . then ( ( ) => $ . html ( ) ) ; }
/*
interface StringTransformOptions {
contents: String,
fetcher: Fetcher,
filePath: String,
index: FetcherIndex
}
 transform (opts: StringTransformOptions) => String
/ * interface StringTransformOptions { contents : String fetcher : Fetcher filePath : String index : FetcherIndex } transform ( opts : StringTransformOptions ) = > String