當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript node-uuid.v4函數代碼示例

本文整理匯總了TypeScript中node-uuid.v4函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript v4函數的具體用法?TypeScript v4怎麽用?TypeScript v4使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了v4函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('unparse', () => {
    const buffer: Buffer = v4(null, new Buffer(''));
    const array: number[] = v4(null, []);

    const unparsed1: string = unparse(buffer);
    expect(unparsed1).to.be.a('string');

    const unparsed2: string = unparse(array);
    expect(unparsed2).to.be.a('string');
  });
開發者ID:goodmind,項目名稱:typed-node-uuid,代碼行數:10,代碼來源:index.ts

示例2: it

  it('should be able to destroy an instance with pubsub listeners', async () => {
    const exchangeName = v4() + '.test';
    const queueName = v4() + '.test';

    const rabbit = new Rabbitr({
      url: process.env.RABBITMQ_URL || 'amqp://guest:guest@localhost/%2F',
    });

    rabbit.subscribe([exchangeName], queueName, {}, ({ack}) => ack());

    await wait(200);

    await rabbit.destroy();
  });
開發者ID:urbanmassage,項目名稱:node-rabbitr,代碼行數:14,代碼來源:destroy.ts

示例3: process_device_add

function process_device_add(client, msg) {
  if (client.flags.authenticated) {
    let device = {
      id: uuid.v4(),
      device_id: uuid.v4(),
      created_at: new Date().toISOString(),
      name: msg.params.name,
      user_id: client.flags.authenticated.user_id
    }
    db.device_add(device)
    protocol.respond_success(client, msg.id, {id: device.id})
  } else {
    protocol.respond_fail(client, msg.id, { message: "Not authenticated" })
  }
}
開發者ID:icecondor,項目名稱:api,代碼行數:15,代碼來源:api.ts

示例4: it

  it('should not receive a message if #clearTimer is called', () => {
    const DELAY = 50;

    const queueName = v4() + '.clear_timer_test';

    const testData = {
      testProp: 'timed-example-data-' + queueName
    };

    let receivedMessages = 0;

    rabbit.subscribe([queueName], queueName, {}, (message) => {
      message.ack();

      receivedMessages++;
    })
      .then(() => createdQueues.push(queueName))
      .then(() =>
        createdExchanges.push(queueName)
      );

    // set the timer and schedule the clear
    rabbit.setTimer(queueName, 'unique_clearing_test_id', testData, DELAY);
    setTimeout(function() {
      rabbit.clearTimer(queueName, 'unique_clearing_test_id');
    }, DELAY / 2);

    // also set a timeout to fire after the message should have already have been delivered to check it wasn't
    return wait(DELAY)
      .then(() => {
        expect(receivedMessages).to.equal(0);
      });
  });
開發者ID:urbanmassage,項目名稱:node-rabbitr,代碼行數:33,代碼來源:timer.ts

示例5: it

        it('Should Add devices', (done) => {

            var deviceId = uuid.v4();
            var expected = { 
                deviceId: deviceId,
                authentication: { 
                    symmetricKey: {
                        primaryKey: 'primKey' 
                    }
                } 
            };

            request.body = expected;

            response.json.and.callFake(function (actual) {
                expect(actual.deviceId).toEqual(expected.deviceId);
                done();
            });

            spyOn(this.deviceAPI.registry, 'create').and.callFake(function (device, callback) {
                callback(null, expected);
            });

            this.deviceAPI.AddDevice(request, response, function (error, res) {
                let correctConnString = `${this.deviceApi.host};DeviceId=${deviceId};SharedAccessKey=${expected.authentication.symmetricKey.primaryKey}`;
                expect(res['_deviceConnectionString']).toEqual(correctConnString);
                done.fail(error);
            });

        });
開發者ID:habukira,項目名稱:Azure-azure-iot-device-management,代碼行數:30,代碼來源:deviceAPI.spec.ts

示例6: it

  it("check", async () => {
    let uuid = Uuid.v4().toString();
    let wc = config.Certor.create(param([], uuid))
    let etcd = await wc.etcd();
    let domains = [new DomainKsk(), new DomainZsk()]
    for (let i in domains) {
      let df = domains[i] 
      assert.deepEqual(true, (await df.start(param(['get'], uuid), etcd)).isErr(), "get-zsk not set")

      assert.deepEqual(true, (await df.start(param(['get', '--domain', 'test'], uuid), etcd)).isErr(), "get-zsk not set")

      assert.deepEqual(true, (await df.start(param(['set', 'zsk'], uuid), etcd)).isErr(), "add without domain()")

      assert.deepEqual("zsk", (await df.start(param(['set', 'zsk', '--domain', 'test'], uuid), etcd)).ok.asJson(), "add without domain()")

      let zsk_fname = `.zsk.test.${uuid}`
      fs.writeFileSync(zsk_fname, "zsk-file")
      assert.deepEqual("zsk-file", (await df.start(param(['set', `@${zsk_fname}`, '--domain', 'test'], uuid), etcd)).ok.asJson(), "add without domain()")

      fs.unlinkSync(zsk_fname)

      assert.deepEqual("zsk-file", (await df.start(param(['get', '--domain', 'test'], uuid), etcd)).ok.asJson(), "add without domain()")

      assert.deepEqual("zsk-file", (await df.start(param(['del', '--domain', 'test'], uuid), etcd)).ok.asJson(), "add without domain()")

      assert.deepEqual(true, (await df.start(param(['get', '--domain', 'test'], uuid), etcd)).isErr(), "add without domain()")
    }
  })
開發者ID:protonet,項目名稱:certor,代碼行數:28,代碼來源:domain-keys-test.ts


注:本文中的node-uuid.v4函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。