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

TypeScript undefined.forEach函数代码示例

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

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



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

示例1: classifier

  topic.actions.forEach((action: ActionCollection) => { // eslint-disable-line no-unused-vars
    const phrases = action.phrases;
    const key = action.action;

    const thisClassifier = new classifier();
    const otherPhrases = _.difference(allPhrases, phrases);
    // console.log(value);
    phrases.forEach(phrase => thisClassifier.addDocument(phrase, 'true'));
    otherPhrases.forEach(phrase => thisClassifier.addDocument(phrase, 'false'));
    thisClassifier.train();

    // console.log(`--${key}--`);
    //
    // const othersChecked = otherPhrases.map(phrase => thisClassifier.classify(phrase)).map((classified, index) => {
    //   if (classified === 'true') {
    //     // console.log('other', index, otherPhrases[index], thisClassifier.getClassifications(otherPhrases[index]));
    //     return otherPhrases[index];
    //   }
    //   return null;
    // });
    //
    // const selfChecked = phrases.map(phrase => thisClassifier.classify(phrase)).map((classified, index) => {
    //   if (classified === 'false') {
    //     // console.log('self', index, value[index], thisClassifier.getClassifications(value[index]));
    //     return phrases[index];
    //   }
    //   // console.log(value[index], thisClassifier.getClassifications(value[index]));
    //   return null;
    // });
    // console.log('other:', otherPhrases.length, '  self:', value.length);
    // console.log('passed for other', _.compact(othersChecked));
    // console.log('failed for home', _.compact(selfChecked));

    classifiers[key] = thisClassifier;
  });
开发者ID:LexieCore,项目名称:bot-framework,代码行数:35,代码来源:classifier.ts


示例2: require

  config.plugins.forEach((plugin) => {
    const CommandApp = require(plugin);

    if (!Array.isArray(CommandApp)) {
      return app.registerApp(CommandApp);
    }

    return CommandApp.forEach(PluginApp => app.registerApp(PluginApp));
  });
开发者ID:Travix-International,项目名称:frint,代码行数:9,代码来源:frint.ts


示例3: require

const actual = (file: string) => {
  const data = require(path.join(srcDir, file));
  const hash: Record<string, any> = {};
  data.forEach((item: any) => {
    for (const key in item) {
      hash[key] = item[key];
    }
  });

  return {
    hash,
    get: (subnet: string) => {
      const item = hash[subnet];
      assert(item);
      return item;
    },
  };
};
开发者ID:runk,项目名称:node-maxmind,代码行数:18,代码来源:integration.test.ts


示例4: require

(() => {
	"use strict";

	const path = require("path");
	let config = require('../config/config.json');
	config.serverRoot = path.join(__dirname, '../');
	const routes = require(config.serverRoot + 'config/routes.json');
	const fs = require("fs");
	const http = require('http');
	const https = require('https');
	const bodyParser = require('body-parser')
	const express = require('express');
	const exphbs = require('express-handlebars');
	const app = express();


	//set view engine
	if (config.handlebarsTemplateEngine) {
		app.set('views', config.serverRoot + '/views');
		
		const exphbsOptions = {
			defaultLayout: 'main',
			layoutsDir: config.serverRoot + '/views/layouts',
			partialsDir: config.serverRoot + '/views/partials',
			extname: ".view.html"
		};

		app.engine('.view.html', exphbs(exphbsOptions));
		app.set('view engine', '.view.html');
		app.enable('view cache');
	}

	//setting the static folder fo the app
	app.use(express.static(path.join(config.serverRoot, '../src/public')));


	//routing
	//loop through the routes.json file
	//connecting the right controller 
	//for each route and create it
	routes.forEach((route) => {
		const controller = require(config.serverRoot + '/controllers/' + route.controller + '.ctrl');
		let middlewares = [];

		//load middlewares if exist for this route
		if (typeof route.middlewares !== "undefined" && route.middlewares.length) {
			route.middlewares.forEach((midName) => {
				const m = require(config.serverRoot + '/middlewares/' + midName + '.mid.ts');
				middlewares.push(m);
			});
		}

		app.all(route.path, middlewares, controller);
	});


	//reducing the http header size 
	//by removing x-powered-by
	app.disable('x-powered-by');


	//set the http server
	if (config.httpServer) {
		const httpServer = http.createServer(app);
		httpServer.listen(config.httpPort, () => {
			console.log(`${config.appName} http server listening on port ${config.httpPort}`);
		});
	}


	//set the https server
	if (config.httpsServer) {
		const sslConfig = {
			key: fs.readFileSync(config.serverRoot + 'config/ssl/file.pem'),
			cert: fs.readFileSync(config.serverRoot + 'config/ssl/file.crt')
		};

		const httpsServer = https.createServer(sslConfig, app);

		httpsServer.listen(config.httpsPort, () => {
			console.log(`${config.appName} https server listening on port ${config.httpsPort}`);
		});
	}
})();
开发者ID:spear4life,项目名称:Socotra,代码行数:84,代码来源:main.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript undefined.getErrorMessage函数代码示例发布时间:2022-05-25
下一篇:
TypeScript undefined.findFiles函数代码示例发布时间: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