LoginSignup
0
0

More than 5 years have passed since last update.

Node.js(JavaScript)で可変長バイナリを書き出す方法

Last updated at Posted at 2017-11-04

可変長のバイナリが作りたかったので、テストしてみました。

コード

test.js
function output() {
  var dataArray = [0,1,2,3,4,5,6,7,8,9];
  dataArray = dataArray.concat([0xaa,0xbb,0xcc,0xdd,0xff,0x1234,0x5678,0xff55]);
  console.log('output test');
  var ub = new Uint8Array(dataArray);
  fs.writeFileSync('outfile',ub);
}

そして結果

image.png

下位のみが拾われる様子。
通常の配列の方が扱いやすいし、これが一番かなと。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0