<commit_before>class Sora {
  constructor(url) {
    this.url = url || "";
  }
  connection() {
    return new SoraConnection(this.url);
  }
}

class SoraConnection {
  constructor(url) {
    this._ws = null;
    this._url = url;
    this._onerror = () => {};
    this._onclose = () => {};
  }
  connect(params) {
    return new Promise((resolve, reject) => {
      if (this._ws === null) {
        this._ws = new WebSocket(this._url);
      }
      this._ws.onopen = () => {
        const message = JSON.stringify({
          type: "connect",
          role: params.role,
          channelId: params.channelId,
          accessToken: params.accessToken
        });
        this._ws.send(message);
      };
      this._ws.onclose = (e) => {
        if (e.code === 4401) {
          reject(e);
        }
        else {
          this._onclose(e);
        }
      };
      this._ws.onerror = (e) => {
        this._onerror(e);
      };
      this._ws.onmessage = (event) => {
        const data = JSON.parse(event.data);
        if (data.type == "offer") {
          resolve(data);
        } else if (data.type == "ping") {
          this._ws.send(JSON.stringify({ type: "pong" }));
        }
      };
    });
  }
  answer(sdp) {
    this._ws.send(JSON.stringify({ type: "answer", sdp }));
  }
  candidate(candidate) {
    let message = candidate.toJSON();
    message.type = "candidate";
    this._ws.send(JSON.stringify(message));<commit_msg>ステータスコードが 440x の場合は全て reject する<commit_after>class Sora {
  constructor(url) {
    this.url = url || "";
  }
  connection() {
    return new SoraConnection(this.url);
  }
}

class SoraConnection {
  constructor(url) {
    this._ws = null;
    this._url = url;
    this._onerror = () => {};
    this._onclose = () => {};
  }
  connect(params) {
    return new Promise((resolve, reject) => {
      if (this._ws === null) {
        this._ws = new WebSocket(this._url);
      }
      this._ws.onopen = () => {
        const message = JSON.stringify({
          type: "connect",
          role: params.role,
          channelId: params.channelId,
          accessToken: params.accessToken
        });
        this._ws.send(message);
      };
      this._ws.onclose = (e) => {
        if (/440\d$/.test(e.code)) {
          reject(e);
        }
        else {
          this._onclose(e);
        }
      };
      this._ws.onerror = (e) => {
        this._onerror(e);
      };
      this._ws.onmessage = (event) => {
        const data = JSON.parse(event.data);
        if (data.type == "offer") {
          resolve(data);
        } else if (data.type == "ping") {
          this._ws.send(JSON.stringify({ type: "pong" }));
        }
      };
    });
  }
  answer(sdp) {
    this._ws.send(JSON.stringify({ type: "answer", sdp }));
  }
  candidate(candidate) {
    let message = candidate.toJSON();
    message.type = "candidate";
    this._ws.send(JSON.stringify(message));
{'fraction_non_alphanumeric': 0.16987620357634112, 'fraction_numerical': 0.0034387895460797797, 'mean_word_length': 1.8603736479842674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3758719', 'n_tokens_mistral': 971, 'n_tokens_neox': 963, 'n_words': 164}