<commit_before>/*
Copyright (c) 2015 <NAME> <http://jessemccarthy.net/>
*/

var
  rs = require('readable-stream'),
  util = require('util');

// A full pragma looks like
// `({"compiler": "browserify", "version": "1.23.456"});`

module.exports = BrowserifyPragma;

function BrowserifyPragma (opts) {
  if (! (this instanceof BrowserifyPragma)) return new BrowserifyPragma(opts);
  var self = this;
  opts = opts || {};

  Object.keys(opts).forEach(function (prop) {
    self[prop] = opts[prop];
  });

  // Store content from start of file.
  self.src = [];
  self.src.byteLength = 0;
  self.detected = false;
  self.present = false;
}
// BrowserifyPragma

/**
 * Generate browserify pragma.
 */
BrowserifyPragma.generate = function (opts) {
  opts = opts || {};

  // Manually construct this as a string (instead of using JSON.stringify()) to
  // ensure property order.
  return BrowserifyPragma.prototype.sample.replace(
    'VERSION',
    opts.version
  );
};
// generate

/**
 * Test for browserify pragma.
 * @param string src
 * @return boolean
 */
BrowserifyPragma.detect = function (src) {
  return this.prototype.re.test(src);
};
// detect

var Pragma = BrowserifyPragma.prototype;

Pragma.encoding = 'utf-8';

// Placeholder version value to represent the max length.
Pragma.version = '123.456.789';

// Max bytes that may precede pragma. 3 = max BOM length.
Pragma.preMaxBytes = 3;

Pragma.sample =
  '({"compiler": "browserify", "version": "VERSION"});'.replace(
    'VERSION',
    Pragma.version
  );

Pragma.re = new RegExp(
  "^" +
  // BOM
  "\\uFEFF?" +
  Pragma.sample
    .replace(/[(){}]/g, '\\$&')
    .replace(
      Pragma.version,
      '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}'
    )
);

// Minimum number of bytes needed to detect pragma.
Pragma.minBytes =
  Pragma.preMaxBytes + Buffer.byteLength(Pragma.sample, Pragma.encoding);
<commit_msg>Fix generate(). Add .template.<commit_after>/*
Copyright (c) 2015 <NAME> <http://jessemccarthy.net/>
*/

var
  rs = require('readable-stream'),
  util = require('util');

// A full pragma looks like
// `({"compiler": "browserify", "version": "1.23.456"});`

module.exports = BrowserifyPragma;

function BrowserifyPragma (opts) {
  if (! (this instanceof BrowserifyPragma)) return new BrowserifyPragma(opts);
  var self = this;
  opts = opts || {};

  Object.keys(opts).forEach(function (prop) {
    self[prop] = opts[prop];
  });

  // Store content from start of file.
  self.src = [];
  self.src.byteLength = 0;
  self.detected = false;
  self.present = false;
}
// BrowserifyPragma

/**
 * Generate browserify pragma.
 */
BrowserifyPragma.generate = function (opts) {
  opts = opts || {};

  // Manually construct this as a string (instead of using JSON.stringify()) to
  // ensure property order.
  return BrowserifyPragma.prototype.template.replace(
    'VERSION',
    opts.version
  );
};
// generate

/**
 * Test for browserify pragma.
 * @param string src
 * @return boolean
 */
BrowserifyPragma.detect = function (src) {
  return this.prototype.re.test(src);
};
// detect

var Pragma = BrowserifyPragma.prototype;

Pragma.encoding = 'utf-8';

// Placeholder version value to represent the max length.
Pragma.version = '123.456.789';

// Max bytes that may precede pragma. 3 = max BOM length.
Pragma.preMaxBytes = 3;

Pragma.template = '({"compiler": "browserify", "version": "VERSION"});';

Pragma.sample = Pragma.template.replace('VERSION', Pragma.version);

Pragma.re = new RegExp(
  "^" +
  // BOM
  "\\uFEFF?" +
  Pragma.template
    .replace(/[(){}]/g, '\\$&')
    .replace(
      'VERSION',
      '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}'
    )
);

// Minimum number of bytes needed to detect pragma.
Pragma.minBytes =
  Pragma.preMaxBytes + Buffer.byteLength(Pragma.sample, Pragma.encoding);

{'fraction_non_alphanumeric': 0.17179215270413573, 'fraction_numerical': 0.01855779427359491, 'mean_word_length': 3.3770301624129933, 'pattern_counts': {'":': 8, '<': 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': '6824285', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1276, 'n_words': 310}