.map(function(modulePages, moduleName) { log.info('moduleName: ' + moduleName); var navItems = []; var modulePage; var xx = _(modulePages) .groupBy('docType') .value(); xx = _.tap(xx,function(docTypes) { // log.info(moduleName, _.keys(docTypes)); // Extract the module page from the collection modulePage = docTypes.module[0]; delete docTypes.module; }); xx = _.tap(xx,function(docTypes) { if ( docTypes.input ) { docTypes.directive = docTypes.directive || []; // Combine input docTypes into directive docTypes docTypes.directive = docTypes.directive.concat(docTypes.input); delete docTypes.input; } }); _.forEach(xx,function(sectionPages, sectionName) { sectionPages = _.sortBy(sectionPages, 'name'); if ( sectionPages.length > 0 ) { // Push a navItem for this section navItems.push({ name: sectionName, type: 'section', href: path.dirname(sectionPages[0].path) }); // Push the rest of the sectionPages for this section _.forEach(sectionPages, function(sectionPage) { navItems.push({ name: sectionPage.name, href: sectionPage.path, type: sectionPage.docType }); }); } }); return { name: moduleName, href: modulePage.path, type: 'group', navItems: navItems }; })
util.makeEmitter = function(){ return lo.tap(new Emitter(), function(emitter){ window.addEventListener('message', function(e){ if (msg_model.isEvent(e.data)){ emitter.emit.apply(emitter, [e.data.name].concat(e.data.args)) } }); }); };
var outputStream = subject.mergeAll(streamsData, function(data) { return _.tap(new stream.PassThrough({ objectMode: true }), function(s) { streams.push(s); _.delay(function() { _.each(data, function(item) { s.push(item); }); s.end(); }, 100); }); });
function edgeTo(target, label) { var edge = cache[target] || _.tap(cache[target] = { source: vertex, target: graph[target], labels: [] }, allEdges.push.bind(allEdges)); edge.labels.push(label); return edge; }
var outputStream = subject.mergeAll(streamsData, function(data) { return _.tap(new stream.PassThrough({ objectMode: true }), function(s) { streams.push(s); _.delay(function() { _.each(data, function(item) { if (item) { s.push(item); } else { s.emit('error', new Error('test stream error')); } }); s.end(); }, 100); }); });
function buildTest (name, testFunction, file, ancestors) { return _.tap({ name: name, type: 'test', testFunction: testFunction, context: Object.create(null), file: file, ancestorNames: _.map(ancestors, 'name') }, function (test) { _.assign(test, { description: function (suiteOrdinal, fileOrdinal) { return testDescription(test, suiteOrdinal, fileOrdinal) } }) }) }
function buildExampleGroup (name, groupDeclaration, file, ancestors) { return _.tap({ name: name, type: 'suite', file: file, beforeAll: groupDeclaration.beforeAll || noOpHook, afterAll: groupDeclaration.afterAll || noOpHook, beforeEach: groupDeclaration.beforeEach || noOpHook, afterEach: groupDeclaration.afterEach || noOpHook, ancestorNames: _.map(ancestors, 'name') }, function (exampleGroup) { _.assign(exampleGroup, { items: itemsIn(groupDeclaration, file, ancestors.concat(exampleGroup)) }) }) }
return JSON.stringify(num); }); var obj = {a:1, b:2}; bool = _.conformsTo(obj, { a: function(x:number) { return true; }, }); num = _.defaultTo(undefined, 2); string = _.defaultTo(undefined, 'str'); bool = _.defaultTo(true, 'str'); string = _.defaultTo('str', true); num = _.tap(1, function(n) { return false; }); bool = _.thru(1, function(n) { return false; }); var timesNums: number[]; timesNums = _.times(5); // $ExpectError string. This type is incompatible with number var strings : string[] = _.times(5); timesNums = _.times(5, function(i: number) { return i + 1; }); // $ExpectError string. This type is incompatible with number timesNums = _.times(5, function(i: number) { return JSON.stringify(i); }); // lodash.flatMap for collections and objects // this arrow function needs a type annotation due to a bug in flow // https://github.com/facebook/flow/issues/1948 _.flatMap([1, 2, 3], (n): number[] => [n, n]);
var profiles = fs.readdirSync(__dirname + '/lib/profiles').map(function (filename) { return _.tap(require('./lib/profiles/' + filename), function (profile) { profile.unamePattern = new RegExp(profile.unamePattern); }); });
Command.prototype.process = function(type) { debug(this.program, this.parameters); return _.tap(childProcess[type](this.program, this.parameters, this.opts), function(proc) { dumpStderr(proc.stderr); }); };
var emptyStream = function() { return _.tap(new stream.PassThrough(), function(s) { s.end(); }); };
.reduce((acc, [key, count]) => _.tap(acc, acc => { acc[key] = (acc[key] || 0) + Number(count); }), { })
return num * num; }); directSquares = map(nums, function(num) { return num * num; }); num = lodash.first(nums); // return type of iterator is reflected in result and chain nativeStrings = nums.map(function(num) { return JSON.stringify(num); }); directStrings = map(nums, function(num) { return JSON.stringify(num); }); var obj = {a:1, b:2}; bool = lodash.conformsTo(obj, { a: function(x:number) { return true; }, }); num = lodash.defaultTo(undefined, 2); string = lodash.defaultTo(undefined, 'str'); bool = lodash.defaultTo(true, 'str'); string = lodash.defaultTo('str', true); num = lodash.tap(1, function(n) { return false; }); bool = lodash.thru(1, function(n) { return false; });