How to use the flatten function from underscore

Find comprehensive JavaScript underscore.flatten code examples handpicked from public code repositorys.

31
32
33
34
35
36
37
38
39
40
const minimist = require('minimist');
const { compileBuildTask } = require('./gulpfile.compile');
const { compileExtensionsBuildTask } = require('./gulpfile.extensions');

// Build
const vscodeEntryPoints = _.flatten([
        buildfile.entrypoint('vs/workbench/workbench.desktop.main'),
        buildfile.base,
        buildfile.workerExtensionHost,
        buildfile.workerNotebook,
fork icon22
star icon147
watch icon19

+ 4 other calls in file

330
331
332
333
334
335
336
337
338
339
340
 * @param {Object} req              Request that was handled in first place.
 * @param {Object} res              Response that will be sent.
 */
function handleUpdateNgsiLD(req, res, next) {
    function reduceActions(actions, callback) {
        callback(null, _.flatten(actions));
    }


    if (contextServerUtils.updateHandler || contextServerUtils.commandHandler) {
        logger.debug(context, 'Handling LD update from [%s]', req.get('host'));
fork icon74
star icon56
watch icon23

60
61
62
63
64
65
66
67
68
69
70
function getLngLats(type, value) {
    if (typeof value !== 'string' && Array.isArray(value) === false) {
        return value;
    }


    const lngLats = _.flatten(splitLngLat(value));
    if (lngLats.length === 2) {
        return { type, coordinates: lngLats };
    }

fork icon74
star icon56
watch icon23

199
200
201
202
203
204
205
206
207
208

const telemetry = gulp.src('.build/telemetry/**', { base: '.build/telemetry', dot: true });

const jsFilter = util.filter(data => !data.isDirectory() && /\.js$/.test(data.path));
const root = path.resolve(path.join(__dirname, '..'));
const dependenciesSrc = _.flatten(productionDependencies.map(d => path.relative(root, d.path)).map(d => [`${d}/**`, `!${d}/**/{test,tests}/**`]));

const deps = gulp.src(dependenciesSrc, { base: '.', dot: true })
        .pipe(filter(['**', '!**/package-lock.json', '!**/yarn.lock', '!**/*.js.map']))
        .pipe(util.cleanNodeModules(path.join(__dirname, '.moduleignore')))
fork icon0
star icon11
watch icon0

+ 19 other calls in file

212
213
214
215
216
217
218
219
220
221
},

registerJSHintTask: function( config, targetFiles ) {
	var path = '<%= path.' + config.name + ' %>', filesToCheck;

	filesToCheck = _.flatten( _.map( targetFiles, function( value ) {
		return value.orig.src;
	} ) );

	grunt.config.set( 'jshint.' + config.slug, filesToCheck.concat( ['!' + path + '/js/**/*.min.js'] ) );
fork icon1
star icon0
watch icon4

842
843
844
845
846
847
848
849
850
851
};

// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
_.difference = function(array) {
  var rest = _.flatten(slice.call(arguments, 1));
  return _.filter(array, function(value){ return !_.include(rest, value); });
};

// Zip together multiple lists into a single array -- elements that share
fork icon0
star icon0
watch icon1

+ 13 other calls in file

446
447
448
449
450
451
452
453
454
455

// Karma sets included=true by default.
// We set it to false by default because RequireJS should be used instead.
files = setDefaults(files);

filesForCoverage = _.flatten(
    _.map(
        ['sourceFiles', 'specFiles'],
        function(collectionName) { return options[collectionName]; }
    )
fork icon0
star icon0
watch icon1

+ 2 other calls in file

153
154
155
156
157
158
159
160
161
162

const optimizeVSCodeWebTask = task.define('optimize-vscode-web', task.series(
        util.rimraf('out-vscode-web'),
        common.optimizeTask({
                src: 'out-build',
                entryPoints: _.flatten(vscodeWebEntryPoints),
                otherSources: [],
                resources: vscodeWebResources,
                loaderConfig: common.loaderConfig(),
                externalLoaderInfo: util.createExternalLoaderConfig(product.webEndpointUrl, commit, quality),
fork icon0
star icon0
watch icon3

+ 17 other calls in file

186
187
188
189
190
191
192
193
194
195
const productJsonStream = gulp.src(['product.json'], { base: '.' })
        .pipe(json({ commit, date }));

const base = 'remote/web';

const dependenciesSrc = _.flatten(getProductionDependencies(path.join(root, base))
        .map(d => path.relative(root, d.path))
        .map(d => [`${d}/**`, `!${d}/**/{test,tests}/**`, `!${d}/.bin/**`]));

const runtimeDependencies = gulp.src(dependenciesSrc, { base, dot: true })
fork icon0
star icon0
watch icon0

+ 9 other calls in file

60
61
62
63
64
65
66
67
68
69
        '!**/test/**'
];

const buildfile = require('../src/buildfile');

const vscodeWebEntryPoints = _.flatten([
        buildfile.entrypoint('vs/workbench/workbench.web.api'),
        buildfile.base,
        buildfile.workerExtensionHost,
        buildfile.workerNotebook,
fork icon0
star icon0
watch icon2

+ 5 other calls in file