當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。