本文整理匯總了TypeScript中@bokehjs/protocol/receiver.Receiver類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Receiver類的具體用法?TypeScript Receiver怎麽用?TypeScript Receiver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Receiver類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe("message with no buffers", () => {
const r = new Receiver()
describe("header consume", () => {
it("should should leave message null", () => {
const res = r.consume('{"msgtype": "FOO", "msgid": "10"}')
expect(res).to.be.undefined
expect(r.message).to.be.null
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
describe("metadata consume", () => {
it("should should leave message null", () => {
const res = r.consume('{}')
expect(res).to.be.undefined
expect(r.message).to.be.null
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
describe("metadata consume", () => {
it("should should set a complete message", () => {
const res = r.consume('{"bar": "20"}')
expect(res).to.be.undefined
expect(r.message).to.be.instanceof(Message)
expect(r.message!.complete()).to.be.true
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
describe("next header consume", () => {
it("should should leave message null", () => {
const res = r.consume('{"msgtype": "FOO", "msgid": "11"}')
expect(res).to.be.undefined
expect(r.message).to.be.null
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
})
示例2: it
it("should should set a complete message", () => {
const res = r.consume(new ArrayBuffer(20))
expect(res).to.be.undefined
expect(r.message).to.be.instanceof(Message)
expect(r.message!.complete()).to.be.true
expect(r.message!.buffers.length).to.be.equal(2)
expect(r.message!.buffers[0].length).to.be.equal(2)
expect(r.message!.buffers[1].length).to.be.equal(2)
expect(r.message!.buffers[0][0]).to.be.equal('foo')
expect(r.message!.buffers[0][1]).to.be.instanceof(ArrayBuffer)
expect(r.message!.buffers[1][0]).to.be.equal('bar')
expect(r.message!.buffers[1][1]).to.be.instanceof(ArrayBuffer)
})
示例3: expect
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)