• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript datetime.elapsed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中common/format/datetime.elapsed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript elapsed函数的具体用法?TypeScript elapsed怎么用?TypeScript elapsed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了elapsed函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: loginSucceeded

async function loginSucceeded(store: Store, profile: Profile) {
  logger.info(`Login succeeded, setting up session`);
  try {
    const userId = profile.id;
    const partition = partitionForUser(String(userId));
    const customSession = session.fromPartition(partition, { cache: true });
    logger.info(`Registering itch protocol for session ${partition}`);
    registerItchProtocol(store, customSession);
  } catch (e) {
    logger.warn(`Could not register itch protocol for session: ${e.stack}`);
  }

  try {
    logger.info(`Restoring tabs...`);
    await restoreTabs(store, profile);
  } catch (e) {
    logger.warn(`Could not restore tabs: ${e.stack}`);
  }

  logger.info(`Dispatching login succeeded`);
  store.dispatch(actions.loginSucceeded({ profile }));

  try {
    logger.info(`Fetching owned keys...`);
    let t1 = Date.now();
    await mcall(
      messages.FetchProfileOwnedKeys,
      {
        profileId: profile.id,
        fresh: true,
        limit: 1,
      },
      convo => {
        hookLogging(convo, logger);
      }
    );
    let t2 = Date.now();
    logger.info(`Fetched owned keys in ${elapsed(t1, t2)}`);
    store.dispatch(actions.ownedKeysFetched({}));
  } catch (e) {
    logger.warn(`In initial owned keys fetch: ${e.stack}`);
  }
}
开发者ID:itchio,项目名称:itch,代码行数:43,代码来源:login.ts


示例2: async


//.........这里部分代码省略.........
                    `There was an error with the certificate for ` +
                    `\`${certificate.subjectName}\` issued by \`${
                      certificate.issuerName
                    }\`.\n\n` +
                    `Please check your proxy configuration and try again.`,
                  detail: `If you ignore this error, the rest of the app might not work correctly.`,
                  buttons: [
                    {
                      label: "Ignore and continue",
                      className: "secondary",
                    },
                    {
                      label: ["menu.file.quit"],
                      action: actions.quit({}),
                    },
                  ],
                  widgetParams: null,
                })
              )
            );
          }
        );
        logger.debug(`Set up certificate error handler`);
      } catch (e) {
        logger.error(
          `Could not set up certificate error handler: ${e.stack ||
            e.message ||
            e}`
        );
      }

      try {
        const { session } = require("electron");
        const netSession = session.fromPartition(NET_PARTITION_NAME, {
          cache: false,
        });

        const envSettings: string =
          process.env.https_proxy ||
          process.env.HTTPS_PROXY ||
          process.env.http_proxy ||
          process.env.HTTP_PROXY;

        let proxySettings = {
          proxy: null as string,
          source: "os" as ProxySource,
        };

        if (envSettings) {
          logger.info(`Got proxy settings from environment: ${envSettings}`);
          proxySettings = {
            proxy: envSettings,
            source: "env",
          };
          testProxy = true;
          store.dispatch(actions.proxySettingsDetected(proxySettings));
        }
        await applyProxySettings(netSession, proxySettings);
      } catch (e) {
        logger.warn(
          `Could not detect proxy settings: ${e ? e.message : "unknown error"}`
        );
      }

      store.dispatch(actions.boot({}));
      dispatchedBoot = true;

      if (env.production && env.appName === "itch") {
        try {
          app.setAsDefaultProtocolClient("itchio");
          app.setAsDefaultProtocolClient("itch");
        } catch (e) {
          logger.error(
            `Could not set app as default protocol client: ${e.stack ||
              e.message ||
              e}`
          );
        }
      }

      if (process.platform === "win32") {
        try {
          await visualElements.createIfNeeded(new MinimalContext());
        } catch (e) {
          logger.error(
            `Could not run visualElements: ${e.stack || e.message || e}`
          );
        }
      }
    } catch (e) {
      throw e;
    } finally {
      const t2 = Date.now();
      logger.info(`preboot ran in ${elapsed(t1, t2)}`);
    }

    if (!dispatchedBoot) {
      store.dispatch(actions.boot({}));
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:preboot.ts


示例3: async

  watcher.on(actions.preboot, async (store, action) => {
    let t1 = Date.now();
    try {
      const system: SystemState = {
        appName: app.getName(),
        appVersion: app.getVersion().replace(/\-.*$/, ""),
        platform: itchPlatform(),
        arch: arch(),
        macos: process.platform === "darwin",
        windows: process.platform === "win32",
        linux: process.platform === "linux",
        sniffedLanguage: app.getLocale(),
        homePath: app.getPath("home"),
        userDataPath: app.getPath("userData"),
        proxy: null,
        proxySource: null,
        quitting: false,
      };
      store.dispatch(actions.systemAssessed({ system }));

      try {
        await loadPreferences(store);
      } catch (e) {
        logger.error(
          `Could not load preferences: ${e.stack || e.message || e}`
        );
      }

      try {
        const netSession = session.fromPartition(NET_PARTITION_NAME, {
          cache: false,
        });

        const envSettings: string =
          process.env.https_proxy ||
          process.env.HTTPS_PROXY ||
          process.env.http_proxy ||
          process.env.HTTP_PROXY;

        let proxySettings = {
          proxy: null as string,
          source: "os" as ProxySource,
        };

        if (envSettings) {
          logger.info(`Got proxy settings from environment: ${envSettings}`);
          proxySettings = {
            proxy: envSettings,
            source: "env",
          };
          testProxy = true;
          store.dispatch(actions.proxySettingsDetected(proxySettings));
        }
        await applyProxySettings(netSession, proxySettings);
      } catch (e) {
        logger.warn(
          `Could not detect proxy settings: ${e ? e.message : "unknown error"}`
        );
      }

      if (env.production && env.appName === "itch") {
        try {
          app.setAsDefaultProtocolClient("itchio");
          app.setAsDefaultProtocolClient("itch");
        } catch (e) {
          logger.error(
            `Could not set app as default protocol client: ${e.stack ||
              e.message ||
              e}`
          );
        }
      }
    } catch (e) {
      throw e;
    } finally {
      const t2 = Date.now();
      logger.info(`preboot ran in ${elapsed(t1, t2)}`);
    }

    store.dispatch(actions.prebootDone({}));

    let devtoolsPath = process.env.ITCH_REACT_DEVTOOLS_PATH;
    if (!devtoolsPath && env.development) {
      let reactDevtoolsId = "fmkadmapgofadopljbjfkapdkoienihi";
      let devtoolsFolder = path.join(
        app.getPath("home"),
        "AppData",
        "Local",
        "Google",
        "Chrome",
        "User Data",
        "Default",
        "Extensions",
        reactDevtoolsId
      );
      try {
        const files = fs.readdirSync(devtoolsFolder);
        let version = files[0];
        if (version) {
          devtoolsPath = path.join(devtoolsFolder, version);
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:preboot.ts


示例4: async

  watcher.on(actions.loginWithPassword, async (store, action) => {
    const { username, password } = action.payload;

    logger.info(`Attempting password login for user ${username}`);
    store.dispatch(actions.attemptLogin({}));

    try {
      // integration tests for the integration test goddess
      if (username === "#api-key") {
        logger.info(`Doing direct API key login...`);
        const t1 = Date.now();
        const { profile } = await withTimeout(
          "API key login",
          LOGIN_TIMEOUT,
          mcall(messages.ProfileLoginWithAPIKey, {
            apiKey: password,
          })
        );
        const t2 = Date.now();
        logger.debug(
          `ProfileLoginWithAPIKey call succeeded in ${elapsed(t1, t2)}`
        );
        await loginSucceeded(store, profile);
        return;
      }

      logger.info(`Doing username/password login...`);
      const t1 = Date.now();
      const { profile, cookie } = await mcall(
        messages.ProfileLoginWithPassword,
        {
          username,
          password,
        },
        client => {
          logger.debug(`Setting up handlers for TOTP & captcha`);
          client.on(
            messages.ProfileRequestCaptcha,
            async ({ recaptchaUrl }) => {
              logger.info(`Showing captcha`);
              const modalRes = await promisedModal(
                store,
                modals.recaptchaInput.make({
                  wind: "root",
                  title: "Captcha",
                  message: "",
                  widgetParams: {
                    url: recaptchaUrl || urls.itchio + "/captcha",
                  },
                  fullscreen: true,
                })
              );

              if (modalRes) {
                logger.info(`Captcha solved`);
                return { recaptchaResponse: modalRes.recaptchaResponse };
              } else {
                // abort
                logger.info(`Captcha cancelled`);
                return { recaptchaResponse: null };
              }
            }
          );

          client.on(messages.ProfileRequestTOTP, async () => {
            logger.info(`Showing TOTP`);
            const modalRes = await promisedModal(
              store,
              modals.twoFactorInput.make({
                wind: "root",
                title: ["login.two_factor.title"],
                message: "",
                widgetParams: {
                  username,
                },
              })
            );

            if (modalRes) {
              logger.info(`TOTP answered`);
              return { code: modalRes.totpCode };
            } else {
              // abort
              logger.info(`TOTP cancelled`);
              return { code: null };
            }
          });
        }
      );

      if (cookie) {
        try {
          logger.info(`Setting cookies...`);
          await setCookie(profile, cookie);
        } catch (e) {
          logger.error(`Could not set cookie: ${e.stack}`);
        }
      }

      await loginSucceeded(store, profile);
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:login.ts



注:本文中的common/format/datetime.elapsed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript errors.formatError函数代码示例发布时间:2022-05-25
下一篇:
TypeScript EventEmitter.EventEmitter类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap