本文整理汇总了TypeScript中bs58.encode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript encode函数的具体用法?TypeScript encode怎么用?TypeScript encode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createPermlink
export function createPermlink(title, author, parent_author, parent_permlink) {
let permlink;
if (title && title.trim() !== '') {
let s = slug(title);
if (s === '') {
s = base58.encode(secureRandom.randomBuffer(4));
}
return getContent(author, s).then(content => {
let prefix;
if (content.body !== '') {
// make sure slug is unique
prefix = `${base58.encode(secureRandom.randomBuffer(4))}-`;
} else {
prefix = '';
}
permlink = prefix + s;
return checkPermLinkLength(permlink);
}).catch(err => {
console.warn('Error while getting content', err);
return permlink;
});
}
// comments: re-parentauthor-parentpermlink-time
const timeStr = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '');
parent_permlink = parent_permlink.replace(/(-\d{8}t\d{9}z)/g, '');
permlink = `re-${parent_author}-${parent_permlink}-${timeStr}`;
return Promise.resolve(checkPermLinkLength(permlink));
}
示例2: getContent
return getContent(author, s).then(content => {
let prefix;
if (content.body !== '') {
// make sure slug is unique
prefix = `${base58.encode(secureRandom.randomBuffer(4))}-`;
} else {
prefix = '';
}
permlink = prefix + s;
return checkPermLinkLength(permlink);
}).catch(err => {
示例3: bytesToBase58
export function bytesToBase58(bytes: Uint8Array): string {
return bs58.encode(bytes);
}
示例4:
import * as bs58 from 'bs58';
{
let encoded: string;
encoded = bs58.encode([255]);
encoded = bs58.encode({0: 255, length: 1});
}
const decoded: number[] = bs58.decode('5Q');
示例5:
export const Base58encode = (bytes:any) => bs58.encode(bytes)