How to use the underscore.filter function in underscore

To help you get started, we’ve selected a few underscore 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 MaayanLab / clustergrammer / src / matrix / make_simple_rows.js View on Github external
//       output_opacity = 0.35;
  //     } else {
  //       output_opacity = 1;
  //     }
  //     return output_opacity;
  //     // return 0.1;
  //   })
  //   .attr('transform', function(d) {
  //     return fine_position_tile(params, d);
  //   });


  if (params.matrix.tile_type == 'updn'){

    // value split
    var row_split_data = underscore.filter(inp_row_data, function(num){
      return num.value_up != 0 || num.value_dn !=0 ;
    });

    // tile_up
    d3.select(row_selection)
      .selectAll('.tile_up')
      .data(row_split_data, function(d){return d.col_name;})
      .enter()
      .append('path')
      .attr('class','tile_up')
      .attr('d', function() {
        return draw_up_tile(params);
      })
      .attr('transform', function(d) {
        fine_position_tile(params, d);
      })
github apigee-127 / volos / swagger / lib / helpers.js View on Github external
function importOAuthTokenPaths(swagger, resourceName, paths) {

  if (paths.length === 0) { return; }

  var allPaths = swagger.paths || (swagger.paths = {});
  var allDefinitions = swagger.definitions || (swagger.definitions = {});

  // err if would overwrite any paths
  var allPathNames = Object.keys(allPaths);
  var existingPaths = _.filter(paths, function(path) { return _.contains(allPathNames, path); });
  if (existingPaths.length > 0) {
    throw new Error('Paths ' + existingPaths + ' already exist. Cannot insert OAuth.');
  }

  // err if would overwrite any definitions
  var existingDefinitions = _.filter(allDefinitions, function(key) {
    return _.contains(Object.keys(oauthSwagger.definitions), key);
  });
  if (existingDefinitions.length > 0) {
    throw new Error('Definitions ' + existingDefinitions + ' already exist. Cannot insert OAuth.');
  }

  // add the token paths
  _.each(paths, function(path, name) {
    var keyPath = '/' + name;
    allPaths[path] = oauthSwagger.paths[keyPath];
github lantanagroup / FHIR.js / test / fhirPath.js View on Github external
return {
                        resourceType: 'Questionnaire',
                        id: 'OCAN2.0.7'
                    };
                }

                assert(false);
            };

            var results = fhir.evaluate(bundle, 'Bundle.entry.resource.questionnaire.resolve()');

            assert(results);
            assert(results.length === 4);

            var questionnaires = _.filter(results, function(result) {
                return result.resourceType === 'Questionnaire';
            });

            assert(questionnaires.length === 4);
            assert(results[0].id === 'RAI-HC2011');
            assert(results[1].id === 'GAIN-Q33.3.7 ONT MI');
            assert(results[2].id === 'OCAN2.0.7');
            assert(results[3].id === 'OCAN2.0.7');
        });
github Foundry376 / Mailspring / app / src / browser / window-manager.ts View on Github external
quitCheck = _.debounce(() => {
    const visibleWindows = _.filter(this._windows, win => win.isVisible());
    const mainWindow = this.get(WindowManager.MAIN_WINDOW);
    const noMainWindowLoaded = !mainWindow || !mainWindow.isLoaded();
    if (visibleWindows.length === 0 && noMainWindowLoaded) {
      app.quit();
    }
  }, 25000);
github bipbop / harlan / src / plugins / lib / accuracy / campaign.js View on Github external
    controller.registerCall('accuracy::campaigns::parse', data => _.filter(data[0], ({period_end}) => moment(period_end, 'YYYY-MM-DD').isAfter()));
github BRCAChallenge / brca-exchange / website / js / index.js View on Github external
render: function() {
        let currentSupporters = _.filter(logos, function(logo) {
                                    return logo.currentSupporter;
                                });
        let notCurrentSupporterLogos = _.filter(logos, function(logo) {
                             return !logo.currentSupporter;
                         });
        var notCurrentSupporterLogoItems = _.map(notCurrentSupporterLogos, ({id, logo, url}) => (
            
                <a href="{url}">
                    <img alt="{id" src="{logo}" id="{id}">
                </a>
            
        ));
        var currentSupporterLogoItems = _.map(currentSupporters, ({id, logo, url}) =&gt; (
            
                <a href="{url}">
                    <img alt="{id" src="{logo}" id="{id}">
                </a>
            
        ));
github coveo / search-ui / src / ui / Facet / BreadcrumbValuesList.ts View on Github external
private buildCollapsed() {
    const numberOfSelected = filter(this.collapsed, (value: FacetValue) => value.selected).length;
    const numberOfExcluded = filter(this.collapsed, (value: FacetValue) => value.excluded).length;
    Assert.check(numberOfSelected + numberOfExcluded == this.collapsed.length);

    const elem = $$('div', {
      className: 'coveo-facet-breadcrumb-value'
    });

    const multiCount = $$('span', {
      className: 'coveo-facet-breadcrumb-multi-count'
    });

    multiCount.text(l('NMore', Globalize.format(numberOfSelected + numberOfExcluded, 'n0')));
    elem.append(multiCount.el);

    const valueElements = map(this.collapsed, facetValue => {
      return new this.breadcrumbValueElementKlass(this.facet, facetValue);
github joola / joola / lib / dispatch / query.js View on Github external
manager.formatResults = function(results, callback) {
  var query = results.queryplan.query;
  results.documents = results.documents || [];

  results.dimensions = results.dimensions || query.dimensions;
  results.metrics = results.metrics || query.metrics;

  //allow engines to return a fake metric to be removed before processing
  results.dimensions = _.filter(results.dimensions, function(dimension) {
    return dimension.key !== 'fake';
  });
  results.metrics = _.filter(results.metrics, function(metric) {
    return metric.key !== 'fake';
  });

  var dindex = 0;
  async.map(results.documents, function(document, cb) {
    //results.documents.forEach(function (document, dindex) {
    delete document.key;
    results.dimensions.forEach(function(dimension) {
      //document[dimension.key] = document[dimension.key];
      if (dimension.datatype == 'date') {
        document[dimension.key] = document[dimension.key];
      }
      /*
             else if (dimension.datatype === 'ip' && document[dimension.key] && document[dimension.key] !== '(not set)') {
             var ip = document[dimension.key];
             document[dimension.key] = joola.common.extend({ip: ip}, joola.common.geoip.lookup(ip)) || '(not set)';
github itchio / itch / src / reducers / profile / navigation.ts View on Github external
on(actions.tabsRestored, (state, action) => {
    const snapshot = action.payload;

    const tab = snapshot.current || state.tab;
    const transient = filter(
      map(snapshot.items, (tab: ITabDataSave) => {
        return tab.id;
      }),
      x => !!x
    );

    return {
      ...state,
      tab,
      openTabs: {
        ...state.openTabs,
        transient,
      },
    };
  });