本文整理汇总了TypeScript中config.has函数的典型用法代码示例。如果您正苦于以下问题:TypeScript has函数的具体用法?TypeScript has怎么用?TypeScript has使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: readLogConfig
function readLogConfig(): LogConfig {
const requiredHTTP: string[] = ['ssl', 'method', 'host', 'port', 'path', 'level'];
const requiredFile: string[] = ['dir', 'filename', 'maxSizeInKB', 'level'];
const requiredConsole: string[] = ['logConsole', 'level'];
let config: LogConfig = {
http: has('log.http') ? readRequired(_.map(requiredHTTP, (name) => 'log.http.' + name), 'log.http.') : undefined,
file: has('log.file') ? readRequired(_.map(requiredFile, (name) => 'log.file.' + name), 'log.file.') : undefined,
console: has('log.console') ? readRequired(_.map(requiredConsole, (name) => 'log.console.' + name), 'log.console.') : undefined,
};
return config;
};
示例2: checkMissedConfig
// Check the config files
function checkMissedConfig () {
const required = [ 'listen.port', 'listen.hostname',
'webserver.https', 'webserver.hostname', 'webserver.port',
'trust_proxy',
'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
'redis.hostname', 'redis.port', 'redis.auth', 'redis.db',
'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address',
'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache',
'log.level',
'user.video_quota',
'cache.previews.size', 'admin.email',
'signup.enabled', 'signup.limit', 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist',
'transcoding.enabled', 'transcoding.threads',
'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route',
'instance.default_nsfw_policy', 'instance.robots',
'services.twitter.username', 'services.twitter.whitelisted'
]
const miss: string[] = []
for (const key of required) {
if (!config.has(key)) {
miss.push(key)
}
}
return miss
}
示例3: url
function url (serviceName: string): string {
const healthCheckUrlLocation = `${serviceName}.infoContributorUrl`
if (config.has(healthCheckUrlLocation)) {
return config.get<string>(healthCheckUrlLocation)
} else {
return config.get<string>(`${serviceName}.url`) + '/info'
}
}
示例4: checkConfig
// Some checks on configuration files
function checkConfig () {
if (config.has('webserver.host')) {
let errorMessage = '`host` config key was renamed to `hostname` but it seems you still have a `host` key in your configuration files!'
errorMessage += ' Please ensure to rename your `host` configuration to `hostname`.'
return errorMessage
}
return null
}
示例5: checkMissedConfig
// Check the config files
function checkMissedConfig () {
const required = [ 'listen.port',
'webserver.https', 'webserver.hostname', 'webserver.port',
'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', 'storage.torrents', 'storage.cache', 'log.level',
'cache.previews.size', 'admin.email', 'signup.enabled', 'signup.limit', 'transcoding.enabled', 'transcoding.threads',
'user.video_quota', 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address',
'instance.name', 'instance.description', 'instance.terms'
]
const miss: string[] = []
for (const key of required) {
if (!config.has(key)) {
miss.push(key)
}
}
return miss
}
示例6:
/// <reference path="config.d.ts" />
import * as config from "config";
var class1: config.IConfig = config;
var value1: string = config.get<string>("");
var value2: any = config.get("");
var has: boolean = config.has("");
// util tests:
var extended1: any = config.util.extendDeep({}, {});
var extended2: any = config.util.extendDeep({}, {}, 20);
var clone1: any = config.util.cloneDeep({});
var clone2: any = config.util.cloneDeep({}, 20);
var equals1: boolean = config.util.equalsDeep({}, {});
var equals2: boolean = config.util.equalsDeep({}, {}, 20);
var diff1: any = config.util.diffDeep({}, {});
var diff2: any = config.util.diffDeep({}, {}, 20);
var immutable1: any = config.util.makeImmutable({});
var immutable2: any = config.util.makeImmutable({}, "");
var immutable3: any = config.util.makeImmutable({}, "", "");
var hidden1: any = config.util.makeHidden({}, "");
var hidden2: any = config.util.makeHidden({}, "", "");
示例7: has
return _.reduce(optional, (result: any, item: OptionalItem) => {
return _.set(result, item.name.replace(regex, ''), has(item.name) ? get(item.name) : item.defaultValue);
}, {});
示例8: Error
throw new Error(`Required configuration was not found: ` + _.map(required, (name: string) => `${name}: ${has(name)} - ${has(name) ? get(name) : '"undefined"'}, `).join());
示例9:
if (false === _.every(required, (name: string) => has(name))) {
示例10: hasConfig
hasConfig(key: string): boolean {
return config.has(key);
}