You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/pdfkit/node_modules/restructure/test.coffee

23 lines
570 B
CoffeeScript

{Struct, String:StringT, Array:ArrayT, Pointer, uint8, DecodeStream, EncodeStream} = require './index.js'
concat = require '../concat-stream/index.js'
struct = new Struct
name: new StringT uint8
age: uint8
ptr: new Pointer uint8, new StringT uint8
console.log struct.size
name: 'devon'
age: 21
ptr: 'hello'
stream = new EncodeStream
stream.pipe concat (buf) ->
console.log buf # .should.deep.equal new Buffer [4, 5, 6, 7, 8, 1, 2, 3, 4]
array = new ArrayT new Pointer(uint8, uint8), uint8
array.encode(stream, [1, 2, 3, 4])
stream.end()