<commit_before>const createPubSubAdapter = () => {
  const actions = {};
  const hOP = actions.hasOwnProperty;
  return {
    subscribe(action, cb) {
      if (!hOP.call(actions, action)) {
        actions[action] = [];
      }
      actions[action].push(cb);
      return [action, cb];
    },
    unsubscribe(token) {
      const [action, cb] = token;
      const callbacks = actions[action];
      const idx = callbacks.indexOf(cb);
      if (idx < 0) {
        console.warn(`You're unsubscribing an unrecognized token`); // eslint-disable-line no-console
      } else {
        callbacks.splice(idx, 1);
      }
    },
    publish(action, params) {
      if (!hOP.call(actions, action)) {
        console.warn(`The action '${action}' being published has no listeners`); // eslint-disable-line no-console
        return;
      }
      actions[action].forEach((cb) => cb.apply(undefined, params));
    },
  };
};

export default createPubSubAdapter;<commit_msg>feat(createDefaultAdapter): Added controls to throws when default adapter APIs are invoked with wron<commit_after>const createDefaultAdapter = () => {
  const actions = {};
  const hOP = actions.hasOwnProperty;
  return {
    subscribe(action, cb) {
      if (!action || typeof action !== 'string') {
        throw new Error(`Default adapter '.subscribe()' expected an action (string) as first argument instead received: ${action}`);
      }

      if (!cb || typeof cb !== 'function') {
        throw new Error(`Default adapter '.subscribe()' expected a function as second argument instead received: ${cb}`);
      }

      if (!hOP.call(actions, action)) {
        actions[action] = [];
      }

      actions[action].push(cb);
      return [action, cb];
    },

    unsubscribe(token) {
      if (!token || !Array.isArray(token)) {
        throw new Error(`Default adapter '.unsubscribe()' expected a token (array) instead received: ${token}`);
      }

      if (token.length !== 2
          || typeof token[0] !== 'string' || typeof token[1] !== 'function') {
        throw new Error(`Default adapter '.unsubscribe()' expected a valid token ([string, function]) instead received: ${token}`);
      }

      const [action, cb] = token;
      const callbacks = actions[action] || [];
      const idx = callbacks.indexOf(cb);
      if (idx < 0) {
        console.error(`You're unsubscribing an unrecognized token ${token}`); // eslint-disable-line no-console
      } else {
        callbacks.splice(idx, 1);
      }
    },

    publish(action, params) {
      if (!action || typeof action !== 'string') {
        throw new Error(`Default adapter '.publish()' expected an action (string) as first argument instead received: ${action}`);
      }

      if (params && !Array.isArray(params)) {
        throw new Error(`Default adapter '.publish()' expected the second argument to be null or an array instead received: ${params}`);
      }

      if (!hOP.call(actions, action)) {
        console.info(`The action '${action}' being published has no listeners`); // eslint-disable-line no-console
        return;
      }

      actions[action].forEach((cb) => cb.apply(undefined, params));
    },
  };
};

export default createDefaultAdapter;
{'fraction_non_alphanumeric': 0.14745392064979693, 'fraction_numerical': 0.0021868166198063107, 'mean_word_length': 2.802850356294537, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3500820', 'n_tokens_mistral': 902, 'n_tokens_neox': 890, 'n_words': 258}