• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.map函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: map

const format_various_diff = (diff, attrs) => (
`<table border="1">
  <tr><th>Champ modifiĂŠ</th><th>Ancienne valeur</th><th>Nouvelle valeur</th></tr>
` +
    map(diff, ({ prev, current }, key) => {
        const opts = { ...client_conf.default_attrs_opts[key], ...attrs[key] };
        return '  <tr>' + [opts && opts.title || key, prev || '<i>aucune</i>', current || '<i>supprimĂŠe</i>'].map(s => `<td>${s}</td>`).join('') + '</tr>'
    }).join("\n") + `
</table>`
);
开发者ID:prigaux,项目名称:compte-externe,代码行数:10,代码来源:v_display.ts


示例2: function

 return _.flatten(_.map(a, function(x) {
   return _.map(b, function(y) {
     return _.concat(x,[y]);
   });
 }), true);
开发者ID:mlukasch,项目名称:indigo,代码行数:5,代码来源:permutations.ts


示例3:

 _.map(old.rows, row => {
   return _.map(row.panels, 'id');
 })
开发者ID:grafana,项目名称:grafana,代码行数:3,代码来源:DashboardMigrator.ts


示例4:

 const responseTransform = result => {
   return _.map(result, value => {
     return { text: value };
   });
 };
开发者ID:grafana,项目名称:grafana,代码行数:5,代码来源:datasource.ts


示例5:

 .map(indices=>_.map(indices,i=>obj[i]))
开发者ID:mlukasch,项目名称:indigo,代码行数:1,代码来源:permutations.ts


示例6: addHistogram

  addHistogram(data) {
    const xBucket = this.scope.ctrl.data.buckets[data.x];
    const yBucketSize = this.scope.ctrl.data.yBucketSize;
    let min, max, ticks;
    if (this.scope.ctrl.data.tsBuckets) {
      min = 0;
      max = this.scope.ctrl.data.tsBuckets.length - 1;
      ticks = this.scope.ctrl.data.tsBuckets.length;
    } else {
      min = this.scope.ctrl.data.yAxis.min;
      max = this.scope.ctrl.data.yAxis.max;
      ticks = this.scope.ctrl.data.yAxis.ticks;
    }
    let histogramData = _.map(xBucket.buckets, bucket => {
      const count = bucket.count !== undefined ? bucket.count : bucket.values.length;
      return [bucket.bounds.bottom, count];
    });
    histogramData = _.filter(histogramData, d => {
      return d[0] >= min && d[0] <= max;
    });

    const scale = this.scope.yScale.copy();
    const histXScale = scale.domain([min, max]).range([0, HISTOGRAM_WIDTH]);

    let barWidth;
    if (this.panel.yAxis.logBase === 1) {
      barWidth = Math.floor(HISTOGRAM_WIDTH / (max - min) * yBucketSize * 0.9);
    } else {
      const barNumberFactor = yBucketSize ? yBucketSize : 1;
      barWidth = Math.floor(HISTOGRAM_WIDTH / ticks / barNumberFactor * 0.9);
    }
    barWidth = Math.max(barWidth, 1);

    // Normalize histogram Y axis
    const histogramDomain = _.reduce(_.map(histogramData, d => d[1]), (sum, val) => sum + val, 0);
    const histYScale = d3
      .scaleLinear()
      .domain([0, histogramDomain])
      .range([0, HISTOGRAM_HEIGHT]);

    const histogram = this.tooltip
      .select('.heatmap-histogram')
      .append('svg')
      .attr('width', HISTOGRAM_WIDTH)
      .attr('height', HISTOGRAM_HEIGHT);

    histogram
      .selectAll('.bar')
      .data(histogramData)
      .enter()
      .append('rect')
      .attr('x', d => {
        return histXScale(d[0]);
      })
      .attr('width', barWidth)
      .attr('y', d => {
        return HISTOGRAM_HEIGHT - histYScale(d[1]);
      })
      .attr('height', d => {
        return histYScale(d[1]);
      });
  }
开发者ID:CorpGlory,项目名称:grafana,代码行数:62,代码来源:heatmap_tooltip.ts


示例7: function

 controller: function($scope, $uibModalInstance, Oppiaineet, OsanMuokkausHelper) {
     $scope.kohdealueet = _.map(
         _.clone(OsanMuokkausHelper.getOppiaine().kohdealueet) || [],
         function(ka: any) {
             ka.$vanhaNimi = _.clone(ka.nimi);
             return ka;
         }
     );
     $scope.poistaKohdealue = function(ka) {
         Oppiaineet.poistaKohdealue(
             {
                 perusteId: ProxyService.get("perusteId"),
                 osanId: OsanMuokkausHelper.getOppiaine().id,
                 kohdealueId: ka.id
             },
             function() {
                 _.remove($scope.kohdealueet, ka);
             },
             Notifikaatiot.serverCb
         );
     };
     $scope.lisaaKohdealue = function() {
         Oppiaineet.lisaaKohdealue(
             {
                 perusteId: ProxyService.get("perusteId"),
                 osanId: OsanMuokkausHelper.getOppiaine().id
             },
             { nimi: { fi: "Uusi tavoitealue" } },
             function(res) {
                 $scope.kohdealueet.push(res);
             }
         );
     };
     $scope.ok = function(kohdealueet) {
         $q
             .all(
                 _(kohdealueet)
                     .reject(function(ka) {
                         return _.isEqual(ka.nimi, ka.$vanhaNimi);
                     })
                     .map(function(ka) {
                         return Oppiaineet.lisaaKohdealue(
                             {
                                 perusteId: ProxyService.get("perusteId"),
                                 osanId: OsanMuokkausHelper.getOppiaine().id
                             },
                             ka
                         ).$promise;
                     })
                     .value()
             )
             .then(
                 Oppiaineet.kohdealueet(
                     {
                         perusteId: ProxyService.get("perusteId"),
                         osanId: OsanMuokkausHelper.getOppiaine().id
                     },
                     $uibModalInstance.close
                 )
             );
     };
 }
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:62,代码来源:osanmuokkaus.ts


示例8: shouldAddField

    return this.get('/_mapping').then(function(result) {

      var typeMap = {
        'float': 'number',
        'double': 'number',
        'integer': 'number',
        'long': 'number',
        'date': 'date',
        'string': 'string',
        'text': 'string',
        'scaled_float': 'number',
        'nested': 'nested'
      };

      function shouldAddField(obj, key, query) {
        if (key[0] === '_') {
          return false;
        }

        if (!query.type) {
          return true;
        }

        // equal query type filter, or via typemap translation
        return query.type === obj.type || query.type === typeMap[obj.type];
      }

      // Store subfield names: [system, process, cpu, total] -> system.process.cpu.total
      var fieldNameParts = [];
      var fields = {};

      function getFieldsRecursively(obj) {
        for (var key in obj) {
          var subObj = obj[key];

          // Check mapping field for nested fields
          if (_.isObject(subObj.properties)) {
            fieldNameParts.push(key);
            getFieldsRecursively(subObj.properties);
          }

          if (_.isObject(subObj.fields)) {
            fieldNameParts.push(key);
            getFieldsRecursively(subObj.fields);
          }

          if (_.isString(subObj.type)) {
            var fieldName = fieldNameParts.concat(key).join('.');

            // Hide meta-fields and check field type
            if (shouldAddField(subObj, key, query)) {
              fields[fieldName] = {
                text: fieldName,
                type: subObj.type
              };
            }
          }
        }
        fieldNameParts.pop();
      }

      for (var indexName in result) {
        var index = result[indexName];
        if (index && index.mappings) {
          var mappings = index.mappings;
          for (var typeName in mappings) {
            var properties = mappings[typeName].properties;
            getFieldsRecursively(properties);
          }
        }
      }

      // transform to array
      return _.map(fields, function(value) {
        return value;
      });
    });
开发者ID:PaulMest,项目名称:grafana,代码行数:77,代码来源:datasource.ts


示例9: function

 var ticks = _.map(data, function(series, seriesIndex) {
   return _.map(series.datapoints, function(point, pointIndex) {
     var tickIndex = seriesIndex * series.datapoints.length + pointIndex;
     return [tickIndex + 1, point[1]];
   });
 });
开发者ID:,项目名称:,代码行数:6,代码来源:


示例10: getMinLog

// Get minimum non zero value.
function getMinLog(series) {
  let values = _.compact(_.map(series.datapoints, p => p[0]));
  return _.min(values);
}
开发者ID:PaulMest,项目名称:grafana,代码行数:5,代码来源:heatmap_data_converter.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.mapKeys函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.lowerFirst函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap