本文整理汇总了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');
});
示例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();
});
示例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" })
}
}
示例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);
});
});
示例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);
});
});
示例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()")
}
})