<commit_before>import debug from 'debug';

import BrowserMsgr from './chrome';
import api from './chromeApi';
import ctor from '../constructor';
import logSeed from './logSeed';





const log = debug(`Brex:talker:${logSeed}`);

export default class Talker extends BrowserMsgr {
  constructor (appId) {
    log('constructor', appId);

    super(appId);
    this.cid = 1;
    this.api = api;
    this.ready = false;
    this.modules = {};
    this.onReadyCbs = ctor.object();
  }

  send (msg, cb) {
    msg.cid = this.cid++;
    msg.ext = this.appId;
    msg.host = window.document.location.hostname;
    msg.url = window.document.location.href;
    msg.isFrame = (window !== top);

    log('send', msg);

    super.send(msg, cb);
  }


  sendAnswer (message, sender, sendResponse) {
    log('sendAnswer ', message, sender);

    return sendResponse({err: true, value: "Unauthorized"});
  }
}<commit_msg>talker response logics<commit_after>import debug from 'debug';

import BrowserMsgr from './chrome';
import api from './chromeApi';
import ctor from '../constructor';
import logSeed from './logSeed';





const log = debug(`Brex:talker:${logSeed}`);

export default class Talker extends BrowserMsgr {
  constructor (appId) {
    log('constructor', appId);

    super(appId);
    this.cid = 1;
    this.api = api;
    this.ready = false;
    this.onReadyCbs = ctor.object();
  }

  send (msg, cb) {
    msg.cid = this.cid++;
    msg.ext = this.appId;
    msg.host = window.document.location.hostname;
    msg.url = window.document.location.href;
    msg.isFrame = (window !== top);

    log('send', msg);

    super.send(msg, cb);
  }


  sendAnswer (message, sender, sendResponse) {
    log('sendAnswer ', message, sender);

    if (this.ready) {
      log('sendAnswer Talker is ready');

      return this.answerByReason(message, sender, sendResponse);
    }

    this.onReadyCbs[`${this.appId}${this.cid}`] = () => {
      log(`sendAnswer when Talker set ready with cb key: ${this.appId}${this.cid}`);

      return this.answerByReason(message, sender, sendResponse);
    }
  }

  answerByReason (message, sender, sendResponse) {
    log('answerByReason %s', message.reason);

    switch (message.reason) {
      case 'get.modules':
        this.sendModulesByProps(message, sender, sendResponse);
        break;
      default:
        sendResponse({err: true, value: "Unauthorized"});
        break;
    }
  }

  sendModulesByProps (message, sender, sendResponse) {
    log('sendModulesByProps');

    let [key, ...modules] = this.config.raw;

    sendResponse({k: 0});

    // modules.forEach((m) => {
    //   for(let k in m) {
    //     if (k === 'f' && m[k])
    //   }
    // });
  }
}
{'fraction_non_alphanumeric': 0.1591246290801187, 'fraction_numerical': 0.001112759643916914, 'mean_word_length': 2.942982456140351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1054199', 'n_tokens_mistral': 915, 'n_tokens_neox': 882, 'n_words': 207}