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


TypeScript lodash.each函数代码示例

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


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

示例1: each

import { each, kebabCase } from 'lodash';
import { ModuleTitle, Semester, ModuleCode } from 'types/modules';
import { Venue } from 'types/venues';
import { SemTimetableConfig } from 'types/timetables';
import { serializeTimetable } from 'utils/timetables';
import config from 'config';

// IMPORTANT: Remember to update any route changes on the sitemap

// Cache semester -> path and path -> semester mappings
export const fromSemester: { [semester: string]: string } = {};
const toSemester: { [key: string]: Semester } = {};
each(config.shortSemesterNames, (name, semester) => {
  const path = kebabCase(name);
  fromSemester[semester] = path;
  toSemester[path] = Number(semester);
});

// Semester -> Timetable path
export function timetablePage(semester: Semester): string {
  return `/timetable/${fromSemester[semester]}`;
}

export const TIMETABLE_SHARE = 'share';
export function timetableShare(semester: Semester, timetable: SemTimetableConfig): string {
  return `${timetablePage(semester)}/${TIMETABLE_SHARE}?${serializeTimetable(timetable)}`;
}

// Timetable path -> Semester
export function semesterForTimetablePage(semStr: string | null | undefined): Semester | null {
  if (!semStr) return null;
开发者ID:nusmodifications,项目名称:nusmods,代码行数:31,代码来源:paths.ts

示例2: init

  init() {
    var app = angular.module('grafana', []);

    moment.locale(config.bootData.user.locale);

    app.config(($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $httpProvider, $provide) => {
      // pre assing bindings before constructor calls
      $compileProvider.preAssignBindingsEnabled(true);

      if (config.buildInfo.env !== 'development') {
        $compileProvider.debugInfoEnabled(false);
      }

      $httpProvider.useApplyAsync(true);

      this.registerFunctions.controller = $controllerProvider.register;
      this.registerFunctions.directive  = $compileProvider.directive;
      this.registerFunctions.factory    = $provide.factory;
      this.registerFunctions.service    = $provide.service;
      this.registerFunctions.filter     = $filterProvider.register;

      $provide.decorator("$http", ["$delegate", "$templateCache", function($delegate, $templateCache) {
        var get = $delegate.get;
        $delegate.get = function(url, config) {
          if (url.match(/\.html$/)) {
            // some template's already exist in the cache
            if (!$templateCache.get(url)) {
              url += "?v=" + new Date().getTime();
            }
          }
          return get(url, config);
        };
        return $delegate;
      }]);
    });

    this.ngModuleDependencies = [
      'grafana.core',
      'ngRoute',
      'ngSanitize',
      '$strap.directives',
      'ang-drag-drop',
      'grafana',
      'pasvaz.bindonce',
      'ui.bootstrap',
      'ui.bootstrap.tpls',
      'react'
    ];

    var module_types = ['controllers', 'directives', 'factories', 'services', 'filters', 'routes'];

    _.each(module_types, type => {
      var moduleName = 'grafana.' + type;
      this.useModule(angular.module(moduleName, []));
    });

    // makes it possible to add dynamic stuff
    this.useModule(coreModule);

    // register react angular wrappers
    registerAngularDirectives();

    var preBootRequires = [System.import('app/features/all')];

    Promise.all(preBootRequires).then(() => {
      // disable tool tip animation
      $.fn.tooltip.defaults.animation = false;
      // bootstrap the app
      angular.bootstrap(document, this.ngModuleDependencies).invoke(() => {
        _.each(this.preBootModules, module => {
          _.extend(module, this.registerFunctions);
        });

        this.preBootModules = null;
      });
    }).catch(function(err) {
      console.log('Application boot failed:', err);
    });
  }
开发者ID:connection-reset,项目名称:grafana,代码行数:79,代码来源:app.ts

示例3: generateTreatments

export function generateTreatments(evidenceTreatments:any)
{
    var treatments: any = {};
    var result: any[] = [];

    _.each(evidenceTreatments, function(content, type) {
        _.each(content, function(item, index) {
            var _level = getLevel(item.level);
            var _treatment = treatmentsToStr(item.content);
            var _tumorType = item.tumorType;
            var _alterations = item.alterations.map(function(alt:any) {
                return alt.alteration;
            }).join(',');
            if (!treatments.hasOwnProperty(_level)) {
                treatments[_level] = {};
            }
            if (!treatments[_level].hasOwnProperty(_alterations)) {
                treatments[_level][_alterations] = {};
            }

            if (!treatments[_level][_alterations].hasOwnProperty(_treatment)) {
                treatments[_level][_alterations][_treatment] = {};
            }

            if (!treatments[_level][_alterations][_treatment].hasOwnProperty(_tumorType)) {
                treatments[_level][_alterations][_treatment][_tumorType] = {
                    articles: [],
                    tumorType: _tumorType,
                    alterations: item.alterations,
                    level: _level,
                    description: item.description,
                    treatment: _treatment
                };
            } else {
                treatments[_level][_alterations][_treatment][_tumorType].description = [treatments[_level][_alterations][_treatment][_tumorType].description, '<br/>', item.description].join();
            }
            treatments[_level][_alterations][_treatment][_tumorType].articles = _.union(treatments[_level][_alterations][_treatment][_tumorType].articles, item.articles);
        });
    });

    _.each(_.keys(treatments).sort(function(a, b) {
        return LEVELS.all.indexOf(a) > LEVELS.all.indexOf(b) ? -1 : 1;
    }), function(level) {
        _.each(_.keys(treatments[level]).sort(), function(_alteration) {
            _.each(_.keys(treatments[level][_alteration]).sort(), function(_treatment) {
                _.each(_.keys(treatments[level][_alteration][_treatment]).sort(), function(_tumorType) {
                    var content = treatments[level][_alteration][_treatment][_tumorType];
                    result.push({
                        level: content.level,
                        variant: content.alterations.map(function(alteration:any) {
                            return alteration.alteration;
                        }),
                        treatment: _treatment,
                        pmids: content.articles.filter(function(article:any) {
                            return !isNaN(article.pmid);
                        }).map(function(article:any) {
                            return Number(article.pmid);
                        }).sort(),
                        abstracts: content.articles.filter(function(article:any) {
                            return _.isString(article.abstract);
                        }).map(function(article:any) {
                            return {
                                abstract: article.abstract,
                                link: article.link
                            };
                        }),
                        description: content.description,
                        cancerType: content.tumorType
                    });
                });
            });
        });
    });

    return result;
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:76,代码来源:OncoKbUtils.ts

示例4: _handleIncomingPayments

  _handleIncomingPayments(coin, network, data) {
    if (!data) return;
    // console.log('[blockchainmonitor.js.158:data:]',data); //TODO

    let outs: any[];
    // ! v8?
    if (!data.outs) {
      if (!data.vout) return;
      outs = _.compact(
        _.map(data.vout, (v) => {
          let addr = _.keys(v)[0];
          const amount = +v[addr];

          return {
            address: addr,
            amount
          };
        })
      );
      if (_.isEmpty(outs)) return;
    } else {
      outs = data.outs;
      _.each(outs, x => {
        if (x.amount) {
          // to satoshis
          x.amount = +(x.amount * 1e8).toFixed(0);
        }
      });
    }
    async.each(
      outs,
      (out, next) => {
        if (!out.address) return next();

        // toDo, remove coin  here: no more same address for diff coins
        this.storage.fetchAddressByCoin(coin, out.address, (
          err,
          address
        ) => {
          if (err) {
            log.error('Could not fetch addresses from the db');
            return next(err);
          }
          if (!address || address.isChange) return next();

          const walletId = address.walletId;
          log.debug(
            'Incoming tx for wallet ' +
            walletId +
            ' [' +
            out.amount +
            'sat -> ' +
            out.address +
            ']'
          );

          const fromTs = Date.now() - 24 * 3600 * 1000;
          this.storage.fetchNotifications(walletId, null, fromTs, (
            err,
            notifications
          ) => {
            if (err) return next(err);
            const alreadyNotified = _.some(notifications, (n) => {
              return (
                n.type == 'NewIncomingTx' && n.data && n.data.txid == data.txid
              );
            });
            if (alreadyNotified) {
              log.debug(
                'The incoming tx ' + data.txid + ' was already notified'
              );
              return next();
            }

            const notification = Notification.create({
              type: 'NewIncomingTx',
              data: {
                txid: data.txid,
                address: out.address,
                amount: out.amount
              },
              walletId
            });

            this._storeAndBroadcastNotification(notification, next);
          });
        });
      },
      (err) => {
        return;
      }
    );
  }
开发者ID:bitpay,项目名称:bitcore,代码行数:93,代码来源:blockchainmonitor.ts

示例5:

 (acc, results) => {
     _.each(results, result => {
         result.filePath = atom.project.relativizePath(result.filePath)[1];
     });
     return acc.concat(results);
 },
开发者ID:OmniSharp,项目名称:atom-languageclient,代码行数:6,代码来源:DocumentFinderService.ts

示例6: generateProjects

function generateProjects(): any {

    let companyIds = Object.keys(store.companyMap);

    let projects = [
        'Cheerful Planet',
        'Star Rainbow',
        'Brave Mountain',
        'Electron',
        'Locomotive',
        'Compass',
        'Plutonium',
        'Jupiter',
        'Scoreboard',
        'Zeus',
        'Gamma',
        'Winter',
        'Helium',
        'Orange Fox',
        'Star Burst',
        'Puppet',
        'Eastern Railroad',
        'April Showers',
        'Dinosaur',
        'Elastic Cloud',
        'Rare Jazz',
        'Tungsten',
        'Sapphire',
        'Golden Viper',
        'Pink Floyd',
        'Aerosmith',
        'Stones',
        'Zeppelin',
        'Eagles',
        'Maroon Five'
    ];

    let locations = [
        'ATL',
        'BOS',
        'DEN',
        'DET',
        'LAS',
        'LAX',
        'MIA',
        'NYC',
        'ORD',
        'SFO'
    ];

    let projectMap: any = {};

    _.each(projects, company => {
        let id = nextId++;
        projectMap[id] = {
            id: id,
            name: company,
            location: chance.pick(locations),
            companyId: parseInt(chance.pick(companyIds))
        };
    });

    return projectMap;
}
开发者ID:jbhg,项目名称:staffer,代码行数:64,代码来源:generate-data.ts

示例7: getRelativeTimesList

  { from: 'now-2d', to: 'now', display: 'Last 2 days', section: 0 },
  { from: 'now-7d', to: 'now', display: 'Last 7 days', section: 0 },
  { from: 'now-30d', to: 'now', display: 'Last 30 days', section: 0 },
  { from: 'now-90d', to: 'now', display: 'Last 90 days', section: 0 },
  { from: 'now-6M', to: 'now', display: 'Last 6 months', section: 0 },
  { from: 'now-1y', to: 'now', display: 'Last 1 year', section: 0 },
  { from: 'now-2y', to: 'now', display: 'Last 2 years', section: 0 },
  { from: 'now-5y', to: 'now', display: 'Last 5 years', section: 0 },
];

const absoluteFormat = 'MMM D, YYYY HH:mm:ss';

const rangeIndex = {};
_.each(rangeOptions, frame => {
  rangeIndex[frame.from + ' to ' + frame.to] = frame;
});

export function getRelativeTimesList(timepickerSettings, currentDisplay) {
  const groups = _.groupBy(rangeOptions, (option: any) => {
    option.active = option.display === currentDisplay;
    return option.section;
  });

  // _.each(timepickerSettings.time_options, (duration: string) => {
  //   let info = describeTextRange(duration);
  //   if (info.section) {
  //     groups[info.section].push(info);
  //   }
  // });
开发者ID:ArcticSnowman,项目名称:grafana,代码行数:29,代码来源:rangeutil.ts

示例8: function

 _.each(seriesList, function(series) {
     _.each(series.datapoints, function(dp) {
         text += series.alias + ',' + new Date(dp[1]).toISOString() + ',' + dp[0] + '\n';
     });
 });
开发者ID:smur89,项目名称:grafana,代码行数:5,代码来源:file_export.ts

示例9: addFuncDef

addFuncDef({
  name: 'aliasByTags',
  category: categories.Special,
  params: [
    { name: 'tag', type: 'string' },
    { name: 'tag', type: 'string', optional: true },
    { name: 'tag', type: 'string', optional: true },
    { name: 'tag', type: 'string', optional: true },
  ],
  defaultParams: ['tag'],
  version: '1.1',
});

_.each(categories, function(funcList, catName) {
  categories[catName] = _.sortBy(funcList, 'name');
});

function isVersionRelatedFunction(func, graphiteVersion) {
  return isVersionGtOrEq(graphiteVersion, func.version) || !func.version;
}

export class FuncInstance {
  def: any;
  params: any;
  text: any;
  added: boolean;

  constructor(funcDef, options) {
    this.def = funcDef;
    this.params = [];
开发者ID:arcolife,项目名称:grafana,代码行数:30,代码来源:gfunc.ts

示例10: mapModel

 function mapModel() {
     _.each($scope.fields, field => {
         field.visible = $scope.fieldOps.hasContent(field);
     });
 }
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:5,代码来源:vaihe.ts


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