Javascript Convert int value to octet stream Array
<p>I want convert an integer (signed) to 32 bit (big endian) into a octet stream and give the octet stream as a array value to the constructor of a
Buffer Object.</p>

<p>I can create it in the console for example for the value -2000:</p>

<pre><code>&lt;code&gt;
buf = Buffer(4)
buf.writeInt32BE(-2000)
buf // is &lt;Buffer ff ff f8 30&gt;
buf1 = new Buffer([0xff, 0xff, 0xf8, 0x30])
&lt;/code&gt;
</code></pre>

<p>The value -3000 is for example -3000 : 0xff ,0xff, 0xf4, 0x48</p>

<p>But the framework i use accepts not the writeInt32BE function and throws exception.</p>

<p>How can i convert a 32 bit integer value signed to a octet Array stream without the writeInt32BE  ? </p>

<p>A function that takes a value and returns an array of octet stream.</p>