<commit_before>// cop - emit value for particular key

module.exports = cop

var Stream = require('stream').Stream
  , key = require('./lib/key.js')

function cop () {
  var args = Array.prototype.slice.call(arguments)
    , first = args[0]
    , isFunction = typeof first === 'function'
    , fun = isFunction ? args.shift() : key

  var stream = new Stream()

  stream.readable = true
  stream.writable = true

  stream.write = function (obj) {
    var value = fun.apply(null, [obj].concat(args))
    if (value) stream.emit('data', value)
  }
  
  // fstream
  stream.add = stream.write

  stream.end = function () {
    stream.emit('end')
  }

  return stream
}<commit_msg>Return true from write<commit_after>// cop - emit value for particular key

module.exports = cop

var Stream = require('stream').Stream
  , key = require('./lib/key.js')

function cop () {
  var args = Array.prototype.slice.call(arguments)
    , first = args[0]
    , isFunction = typeof first === 'function'
    , fun = isFunction ? args.shift() : key

  var stream = new Stream()

  stream.readable = true
  stream.writable = true

  stream.write = function (obj) {
    var value = fun.apply(null, [obj].concat(args))
    if (value) stream.emit('data', value)
    return true
  }
  
  // fstream
  stream.add = stream.write

  stream.end = function () {
    stream.emit('end')
  }

  return stream
}
{'fraction_non_alphanumeric': 0.1437908496732026, 'fraction_numerical': 0.0014524328249818446, 'mean_word_length': 2.9371428571428573, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2153054', 'n_tokens_mistral': 446, 'n_tokens_neox': 432, 'n_words': 117}