test('test object logging', function (t) { t.on('end', bole.reset) var sink = listStream.obj() , log = bole('simple') , expected = [] bole.output({ level : 'debug' , stream : sink }) expected.push(mklogobj('simple', 'debug', { aDebug : 'object' })) log.debug({ aDebug: 'object' }) expected.push(mklogobj('simple', 'info', { anInfo : 'object' })) log.info({ anInfo: 'object' }) expected.push(mklogobj('simple', 'warn', { aWarn : 'object' })) log.warn({ aWarn: 'object' }) expected.push(mklogobj('simple', 'error', { anError : 'object' })) log.error({ anError: 'object' }) sink.end(function () { t.equal(sink.length, expected.length, 'correct number of log entries') for (var i = 0; i < expected.length; i++) t.deepEqual(sink.get(i), expected[i], 'correct log entry #' + i) t.end() }) })
function db2arr (createReadStream, t, callback, opts) { createReadStream(opts) .pipe(listStream.obj (function (err, arr) { if (err) return t.fail(err) callback(null, arr) })) }
self.waterfall(action, options, function (next) { var statement = self.builder.find(options); // // Ensure next can only be called once // If we are not a stream, figure out if we want to return an object or an // array, and return the appropriate thing by unwrapping if necessary // var fn = once(function (err, result) { if (singleTypes.indexOf(options.type) !== -1) result = result && result[0]; next(err, result); }); // // TODO: Use something like `errs` to propagate back the error with the // actual entity object that was the culprit // if (statement instanceof Error) { return void setImmediate(next, statement); } var stream = statement // // ExtendQuery returns the priam connection query so we have access to // those functions // .extendQuery(self.connection.beginQuery()) // // Allow configurable consistency // .consistency(options.consistency || self.readConsistency) .stream(); // // Pipe the stream to the proxy stream or the list-stream that will collect // the data for us and return to the caller // stream .on('error', fn) // // Simple Stream to re-transform back to camelCase keys // .pipe(through.obj(function (data, enc, callback) { return void callback(null, self.toInstance(data)); })) .pipe(proxy ? proxy : ls.obj(fn)); }, done);
const posts = () => { return gulp.src('./src/md/post/*.md') .pipe(plumber()) .pipe(frontMatter()) .pipe(listStream.obj((err, data) => { const json = {} data.forEach(post => { json[post.frontMatter.page_id] = post.frontMatter }) fs.writeFileSync('./src/json/posts.json', jsonPretty(json)) fs.writeFileSync('./src/json/archives.json', jsonPretty(formatJson.archives(json, 'archives'))) fs.writeFileSync('./src/json/neighbors.json', jsonPretty(formatJson.neighbors(formatJson.archives(json, 'archives').archives))) fs.writeFileSync('./src/json/tags.json', jsonPretty(formatJson.tags(json))) fs.writeFileSync('./src/json/years.json', jsonPretty(formatJson.years(json))) })) }
test('stream all the things', function (t) { var childCount; fixture .on('error', t.error.bind(t)) .pipe(new Parent(child)) .on('log', function (log) { childCount = log.count; }) .on('error', t.error.bind(t)) .pipe(jsonStream()) .pipe(ls.obj(function (err, ary) { t.equals(ary.length, childCount, 'child objects should equal parent objects'); t.end(); })); });
if (argv.group) list = groupCommits(list) list = list.map(function (commit) { return commitToOutput(commit, simple, ghId) }) if (!quiet) printCommits(list) }) } var _startrefcmd = replace(refcmd, { ref: argv['start-ref'] || defaultRef }) , _endrefcmd = argv['end-ref'] && replace(refcmd, { ref: argv['end-ref'] }) , _sincecmd = replace(commitdatecmd, { refcmd: _startrefcmd }) , _untilcmd = argv['end-ref'] ? replace(commitdatecmd, { refcmd: _endrefcmd }) : untilcmd , _gitcmd = replace(gitcmd, { sincecmd: _sincecmd, untilcmd: _untilcmd }) debug('%s', _startrefcmd) debug('%s', _endrefcmd) debug('%s', _sincecmd) debug('%s', _untilcmd) debug('%s', _gitcmd) gitexec.exec(process.cwd(), _gitcmd) .pipe(split2()) .pipe(commitStream(ghId.user, ghId.name)) .pipe(list.obj(onCommitList))