toBuffer()

Returns the binary representation of the ObjectId as a Node.js Buffer.

Usage

import { ObjectId } from 'funtool';

const id = new ObjectId();
const buffer = id.toBuffer(); // <Buffer 5f 1d 7f 3b 1c 9d 44 00 00 00 00>

Signature

toBuffer(): Buffer

Return Value

Returns a 12-byte Buffer containing the raw ObjectId bytes.

Notes

  • Useful for binary storage or transmission
  • Buffer length is always 12 bytes
  • First 4 bytes represent timestamp
  • Next 5 bytes are random values
  • Last 3 bytes are counter