本文整理汇总了TypeScript中md5.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript md5.default方法的具体用法?TypeScript md5.default怎么用?TypeScript md5.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类md5
的用法示例。
在下文中一共展示了md5.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ensureNoPrevExec
function ensureNoPrevExec(code: string): string {
return `(() => {
if (window['${md5(code)}'] === true) {
return;
}
window['${md5(code)}'] = true;
${code}
})()`;
}
示例2:
const objs = contents.map((content, index) => ({
objectID: index ? md5(`${href}${index}`) : md5(href),
fileName,
repo: repoName,
categories: file
.split('/')
.filter(
c => Number.isNaN(parseInt(c, 10)) && c.indexOf('.md') === -1
),
href,
desc,
content
}));
示例3:
static async checkPasswordMd5() {
console.log(' checkPasswordMd5')
const users = await User.findAll()
if (users.length === 0 || isMd5(users[0].password)) {
console.log(' users empty or md5 check passed')
return
}
for (const user of users) {
if (!isMd5(user.password)) {
user.password = md5(md5(user.password))
await user.save()
console.log(`handle user ${user.id}`)
}
}
}
示例4: getPreviewClippingNamespace
export const getComponentScreenshot = (componentId: string, previewName: string, state: ApplicationState) => {
const ss = state.componentScreenshots[state.componentScreenshots.length - 1];
const clippingNamespace = getPreviewClippingNamespace(componentId, previewName);
return ss && ss.clippings[clippingNamespace] && {
previewName,
uri: `http://localhost:${state.options.port}/screenshots/${md5(state.componentScreenshots[state.componentScreenshots.length - 1].uri)}`,
clip: ss.clippings[clippingNamespace]
};
};
示例5: getIndex
function* getIndex(req: Request, res: Response) {
let state: ExtensionState = yield select();
if (!state.childDevServerInfo) {
yield put(startDevServerRequest());
yield take(CHILD_DEV_SERVER_STARTED);
state = yield select();
}
const { getEntryHTML } = require(getTandemDirectory(state));
res.send(getEntryHTML({
apiHost: `http://localhost:${state.childDevServerInfo.port}`,
textEditorHost: `http://localhost:${state.port}`,
storageNamespace: md5(state.rootPath),
filePrefix: "/tandem"
}));
}
示例6: getGeneratedMetricHash
function getGeneratedMetricHash(title: string, format: string, expression: string) {
return md5(`${expression}#${title}#${format}`);
}
示例7:
export const getEmailHash = (email: string) => {
return email && md5(email.trim().toLowerCase());
}
示例8: grapherUrlToFilekey
export function grapherUrlToFilekey(grapherUrl: string) {
const url = parseUrl(grapherUrl)
const slug = _.last(url.pathname.split('/')) as string
const queryStr = url.query as any
return `${slug}${queryStr ? "-"+md5(queryStr) : ""}`
}
示例9:
return state.componentScreenshots.find((screenshot) => md5(screenshot.uri) === req.params.screenshotHash);
示例10: buildLinkIndex
export async function buildLinkIndex(client) {
const index = client.initIndex('link');
// 设置相关性
index.setSettings({
searchableAttributes: ['title', 'fileName', 'categories', 'desc', 'href'],
attributesForFaceting: ['year', 'type', 'categories']
});
const repoName = 'Awesome-Lists';
// 获取仓库的配置信息
const repo: ReposityConfig = repos[repoName];
const files = walkSync(repo.localPath).filter(
path =>
path.endsWith('.md') &&
path.indexOf('README') === -1 &&
path.indexOf('ABOUT') === -1 &&
path.indexOf('Weekly') === -1
);
// 待提交到 Algo 的对象
let pendingObjs = [];
for (let file of files) {
// 封装出文件链接
const fileHref = `${repo.sUrl}/blob/master/${file}`;
const absoluteFile = `${repo.localPath}/${file}`;
let fileName: string = file.split('/').reverse()[0];
// 读取文件内容
const content = await readFileAsync(absoluteFile, { encoding: 'utf-8' });
if (!content) {
continue;
}
let match;
while ((match = LinkRegex.exec(content))) {
const [raw, rawTitle, href, desc] = match;
// 这里进行过滤,过滤掉 URL 重复的部分
if (!href || bloom.has(href)) {
continue;
}
const { year, title, type } = extractInfoFromTitle(rawTitle);
bloom.add(href);
count++;
const obj: LinkItem = {
objectID: md5(href),
title,
href,
desc: desc ? desc.replace(':', '').trim() : '',
raw,
year,
type,
fileName: fileName.split('.')[0],
fileHref,
categories: file
.split('/')
.filter(c => Number.isNaN(parseInt(c, 10)) && c.indexOf('.md') === -1)
};
pendingObjs.push(obj);
if (pendingObjs.length >= BatchNum) {
try {
await index.addObjects(pendingObjs);
pendingObjs = [];
} catch (e) {
console.error(e);
}
}
}
// 提交剩余的
if (pendingObjs.length > 0) {
try {
await index.addObjects(pendingObjs);
pendingObjs = [];
} catch (e) {
console.error(e);
}
}
}
console.log(`${repoName} indexed finally. ${count} links`);
}