<commit_before>var Transform = require("stream").Transform
var util = require("util")

function ITransformThings(options) {
  Transform.call(this, options)
  this._writableState.objectMode = true
  this._readableState.objectMode = false
}
util.inherits(ITransformThings, Transform)

ITransformThings.prototype._transform = function(chunk, enc, done) {
  this.push(chunk.toString())
  done()
}

var ts = new ITransformThings()
ts.pipe(process.stdout)
ts.write(function(foo) { return foo })
ts.write("bar")
ts.write([1,2,3])
ts.end()<commit_msg>Example based on question<commit_after>var Transform = require("stream").Transform
var util = require("util")

function ITransformThings(options) {
    Transform.call(this, options)
    this._writableState.objectMode = true
    this._readableState.objectMode = false
}
util.inherits(ITransformThings, Transform)

ITransformThings.prototype._transform = function(chunk, enc, done) {
    if(typeof chunk === 'function') {
        chunk = chunk();
    }
    this.push(chunk.toString());
    done()
}

var ts = new ITransformThings()
ts.pipe(process.stdout)
ts.write(function() { return 'awesome' })
ts.write("bar")
ts.write([1,2,3])
ts.end()
{'fraction_non_alphanumeric': 0.14563928873835733, 'fraction_numerical': 0.005080440304826418, 'mean_word_length': 5.320855614973262, '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': '3211939', 'n_tokens_mistral': 391, 'n_tokens_neox': 370, 'n_words': 73}