<commit_before>'use strict';

var debug = require('debug')('cachex');

/**
 * @param {Object} store The cache store client, must have set(key, value, time)
 * and get(key) methods, the get/set must be an yieldable method
 * @param {String} prefix prefix, used for key
 * @param {String} name method name, used for key
 * @param {Generator|Thunkify} yieldable must be a yieldable object
 * @param {Number} expire the expire time, in seconds
 * @return Generator the new generator, will auto process cache
 */
module.exports = function (store, prefix, name, yieldable, expire) {
  return function * () {
    // copy arguments
    var args = new Array(arguments.length);
    for (var i = 0; i < arguments.length; i++) {
      args[i] = arguments[i];
    }
    var key = prefix + ':' + name + ':' + args.join(':');
    var result = yield store.get(key);
    debug('get value for key: %s with cache, value is: %j', key, result);
    if (!result) {
      result = yield* yieldable.apply(null, arguments);
      debug('get value for key: %s with origin way', key);<commit_msg>throw TypeError, when key is object<commit_after>'use strict';

var debug = require('debug')('cachex');

/**
 * @param {Object} store The cache store client, must have set(key, value, time)
 * and get(key) methods, the get/set must be an yieldable method
 * @param {String} prefix prefix, used for key
 * @param {String} name method name, used for key
 * @param {Generator|Thunkify} yieldable must be a yieldable object
 * @param {Number} expire the expire time, in seconds
 * @return Generator the new generator, will auto process cache
 */
module.exports = function (store, prefix, name, yieldable, expire) {
  return function * () {
    // copy arguments
    var args = new Array(arguments.length);
    for (var i = 0; i < arguments.length; i++) {
      args[i] = arguments[i];
      if (typeof args[i] === 'object') {
        throw new TypeError('use object not fit cache key');
      }
    }
    var key = prefix + ':' + name + ':' + args.join(':');
    var result = yield store.get(key);
    debug('get value for key: %s with cache, value is: %j', key, result);
    if (!result) {
      result = yield* yieldable.apply(null, arguments);
      debug('get value for key: %s with origin way', key);
{'fraction_non_alphanumeric': 0.13876651982378854, 'fraction_numerical': 0.000881057268722467, 'mean_word_length': 3.514910536779324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1703857', 'n_tokens_mistral': 679, 'n_tokens_neox': 670, 'n_words': 270}