当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript UUID.v4函数代码示例

本文整理汇总了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(),
         },
       },
     ],
   });
 });
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: v4

export const addTodo = (text: string) => ({
  type: 'ADD_TODO',
  payload: {
    id: v4(),
    text
  }
});
开发者ID:ajaythomas123,项目名称:React-Redux-Typescript-Todo-App,代码行数:7,代码来源:todos.ts

示例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 []
      }
    }
  })
开发者ID:influxdata,项目名称:influxdb,代码行数:28,代码来源:notifications.ts

示例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');
});
开发者ID:lovett,项目名称:notifier,代码行数:30,代码来源:push.ts

示例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);
					}
				})
开发者ID:pmoelgaard,项目名称:nx-sails-swagger-api,代码行数:28,代码来源:index.ts

示例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)
    })
开发者ID:patrickhulce,项目名称:klay,代码行数:8,代码来源:destroy.test.ts

示例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)
    })
开发者ID:patrickhulce,项目名称:klay,代码行数:10,代码来源:update.test.ts

示例8: _validateAnalyticsSharingUuid

function _validateAnalyticsSharingUuid(value: string) {
  if (value == '') {
    return uuidV4();
  } else {
    return value;
  }
}
开发者ID:angular,项目名称:angular-cli,代码行数:7,代码来源:config-impl.ts


注:本文中的UUID.v4函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。