<commit_before>"use strict";

const Promise = require('bluebird');

const defaultFlagMap = [
    { match: String, make: String, guess: s => true },
    { match: Number, make: Number, guess: s => !isNaN(s) },
    { match: Boolean, make: s => s === 'true', guess: s => (s === 'true' || s === 'false') },
    { match: Date, make: s=> new Date(s), guess: s => ( s === new Date(Date.parse(s)).toString() ) }
];

const defaultOptions = {
    mapTypes: true,
    guessTypes: false,
    typeMapFlags: defaultFlagMap,
    defaultType: defaultFlagMap[0]
}

function consulKvObjectForge(kvSync, userOptions) {
    if (!(kvSync && ['get', 'set', 'del'].every(k => kvSync[k] instanceof Function))) {
        throw new Error('constructing consul-kv-object requires consul.kv as argument');
    }
    const kv = Promise.promisifyAll(kvSync);

    var consulObjectOptions = Object.keys(defaultOptions)
        .reduce(
            function (options, defaultKey) {<commit_msg>Fixes date heuristics<commit_after>"use strict";

const Promise = require('bluebird');

const defaultFlagMap = [
    { match: String, make: String, guess: s => true },
    { match: Number, make: Number, guess: s => !isNaN(s) },
    { match: Boolean, make: s => s === 'true', guess: s => (s === 'true' || s === 'false') },
    { match: Date, make: s=> new Date(s), guess: function(s) {
        if ( !s.match(/[0-9]{4}.*([0-9]{2}:[0-9]{2})?/)) return false;
        var t=new Date(s).getTime();
        if ( t===0 || isNaN(t) || t>=9999999999999 ) return false;
        return true;
    }}
];

const defaultOptions = {
    mapTypes: true,
    guessTypes: false,
    typeMapFlags: defaultFlagMap,
    defaultType: defaultFlagMap[0]
}

function consulKvObjectForge(kvSync, userOptions) {
    if (!(kvSync && ['get', 'set', 'del'].every(k => kvSync[k] instanceof Function))) {
        throw new Error('constructing consul-kv-object requires consul.kv as argument');
    }
    const kv = Promise.promisifyAll(kvSync);

    var consulObjectOptions = Object.keys(defaultOptions)
        .reduce(
            function (options, defaultKey) {
{'fraction_non_alphanumeric': 0.17360114777618366, 'fraction_numerical': 0.011956001912960305, 'mean_word_length': 3.4228329809725158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '2607494', 'n_tokens_mistral': 686, 'n_tokens_neox': 675, 'n_words': 180}