當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。