<commit_before>(function () {
    "use strict";

    var readline = require('readline');
    var config = require('./prompt.json'); 
    const EventEmitter = require('events');

    class Prompt extends EventEmitter {        

        constructor() {
            super();

            // initialize prompt
            this.rl = readline.createInterface({ 
                input: process.stdin, 
                output: process.stdout,
                completer: this._completer.bind(this)
            });
            this.rl.setPrompt(config.prompt);
            this.rl.on('line', this.emit.bind(this, 'line'));
        }

        next(code) {
            if (this.exit) {
                code = code === undefined ? 0 : code;
                this.emit('end', code);
            }
            else {
                setImmediate(this.rl.prompt.bind(this.rl));
            }
        }

        _completer(line) {
            var lastWord = line.substring(line.lastIndexOf(' ') + 1);
            if (!lastWord) return [[],lastWord];

            var wordCase = lastWord.charAt(lastWord.length - 1);
            var caseFix = wordCase === wordCase.toUpperCase() ? String.prototype.toUpperCase : String.prototype.toLowerCase; 
            
            var regex = new RegExp(lastWord, "i");
            var hits = config.keywords
                            .filter(c => { return regex.test(c); })
                            .map(x => { return caseFix.call(x); });
                            
            return [hits.length ? hits : [], lastWord];
        }
    }

    module.exports = exports = Prompt;
} ());<commit_msg>only search keyword that beginning<commit_after>(function () {
    "use strict";

    var readline = require('readline');
    var config = require('./prompt.json'); 
    const EventEmitter = require('events');

    class Prompt extends EventEmitter {        

        constructor() {
            super();

            // initialize prompt
            this.rl = readline.createInterface({ 
                input: process.stdin, 
                output: process.stdout,
                completer: this._completer.bind(this)
            });
            this.rl.setPrompt(config.prompt);
            this.rl.on('line', this.emit.bind(this, 'line'));
        }

        next(code) {
            if (this.exit) {
                code = code === undefined ? 0 : code;
                this.emit('end', code);
            }
            else {
                setImmediate(this.rl.prompt.bind(this.rl));
            }
        }

        _completer(line) {
            var lastWord = line.substring(line.lastIndexOf(' ') + 1);
            if (!lastWord) return [[],lastWord];

            var wordCase = lastWord.charAt(lastWord.length - 1);
            var caseFix = wordCase === wordCase.toUpperCase() ? String.prototype.toUpperCase : String.prototype.toLowerCase; 
            
            var regex = new RegExp("^" + lastWord, "i");
            var hits = config.keywords
                            .filter(c => { return regex.test(c); })
                            .map(x => { return caseFix.call(x); });
                            
            return [hits.length ? hits : [], lastWord];
        }
    }

    module.exports = exports = Prompt;
} ());
{'fraction_non_alphanumeric': 0.1302354020177316, 'fraction_numerical': 0.0018343014368694588, 'mean_word_length': 1.443614637789395, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4687514', 'n_tokens_mistral': 898, 'n_tokens_neox': 849, 'n_words': 173}