當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.map函數代碼示例

本文整理匯總了TypeScript中underscore.map函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript map函數的具體用法?TypeScript map怎麽用?TypeScript map使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了map函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: testUndeclaredImports

function testUndeclaredImports() {
    console.log(foo1); // failure on 'foo1'
    console.log(foo2); // failure on 'foo2'
    console.log(foo3); // failure on 'foo3'
    map([], (x) => x); // failure on 'map'
}
開發者ID:meros,項目名稱:tslint,代碼行數:6,代碼來源:nousebeforedeclare.test.ts

示例2: processItems

    return processItems({ id: null } as any, saleItems.map((i) => i.item)).then((items) => {
      const itemsById = _.indexBy(items, 'id');
      const categories = _.compact(
        _.map(vendor.saleItemCategories, (category: any) => {
          const categoryInfo = vendorDef.categories[category.categoryIndex];
          if (_.contains(categoryBlacklist, categoryInfo.categoryHash)) {
            return null;
          }

          const categoryItems = category.saleItems.map((saleItem) => {
            const unlocked = isSaleItemUnlocked(saleItem);
            return {
              index: saleItem.vendorItemIndex,
              costs: saleItem.costs
                .map((cost) => {
                  return {
                    value: cost.value,
                    currency: _.pick(
                      defs.InventoryItem.get(cost.itemHash),
                      'itemName',
                      'icon',
                      'itemHash'
                    )
                  };
                })
                .filter((c) => c.value > 0),
              item: itemsById[`vendor-${vendorDef.hash}-${saleItem.vendorItemIndex}`],
              // TODO: caveat, this won't update very often!
              unlocked,
              unlockedByCharacter: unlocked ? [store.id] : [],
              failureStrings: saleItem.failureIndexes
                .map((i) => vendorDef.failureStrings[i])
                .join('. ')
            };
          });

          let hasArmorWeaps = false;
          let hasVehicles = false;
          let hasShadersEmbs = false;
          let hasEmotes = false;
          let hasConsumables = false;
          let hasBounties = false;
          categoryItems.forEach((saleItem) => {
            const item = saleItem.item;
            if (
              item.bucket.sort === 'Weapons' ||
              item.bucket.sort === 'Armor' ||
              item.type === 'Artifact' ||
              item.type === 'Ghost'
            ) {
              if (item.talentGrid) {
                item.dtrRoll = _.compact(item.talentGrid.nodes.map((i) => i.dtrRoll)).join(';');
              }
              hasArmorWeaps = true;
            }
            if (item.type === 'Ship' || item.type === 'Vehicle') {
              hasVehicles = true;
            }
            if (item.type === 'Emblem' || item.type === 'Shader') {
              hasShadersEmbs = true;
            }
            if (item.type === 'Emote') {
              hasEmotes = true;
            }
            if (item.type === 'Material' || item.type === 'Consumable') {
              hasConsumables = true;
            }
            if (item.type === 'Bounties') {
              hasBounties = true;
            }
          });

          return {
            index: category.categoryIndex,
            title: categoryInfo.displayTitle,
            saleItems: categoryItems,
            hasArmorWeaps,
            hasVehicles,
            hasShadersEmbs,
            hasEmotes,
            hasConsumables,
            hasBounties
          };
        })
      );

      items.forEach((item: any) => {
        item.vendorIcon = createdVendor.icon;
      });

      createdVendor.categories = categories;

      createdVendor.hasArmorWeaps = _.any(categories, (c) => c.hasArmorWeaps);
      createdVendor.hasVehicles = _.any(categories, (c) => c.hasVehicles);
      createdVendor.hasShadersEmbs = _.any(categories, (c) => c.hasShadersEmbs);
      createdVendor.hasEmotes = _.any(categories, (c) => c.hasEmotes);
      createdVendor.hasConsumables = _.any(categories, (c) => c.hasConsumables);
      createdVendor.hasBounties = _.any(categories, (c) => c.hasBounties);

      return createdVendor;
//.........這裏部分代碼省略.........
開發者ID:bhollis,項目名稱:DIM,代碼行數:101,代碼來源:vendor.service.ts

示例3: ShowChart

    ShowChart(summaryData: any) {
        var centreName = [];
        var bookingData = [];
        var expenditureData = [];
        var receivableData = [];
        var profitData = [];
        _.map(summaryData["homeList"], (item) => {
            //debugger 
            centreName.push(item.centreDesc);
            bookingData.push(item.bookingAmount);
            expenditureData.push(item.maintenance);
            receivableData.push(item.receivable);
            profitData.push(item.profit);
            return item;
        });

        //var centreName = ['Tariq Rd', 'Nomayesh', 'Joher', 'Korangi', 'Landhi'];
        //var bookingData = [18500, 11300, 13700, 22400, 6200];
        //var expenditureData = [9000, 5700, 6500, 10200, 3000];
        //var receivableData = [3350, 2500, 4000, 6500, 2000];
        //var profitData = [9500, 5600, 7200, 12200, 3200];

        //this.homeItemView.$el.find("#container").highcharts({
        this.homeItemView.$el.find("#container")["highcharts"]({
            chart: {
                type: 'column',
                backgroundColor: 'transparent',
                options3d: {
                    enabled: true,
                    alpha: 15,
                    beta: 15,
                    viewDistance: 25,
                    depth: 40
                },
                marginTop: 80,
                marginRight: 40
            },

            title: {
                text: 'Booking Summary Report - Centre Wise',
                style: {
                    color: 'grey'
                }
            },

            xAxis: {
                categories: centreName
            },
            legend: {
                //layout: 'horizontal',
                itemStyle: {
                    color: 'grey'
                }

            },

            yAxis: {
                allowDecimals: false,
                min: 0,
                title: {
                    text: 'Amount in Rs'
                }
            },

            tooltip: {
                headerFormat: '<b>{point.key}</b><br>',
                pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: {point.y}'
            },

            plotOptions: {
                column: {
                    stacking: 'normal',
                    depth: 40
                }
            },
            series: [
                {
                    name: 'Booking',
                    data: bookingData,
                    stack: 'Booking'
                }, {
                    name: 'Maintenance',
                    data: expenditureData,
                    stack: 'Maintenance'
                }, {
                    name: 'Receivable',
                    data: receivableData,
                    stack: 'Receivable'
                }, {
                    name: 'Profit',
                    data: profitData,
                    stack: 'Profit'
                }]
        });

        var item = this.homeItemView.$el.find("text")[this.homeItemView.$el.find("text").length - 1];
        if (item != undefined) {
            item.innerHTML = "";
        }

//.........這裏部分代碼省略.........
開發者ID:saeed-ahmed,項目名稱:CCTracking,代碼行數:101,代碼來源:HomeCtrl.ts

示例4: map

import { actions } from "common/actions";
import reducer from "common/reducers/reducer";
import { DownloadsState } from "common/types";
import { indexBy, map } from "underscore";

const SPEED_DATA_POINT_COUNT = 60;

const initialState: DownloadsState = {
  speeds: map(new Array(SPEED_DATA_POINT_COUNT), x => 0),
  items: {},
  progresses: {},
  paused: true,
};

export default reducer<DownloadsState>(initialState, on => {
  on(actions.downloadsListed, (state, action) => {
    const { downloads } = action.payload;
    return {
      ...state,
      items: indexBy(downloads, "id"),
    };
  });

  on(actions.downloadProgress, (state, action) => {
    const { download, progress, speedHistory } = action.payload;
    return {
      ...state,
      progresses: {
        ...state.progresses,
        [download.id]: progress,
      },
開發者ID:itchio,項目名稱:itch,代碼行數:31,代碼來源:downloads.ts

示例5: getDefinitions

 getDefinitions().then((defs) => {
   const rawRecordBooks = stores[0].advisors.recordBooks;
   vm.recordBooks = _.map(rawRecordBooks, (rb) => processRecordBook(defs, rb));
 });
開發者ID:bhollis,項目名稱:DIM,代碼行數:4,代碼來源:record-books.component.ts

示例6: function

if((window as any).appPrefix === undefined){
    if(!window.entcore){
        window.entcore = {};
    }
	if(window.location.pathname.split('/').length > 0){
		(window as any).appPrefix = window.location.pathname.split('/')[1];
        window.entcore.appPrefix = (window as any).appPrefix;
	}
}

var xsrfCookie;
if(document.cookie){
    var cookies = _.map(document.cookie.split(';'), function(c){
        return {
            name: c.split('=')[0].trim(), 
            val: c.split('=')[1].trim()
        };
    });
    xsrfCookie = _.findWhere(cookies, { name: 'XSRF-TOKEN' });
}

export var appPrefix: string = (window as any).appPrefix;

if((window as any).infraPrefix === undefined){
	(window as any).infraPrefix = 'infra';
}

export let infraPrefix: string = (window as any).infraPrefix;
export let currentLanguage = '';

export const devices = {
開發者ID:entcore,項目名稱:infra-front,代碼行數:31,代碼來源:globals.ts

示例7: getFields

 getFields() {
   var defaultTemplates = _.map(TemplateCache.getDefaultTemplates(), name => TemplateCache.getTemplate(name));
   return _.flatten(_.map(defaultTemplates, (template: Template) => template.getFields()));
 }
開發者ID:francoislg,項目名稱:search-ui,代碼行數:4,代碼來源:DefaultResultTemplate.ts

示例8: map

 getQuickFilterText: (params: agGridModule.GetQuickFilterTextParams) => {
   const allValues = map(params.value.result.raw, val => val.toString());
   return Object.keys(params.value.result.raw)
     .concat(allValues)
     .join(' ');
 },
開發者ID:coveo,項目名稱:search-ui,代碼行數:6,代碼來源:MetaDataTable.ts


注:本文中的underscore.map函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。