Skip to main content
Deno 2 is finally here 🎉️
Learn more

bson-deno

Deno

Note: this is in a highly experimental state

Port of the js-bson library to deno, with the goal of feature compatibility and completeness with upstream.

This port has been autogenerated from the upstream js-bson by this build tool - please don’t make any manual changes to this repository, esp to ./_src and report any bugs either to the build tool, or even upstream

Usage

Simple example

import * as BSON from 'https://deno.land/x/bson_deno@v0.1.0/mod.ts';
const Long = BSON.Long;

// Serialize a document
const doc = { long: Long.fromNumber(100) };
const data = BSON.serialize(doc);
console.log('data:', data);

// Deserialize the resulting Buffer
const doc_2 = BSON.deserialize(data);
console.log('doc_2:', doc_2);

known issues

  • types cannot be initialized as function calls
  • the BSON.Timestamp type has a broken initializer
  • Buffer serialization is broken
  • we have a few skipped test cases