本文整理汇总了TypeScript中url.resolve函数的典型用法代码示例。如果您正苦于以下问题:TypeScript resolve函数的具体用法?TypeScript resolve怎么用?TypeScript resolve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolve函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
resolveReference: (ref, base = documentUrl) => {
return url.resolve(base, ref);
}
示例2:
parentIds.forEach((parent: string) => {
if (parent) {
this.absoluteId = url.resolve(parent, this.absoluteId);
}
});
示例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}`)
}
示例4:
resolveReference: (ref, base) => {
if (base) {
documentUrl = url.resolve(documentUrl, base);
}
return url.resolve(documentUrl, ref);
}
示例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('/'));
}
示例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"));
});
示例7:
sourcemap.sources.map(source => urlLib.resolve(mapUrl, source));
示例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)))
})