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


TypeScript url.resolve函數代碼示例

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


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

示例1:

		resolveReference: (ref, base = documentUrl) => {
			return url.resolve(base, ref);
		}
開發者ID:Microsoft,項目名稱:vscode-css-languageservice,代碼行數:3,代碼來源:navigation.test.ts

示例2:

 parentIds.forEach((parent: string) => {
     if (parent) {
         this.absoluteId = url.resolve(parent, this.absoluteId);
     }
 });
開發者ID:tycho01,項目名稱:dtsgenerator,代碼行數:5,代碼來源:schemaid.ts

示例3: parseDependency


//.........這裏部分代碼省略.........
      location
    }
  }

  // `bitbucket:org/repo/path#sha`
  if (type === 'bitbucket') {
    const meta = gitFromPath(src)
    const { org, repo, path, sha } = meta
    const location = `https://bitbucket.org/${org}/${repo}/raw/${sha}/${path}`

    return {
      raw,
      meta,
      type,
      location
    }
  }

  // `npm:dependency`, `npm:@scoped/dependency`
  if (type === 'npm') {
    const parts = src.split('/')
    const isScoped = parts.length > 0 && parts[0].charAt(0) === '@'
    const hasPath = isScoped ? parts.length > 2 : parts.length > 1

    if (!hasPath) {
      parts.push('package.json')
    }

    return {
      raw,
      type: 'npm',
      meta: {
        name: isScoped ? parts.slice(0, 2).join('/') : parts[0],
        path: join(...parts.slice(isScoped ? 2 : 1))
      },
      location: join(...parts)
    }
  }

  // `bower:dependency`
  if (type === 'bower') {
    const parts = src.split('/')

    if (parts.length === 1) {
      parts.push('bower.json')
    }

    return {
      raw,
      type: 'bower',
      meta: {
        name: parts[0],
        path: join(...parts.slice(1))
      },
      location: join(...parts)
    }
  }

  // `http://example.com/foo.d.ts`
  if (type === 'http' || type === 'https') {
    return {
      raw,
      type,
      meta: {},
      location: raw
    }
  }

  // `registry:source/module#tag`, `registry:source/module@version`
  if (type === 'registry') {
    const parts = /^([^\/]+)\/(.+?)(?:@(.*?)|#(.*?))?$/.exec(src)

    if (parts == null) {
      throw new TypeError(`Unable to parse: ${raw}`)
    }

    const [, source, name, version, tag] = parts

    if (version != null && tag != null) {
      throw new TypeError(`Unable to use tag and version together: ${raw}`)
    }

    const prefix = `/entries/${encodeURIComponent(source)}/${encodeURIComponent(name)}`
    const path = tag ? `${prefix}/tags/${encodeURIComponent(tag)}` : `${prefix}/versions/${encodeURIComponent(version || '*')}/latest`

    return {
      raw,
      type,
      meta: {
        source,
        name,
        version,
        tag
      },
      location: resolveUrl(rc.registryURL, path)
    }
  }

  throw new TypeError(`Unknown dependency: ${raw}`)
}
開發者ID:abouthiroppy,項目名稱:core,代碼行數:101,代碼來源:parse.ts

示例4:

 resolveReference: (ref, base) => {
   if (base) {
     documentUrl = url.resolve(documentUrl, base);
   }
   return url.resolve(documentUrl, ref);
 }
開發者ID:tiravata,項目名稱:vetur,代碼行數:6,代碼來源:links.test.ts

示例5: convertToWeb

	public convertToWeb(path_string: string): string {
		var relative = path.relative(this.webRoot, path_string);
		var parts = relative.split('/');
		while (parts[0] === '.' || parts[0] === '..') parts.shift();
		return url.resolve(this.baseUrl, '/' + parts.join('/'));
	}
開發者ID:yurydelendik,項目名稱:vscode-ff-debug,代碼行數:6,代碼來源:ffUrlHelper.ts

示例6:

 $("tr > td > a.buttonlink").each((i,el) => {
     if($(el).parent().parent().hasClass("download_link_sponsored")) {return;}
     
     streams[streams.length] = url.resolve(episode.url,$(el).attr("href"));
 });
開發者ID:SwadicalRag,項目名稱:node-pftv-api,代碼行數:5,代碼來源:tv.ts

示例7:

 sourcemap.sources.map(source => urlLib.resolve(mapUrl, source));
開發者ID:Polymer,項目名稱:vulcanize,代碼行數:1,代碼來源:source-map.ts

示例8: Promise

  return new Promise((resolve) => {
    const { meta } = parseDependency(expandRegistry(raw))
    const path = `entries/${encodeURIComponent(meta.source)}/${encodeURIComponent(meta.name)}`

    return resolve(readJsonFrom(resolveUrl(rc.registryURL, path)))
  })
開發者ID:timbrown81,項目名稱:core,代碼行數:6,代碼來源:view.ts


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