<commit_before>/* SQB
 ------------------------
 (c) 2017-present Panates
 SQB may be freely distributed under the MIT license.
 For details and documentation:
 https://panates.github.io/sqb/
 */

/**
 * Module dependencies.
 * @private
 */
const ParamType = require('./enums').ParamType;
const ReservedWords = [
  'schema', 'table', 'field', 'index',
  'select', 'insert', 'update', 'delete', 'with', 'merge',
  'join', 'inner', 'outer', 'left', 'right', 'full',
  'from', 'where', 'order', 'by', 'group', 'having',
  'acs', 'ascending', 'dsc', 'descending', 'distinct',
  'and', 'or', 'not', 'between', 'null', 'like',
  'count', 'sum', 'average'];

/**
 * Expose `Serializable`.
 */
module.exports = Serializable;

/**
 * @constructor
 * @public
 */
function Serializable() {
  this.type = undefined;
}

Serializable.prototype = {
  get isSerializable() {
    return true;
  }
};
Serializable.prototype.constructor = Serializable;

/* istanbul ignore next*/
/**
 *
 * @param {Object} ctx
 * @return {string}
 * @abstract
 */
Serializable.prototype._serialize = function(ctx) {
  return '';
};

Serializable.serializeFallback = function(ctx, type, o, defFn) {
  return ctx && ctx.extension && ctx.extension.serialize &&
      ctx.extension.serialize(ctx, type, o, defFn) || defFn();
};

Serializable.serializeObject = function(ctx, o) {
  if (o == null)
    return 'null';
  if (o instanceof RegExp)
    return serializeParam(ctx, o.source);
  var s;
  if (Array.isArray(o)) {
    s = '';
    o.forEach(function(t, i) {
      s += (i ? ',' : '') + Serializable.serializeObject(ctx, t);
    });
    return '(' + s + ')';
  }
  if (o.isSerializable) {
    s = o._serialize(ctx);
    return s ? (o.isQuery ? '(' + s + ')' : s) :
        /* istanbul ignore next */
        'null';
  }
  if (o instanceof Date) {
    return Serializable.serializeFallback(ctx, 'date', o, function() {
      return serializeDateValue(o);
    });
  }
  if (typeof o === 'string') {
    return Serializable.serializeFallback(ctx, 'string', o, function() {
      return serializeStringValue(o);
    });
  }
  return o;
};

Serializable.joinArray = function(arr, sep, lfLen) {
  var out = '';
  var line = '';
  var k = 0;
  lfLen = lfLen || 60;
  sep = sep || ',';
  arr.forEach(function(s) {
    /* istanbul ignore next */
    if (!s) return;
    line += (k > 0 ? sep : '');
    if (line.length > lfLen) {
      out += (out ? '\n' : '') + line;
      line = '';
    } else line += line ? ' ' : '';
    line += s;
    k++;<commit_msg>[Fix] Fixed bug in joinArray() method<commit_after>/* SQB
 ------------------------
 (c) 2017-present Panates
 SQB may be freely distributed under the MIT license.
 For details and documentation:
 https://panates.github.io/sqb/
 */

/**
 * Module dependencies.
 * @private
 */
const ParamType = require('./enums').ParamType;
const ReservedWords = [
  'schema', 'table', 'field', 'index',
  'select', 'insert', 'update', 'delete', 'with', 'merge',
  'join', 'inner', 'outer', 'left', 'right', 'full',
  'from', 'where', 'order', 'by', 'group', 'having',
  'acs', 'ascending', 'dsc', 'descending', 'distinct',
  'and', 'or', 'not', 'between', 'null', 'like',
  'count', 'sum', 'average'];

/**
 * Expose `Serializable`.
 */
module.exports = Serializable;

/**
 * @constructor
 * @public
 */
function Serializable() {
  this.type = undefined;
}

Serializable.prototype = {
  get isSerializable() {
    return true;
  }
};
Serializable.prototype.constructor = Serializable;

/* istanbul ignore next*/
/**
 *
 * @param {Object} ctx
 * @return {string}
 * @abstract
 */
Serializable.prototype._serialize = function(ctx) {
  return '';
};

Serializable.serializeFallback = function(ctx, type, o, defFn) {
  return ctx && ctx.extension && ctx.extension.serialize &&
      ctx.extension.serialize(ctx, type, o, defFn) || defFn();
};

Serializable.serializeObject = function(ctx, o) {
  if (o == null)
    return 'null';
  if (o instanceof RegExp)
    return serializeParam(ctx, o.source);
  var s;
  if (Array.isArray(o)) {
    s = '';
    o.forEach(function(t, i) {
      s += (i ? ',' : '') + Serializable.serializeObject(ctx, t);
    });
    return '(' + s + ')';
  }
  if (o.isSerializable) {
    s = o._serialize(ctx);
    return s ? (o.isQuery ? '(' + s + ')' : s) :
        /* istanbul ignore next */
        'null';
  }
  if (o instanceof Date) {
    return Serializable.serializeFallback(ctx, 'date', o, function() {
      return serializeDateValue(o);
    });
  }
  if (typeof o === 'string') {
    return Serializable.serializeFallback(ctx, 'string', o, function() {
      return serializeStringValue(o);
    });
  }
  return o;
};

Serializable.joinArray = function(arr, sep, lfLen) {
  var out = '';
  var line = '';
  var k = 0;
  lfLen = lfLen || 60;
  sep = sep || ',';
  arr.forEach(function(s) {
    /* istanbul ignore next */
    if (s === undefined) return;
    line += (k > 0 ? sep : '');
    if (line.length > lfLen) {
      out += (out ? '\n' : '') + line;
      line = '';
    } else line += line ? ' ' : '';
    line += s;
    k++;
{'fraction_non_alphanumeric': 0.20367807000197746, 'fraction_numerical': 0.0031639311844967374, 'mean_word_length': 2.9701726844583987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4290418', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1718, 'n_words': 429}