本文整理汇总了TypeScript中uuid类的典型用法代码示例。如果您正苦于以下问题:TypeScript uuid类的具体用法?TypeScript uuid怎么用?TypeScript uuid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了uuid类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: retrieve
async retrieve (user: User, paymentReference: string): Promise<PaymentRetrieveResponse | undefined> {
/*
Calculated from:
dependencies
| where name contains "GET /card-payments"
| summarize avg(duration)
*/
const payRetrieveDelayInMs = 681
await delay(payRetrieveDelayInMs)
return Promise.resolve(
{
amount: 185,
description: description,
reference: paymentReference,
currency: 'GBP',
caseReference: uuid(),
channel: 'online',
method: 'card',
externalProvider: 'gov pay',
status: 'Success',
externalReference: 'a-gov-pay-reference',
siteId: siteId,
serviceName: serviceName,
fees: [
{ calculated_amount: 185, code: 'X0029', version: '1' }
]
})
}
示例2: switch
export const addRequestReducer = (state = initialState, action: Action) => {
switch (action.type) {
case UPDATE_REQUEST_FIELDS:
return {
...state,
fields: {
...state.fields,
...action.payload
}
};
case UPDATE_REQUEST_ROOT_FIELDS:
return {
...state,
...action.payload
};
case RESET:
return {
...initialState,
fields: {
...initialState.fields,
requestId: uuid().replace(/-/g, "")
}
};
default:
return state;
}
};
示例3: forLogin
static forLogin (req: express.Request,
res: express.Response,
receiver: RoutablePath = Paths.receiver): string {
const redirectUri = buildURL(req, receiver.uri)
const state = uuid()
OAuthHelper.storeStateCookie(req, res, state)
return `${loginPath}?response_type=code&state=${state}&client_id=${clientId}&redirect_uri=${redirectUri}`
}
示例4: createClaimData
export function createClaimData (claimantType: PartyType, defendantType: PartyType, hasEmailAddress: boolean = true,
interestType: InterestType = InterestType.STANDARD): ClaimData {
let claimData = {
claimants: [createClaimant(claimantType)],
defendants: [createDefendant(defendantType, hasEmailAddress)],
payment: {
amount: claimFee * 100,
reference: 'RC-1524-6488-1670-7520',
status: 'success'
},
feeAmountInPennies: claimFee * 100,
amount: claimAmount,
interest: {
type: 'no interest'
},
reason: claimReason,
timeline: { rows: [{ date: 'may', description: 'ok' }] },
externalId: uuid(),
get total (): number {
switch (interestType) {
case InterestType.STANDARD:
return this.amount.getClaimTotal() + claimFee
case InterestType.BREAKDOWN:
return this.amount.getClaimTotal() + fixedInterestAmount + claimFee
}
},
moneyReceivedOn: null
} as ClaimData
switch (interestType) {
case InterestType.BREAKDOWN:
claimData.interest = {
type: 'breakdown',
interestBreakdown: {
totalAmount: fixedInterestAmount,
explanation: 'up to today'
},
specificDailyAmount: dailyInterestAmount
}
claimData.interest.interestDate = {
endDateType: 'settled_or_judgment'
}
break
case InterestType.STANDARD:
claimData.interest = {
type: 'standard',
rate: 8
}
claimData.interest.interestDate = {
type: 'submission'
}
break
}
return claimData
}
示例5: uuid
router.get('/signin/twitter', async ctx => {
const twCtx = await twAuth.begin();
const sessid = uuid();
redis.set(sessid, JSON.stringify(twCtx));
const expires = 1000 * 60 * 60; // 1h
ctx.cookies.set('signin_with_twitter_session_id', sessid, {
path: '/',
domain: config.host,
secure: config.url.startsWith('https'),
httpOnly: true,
expires: new Date(Date.now() + expires),
maxAge: expires
});
ctx.redirect(twCtx.url);
});
示例6: function
executeTrigger: async function (trigger)
{
switch (trigger.name)
{
case 'watch':
var stat = await promisify(fs.stat)(trigger.params['path'] as string);
if (stat.isDirectory() || stat.isFile())
{
var id = uuid();
var watcher = fs.watch(trigger.params['path'] as string, function (event, fileName)
{
if (!trigger.params['event'] || trigger.params['event'] == event)
server.trigger({ id: id, data: { path: fileName, mtime: new Date().toJSON() } });
});
registeredTriggers[id] = watcher;
}
break;
}
return null;
}
示例7: addSlackButtons
private addSlackButtons(f: IQueryResponseField, row: IQueryResponseRow, attachment: IAttachment) {
if (!SlackUtils.slackButtonsEnabled) { return }
const d = row[f.name]
if (!d.links) { return }
const usableActions = d.links.filter((l) => (l.type === "action") && !l.form && !l.form_url)
if (!(usableActions.length > 0)) { return }
attachment.actions = usableActions.map((link) => {
return {
name: "data_action",
text: link.label,
type: "button",
value: JSON.stringify({lookerUrl: this.options.baseUrl, action: link}),
}
})
attachment.callback_id = uuid()
}
示例8: uuid
import * as uuid from "uuid";
import { newRequest, Action } from "../types";
import { RESET, UPDATE_REQUEST_FIELDS, UPDATE_REQUEST_ROOT_FIELDS } from "../actions/addRequest";
export const initialState: newRequest = {
fields: {
url: "",
method: "GET",
type: "xmlhttprequest",
requestId: uuid().replace(/-/g, "")
},
error: ""
};
export const addRequestReducer = (state = initialState, action: Action) => {
switch (action.type) {
case UPDATE_REQUEST_FIELDS:
return {
...state,
fields: {
...state.fields,
...action.payload
}
};
case UPDATE_REQUEST_ROOT_FIELDS:
return {
...state,
...action.payload
};
case RESET:
示例9: constructor
constructor(attrs: any) {
this.id = uuid();
this.start = moment.tz(attrs.start, attrs.timezone || 'Europe/Berlin');
this.duration = attrs.duration;
this.isAllDay = attrs.isAllDay || false;
}
示例10:
rename: (name) => {
return `${name}-${uuid()}`
},