本文整理汇总了TypeScript中prettyjson.render函数的典型用法代码示例。如果您正苦于以下问题:TypeScript render函数的具体用法?TypeScript render怎么用?TypeScript render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: request
request({ method : 'GET', uri: uri, json: true}, (error, response, body) => {
if(!error && response.statusCode == 200) {
let zones : Zone[] = response.body;
if(messageArray.length === 2) {
let zoneToSearchFor = messageArray[1].toLocaleUpperCase();
let isFound = false;
zones.every( (value,index,array) => {
if(value.name.toLocaleUpperCase() === zoneToSearchFor || value.name.toLocaleUpperCase().indexOf(zoneToSearchFor) > -1) {
console.log(`Found zone user selected`);
bot.sendMessage(message.channel, `\`\`\`${prettyjson.render(value)}\`\`\`\n`);
isFound = true;
return false;
}
return true;
});
if(!isFound){
bot.sendMessage(message.channel, `Could not find zone with name '${zoneToSearchFor}'`);
}
} else {
// all zones
bot.sendMessage(message.channel, `\`\`\`${prettyjson.render(zones.map( a => {return `${a.id} :: ${a.name}`;}))}\`\`\`\n`);
}
} else {
bot.sendMessage(message.channel, `\`\`\`${prettyjson.render(body)}\`\`\`\n`);
}
});
开发者ID:dellinger,项目名称:warcraft-rankings-discord-bot,代码行数:26,代码来源:WCLActions.ts
示例2: async
export const handler = async ({
email,
raw,
}: PaHandlerOptions): Promise<void> => {
if (!raw) {
spinner.start();
}
try {
const pasteData = await pasteAccount(email, { userAgent });
if (pasteData && raw) {
logger.log(JSON.stringify(pasteData));
} else if (pasteData) {
spinner.stop();
logger.log(prettyjson.render(pasteData));
} else if (!pasteData && !raw) {
spinner.succeed('Good news — no pwnage found!');
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
开发者ID:wKovacs64,项目名称:pwned,代码行数:26,代码来源:pa.ts
示例3: async
export const handler = async ({
account,
domainFilter: domain,
truncate,
raw,
}: SearchHandlerOptions): Promise<void> => {
if (!raw) {
spinner.start();
}
try {
const searchData = await search(account, { domain, truncate, userAgent });
const foundData = !!(searchData.breaches || searchData.pastes);
if (foundData && raw) {
logger.log(JSON.stringify(searchData));
} else if (foundData) {
spinner.stop();
logger.log(prettyjson.render(searchData));
} else if (!foundData && !raw) {
spinner.succeed('Good news — no pwnage found!');
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
开发者ID:wKovacs64,项目名称:pwned,代码行数:29,代码来源:search.ts
示例4: async
export const handler = async ({
domainFilter: domain,
raw,
}: BreachesHandlerOptions): Promise<void> => {
if (!raw) {
spinner.start();
}
try {
const breachData = await breaches({ domain, userAgent });
if (breachData.length && raw) {
logger.log(JSON.stringify(breachData));
} else if (breachData.length) {
spinner.stop();
logger.log(prettyjson.render(breachData));
} else if (!breachData.length && !raw) {
spinner.succeed('No breaches found.');
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
开发者ID:wKovacs64,项目名称:pwned,代码行数:26,代码来源:breaches.ts
示例5: async
export const handler = async ({
account,
domainFilter: domain,
includeUnverified,
truncate,
raw,
}: BaHandlerOptions): Promise<void> => {
if (!raw) {
spinner.start();
}
try {
const breachData = await breachedAccount(account.trim(), {
domain,
includeUnverified,
truncate,
userAgent,
});
if (breachData && raw) {
logger.log(JSON.stringify(breachData));
} else if (breachData) {
spinner.stop();
logger.log(prettyjson.render(breachData));
} else if (!breachData && !raw) {
spinner.succeed('Good news — no pwnage found!');
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
开发者ID:wKovacs64,项目名称:pwned,代码行数:34,代码来源:ba.ts
示例6: async
export const handler = async ({
name,
raw,
}: BreachHandlerOptions): Promise<void> => {
if (!raw) {
spinner.start();
}
try {
const breachData = await breach(name, { userAgent });
if (breachData && raw) {
logger.log(JSON.stringify(breachData));
} else if (breachData) {
spinner.stop();
logger.log(prettyjson.render(breachData));
} else if (!breachData && !raw) {
spinner.succeed('No breach found by that name.');
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
开发者ID:wKovacs64,项目名称:pwned,代码行数:26,代码来源:breach.ts
示例7: async
export const handler = async ({ raw }: DcHandlerOptions): Promise<void> => {
if (!raw) {
spinner.start();
}
try {
const dataClassesData = await dataClasses({ userAgent });
if (Array.isArray(dataClassesData) && dataClassesData.length) {
if (raw) {
logger.log(JSON.stringify(dataClassesData));
} else {
spinner.stop();
logger.log(prettyjson.render(dataClassesData));
}
} else if (!raw) {
throw new Error(
'No data classes found. This is unexpected - the remote API may be having difficulties.',
);
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
开发者ID:wKovacs64,项目名称:pwned,代码行数:27,代码来源:dc.ts
示例8:
zones.every( (value,index,array) => {
if(value.name.toLocaleUpperCase() === zoneToSearchFor || value.name.toLocaleUpperCase().indexOf(zoneToSearchFor) > -1) {
console.log(`Found zone user selected`);
bot.sendMessage(message.channel, `\`\`\`${prettyjson.render(value)}\`\`\`\n`);
isFound = true;
return false;
}
return true;
});
开发者ID:dellinger,项目名称:warcraft-rankings-discord-bot,代码行数:9,代码来源:WCLActions.ts
注:本文中的prettyjson.render函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论