本文整理汇总了TypeScript中require.has函数的典型用法代码示例。如果您正苦于以下问题:TypeScript has函数的具体用法?TypeScript has怎么用?TypeScript has使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: compile
/**
Uses HTMLBars `compile` function to process a string into a compiled template.
This is not present in production builds.
@private
@method compile
@param {String} templateString This is the string to be compiled by HTMLBars.
@param {Object} options This is an options hash to augment the compiler options.
*/
export default function compile(templateString: string, options: CompileOptions) {
if (!template && has('@ember/-internals/glimmer')) {
// tslint:disable-next-line:no-require-imports
template = require('@ember/-internals/glimmer').template;
}
if (!template) {
throw new Error(
'Cannot call `compile` with only the template compiler loaded. Please load `ember.debug.js` or `ember.prod.js` prior to calling `compile`.'
);
}
let precompiledTemplateString = precompile(templateString, options);
let templateJS = new Function(`return ${precompiledTemplateString}`)();
return template(templateJS);
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:26,代码来源:compile.ts
示例2: require
import require, { has } from 'require';
type MaybeFetch = {
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
} | null;
let _fetch: MaybeFetch = null;
if (has('fetch')) {
// use `fetch` module by default, this is commonly provided by ember-fetch
_fetch = require('fetch').default;
} else if (typeof fetch === 'function') {
// fallback to using global fetch
_fetch = fetch;
}
export default _fetch;
开发者ID:emberjs,项目名称:data,代码行数:17,代码来源:fetch.ts
示例3: require
import require, { has } from 'require';
import bootstrap from './bootstrap';
// Globals mode template compiler
if (has('@ember/application') && has('ember-browser-environment') && has('ember-glimmer')) {
// tslint:disable:no-require-imports
let emberEnv = require('ember-browser-environment');
let emberGlimmer = require('ember-glimmer');
let emberApp = require('@ember/application');
let Application = emberApp.default;
let { hasTemplate, setTemplate } = emberGlimmer;
let { hasDOM } = emberEnv;
Application.initializer({
name: 'domTemplates',
initialize() {
let context;
if (hasDOM) {
context = document;
}
bootstrap({ context, hasTemplate, setTemplate });
},
});
}
开发者ID:chundabear,项目名称:ember.js,代码行数:25,代码来源:initializer.ts
示例4: has
import require, { has } from 'require';
import bootstrap from './bootstrap';
// Globals mode template compiler
if (
has('@ember/application') &&
has('@ember/-internals/browser-environment') &&
has('@ember/-internals/glimmer')
) {
// tslint:disable:no-require-imports
let emberEnv = require('@ember/-internals/browser-environment');
let emberGlimmer = require('@ember/-internals/glimmer');
let emberApp = require('@ember/application');
let Application = emberApp.default;
let { hasTemplate, setTemplate } = emberGlimmer;
let { hasDOM } = emberEnv;
Application.initializer({
name: 'domTemplates',
initialize() {
let context;
if (hasDOM) {
context = document;
}
bootstrap({ context, hasTemplate, setTemplate });
},
});
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:29,代码来源:initializer.ts
注:本文中的require.has函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论