<commit_before>/**
 * @fileoverview Helpers for measuring elements.
 */

goog.provide('treesaver.dimensions');

goog.require('treesaver.capabilities');
goog.require('treesaver.constants');

/**
 * Alias for Size type
 *
 * @typedef {{ w: number, h: number }}
 */
treesaver.dimensions.Size;

/**
 * Alias for SizeRange type
 *
 * @typedef {{ w: number, h: number, maxW: number, maxH: number }}
 */
treesaver.dimensions.SizeRange;

/**
 * Regex to determine whether a value is a pixel value.
 * @private
 */
treesaver.dimensions.pixel = /^-?\d+(?:px)?$/i;


/**
 * Regex to determine whether a value contains a number.
 * @private
 */
treesaver.dimensions.number = /^-?\d/;

/**
 * Whether the given size fits within the bounds set by the range
 *
 * @param {treesaver.dimensions.SizeRange|treesaver.dimensions.Metrics} range
 * @param {treesaver.dimensions.Size} size
 * @return {boolean} True if both dimensions are within the min and max.
 */
treesaver.dimensions.inSizeRange = function(range, size) {
  if (!range) {
    return false;
  }

  // Use minW/minH for Metrics, w/h for a range
  // TODO: Make this consistent
  var w = 'minW' in range ? range.minW : range.w,
      h = 'minH' in range ? range.minH : range.h;

  return size.w >= w && size.h >= h &&
    size.w <= range.maxW && size.h <= range.maxH;
};

/**
 *
 * @param {treesaver.dimensions.SizeRange} a
 * @param {treesaver.dimensions.Metrics} b
 * @param {boolean} outer
 * @return {treesaver.dimensions.SizeRange}
 */
treesaver.dimensions.mergeSizeRange = function(a, b, outer) {
  a = a || {};
  b = b || {};

  var bpHeight = outer ? b.bpHeight || (b.outerH ? b.outerH - b.h : 0) : 0,
      bpWidth = outer ? b.bpWidth || (b.outerW ? b.outerW - b.w : 0) : 0;

  return {
    w: Math.max(a.w || 0, (b.w + bpWidth) || 0),
    h: Math.max(a.h || 0, (b.h + bpHeight) || 0),
    maxW: Math.min(a.maxW || Infinity, b.maxW + bpWidth || Infinity),<commit_msg>Fix silly compiler minification error on my part<commit_after>/**
 * @fileoverview Helpers for measuring elements.
 */

goog.provide('treesaver.dimensions');

goog.require('treesaver.capabilities');
goog.require('treesaver.constants');

/**
 * Alias for Size type
 *
 * @typedef {{ w: number, h: number }}
 */
treesaver.dimensions.Size;

/**
 * Alias for SizeRange type
 *
 * @typedef {{ w: number, h: number, maxW: number, maxH: number }}
 */
treesaver.dimensions.SizeRange;

/**
 * Regex to determine whether a value is a pixel value.
 * @private
 */
treesaver.dimensions.pixel = /^-?\d+(?:px)?$/i;


/**
 * Regex to determine whether a value contains a number.
 * @private
 */
treesaver.dimensions.number = /^-?\d/;

/**
 * Whether the given size fits within the bounds set by the range
 *
 * @param {treesaver.dimensions.SizeRange|treesaver.dimensions.Metrics} range
 * @param {treesaver.dimensions.Size} size
 * @return {boolean} True if both dimensions are within the min and max.
 */
treesaver.dimensions.inSizeRange = function(range, size) {
  if (!range) {
    return false;
  }

  // Use minW/minH for Metrics, w/h for a range
  // TODO: Make this consistent
  var w = (range.minW || range.minW === 0) ? range.minW : range.w,
      h = (range.minH || range.minH === 0) ? range.minH : range.h;

  return size.w >= w && size.h >= h &&
    size.w <= range.maxW && size.h <= range.maxH;
};

/**
 *
 * @param {treesaver.dimensions.SizeRange} a
 * @param {treesaver.dimensions.Metrics} b
 * @param {boolean} outer
 * @return {treesaver.dimensions.SizeRange}
 */
treesaver.dimensions.mergeSizeRange = function(a, b, outer) {
  a = a || {};
  b = b || {};

  var bpHeight = outer ? b.bpHeight || (b.outerH ? b.outerH - b.h : 0) : 0,
      bpWidth = outer ? b.bpWidth || (b.outerW ? b.outerW - b.w : 0) : 0;

  return {
    w: Math.max(a.w || 0, (b.w + bpWidth) || 0),
    h: Math.max(a.h || 0, (b.h + bpHeight) || 0),
    maxW: Math.min(a.maxW || Infinity, b.maxW + bpWidth || Infinity),
{'fraction_non_alphanumeric': 0.17139933486825276, 'fraction_numerical': 0.004604758250191865, 'mean_word_length': 3.1862955032119915, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6776290', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1374, 'n_words': 374}