Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thekorn/bson-deno

port of js-bson to deno
https://github.com/thekorn/bson-deno

Last synced: about 2 months ago
JSON representation

port of js-bson to deno

Awesome Lists containing this project

README

        

# bson-deno

![Deno](https://github.com/thekorn/bson-deno/actions/workflows/deno.yml/badge.svg)

**Note: this is in a highly experimental state**

Port of the [js-bson](https://github.com/mongodb/js-bson.git) 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](https://github.com/thekorn/deno-build-mongodb-native) - 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](https://github.com/mongodb/js-bson)

## Usage

Simple example

```typescript
import * as BSON from 'https://deno.land/x/[email protected]/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