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