<commit_before>export function grayscale( imageData ) {
  const { data } = imageData;

  for ( let i = 0, il = data.length; i < il; i += 4 ) {
    const r = data[ i     ];
    const g = data[ i + 1 ];
    const b = data[ i + 2 ];

    // CIE RGB luminance.
    const value = 0.2126 * r + 0.7152 * g + 0.0722 * b;
    data[ i ] = data[ i + 1 ] = data[ i + 2 ] = value;
  }

  return imageData;
}<commit_msg>Don't mutate original ImageData object in grayscale conversion.<commit_after>import createImageData from './image-data';

export function grayscale( imageData ) {
  const { data, width, height } = imageData;

  const output = createImageData( width, height );
  const dst    = output.data;

  for ( let i = 0, il = data.length; i < il; i += 4 ) {
    const r = data[ i     ];
    const g = data[ i + 1 ];
    const b = data[ i + 2 ];

    // CIE RGB luminance.
    const value = 0.2126 * r + 0.7152 * g + 0.0722 * b;
    dst[ i ] = dst[ i + 1 ] = dst[ i + 2 ] = value;
  }

  return output;
}
{'fraction_non_alphanumeric': 0.1462925851703407, 'fraction_numerical': 0.04208416833667335, 'mean_word_length': 2.233009708737864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '896387', 'n_tokens_mistral': 402, 'n_tokens_neox': 353, 'n_words': 127}