<commit_before>var _ = require('lodash');
var JSONStream = require('JSONStream');
var Rx = require('rx');
var RxNode = require('rx-node');

var rxJSONStream = {};

/*
rxJSONStream.parse = function(pattern, mapFilterFunction) {
  var stream = JSONStream.parse(pattern, mapFilterFunction);
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    console.log('x');
    //console.log(x);
    stream.write(x);
    return jsonSource.map(function(result) {
      console.log('result length' + JSON.stringify(result).length);
      return result;
    });
  };
};
//*/

rxJSONStream.parse = function(pattern, mapFilterFunction) {
  var stream = JSONStream.parse(pattern, mapFilterFunction);
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    stream.write(x);
    return jsonSource;
  };
};

/*
rxJSONStream.stringify = function(open, sep, close) {
  var stream = JSONStream.stringify(open, sep, close);
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    stream.write(x);
    return jsonSource;
  };
};
//*/

//*
rxJSONStream.stringify = function(open, sep, close) {
  var stream = JSONStream.stringify();
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    console.log('xbeforestringifywritelength:' + JSON.stringify(x).length);
    stream.write(x);
    //stream.write(x);
    return jsonSource.map(function(result) {
      console.log('xstringify52length' + JSON.stringify(result).length);
      return result;
    });
  };
};
//*/

/*
rxJSONStream.stringify = function(open, sep, close) {
  var stream = JSONStream.stringify(open, sep, close);
  return RxNode.fromWritableStream(stream);
};
//*/

rxJSONStream.stringifyObject = function(open, sep, close) {
  var stream = JSONStream.stringifyObject(open, sep, close);
  //var stream = JSONStream.stringifyObject();
  var jsonSource = RxNode.fromWritableStream(stream);
  return function(x, idx, source) {
    console.log('xbeforestringifyobjectwritelength:' + JSON.stringify(x).length);
    stream.write(['key', x]);
    //stream.write(x);
    return jsonSource.map(function(result) {
      console.log('result length:' + JSON.stringify(result).length);
      return result;
    });
  };
};<commit_msg>Got rxJSONStream stringifyObject working in demo<commit_after>var _ = require('lodash');
var JSONStream = require('JSONStream');
var Rx = require('rx');
var RxNode = require('rx-node');

var rxJSONStream = {};

/*
rxJSONStream.parse = function(pattern, mapFilterFunction) {
  var stream = JSONStream.parse(pattern, mapFilterFunction);
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    console.log('x');
    //console.log(x);
    stream.write(x);
    return jsonSource.map(function(result) {
      console.log('result length' + JSON.stringify(result).length);
      return result;
    });
  };
};
//*/

rxJSONStream.parse = function(pattern, mapFilterFunction) {
  var stream = JSONStream.parse(pattern, mapFilterFunction);
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    stream.write(x);
    return jsonSource;
  };
};

/*
rxJSONStream.stringify = function(open, sep, close) {
  var stream = JSONStream.stringify(open, sep, close);
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    stream.write(x);
    return jsonSource;
  };
};
//*/

//*
rxJSONStream.stringify = function(open, sep, close) {
  var stream = JSONStream.stringify();
  var jsonSource = Rx.Observable.fromEvent(stream, 'data');
  return function(x, idx, source) {
    console.log('xbeforestringifywritelength:' + JSON.stringify(x).length);
    stream.write(x);
    //stream.write(x);
    return jsonSource.map(function(result) {
      console.log('xstringify52length' + JSON.stringify(result).length);
      return result;
    });
  };
};
//*/

/*
rxJSONStream.stringify = function(open, sep, close) {
  var stream = JSONStream.stringify(open, sep, close);
  return RxNode.fromWritableStream(stream);
};
//*/

rxJSONStream.stringifyObject = function(open, sep, close) {
  var stream = JSONStream.stringifyObject(open, sep, close);
  var jsonSource = RxNode.fromWritableStream(stream);
  return function(x, idx, source) {
    console.log('xbeforestringifyobjectwritelength:' + JSON.stringify(x).length);
    //stream.write(['key', x]);
    stream.write(x);
    return jsonSource.map(function(result) {
      console.log('result length:' + JSON.stringify(result).length);
      return result;
    });
  };
};
{'fraction_non_alphanumeric': 0.15736367539716617, 'fraction_numerical': 0.0008587376556462001, 'mean_word_length': 4.205586592178771, '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': '1256856', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1447, 'n_words': 288}