本文整理匯總了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);
}