当前位置: 首页>>代码示例>>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;未经允许,请勿转载。