本文整理汇总了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)})`
})
示例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;
}
示例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;
}
示例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 });
}
示例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);
}