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


TypeScript shortid.generate函數代碼示例

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


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

示例1: createStage

export function createStage() {
    const newStage: any = {};
    newStage.keyid = shortid.generate();
    return {
        type: constants.CREATE_STAGE,
        stage: newStage
    }
}
開發者ID:thehachez,項目名稱:maduk,代碼行數:8,代碼來源:index.ts

示例2:

export const shortId = () => {
  /**
   * 默認是從這些值裏麵生成的(64位值)
   * 生成的值滿足這些條件:7-14 位、A-Z, a-z, 0-9, _-
   * 默認值:0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_
   */
  return shortid.generate()
}
開發者ID:linkFly6,項目名稱:Said,代碼行數:8,代碼來源:format.ts

示例3: generateShortid

const createSandboxDirectory = (
  name: string,
  parentShortid?: string,
): ISandboxDirectory => ({
  directory_shortid: parentShortid,
  shortid: generateShortid(),
  title: name,
});
開發者ID:ghoullier,項目名稱:codesandbox-cli,代碼行數:8,代碼來源:file-mapper.ts

示例4: beginTracking

 beginTracking(task: ITask): string {
     let TrackingId = shortid.generate();
     this._map[TrackingId] = {
         j: task.j
         ,t: task.t
     };
     return TrackingId;
 }
開發者ID:wchang28,項目名稱:node-grid-2,代碼行數:8,代碼來源:launcherApp.ts

示例5: saveNotification

    public saveNotification(notification: Notification) {

        if (!notification.id) {
            notification.id = shortid.generate();
            this.notifications.push(notification);
        }

        this.saveNotifications();
    }
開發者ID:grecosoft,項目名稱:NetFusion,代碼行數:9,代碼來源:notifications.ts

示例6: buildGraphName

  buildGraphName(args: any, prefix: string | null): string {
    prefix = prefix || this.currentDir.split(path.sep).join('_')

    if (Object.keys(args).length) {
      return `${prefix}_args_${genUtil.serializeArgs(args)}`
    } else {
      return `${prefix}_${shortId.generate()}`
    }
  }
開發者ID:instructure,項目名稱:ftl-engine,代碼行數:9,代碼來源:Processor.ts

示例7: generate

	function generate(code: randomIdType) {
		if (code === randomIdType.Number) {
			captureMinimumNumber();
			return;
		}

		var value: string = (code === randomIdType.ShortId) ? shortid.generate() : uuid.v4();
		displayResult(value);
	}
開發者ID:tkorcak,項目名稱:createidsvscode,代碼行數:9,代碼來源:extension.ts

示例8: addSelector

export function addSelector(eve: JQueryEventObject, stageKey, uniqueSelector) {
    const newSelector: any = {};
    const target: any = eve.target;

    newSelector.stagekey = stageKey;
    newSelector.keyid = shortid.generate();
    newSelector.element = target;

    if (target.tagName) {
        newSelector.tagName = target.tagName;
    }
    if (target.id) {
        newSelector.id = target.id;
    }
    if (target.className) {
        newSelector.tagName = target.className;
    }
    if (target.nodeName) {
        newSelector.nodeName = target.nodeName;
    }
    if (target.value) {
        newSelector.value = target.value;
    }

    return (dispatch, getState: () => StateDef) => {
        
        const stages = getState().stages;
        const selectors = getState().selectorsStack;
        const findSelectorRepeat = _.find(selectors, (selector) => selector.element === target);
        
        if (stages.length <= 0) {
            
            dispatch({
                type: constants.SHOW_MESSAGE,
                message: "primero debes crear un stage"
            });

        } else if (findSelectorRepeat) {
           
            dispatch({
                type: constants.SHOW_MESSAGE,
                message: "el elemento ya se encuentra dentro de: " + _.find(stages, (stage)=> stage.keyid === findSelectorRepeat.stagekey).name
            });

        } else {

            dispatch({
                type: constants.ADD_SELECTOR,
                payload: {
                    selector: newSelector,
                    uniqueSelector
                }
            });
        }
    }
}
開發者ID:thehachez,項目名稱:maduk,代碼行數:56,代碼來源:index.ts

示例9: async

const storeUpload = async ({ stream, filename }): Promise<any> => {
  const id = shortid.generate()
  const path = `${uploadDir}/${id}-${filename}`

  return new Promise((resolve, reject) =>
    stream
      .pipe(createWriteStream(path))
      .on('finish', () => resolve({ id, path }))
      .on('error', reject),
  )
}
開發者ID:slimui,項目名稱:graphql-yoga,代碼行數:11,代碼來源:index.ts

示例10: init

  init(params) {
    this.user = new UserModel(shortid.generate(), params.name);
    this.user.setSocket(this.socket);
    this.sync({
      include: ['room', 'room.**', 'user']
    });
    this.expose('post');
    this.room = Rooms.fetch(params.room_id, () => new RoomModel({ id: params.room_id, name: shortid.generate() }));

    this.room.join(this.user);
  }
開發者ID:coronajs,項目名稱:corona-chatroom,代碼行數:11,代碼來源:controllers.ts


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