本文整理匯總了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)))
})