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