當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript require.has函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。