<commit_before>'use strict';
var { fromEvent } = require('rxjs');
var { filter, map, share } = require('rxjs/operators');

function normalizeKeypressEvents(value, key) {
  return { value: value, key: key || {} };
}

module.exports = function(rl) {
  var keypress = fromEvent(rl.input, 'keypress', normalizeKeypressEvents)
    // Ignore `enter` key. On the readline, we only care about the `line` event.
    .pipe(filter(({ key }) => key.name !== 'enter' && key.name !== 'return'));

  return {
    line: fromEvent(rl, 'line'),
    keypress: keypress,

    normalizedUpKey: keypress.pipe(
      filter(
        ({ key }) =>
          key.name === 'up' || key.name === 'k' || (key.name === 'p' && key.ctrl)
      ),
      share()
    ),<commit_msg>close keypress stream when rl close (#835)<commit_after>'use strict';
var { fromEvent } = require('rxjs');
var { filter, map, share, takeUntil } = require('rxjs/operators');

function normalizeKeypressEvents(value, key) {
  return { value: value, key: key || {} };
}

module.exports = function(rl) {
  var keypress = fromEvent(rl.input, 'keypress', normalizeKeypressEvents)
    .pipe(takeUntil(fromEvent(rl, 'close')))
    // Ignore `enter` key. On the readline, we only care about the `line` event.
    .pipe(filter(({ key }) => key.name !== 'enter' && key.name !== 'return'));

  return {
    line: fromEvent(rl, 'line'),
    keypress: keypress,

    normalizedUpKey: keypress.pipe(
      filter(
        ({ key }) =>
          key.name === 'up' || key.name === 'k' || (key.name === 'p' && key.ctrl)
      ),
      share()
    ),
{'fraction_non_alphanumeric': 0.1876981610653139, 'fraction_numerical': 0.0019023462270133164, 'mean_word_length': 3.2305630026809653, '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': '4610226', 'n_tokens_mistral': 522, 'n_tokens_neox': 512, 'n_words': 133}