本文整理汇总了TypeScript中UUID.v4函数的典型用法代码示例。如果您正苦于以下问题:TypeScript v4函数的具体用法?TypeScript v4怎么用?TypeScript v4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了v4函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: before
before(async () => {
await esArchiver.load('empty_kibana');
await sourceConfigurationService.createConfiguration('default', {
name: 'Test Source',
logColumns: [
{
timestampColumn: {
id: uuidv4(),
},
},
{
fieldColumn: {
id: uuidv4(),
field: 'host.name',
},
},
{
fieldColumn: {
id: uuidv4(),
field: 'event.dataset',
},
},
{
messageColumn: {
id: uuidv4(),
},
},
],
});
});
示例2: v4
export const addTodo = (text: string) => ({
type: 'ADD_TODO',
payload: {
id: v4(),
text
}
});
示例3: produce
produce(state, draftState => {
switch (action.type) {
case 'PUBLISH_NOTIFICATION': {
const {notification} = action.payload
const publishedNotification = {
...notification,
id: uuid.v4(),
}
const matchIndex = state.findIndex(
n => n.type && notification.type && n.type === notification.type
)
const isUnique = matchIndex === -1
if (isUnique) {
draftState.unshift(publishedNotification)
}
return
}
case 'DISMISS_NOTIFICATION': {
const {id} = action.payload
return draftState.filter(n => n.id !== id)
}
case 'DISMISS_ALL_NOTIFICATIONS': {
return []
}
}
})
示例4: async
router.get('/', async (req: express.Request, res: express.Response) => {
const id = uuid.v4();
const timer = setInterval(() => {
res.write('event:keepalive\ndata:\n\n');
}, 30000);
req.socket.setKeepAlive(true);
req.socket.setTimeout(0);
req.connection.on('close', () => {
clearInterval(timer);
delete req.app.locals.pushClients[id];
res.end();
});
req.app.locals.pushClients[id] = res;
// The no-transform value of the Cache-Control header tells the
// compresssion middleware not to compress this
// response. Otherwise, the client never sees any of the writes.
res.writeHead(200, {
'Cache-Control': 'no-cache, no-transform',
'Connection': 'keep-alive',
'Content-Type': 'text/event-stream',
'X-Accel-Buffering': 'no',
});
res.write('event:connection\ndata:\n\n');
});
示例5: function
$request(reqOut, function (err: Error, message: any, body: any): void {
console.log('*************************');
console.log('' + vertex + ' ' + targetUrl);
console.log('-------------------------');
console.dir(headers);
console.log('=========================');
console.dir(body);
if (params && body && !params.id && !_.isArray(body)) {
body.id = body.id || uuid.v4();
body = [body];
}
else if (_.isArray(body)) {
_.each(body, function (item: any) {
item.id = item.id || uuid.v4();
});
}
if (!err) {
res
.status(message.statusCode)
.send(body);
}
else {
res.serverError(err);
}
})
示例6: it
it('should pass list authorization', async () => {
const route = buildRoute({type: 'destroy', byId: false, byList: true, authorization})
const body = [uuid(), uuid()]
const req = {grants, body}
await utils.runMiddleware(route.middleware, req)
expect(destroyStub).toHaveBeenCalledTimes(2)
})
示例7: it
it('should pass list authorization', async () => {
const route = buildRoute({type: 'update', byId: false, byList: true, authorization})
const body = [{id: uuid(), ...utils.defaultUser}, {id: uuid(), ...utils.defaultUser}]
const req = {grants, body}
const {res} = await utils.runMiddleware(route.middleware, req)
expect(await res.promise).toEqual(req.validated.body)
expect(updateAllStub).toHaveBeenCalledTimes(1)
})
示例8: _validateAnalyticsSharingUuid
function _validateAnalyticsSharingUuid(value: string) {
if (value == '') {
return uuidV4();
} else {
return value;
}
}