title: The "size" argument must be of type number in Nodejs
body: <p>I want to onverting mongodb Binary _id to UUID using node so in order a googling and find my response at <a href="https://stackoverflow.com/questions/25789342/converting-mongodb-binary-id-to-luuid-using-node/25792240#25792240">this post</a> :</p>
  
  <p>I want to insert this UUId into postgres database.This is my pg function on node.js:</p>
  
  <pre><code>function insert(arg) {
      console.log('insert location');
      arg.forEach(element =&gt; {
          (async () =&gt; {
              await pool.query(
                  `insert into public."Location" ("Id", "Lat", "Lng", "CreationDateTime", "DeviceId", "Topic", "UserId") 
              VALUES ('${uuidv1()}', ${element.Lat}, ${element.Lng}, $1, ${element.DeviceId}, $2, $3)`,[element.CreationDateTime, element.Topic,Bin2HexUUID(element.UserId)]);
          })();
      });
  }
  </code></pre>
  
  <p>This is <code>element.UserId</code> :</p>
  
  <pre><code>Binary {_bsontype: "Binary", sub_type: 4, position: 16, …}
  _bsontype:"Binary"
  </code></pre>
  
  <p>and this is <code>Bin2HexUUID</code> method:</p>
  
  <pre><code>function Bin2HexUUID(bin){
      var hex = new Buffer.alloc(bin, 'base64').toString('hex');
      return hex.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, function (){
          return arguments[1]+"-"+arguments[2]+"-"+arguments[3]+"-"+arguments[4]+"-"+arguments[5];
      });
  }
  </code></pre>
  
  <p>When i run script i got this error:</p>
  
  <pre><code>new Buffer.alloc(bin, 'base64').toString('hex')
  NodeError: The "size" argument must be of type number. Received type object
  ----------------------
  (node:2292) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "size" argument must be of type number. Received type object
  </code></pre>
  
  <p>For first time i used <code>new Buffer(bin, 'base64').toString('hex')</code> but seems new Buffer is deprecated.. </p>
  
  <p>This is my Node and Npm version:</p>
  
  <pre><code>node -v
  v10.8.0
  
  npm -v
  6.2.0
  </code></pre>