Slide 33
Slide 33 text
async/await
async read(target, callback) {
let result = await this.readSlice(4)
const file_signature = char_to_string(result)
result = await this.readSlice(2)
const file_source_id = (new DataView(result)).getUint16()
result = await this.readSlice(2)
const global_encording = (new DataView(result)).getUint16(0, true)
result = await this.readSlice(4)
const guid_data1 = (new DataView(result)).getUint32(0, true)
…
const z = new DataView(result)
const max_z = z.getFloat64(0, true)
const min_z = z.getFloat64(8, true)
this.reader.abort()
callback(max_x, min_x, max_y, min_y)
}
await this.readSlice で何バイト読
むか指定
読まれたバイナリの処理の責務が
すべてread関数になる
最後はthis.reader.abort()を実行
してcallbackを呼ぶ