当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript uuid.default函数代码示例

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


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

示例1: uuid

 make: base => {
   return {
     ...base,
     widget: spec.key,
     __response: undefined,
     id: uuid(),
   };
 },
开发者ID:HorrerGames,项目名称:itch,代码行数:8,代码来源:index.ts

示例2: async

  watcher.on(actions.navigate, async (store, action) => {
    const { url, resource, data, window, background } = action.payload;
    logger.debug(`Navigating to ${url} ${background ? "(in background)" : ""}`);

    if (window === "root" && opensInWindow[url]) {
      store.dispatch(
        actions.openWindow({
          initialURL: url,
          modal: false,
          role: "secondary",
        })
      );
      return;
    }

    const sp = Space.fromInstance({
      history: [{ url, resource }],
      currentIndex: 0,
      data,
    });
    if (sp.protocol() == "mailto:") {
      logger.debug(`Is mailto link, opening as external and skipping tab open`);
      shell.openExternal(sp.suffix);
      return;
    }

    const rs = store.getState();
    const { enableTabs } = rs.preferences;
    if (enableTabs && window === "root") {
      store.dispatch(
        actions.openTab({
          window,
          tab: uuid(),
          url,
          resource,
          background,
          data,
        })
      );
    } else {
      const tab = rs.windows[window].navigation.openTabs[0];

      // navigate the single tab
      store.dispatch(
        actions.evolveTab({
          tab,
          replace: false,
          window,
          url,
          resource,
          data,
        })
      );
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:55,代码来源:navigation.ts

示例3: async

  watcher.on(actions.closeAllTabs, async (store, action) => {
    const { wind } = action.payload;
    const rs = store.getState();
    if (!hasMultipleTabs(rs, wind)) {
      return;
    }

    const { openTabs } = rs.winds[wind].navigation;
    const tab = uuid();
    store.dispatch(
      actions.tabOpened({
        wind,
        url: "itch://new-tab",
        tab,
      })
    );
    store.dispatch(
      actions.tabsClosed({
        wind,
        tabs: openTabs,
        andFocus: tab,
      })
    );
  });
开发者ID:itchio,项目名称:itch,代码行数:24,代码来源:navigation.ts

示例4: asTask

async function asTask(opts: IAsTaskOpts) {
  const id = uuid();

  const { store, name, gameId } = opts;

  const memlog = new memory.WritableStream();
  const logger = makeLogger({ customOut: memlog });

  store.dispatch(
    actions.taskStarted({
      id,
      name,
      gameId,
      startedAt: Date.now(),
    })
  );

  const ctx = new Context(store);
  ctx.registerTaskId(id);
  ctx.on("progress", (ev: IProgressInfo) => {
    store.dispatch(actions.taskProgress({ id, ...ev }));
  });

  getCurrentTasks()[id] = ctx;

  let err: Error;

  const { work, onError, onCancel } = opts;

  try {
    await work(ctx, logger);
  } catch (e) {
    err = e;
  }

  delete getCurrentTasks()[id];
  try {
    logger.close();
  } catch (e) {
    rootLogger.warn(`Couldn't close logger: ${e.stack}`);
  }

  if (err) {
    if (isCancelled(err)) {
      rootLogger.warn(`Task ${name} cancelled`);
      if (onCancel) {
        await onCancel();
      }
    } else if (isAborted(err)) {
      rootLogger.warn(`Task ${name} aborted`);
      if (onCancel) {
        await onCancel();
      }
    } else {
      rootLogger.warn(`Task ${name} threw: ${err.stack}`);
      if (onError) {
        await onError(err, memlog ? memlog.toString() : "(No log)");
      }
    }
  }

  store.dispatch(
    actions.taskEnded({
      id,
      err: err ? `${err}` : null,
    })
  );
}
开发者ID:HorrerGames,项目名称:itch,代码行数:68,代码来源:as-task.ts

示例5: asTask

async function asTask(opts: AsTaskOpts) {
  const id = uuid();

  const { store, name, gameId, caveId } = opts;

  const logger = recordingLogger(mainLogger);

  store.dispatch(
    actions.taskStarted({
      id,
      name,
      gameId,
      caveId,
      startedAt: Date.now(),
    })
  );

  const ctx = new Context(store);
  ctx.registerTaskId(id);
  ctx.on("progress", (ev: ProgressInfo) => {
    store.dispatch(actions.taskProgress({ id, ...ev }));
  });

  getCurrentTasks()[id] = ctx;

  let err: Error;

  const { work, onError, onCancel } = opts;

  try {
    await work(ctx, logger);
  } catch (e) {
    err = e;
  }

  delete getCurrentTasks()[id];

  if (err) {
    if (isCancelled(err)) {
      mainLogger.warn(`Task ${name} cancelled`);
      if (onCancel) {
        await onCancel();
      }
    } else if (isAborted(err)) {
      mainLogger.warn(`Task ${name} aborted`);
      if (onCancel) {
        await onCancel();
      }
    } else {
      mainLogger.warn(`Task ${name} threw: ${err.stack}`);
      if (onError) {
        await onError(err, logger.getLog());
      }
    }
  }

  store.dispatch(
    actions.taskEnded({
      id,
      err: err ? `${err}` : null,
    })
  );
}
开发者ID:itchio,项目名称:itch,代码行数:63,代码来源:as-task.ts


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