How to use the lodash.filter function in lodash

To help you get started, we’ve selected a few lodash 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 thomaschampagne / elevate / plugin / options / app / directives / fitnessTrend / fitnessTrendGraph.ts View on Github external
x: fitData.timestamp,
                        y: -10,
                    });
                    overtrain_zone_points.push({
                        x: fitData.timestamp,
                        y: -30,
                    });
                }
            });

            // Adding days of preview (CTL + ATL + TSB dashed) after if toTimestamp is today
            const ctlPreviewValues: any[] = [];
            const atlPreviewValues: any[] = [];
            const tsbPreviewValues: any[] = [];

            const fitnessDataPreview: IFitnessActivity[] = _.filter(fitnessData, {
                previewDay: true,
            });

            // If "toTimestamp" is today
            // We add preview curves...
            if (moment(toTimestamp).format("YYYYMMDD") === moment().format("YYYYMMDD")) {

                _.forEach(fitnessDataPreview, (fitData: IFitnessActivity) => {

                    ctlPreviewValues.push({
                        x: fitData.timestamp,
                        y: fitData.ctl,
                    });

                    atlPreviewValues.push({
                        x: fitData.timestamp,
github shoutem / extensions / shoutem.cms / server / src / components / sort-options / SortOptions.jsx View on Github external
calculateDisplayProperties(schema, sortOptions) {
    const properties = _.get(schema, 'properties');
    if (_.isEmpty(properties)) {
      return;
    }

    const fields = _.map(properties, (field, name) => ({
      ...field,
      name,
    }));

    const schemaDisplayFields = _.filter(fields, (property) => (
      !_.includes(UNSUPPORTED_FORMATS, property.format)
    ));

    const displayFields = [
      ...schemaDisplayFields,
      ...ALWAYS_AVAILABLE_SORT_FORMATS,
    ];

    // resolve field and order or set defaults
    const field = _.get(sortOptions, 'field', 'name');
    const order = _.get(sortOptions, 'order', 'ascending');

    const currentField = _.find(displayFields, { name: field });

    this.setState({
      displayFields,
github pantsel / konga / api / controllers / KongConsumersController.js View on Github external
return !service.acl && !service.auths.length;
      })
      sails.log("***********************************************")
      sails.log("KongConsumersController:services:open", _.map(open, item => item.name))
      sails.log("***********************************************")

      // Gather services with auths matching at least one consumer credential
      let matchingAuths = _.filter(services,function (service) {
        return _.intersection(service.auths, consumerAuths).length > 0;
      });
      sails.log("***********************************************")
      sails.log("KongConsumersController:services:matchingAuths", _.map(matchingAuths, item => item.name))
      sails.log("***********************************************")

      // Gather services with access control restrictions whitelisting at least one of the consumer's groups.
      let whitelisted = _.filter(services,function (service) {
        return service.acl && _.intersection(service.acl.config.whitelist,consumerGroups).length > 0;
      });
      sails.log("***********************************************")
      sails.log("KongConsumersController:services:whitelisted", _.map(whitelisted, item => item.name))
      sails.log("***********************************************")


      // Gather services with no authentication plugins
      // & access control restrictions whitelisting at least one of the consumer's groups.
      let whitelistedNoAuth = _.filter(services,function (service) {
        return service.acl
          && _.intersection(service.acl.config.whitelist,consumerGroups).length > 0
          && (!service.auths || !service.auths.length);
      });
      sails.log("***********************************************")
      sails.log("KongConsumersController:services:whitelistedNoAuth", _.map(whitelistedNoAuth, item => item.name))
github choerodon / choerodon-front-agile / agile / src / app / agile / containers / project / Issue / AdvancedSearch / AdvancedSearch.js View on Github external
handleAssigneeSelectChange = (value) => {
      this.filterControler = new IssueFilterControler();
      IssueStore.setSelectedAssignee(value);
      if (value.find(item => item === 'none')) {
        this.filterControler.assigneeFilterUpdate([]);
        this.filterControler.cache.get('userFilter').otherArgs.assigneeId = ['0'].concat(filter(value, item => item !== 'none'));
        // IssueStore.setFilterMap(this.filterControler.cache);
      } else {
        if (!this.filterControler.cache.get('userFilter').otherArgs) {
          this.filterControler.cache.get('userFilter').otherArgs = {};
        }
        this.filterControler.cache.get('userFilter').otherArgs.assigneeId = [];
        // IssueStore.setFilterMap(this.filterControler.cache);
        this.filterControler.assigneeFilterUpdate(value);
      }
      IssueStore.judgeFilterConditionIsEmpty();
      IssueStore.judgeConditionWithFilter();
      IssueStore.updateIssues(this.filterControler);
    }
github Automattic / wp-calypso / client / state / domains / dns / reducer.js View on Github external
function removeDuplicateWpcomRecords( domain, records ) {
	const rootARecords = filter( records, isRootARecord( domain ) );
	const wpcomARecord = find( rootARecords, isWpcomRecord );
	const customARecord = find( rootARecords, negate( isWpcomRecord ) );

	if ( wpcomARecord && customARecord ) {
		return without( records, wpcomARecord );
	}

	return records;
}
github choerodon / devops-service / react / routes / envOverview / domainOverview / DomainOverview.js View on Github external
removeDeleteModal(id) {
    const { deleteArr } = this.state;
    const newDeleteArr = _.filter(deleteArr, ({ deleteId }) => deleteId !== id);
    this.setState({ deleteArr: newDeleteArr });
  }
github vuefront / vuefront / src / components / organisms / product-options / product-options.vue View on Github external
checkActive(e, option) {
      let result = filter(
        this.options,
        value => value.id === option.id && e === value.value
      );

      return !isEmpty(result);
    },
    handleOptionChange(e, option) {
github RallyApps / rally-app-builder / lib / build / get-script.js View on Github external
getFiles({configJson, appPath}, callback){
    let localFiles =  _.filter(configJson.javascript, isScriptLocal);
    let localCssFiles =  _.filter(configJson.css, isScriptLocal);
    return async.series({
      javascript_files: jsCallback=> {
        return this.getJavaScripts({appPath, scripts: localFiles, compress:true}, jsCallback);
      },
      uncompressed_javascript_files: jsCallback=> {
        return this.getJavaScripts({appPath, scripts: localFiles, compress:false}, jsCallback);
      },
      css_file_names: cssCallback=> {
        return cssCallback(null, _.map(localCssFiles, css.getGeneratedFileName));
      },
      css_files: cssCallback=> {
        return this.getStylesheets({appPath, scripts: localCssFiles, compress: true}, cssCallback);
      },
      uncompressed_css_files: cssCallback=> {
        return this.getStylesheets({appPath, scripts: localCssFiles, compress: false}, cssCallback);
      },
github Asymmetrik / akin / lib / sample.service.js View on Github external
.then(([userRecommendationsObj, userItemWeights, dnr]) => {

        var itemIdToWeightMap = getItemIdToWeightMap(userItemWeights);

        var allRecommendations = _.get(userRecommendationsObj, 'recommendations', []);

        var itemToScoreMap = {};
        _.forEach(allRecommendations, (rec) => {
            itemToScoreMap[rec.item] = rec.weight;
        });

        var filteredRecommendations = _.filter(allRecommendations, filterRecommendations.bind(this, dnr, itemIdToWeightMap));

        var sampleRecommendations = getSamples(filteredRecommendations, numberOfSamples);

        return addScoreToItems(itemToScoreMap, _.map(sampleRecommendations, 'item'));

    });
};
github m3db / m3 / src / ctl / ui / src / components / RollupRuleEditor.js View on Github external
function removeRequiredTags(tags, requiredTags) {
  return _.filter(tags, t => !_.includes(requiredTags, t));
}