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


TypeScript v4.default函數代碼示例

本文整理匯總了TypeScript中uuid/v4.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Error

export async function downloadHelm(version?: string): Promise<string> {
    if (!version) version = await getStableHelmVersion();
    var cachedToolpath = toolLib.findLocalTool(helmToolName, version);
    if (!cachedToolpath) {
        try {
            var helmDownloadPath = await toolLib.downloadTool(getHelmDownloadURL(version), helmToolName + "-" + version + "-" + uuidV4() + ".zip");
        } catch (exception) {
            throw new Error(tl.loc("HelmDownloadFailed", getHelmDownloadURL(version), exception));
        }
        var unzipedHelmPath = await toolLib.extractZip(helmDownloadPath);
        cachedToolpath = await toolLib.cacheDir(unzipedHelmPath, helmToolName, version);
    }

    var helmpath = findHelm(cachedToolpath);
    if (!helmpath) {
        throw new Error(tl.loc("HelmNotFoundInFolder", cachedToolpath))
    }

    fs.chmodSync(helmpath, "777");
    return helmpath;
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:21,代碼來源:helmutility.ts

示例2: createCellAbove

function createCellAbove(
  state: NotebookModel,
  action: actionTypes.CreateCellAbove
) {
  const id = action.payload.id ? action.payload.id : state.cellFocused;
  if (!id) {
    return state;
  }

  const { cellType } = action.payload;
  const cell = cellType === "markdown" ? emptyMarkdownCell : emptyCodeCell;
  const cellId = uuid();
  return state.update("notebook", (notebook: ImmutableNotebook) => {
    const cellOrder: Immutable.List<CellId> = notebook.get(
      "cellOrder",
      Immutable.List()
    );
    const index = cellOrder.indexOf(id);
    return insertCellAt(notebook, cell, cellId, index);
  });
}
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:21,代碼來源:notebook.ts

示例3: createCellBelow

function createCellBelow(
  state: NotebookModel,
  action: actionTypes.CreateCellBelow
): RecordOf<DocumentRecordProps> {
  const id = action.payload.id ? action.payload.id : state.cellFocused;
  if (!id) {
    return state;
  }

  const { cellType, source } = action.payload;
  const cell = cellType === "markdown" ? emptyMarkdownCell : emptyCodeCell;
  const cellId = uuid();
  return state.update("notebook", (notebook: ImmutableNotebook) => {
    const index = notebook.get("cellOrder", List()).indexOf(id) + 1;
    return insertCellAt(
      notebook,
      (cell as ImmutableMarkdownCell).set("source", source),
      cellId,
      index
    );
  });
}
開發者ID:nteract,項目名稱:nteract,代碼行數:22,代碼來源:notebook.ts

示例4: merge

        mergeMap(data => {
          const session = uuid();
          const kernel = Object.assign({}, data.response, {
            channel: kernels.connect(
              config,
              data.response.id,
              session
            )
          });

          kernel.channel.next(kernelInfoRequest());

          return merge(
            of(
              actions.activateKernelFulfilled({
                serverId,
                kernelName,
                kernel
              })
            )
          );
        })
開發者ID:nteract,項目名稱:play,代碼行數:22,代碼來源:epics.ts

示例5: handleSendNewMessageAction

function handleSendNewMessageAction(state: StoreData, action: SendNewMessageAction) {

  // using cloneDeep for copying the object properties if they are objects
  //const newStoreState = _.cloneDeep(state);

  // since the state has no nested objects, we will use shallow copy
  const newStoreState: StoreData= {
    participants: state.participants,
    // shallow copy (a new object reference that points to the current object)
    // because we are not gonna mutate the whole map but just one thread
    threads: Object.assign({}, state.threads),
    messages: Object.assign({}, state.messages)
  };

  // shallow copy of the previous version of the current thread to mutate the message ids array because both of then are frozen
  newStoreState.threads[action.payload.threadId] = Object.assign({}, state.threads[action.payload.threadId]);
  // then assign the copy to a variable
  const currentThread = newStoreState.threads[action.payload.threadId];

  const newMessage: Message = {
      text: action.payload.text,
      threadId: action.payload.threadId,
      timestamp: new Date().getTime(),
      participantId: action.payload.participantId,
      id: uuid()
  };

  // linking the thread to the messages
  // then copy the message ids array into new array
  // because it's still pointing to a previously existing frozen array because it's immutable
  currentThread.messageIds = currentThread.messageIds.slice(0);
  // then push the new message id into it
  currentThread.messageIds.push(newMessage.id);

  // save the message by using the newStoreState instead of using state to prevent mutating the store state directly
  newStoreState.messages[newMessage.id] = newMessage;

  return newStoreState;
}
開發者ID:MidoShahin,項目名稱:Chat-App-using-ngrx-store,代碼行數:39,代碼來源:uiStoreDataReducer.ts

示例6: getStableHelmVersion

async function getStableHelmVersion() : Promise<string>{
    var downloadPath = path.join(getTempDirectory(), uuidV4() +".json");
    var options = {
        hostname: 'api.github.com',
        port: 443,
        path: '/repos/kubernetes/helm/releases/latest',
        method: 'GET',
        secureProtocol: "TLSv1_2_method",
        headers: {
            'User-Agent' : 'vsts'
          }
    }

    try{
        await downloadutility.download(options, downloadPath, true);
        var version = await getReleaseVersion(downloadPath);
        return version;
    } catch(error) {
        tl.warning(tl.loc("HelmLatestNotKnown", helmLatestReleaseUrl, error, stableHelmVersion));
    }

    return stableHelmVersion;
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:23,代碼來源:helminstaller.ts

示例7: async

export const createSockets = async (
  config: JupyterConnectionInfo,
  subscription: string = "",
  identity = uuid(),
  jmp = moduleJMP
) => {
  const [shell, control, stdin, iopub] = await Promise.all([
    createSocket("shell", identity, config, jmp),
    createSocket("control", identity, config, jmp),
    createSocket("stdin", identity, config, jmp),
    createSocket("iopub", identity, config, jmp)
  ]);

  // NOTE: ZMQ PUB/SUB subscription (not an Rx subscription)
  iopub.subscribe(subscription);

  return {
    shell,
    control,
    stdin,
    iopub
  };
};
開發者ID:nteract,項目名稱:nteract,代碼行數:23,代碼來源:index.ts

示例8: focusNextCell

function focusNextCell(
  state: NotebookModel,
  action: actionTypes.FocusNextCell
): RecordOf<DocumentRecordProps> {
  const cellOrder = state.getIn(["notebook", "cellOrder"]);

  const id = action.payload.id ? action.payload.id : state.get("cellFocused");
  // If for some reason we neither have an ID here or a focused cell, we just
  // keep the state consistent
  if (!id) {
    return state;
  }

  const curIndex = cellOrder.findIndex((foundId: CellId) => id === foundId);
  const curCellType = state.getIn(["notebook", "cellMap", id, "cell_type"]);

  const nextIndex = curIndex + 1;

  // When at the end, create a new cell
  if (nextIndex >= cellOrder.size) {
    if (!action.payload.createCellIfUndefined) {
      return state;
    }

    const cellId: string = uuid();
    const cell = curCellType === "code" ? emptyCodeCell : emptyMarkdownCell;

    const notebook: ImmutableNotebook = state.get("notebook");

    return state
      .set("cellFocused", cellId)
      .set("notebook", insertCellAt(notebook, cell, cellId, nextIndex));
  }

  // When in the middle of the notebook document, move to the next cell
  return state.set("cellFocused", cellOrder.get(nextIndex));
}
開發者ID:nteract,項目名稱:nteract,代碼行數:37,代碼來源:notebook.ts

示例9: createCellBefore

function createCellBefore(
  state: NotebookModel,
  action: actionTypes.CreateCellBefore
) {
  console.log(
    "DEPRECATION WARNING: This function is being deprecated. Please use createCellAbove() instead"
  );
  const id = action.payload.id ? action.payload.id : state.cellFocused;
  if (!id) {
    return state;
  }

  const { cellType } = action.payload;
  const cell = cellType === "markdown" ? emptyMarkdownCell : emptyCodeCell;
  const cellId = uuid();
  return state.update("notebook", (notebook: ImmutableNotebook) => {
    const cellOrder: Immutable.List<CellId> = notebook.get(
      "cellOrder",
      Immutable.List()
    );
    const index = cellOrder.indexOf(id);
    return insertCellAt(notebook, cell, cellId, index);
  });
}
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:24,代碼來源:notebook.ts

示例10: knex

export async function save({
  sceneId,
  name,
  description,
  createdBy,
  enabled = true,
}: {
  sceneId: string;
  name: string;
  description: string;
  createdBy: string;
  enabled?: boolean;
}): Promise<string> {
  const aliasId = uuidv4();
  await knex(TABLE).insert({
    aliasId,
    sceneId,
    description,
    name,
    enabled,
    createdBy,
  });
  return aliasId;
}
開發者ID:7h1b0,項目名稱:Anna,代碼行數:24,代碼來源:alias.ts


注:本文中的uuid/v4.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。