本文整理汇总了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
}
}
示例2:
export const shortId = () => {
/**
* 默认是从这些值里面生成的(64位值)
* 生成的值满足这些条件:7-14 位、A-Z, a-z, 0-9, _-
* 默认值:0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_
*/
return shortid.generate()
}
示例3: generateShortid
const createSandboxDirectory = (
name: string,
parentShortid?: string,
): ISandboxDirectory => ({
directory_shortid: parentShortid,
shortid: generateShortid(),
title: name,
});
示例4: beginTracking
beginTracking(task: ITask): string {
let TrackingId = shortid.generate();
this._map[TrackingId] = {
j: task.j
,t: task.t
};
return TrackingId;
}
示例5: saveNotification
public saveNotification(notification: Notification) {
if (!notification.id) {
notification.id = shortid.generate();
this.notifications.push(notification);
}
this.saveNotifications();
}
示例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()}`
}
}
示例7: generate
function generate(code: randomIdType) {
if (code === randomIdType.Number) {
captureMinimumNumber();
return;
}
var value: string = (code === randomIdType.ShortId) ? shortid.generate() : uuid.v4();
displayResult(value);
}
示例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
}
});
}
}
}
示例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),
)
}
示例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);
}