本文整理汇总了TypeScript中js-base64.Base64类的典型用法代码示例。如果您正苦于以下问题:TypeScript Base64类的具体用法?TypeScript Base64怎么用?TypeScript Base64使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Base64类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createHtml
function createHtml(svg: Buffer): string {
const html = `<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src vscode-resource:; script-src vscode-resource:; img-src data:;">
<link href="${mediaPath('core.css')}" rel="stylesheet" type="text/css" media="all">
<link href="${mediaPath('button.css')}" rel="stylesheet" type="text/css" media="all">
<script src="${mediaPath('jquery-3.3.1.min.js')}"></script>
<script src="${mediaPath('export.js')}"></script>
</head>
<body>
<h1>Export Uiflow Diagram</h1>
<a id="export" href="#" class="btn">Export PNG</a>
<h1>Preview</h1>
<div id="img_cnt">
<h2>img</h2>
<img id="img" src="data:image/svg+xml;base64,${Base64.encode(svg.toString().replace(/\u0008/g, ''))}">
</div>
<div id="svg_cnt">
<h2>svg</h2>
${svg}
</div>
<div id="canvas_cnt">
<h2>canvas</h2>
<canvas></canvas>
</div>
</body>
</html>`;
return html;
}
开发者ID:kexi,项目名称:vscode-uiflow,代码行数:30,代码来源:export.ts
示例2: decodePayload
static decodePayload (jwt: string): {[key: string]: any} {
try {
const payload = jwt.substring(jwt.indexOf('.'), jwt.lastIndexOf('.'))
return JSON.parse(Base64.decode(payload))
} catch (err) {
throw new Error(`Unable to parse JWT token: ${jwt}`)
}
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:8,代码来源:jwtUtils.ts
示例3: getKubeConfigFromAKS
// get kubeconfig file content
async function getKubeConfigFromAKS(azureSubscriptionEndpoint: string, resourceGroup: string, clusterName: string) : Promise<string> {
var azureEndpoint: AzureEndpoint = await (new AzureRMEndpoint(azureSubscriptionEndpoint)).getEndpoint();
var aks = new AzureAksService(azureEndpoint);
tl.debug(tl.loc("KubernetesClusterResourceGroup", clusterName, resourceGroup));
var clusterInfo : AKSClusterAccessProfile = await aks.getAccessProfile(resourceGroup, clusterName);
var Base64 = require('js-base64').Base64;
return Base64.decode(clusterInfo.properties.kubeConfig);
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:11,代码来源:armkubernetescluster.ts
示例4: Uint8ToBase64
/**
* thanks to
* https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string
*/
static Uint8ToBase64(data:Uint8Array):string{
let chunks = [];
let block = 0x8000;
for( let i = 0; i< data.length; i += block){
chunks.push( String.fromCharCode.apply(null, data.subarray(i, i + block)));
}
return Base64.encode(chunks.join(""));
}
开发者ID:sdllc,项目名称:Basic-Excel-R-Toolkit,代码行数:14,代码来源:utilities.ts
示例5: createKubeconfig
export function createKubeconfig(kubernetesServiceEndpoint: string): string
{
var kubeconfigTemplateString = '{"apiVersion":"v1","kind":"Config","clusters":[{"cluster":{"certificate-authority-data": null,"server": null}}], "users":[{"user":{"token": null}}]}';
var kubeconfigTemplate = JSON.parse(kubeconfigTemplateString);
//populate server url, ca cert and token fields
kubeconfigTemplate.clusters[0].cluster.server = tl.getEndpointUrl(kubernetesServiceEndpoint, false);
kubeconfigTemplate.clusters[0].cluster["certificate-authority-data"] = tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'serviceAccountCertificate', false);
kubeconfigTemplate.users[0].user.token = Base64.decode(tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'apiToken', false));
return JSON.stringify(kubeconfigTemplate);
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:12,代码来源:kubectlutility.ts
示例6: Error
export const getDBIdFromGraphqlId = (
graphqlId: string,
schema?: string
): number => {
// This is temporary solution, we will use slugs in the future
const rawId = Base64.decode(graphqlId);
const regexp = /(\w+):(\d+)/;
const [, expectedSchema, id] = regexp.exec(rawId);
if (schema && schema !== expectedSchema) {
throw new Error("Schema is not correct");
}
return parseInt(id, 10);
};
开发者ID:p2p-ms,项目名称:front,代码行数:13,代码来源:utils.ts
示例7:
import { Base64 } from 'js-base64'
Base64.encode('dankogai'); // ZGFua29nYWk=
Base64.encode('小飼弾'); // 5bCP6aO85by+
Base64.encodeURI('小飼弾'); // 5bCP6aO85by-
Base64.decode('ZGFua29nYWk='); // dankogai
Base64.decode('5bCP6aO85by+'); // 小飼弾
// note .decodeURI() is unnecessary since it accepts both flavors
Base64.decode('5bCP6aO85by-'); // 小飼弾
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:10,代码来源:js-base64-tests.ts
示例8:
export const getGraphqlIdFromDBId = (id: string, schema: string): string =>
// This is temporary solution, we will use slugs in the future
Base64.encode(`${schema}:${id}`);
开发者ID:p2p-ms,项目名称:front,代码行数:3,代码来源:utils.ts
示例9:
import { Base64 } from 'js-base64';
Base64.encode(''); // $ExpectType string
Base64.encode('', true); // $ExpectType string
Base64.encodeURI(''); // $ExpectType string
Base64.decode(''); // $ExpectType string
Base64.atob(''); // $ExpectType string
Base64.btoa(''); // $ExpectType string
Base64.fromBase64(''); // $ExpectType string
Base64.toBase64(''); // $ExpectType string
Base64.toBase64('', true); // $ExpectType string
Base64.btou(''); // $ExpectType string
Base64.utob(''); // $ExpectType string
Base64.noConflict(); // $ExpectType typeof Base64
Base64.extendString(); // $ExpectType void
''.toBase64(); // $ExpectType string
''.toBase64(true); // $ExpectType string
''.toBase64URI(); // $ExpectType string
''.fromBase64(); // $ExpectType string
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:21,代码来源:js-base64-module.test.ts
示例10: inflateBase64
export function inflateBase64(encoded: string): string {
const bytes = Base64.atob(encoded);
return pako.inflate(bytes, { to: "string" });
}
开发者ID:nrkn,项目名称:quicktype,代码行数:4,代码来源:Support.ts
注:本文中的js-base64.Base64类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论