<commit_before>const _ = require('underscore');
const { _request } = require('./request');
const AV = require('./av');

const serializeMessage = message => {
  if (typeof message.toJSON === 'function') {
    return message.toJSON();
  }
  if (typeof message !== 'string') {
    return JSON.stringify(message);
  }
  return message;
};

/**
 * <p>An AV.Conversation is a local representation of a LeanCloud realtime's
 * conversation. This class is a subclass of AV.Object, and retains the
 * same functionality of an AV.Object, but also extends it with various
 * conversation specific methods, like get members, creators of this conversation.
 * </p>
 *
 * @class AV.Conversation
 * @param {String} name The name of the Role to create.
 * @param {Object} [options]
 * @param {Boolean} [options.isSystem] Set this conversation as system conversation.
 * @param {Boolean} [options.isTransient] Set this conversation as transient conversation.<commit_msg>fix(conversation): make compatible w/ Message from leancloud-realtime@4<commit_after>const _ = require('underscore');
const { _request } = require('./request');
const AV = require('./av');

const serializeMessage = message => {
  if (typeof message === 'string') {
    return message;
  }
  if (typeof message.getPayload === 'function') {
    return JSON.stringify(message.getPayload());
  }
  return JSON.stringify(message);
};

/**
 * <p>An AV.Conversation is a local representation of a LeanCloud realtime's
 * conversation. This class is a subclass of AV.Object, and retains the
 * same functionality of an AV.Object, but also extends it with various
 * conversation specific methods, like get members, creators of this conversation.
 * </p>
 *
 * @class AV.Conversation
 * @param {String} name The name of the Role to create.
 * @param {Object} [options]
 * @param {Boolean} [options.isSystem] Set this conversation as system conversation.
 * @param {Boolean} [options.isTransient] Set this conversation as transient conversation.
{'fraction_non_alphanumeric': 0.12022132796780684, 'fraction_numerical': 0.0005030181086519115, 'mean_word_length': 4.404891304347826, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '725508', 'n_tokens_mistral': 543, 'n_tokens_neox': 530, 'n_words': 207}