How to use the mongodb-extended-json.createStringifyStream function in mongodb-extended-json

To help you get started, we’ve selected a few mongodb-extended-json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rueckstiess / mgeneratejs / bin / mgenerate.js View on Github external
.wrap(100);

if (process.stdin.isTTY) {
  // running in TTY mode, get template from non-positional argument
  yargs
    .usage('Usage: mgeneratejs  [template]')
    .demand(1, 'must provide a template file or string');
} else {
  yargs.usage('Usage: mgeneratejs  < [template]');
}

var argv = yargs.argv;
var template;
var stringifyStream = argv.jsonArray
  ? eJSONStringifyStream('[\n  ', ',\n  ', '\n]\n')
  : eJSONStringifyStream('', '\n', '\n');

function generate() {
  es.readable(function(count, callback) {
    if (count >= argv.number) {
      return this.emit('end');
    }
    this.emit('data', mgenerate(template));
    callback();
  })
    .pipe(stringifyStream)
    .pipe(process.stdout);
}

if (process.stdin.isTTY) {
  var str = argv._[0];
  template = _.startsWith(str, '{')
github rueckstiess / mgeneratejs / bin / mgenerate.js View on Github external
.strict()
  .wrap(100);

if (process.stdin.isTTY) {
  // running in TTY mode, get template from non-positional argument
  yargs
    .usage('Usage: mgeneratejs  [template]')
    .demand(1, 'must provide a template file or string');
} else {
  yargs.usage('Usage: mgeneratejs  < [template]');
}

var argv = yargs.argv;
var template;
var stringifyStream = argv.jsonArray
  ? eJSONStringifyStream('[\n  ', ',\n  ', '\n]\n')
  : eJSONStringifyStream('', '\n', '\n');

function generate() {
  es.readable(function(count, callback) {
    if (count >= argv.number) {
      return this.emit('end');
    }
    this.emit('data', mgenerate(template));
    callback();
  })
    .pipe(stringifyStream)
    .pipe(process.stdout);
}

if (process.stdin.isTTY) {
  var str = argv._[0];