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


TypeScript file-url.default函數代碼示例

本文整理匯總了TypeScript中file-url.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createTweetMessage

	ipcRenderer.on('itunes-get-track-reply', (event, arg) => {
		nowPlayingTrack = arg as NowPlayingTrack
		console.log('get track success')
		console.log(nowPlayingTrack)
		trackNameElement.innerHTML = createTweetMessage(nowPlayingTrack)
		artworkImageElement.style.backgroundImage = `url(${fileUrl(nowPlayingTrack.artworkPath)})`
	})
開發者ID:castaneai,項目名稱:nowpl,代碼行數:7,代碼來源:index.ts

示例2: CreateFileOrFolderUri

export function CreateFileOrFolderUri(absolutePath: string): string {
  if (!isAbsolute(absolutePath)) {
    throw new Error(`Can only create file URIs from absolute paths. Got '${absolutePath}'`);
  }
  let result = fileUri(absolutePath, { resolve: false });
  // handle UNCs
  if (absolutePath.startsWith("//") || absolutePath.startsWith("\\\\")) {
    result = result.replace(/^file:\/\/\/\//, "file://");
  }
  return result;
}
開發者ID:indrajithbandara,項目名稱:autorest,代碼行數:11,代碼來源:uri.ts

示例3: grammarFromSource

async function grammarFromSource(rngSource: string | Grammar):
Promise<Grammar> {
  if (rngSource instanceof Grammar) {
    return rngSource;
  }

  const rngSourceContent = fs.readFileSync(path.resolve(rngSource),
                                           "utf8").toString();
  // We try loading the tree as a JSON file. It may not work if the file is not
  // actually JSON.
  let obj: {} | undefined;
  try {
    obj = JSON.parse(rngSourceContent);
  }
  // tslint:disable-next-line:no-empty
  catch {}

  if (obj !== undefined) {
    return readTreeFromJSON(obj);
  }

  // Treat it as a Relax NG schema.
  return (await convertRNGToPattern(new URL(fileUrl(rngSource)))).pattern;
}
開發者ID:lddubeau,項目名稱:salve,代碼行數:24,代碼來源:parse.ts

示例4: CreateFileOrFolderUri

export function CreateFileOrFolderUri(absolutePath: string): string {
  if (!isAbsolute(absolutePath)) {
    throw new Error("Can only create file URIs from absolute paths.");
  }
  return fileUri(absolutePath, { resolve: false });
}
開發者ID:jianghaolu,項目名稱:AutoRest,代碼行數:6,代碼來源:uri.ts

示例5: start

async function start(): Promise<void> {
  let startTime: number | undefined;
  if (args.simplified_input) {
    return convert({
      simplified: parseSimplifiedSchema(
        args.input_path,
        fs.readFileSync(args.input_path).toString()),
      warnings: [],
      manifest: [],
    });
  }

  const resourceLoader = makeResourceLoader();

  let simplified: Element | undefined;
  let warnings: string[] | undefined;
  if (args.validator !== "none") {
    if (args.verbose) {
      console.log("Validating RNG...");
      if (args.timing) {
        startTime = Date.now();
      }
    }

    const validator = makeValidator(args.validator, {
      verbose: args.verbose,
      timing: args.timing,
      resourceLoader,
      keepTemp: args.keep_temp,
      simplifyTo: args.simplify_to,
      ensureTempDir,
      validate: true,
      createManifest: false,
      manifestHashAlgorithm: "void",
    });

    ({ simplified, warnings } =
     await validator.validate(new URL(fileUrl(args.input_path))));

    if (args.timing) {
      console.log(`Validation delta: ${Date.now() - startTime!}`);
    }
  }

  if (simplified !== undefined) {
    return convert({
      simplified,
      warnings: warnings === undefined ? [] : warnings,
      manifest: [],
    });
  }

  const simplifier = makeSimplifier(args.simplifier, {
    verbose: args.verbose,
    timing: args.timing,
    keepTemp: args.keep_temp,
    simplifyTo: args.simplify_to,
    ensureTempDir,
    resourceLoader,
    validate: false,
    createManifest: false,
    manifestHashAlgorithm: "void",
  });

  return simplifier.simplify(new URL(fileUrl(args.input_path))).then(convert);
}
開發者ID:lddubeau,項目名稱:salve,代碼行數:66,代碼來源:convert.ts


注:本文中的file-url.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。