當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript prettyjson.render函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。