本文整理汇总了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);
}
示例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;
示例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 });
},
});
}
示例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 });
},
});
}