• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    JavaScript
  • License
    zlib License
  • Created over 13 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[project inactive] Buffalo is a lightweight BSON library for Node.js

Project Inactive

I am no longer have the time to work on this project. Feel free to fork!

Buffalo

Buffalo is a lightweight BSON and Mongo Wire Protocol library for Node.js. It was built as the underlying engine for Mongolian DeadBeef.

The motivation is to make a fast and simple parser and serializer for BSON.

Build Status

Installation

DISCLAIMER: The API is experimental. I will be adding, removing, and changing the API in the interest of a solid API. Use at your own risk

You can either clone the source and install with npm link, or install the latest published version from npm with npm install buffalo.

Running Tests

Run the tests with npm test.

API

Buffalo exposes two methods:

exports.parse = function(buffer) { ... }
exports.serialize = function(object) { ... }

And several types:

exports.Long // goog.math.Long - http://closure-library.googlecode.com/svn/docs/class_goog_math_Long.html
exports.ObjectId = function(buffer) // buffer must be a 12-byte Buffer, accessible via the bytes property
exports.ObjectId = function(string) // string must be a 24-char hex string
exports.ObjectId = function(number) // generate an ObjectId from a timestamp number
exports.ObjectId = function(date)   // generate an ObjectId from a date
exports.ObjectId = function() // generates an ObjectId
exports.Timestamp // under construction

The BSON types are mapped as follows:

  • 0x01 - Floating point - mapped to Number
  • 0x02 - UTF-8 string - mapped to String
  • 0x03 - Embedded document - mapped to Object
  • 0x04 - Array - mapped to Array
  • 0x05 - Binary data - mapped to Node.js Buffer (with property subtype)
  • 0x06 - Undefined - mapped to undefined
  • 0x07 - ObjectId - mapped to exports.ObjectId
  • 0x08 - Boolean - mapped to true or false
  • 0x09 - UTC datetime - mapped to Date
  • 0x0A - Null value - mapped to null
  • 0x0B - Regular expression - mapped to RegExp (Note: only flags g, i, and m are supported)
  • 0x0C - DBPointer - currently unmapped
  • 0x0D - JavaScript code - mapped to Function or Object with property code
  • 0x0E - Symbol - mapped to String
  • 0x0F - JavaScript code w/ scope - mapped to Function or Object with properties code and scope
  • 0x10 - 32-bit Integer - mapped to Number
  • 0x11 - Timestamp - mapped to exports.Timestamp
  • 0x12 - 64-bit integer - mapped to exports.Long
  • 0xFF - Min key - currently unmapped
  • 0x7F - Max key - currently unmapped

Examples

var BSON = require('buffalo')

// Parse a Buffer
var object = BSON.parse(buffer)

// Serialize an object
var buffer = BSON.serialize(object)

Contributing

Try it out and send me feedback! Unit tests and documentation are good, too.

License

Buffalo is open source software under the zlib license.

More Repositories

1

node-mongolian

[project inactive] Mongolian DeadBeef is an awesome Mongo DB driver for node.js
JavaScript
349
star
2

node-tosource

Converts JavaScript objects to source
TypeScript
101
star
3

node-licensecheck

A quick way to see the licenses of node modules you depend on—recursively.
JavaScript
56
star
4

gulp-watchify

gulp + watchify
JavaScript
54
star
5

node-ractify

ractive.js + browserify
JavaScript
33
star
6

lascaux-sketch

Lascaux Sketch 2 is an open source web-based digital painting tool
TypeScript
23
star
7

trimerge

Three-way merge JSON structures
TypeScript
18
star
8

node-safestart

Safe start ensures all your node dependencies exist and are up to date
JavaScript
15
star
9

graphql-98

A visual GraphQL data browser. Like a SQL GUI for GraphQL!
TypeScript
13
star
10

firestarter

Fire Starter – Allegro Speedhack 2005
C++
12
star
11

falcor-shapes

object-based falcor pathset generator
JavaScript
11
star
12

jtablet

(Unsupported) JTablet provides a simple open-source (zlib license) interface for accessing tablet input in your Java applications.
Java
11
star
13

node-stylish

Stylus middleware for connect
JavaScript
9
star
14

polyfill.js

JavaScript polyfills
JavaScript
9
star
15

nithub

Nithub mashes up the npm and github apis to organize and rank npm packages.
JavaScript
8
star
16

trimerge-sync

Distributed data sync using trimerge
TypeScript
8
star
17

collabodux

Collabodux is an idea and experimental library for realtime collaboration on JSON structures. It is a client-oriented, declarative-functional approach to shared application state.
TypeScript
8
star
18

mode7ex

[2002] Mode 7 Ex extension for Multimedia Fusion
C++
5
star
19

node-waiter

A simple way to wait for multiple asynchronous calls to return in Node.js.
JavaScript
4
star
20

babel-preset-es2015-webpack2

Babel preset for all es2015 plugins except es2015-modules-commonjs (because webpack2 supports it already!).
JavaScript
4
star
21

node-taxman

Taxman caches values for you.
JavaScript
3
star
22

node-shimmy

JavaScript
2
star
23

node-localdeps

Symbolic links local dependencies to your project
JavaScript
2
star
24

node-handleify

browserify 2 + precompiled client-side handlebars
JavaScript
2
star
25

marcello3d.github.io

personal site
JavaScript
2
star
26

alt

JavaScript
2
star
27

draft-canvas

TypeScript
2
star
28

klikjs

Next.js-based Website that lets you play Classic Klik & Play games online
HTML
2
star
29

battle-of-the-braces-2012

Hackday project with @defunctzombie
JavaScript
1
star
30

headless-electron

Run node scripts in a headless electron environment
TypeScript
1
star
31

gulp-boilerplate.js

experimental gulpfile.js boilerplate for webapps
JavaScript
1
star
32

ractify-loader

Ractive component loader for webpack
JavaScript
1
star
33

io-ts-path

Generate type-safe paths from io-ts models.
TypeScript
1
star
34

react-electron-sample-app

JavaScript
1
star
35

casbah-mapper

Scala object to MongoDB mapper that builds atop Casbah
Scala
1
star
36

node-listenable

simple event emitter
JavaScript
1
star