当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.toPairs函数代码示例

本文整理汇总了TypeScript中lodash.toPairs函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toPairs函数的具体用法?TypeScript toPairs怎么用?TypeScript toPairs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了toPairs函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Date

            .then(rows => {
              let total = 0
              const totalChannel = {}
              const result = {}
              const min = dates.format(moment(new Date(dates.min)).subtract(1, 'day'))
              result[min] = Object.assign({}, statsBase)

              rows.map(row => {
                const date = dates.format(row.date)
                if (!result[date]) {
                  result[date] = Object.assign({}, statsBase)
                }
                if (!totalChannel[row.channel]) {
                  totalChannel[row.channel] = 0
                }
                const count = parseInt(row.count)
                totalChannel[row.channel] += count
                result[date].total = total += count
                result[date][row.channel] = totalChannel[row.channel]
              })

              const max = dates.format(moment(new Date(dates.max)).add(1, 'hour'))
              result[max] = Object.assign({}, statsBase, { total: total }, totalChannel)

              return _.toPairs(result).map(([k, v]) => {
                v['name'] = k
                return v
              })
            })
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:29,代码来源:stats.ts

示例2: function

        _.forEach(input.cells, function (cell) {

          let index = _.pick(cell, drilldowns);

          let indexPairs = _.toPairs(index);

          let already = _.find(results, function (result) {
            return _.every(indexPairs, function (indexPair) {
              return result[indexPair[0]] == indexPair[1];
            });
          });

          if(already==undefined){
            already = index;
            results.push(already);
          }

          _.forEach(aggregates, function (aggregate) {
            if(!already[aggregate]) {
              already[aggregate] = cell[aggregate];
            }
            else{
              already[aggregate] *= cell[aggregate];
            }
          });

        })
开发者ID:mlukasch,项目名称:indigo,代码行数:27,代码来源:multiplication.ts

示例3: createMetricLabel

  createMetricLabel(md, target, groupByTags, options) {
    if (target.alias) {
      const scopedVars = _.clone(options.scopedVars || {});
      _.each(md.tags, (value, key) => {
        scopedVars['tag_' + key] = { value: value };
      });
      return this.templateSrv.replace(target.alias, scopedVars);
    }

    let label = md.metric;
    const tagData = [];

    if (!_.isEmpty(md.tags)) {
      _.each(_.toPairs(md.tags), tag => {
        if (_.has(groupByTags, tag[0])) {
          tagData.push(tag[0] + '=' + tag[1]);
        }
      });
    }

    if (!_.isEmpty(tagData)) {
      label += '{' + tagData.join(', ') + '}';
    }

    return label;
  }
开发者ID:acedrew,项目名称:grafana,代码行数:26,代码来源:datasource.ts

示例4: getOriginalMetricName

 getOriginalMetricName(labelData) {
   const metricName = labelData.__name__ || '';
   delete labelData.__name__;
   const labelPart = _.map(_.toPairs(labelData), label => {
     return label[0] + '="' + label[1] + '"';
   }).join(',');
   return metricName + '{' + labelPart + '}';
 }
开发者ID:grafana,项目名称:grafana,代码行数:8,代码来源:result_transformer.ts

示例5: function

 this.getOriginalMetricName = function(labelData) {
   var metricName = labelData.__name__ || '';
   delete labelData.__name__;
   var labelPart = _.map(_.toPairs(labelData), function(label) {
     return label[0] + '="' + label[1] + '"';
   }).join(',');
   return metricName + '{' + labelPart + '}';
 };
开发者ID:Sensetif,项目名称:grafana,代码行数:8,代码来源:datasource.ts

示例6:

      calculated: (state, dependencies) => {

        let resources = state.values || [];
        let resourceTypes = _.toPairs(
          _.groupBy(state.values, 'kind')).map(val => ({ name: val[0], value: val[1].length})
        );

        return  { resources, resourceTypes };
      }
开发者ID:kishoreBhojan,项目名称:ibex-dashboard,代码行数:9,代码来源:azure.ts

示例7: formatSubj

  private formatSubj(cnf: OpenSSLConfig) {
    const subjNames = new Map([
      ['countryName', 'C'],
      ['stateOrProvinceName', 'ST'],
      ['localityName', 'L'],
      ['organizationName', 'O'],
      ['commonName', 'CN'],
    ]);

    return '/' + lodash.toPairs(cnf).filter(([k]) => subjNames.has(k)).map(([k, v]) => `${subjNames.get(k)}=${v}`).join('/');
  }
开发者ID:driftyco,项目名称:ionic-cli,代码行数:11,代码来源:generate.ts

示例8: memoize

export const groupByDomains = memoize((measures: T.MeasureEnhanced[]) => {
  const domains = toPairs(groupBy(measures, measure => measure.metric.domain)).map(r => ({
    name: r[0],
    measures: r[1]
  }));

  return sortBy(domains, [
    (domain: { name: string; measures: T.MeasureEnhanced[] }) => {
      const idx = KNOWN_DOMAINS.indexOf(domain.name);
      return idx >= 0 ? idx : KNOWN_DOMAINS.length;
    },
    'name'
  ]);
});
开发者ID:deolm,项目名称:sonarqube,代码行数:14,代码来源:utils.ts

示例9: Error

export function getCollectionLinksSorted<D extends Tyr.Document>(
  plugin: GraclPlugin,
  col: Tyr.CollectionInstance<D>,
  opts: { direction: string; relate?: string } = { direction: 'outgoing' }
): Tyr.FieldInstance[] {
  const collectionFieldCache = plugin.sortedLinkCache;
  const hash = `${col.def.name}:${_.toPairs(opts)
    .map(e => e.join('='))
    .sort()
    .join(':')}`;

  if (collectionFieldCache[hash]) {
    return collectionFieldCache[hash];
  }

  const linkFields = col.links(opts);

  // sort fields by link collection name
  const links = _.chain(linkFields)
    .groupBy(field => field.link!.def.name)
    .map((colLinks: Tyr.FieldInstance[], colName: string) => {
      /**
       * multiple links to collection?
       */
      if (colLinks.length > 1) {
        const filtered = colLinks.filter(
          field =>
            !!(field.def as Tyr.FieldDefinition & {
              graclTypes?: string[] | string;
            }).graclTypes
        );

        /**
         * no graclType links? use first available...
         *
         * TODO: multiple?
         */
        if (filtered.length === 0) {
          return colLinks.slice(0, 1);
          /**
           * one? use it
           */
        } else if (filtered.length === 1) {
          return filtered;
        } else {
          throw new Error(
            `Multiple links to ${colName} for collection ${
              col.def.name
            } have graclTypes`
          );
        }
      } else {
        return colLinks;
      }
    })
    .flatten()
    .sortBy((field: Tyr.FieldInstance) => field.link && field.link.def.name)
    .value() as Tyr.FieldInstance[];

  return (collectionFieldCache[hash] = links);
}
开发者ID:CrossLead,项目名称:tyranid-gracl,代码行数:61,代码来源:getCollectionLinksSorted.ts

示例10: toPairs

 .subscribe(album => {
   this.album = album
   this.trackGroups = toPairs(groupBy(album.tracks, 'group'))
   this.albumImageUrl = this.nmlService.signResourceUrl(album.artwork, {w: 50, h: 50})
 })
开发者ID:simoneb,项目名称:nml,代码行数:5,代码来源:album-details.ts


注:本文中的lodash.toPairs函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。