本文整理汇总了TypeScript中uint64be.encode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript encode函数的具体用法?TypeScript encode怎么用?TypeScript encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Read RollBackTransaction', done => {
const message = 'Hello World';
const socket = new MockSocket();
let buffer = Buffer.concat([new Buffer('A'), uint64be.encode(message.length), new Buffer(message)]);
// Write part of a second message
const partOfSecondMessage = Buffer.concat([new Buffer('A'), uint64be.encode(message.length)]);
buffer = Buffer.concat([buffer, partOfSecondMessage]);
const stream = new SocketStream((socket as any) as net.Socket, buffer)
stream.BeginTransaction();
assert.equal(stream.ReadString(), message, 'First message not read properly');
const secondMessage = stream.ReadString();
assert.equal(stream.HasInsufficientDataForReading, true, 'Should not have sufficient data for reading');
stream.RollBackTransaction();
assert.equal(stream.ReadString(), message, 'First message not read properly after rolling back transaction');
done();
});