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

TypeScript undefined.hasOwnProperty函数代码示例

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

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



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

示例1: parse

export function parse (): Config {

  try {
    const packageJson = require(`${process.cwd()}/package.json`)
    if (packageJson.hasOwnProperty('graphql')) {
      return parseConfigJson(packageJson.graphql)
    }
  } catch (ex) {
    // do nothing here
  }

  try {
    const graphqlrc = JSON.parse(readFileSync(`${process.cwd()}/.graphqlrc`, 'utf-8'))
    return parseConfigJson(graphqlrc)
  } catch (ex) {
    // do nothing here
  }

  if (process.env.hasOwnProperty('GRAPHQL_ENDPOINT')) {
    const endpoint = process.env.GRAPHQL_ENDPOINT
    if (!isWebUri(endpoint)) {
      throw new Error(`No valid GraphQL endpoint: ${endpoint}`)
    }

    return {
      url: endpoint,
      type: 'request',
    } as ConfigRequest
  }

  throw new Error('Couldn\'t find a GraphQL config. Please refer to https://github.com/graphcool/graphql-config')
}
开发者ID:julianbauer,项目名称:graphql-config,代码行数:32,代码来源:index.ts


示例2: require

 .flatMap((modelSchema) => {
   let schema = require(modelSchema), loader;
   if (schema.hasOwnProperty('mongodb')) {
     loader = mongoDbAttached(app, schema, configs);
   } else {
     loader = defaultAttached(app, schema, configs);
   }
   return loader;
 });
开发者ID:aelbore,项目名称:loopback-model-binder,代码行数:9,代码来源:model-loader.ts


示例3: assert

                lines.forEach(line => {
                    if (line.search(/Get-VstsLocString/i) > 0) {
                        var result = /Get-VstsLocString +-Key +('[^']+'|"[^"]+"|[^ )]+)/i.exec(line);
                        if (!result) {
                            assert(false, 'Bad format string in file ' + psFile + ' on line: ' + line);
                        }

                        var key = result[1].replace(/['"]/g, "");
                        assert(
                            obj.hasOwnProperty('messages') && obj.messages.hasOwnProperty(key),
                            "Loc resource key not found in task.json/module.json. Resource key: '" + key + "', PS file: '" + psFile + "', JSON file: '" + jsonFile + "'.");
                    }
                });
开发者ID:AndyGerlicher,项目名称:vso-agent-tasks,代码行数:13,代码来源:_suite.ts


示例4: addRoutes

function addRoutes(base: 'protected'|'unprotected') {
    const routes = getRouteModuleNames(path.resolve(__dirname, base));
    for (const routeModuleName of routes) {
        const routeModule = require(`./${base}/${routeModuleName}`);
        for (const routeKey in routeModule) {
            if (!routeModule.hasOwnProperty(routeKey)) continue;
            const route: Router = routeModule[routeKey];
            if (base === 'protected')
                router.use(`/api/${routeModuleName}`, jwt, route.routes(), route.allowedMethods());
            else
                router.use(`/api/${routeModuleName}`, route.routes(), route.allowedMethods());
        }
    }
}
开发者ID:giggio,项目名称:transempregos-portal,代码行数:14,代码来源:router.ts


示例5: it

	it('Find invalid message key in task.json', (done) => {
		this.timeout(1000);
		
		var tasksRootFolder =  path.resolve(__dirname, '../../../Tasks');
		var jsons: string[] = [];
		fs.readdirSync(tasksRootFolder).forEach(folderName=> {
			if(fs.statSync(path.join(tasksRootFolder, folderName)).isDirectory()) { 
				jsons.push(path.join(tasksRootFolder, folderName, "task.json"));
			}
		})
        // The Common folder does not get copied under _build so scan the source folder instead.
        var commonFolder = path.resolve(__dirname, "../../../../Tasks/Common");
        fs.readdirSync(commonFolder).forEach(folderName => {
            var moduleFolder = path.join(commonFolder, folderName);
            var moduleJson = path.join(moduleFolder, "module.json");
            if (fs.statSync(moduleFolder).isDirectory() && fs.existsSync(moduleJson)) {
                jsons.push(moduleJson);
            }
        })

		for(var i = 0; i < jsons.length; i++) {
			var json = jsons[i];
			var obj = require(json);
			if(obj.hasOwnProperty('messages')) {
				for(var key in obj.messages) {
					var jsonName = path.relative(tasksRootFolder, json);
					assert(key.search(/\W+/gi) < 0, ('(' + jsonName +')' + 'messages key: \'' + key +'\' contain non-word characters, only allows [a-zA-Z0-9_].'));
					if(typeof(obj.messages[key]) === 'object') {
						assert(obj.messages[key].loc, ('(' + jsonName +')' + 'messages key: \'' + key +'\' should have a loc string.'));
						assert(obj.messages[key].loc.toString().length >= 0, ('(' + jsonName +')' + 'messages key: \'' + key +'\' should have a loc string.'));
						assert(obj.messages[key].fallback, ('(' + jsonName +')' + 'messages key: \'' + key +'\' should have a fallback string.'));
						assert(obj.messages[key].fallback.toString().length > 0, ('(' + jsonName +')' + 'messages key: \'' + key +'\' should have a fallback string.'));
					}
					else if(typeof(obj.messages[key]) === 'string') {
						assert(obj.messages[key].toString().length > 0, ('(' + jsonName +')' + 'messages key: \'' + key +'\' should have a loc string.'));
					} 
        		}
			}
		}
		
		done();
	})
开发者ID:AndyGerlicher,项目名称:vso-agent-tasks,代码行数:42,代码来源:_suite.ts


示例6: it

    it('validate loc string key in lib.json', function (done) {
        this.timeout(1000);

        var jsonPath = path.join(__dirname, '../lib.json');
        var json = require(jsonPath);
        if (json && json.hasOwnProperty('messages')) {
            for (var key in json.messages) {
                assert(key.search(/\W+/gi) < 0, ('messages key: \'' + key + '\' contain non-word characters, only allows [a-zA-Z0-9_].'));
                assert(key.search(/^LIB_/) === 0, ('messages key: \'' + key + '\' should start with \'LIB_\'.'));
                if (typeof (json.messages[key]) === 'object') {
                    assert(false, ('messages key: \'' + key + '\' should have a loc string, not a object.'));
                }
                else if (typeof (json.messages[key]) === 'string') {
                    assert(json.messages[key].toString().length > 0, ('messages key: \'' + key + '\' should have a loc string.'));
                }
            }
        }

        done();
    })
开发者ID:tspascoal,项目名称:vsts-task-lib,代码行数:20,代码来源:loctests.ts


示例7: overrideSysDefaults

        overrideSysDefaults(ts_impl: typeof ts, state: TypeScriptPluginState, serverFile: string) {
            const path = require('path');
            let tsPath = path.join(state.serverFolderPath, 'typescript.js');
            try {
                let fullTypescriptVersion = require(tsPath);
                for (let prop in fullTypescriptVersion) {
                    if (fullTypescriptVersion.hasOwnProperty(prop)) {
                        ts_impl[prop] = fullTypescriptVersion[prop];
                    }
                }

                ts_impl["ide_processed"] = true;

                //clean resources
                let name = require.resolve(tsPath);
                delete require.cache[name];
            } catch (err) {
                //do nothing
            }


            super.overrideSysDefaults(ts_impl, state, serverFile);
        }
开发者ID:wj86611199,项目名称:intellij-plugins,代码行数:23,代码来源:angular-plugin.ts


示例8: databaseUrl

    player: {
        username: string,
        password: string
    }

    database: {
        host: string,
        port: number,
        schema: string,
        username: string,
        password: string
    }

    get databaseUrl(): string {
        return "mongodb://" + this.database.username + ":" + this.database.password + "@" + this.database.host + ":" + this.database.port + "/" + this.database.schema;
    }
}

export var configuration: Configuration = new Configuration();

var configurationFile = DEFAULT_CONFIGURATION_FILE;
var configurationJson: {} = require(configurationFile);

for (var key in configurationJson) {
    if (!configurationJson.hasOwnProperty(key)) {
        continue;
    }

    configuration[key] = configurationJson[key];
}
开发者ID:herrevilkitten,项目名称:mux-per-ass,代码行数:30,代码来源:config.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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