<commit_before>import { createVirtualRenderer } from './virtualRenderer';
import canUseDOM from '../utils/canUseDOM';
import { rulesToCSS } from '../utils/css';
import asap from 'asap';

/**
 * Create a DOM renderer to use for rendering styles
 * to an HTML document.
 *
 * @param  {Object}       options
 * @param  {HTMLDocument} options.domDocument - usually from window
 * @param  {Node}         options.element     - pass an existing element or elements keyed by group
 *                                              in an object to use for stylishly
 * @return {Object}                           - the renderer
 */
export function createDOMRenderer({
  domDocument = canUseDOM && window.document,
  element = {
    default: getStylishlyDOMElement(domDocument, 'default'),
  },
} = {}) {
  const renderer = createVirtualRenderer();

  if (element && !element.hasOwnProperty('default')) {
    element = { default: element };
  }

  let isBuffering = false;
  const bufferContent = { default: '' };

  renderer.events.on('renderSheet', (id, rules, options) => {
    buffer((css) => css + rulesToCSS(rules), options);
  });

  renderer.events.on('removeSheet', (id, rules, options) => {<commit_msg>Add requestFlush from asap to the renderer object<commit_after>import { createVirtualRenderer } from './virtualRenderer';
import canUseDOM from '../utils/canUseDOM';
import { rulesToCSS } from '../utils/css';
import asap from 'asap/raw';

/**
 * Create a DOM renderer to use for rendering styles
 * to an HTML document.
 *
 * @param  {Object}       options
 * @param  {HTMLDocument} options.domDocument - usually from window
 * @param  {Node}         options.element     - pass an existing element or elements keyed by group
 *                                              in an object to use for stylishly
 * @return {Object}                           - the renderer
 */
export function createDOMRenderer({
  domDocument = canUseDOM && window.document,
  element = {
    default: getStylishlyDOMElement(domDocument, 'default'),
  },
} = {}) {
  if (element && !element.hasOwnProperty('default')) {
    element = { default: element };
  }

  const renderer = createVirtualRenderer();
  renderer.requestFlush = asap.requestFlush;

  let isBuffering = false;
  const bufferContent = { default: '' };

  renderer.events.on('renderSheet', (id, rules, options) => {
    buffer((css) => css + rulesToCSS(rules), options);
  });

  renderer.events.on('removeSheet', (id, rules, options) => {
{'fraction_non_alphanumeric': 0.12605718888441403, 'fraction_numerical': 0.0, 'mean_word_length': 2.9554140127388533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7550404', 'n_tokens_mistral': 690, 'n_tokens_neox': 679, 'n_words': 205}