Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marcello Bastea-Forte
committed
Jun 21, 2011
0 parents
commit bbc1ca0
Showing
9 changed files
with
1,623 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2011 Marcello Bastéa-Forte (marcello@cellosoft.com) | ||
|
||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
arising from the use of this software. | ||
|
||
Permission is granted to anyone to use this software for any purpose, | ||
including commercial applications, and to alter it and redistribute it | ||
freely, subject to the following restrictions: | ||
|
||
1. The origin of this software must not be misrepresented; you must not | ||
claim that you wrote the original software. If you use this software | ||
in a product, an acknowledgment in the product documentation would be | ||
appreciated but is not required. | ||
|
||
2. Altered source versions must be plainly marked as such, and must not be | ||
misrepresented as being the original software. | ||
|
||
3. This notice may not be removed or altered from any source | ||
distribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
Buffalo | ||
================== | ||
Buffalo is a lightweight [BSON][1] library for [Node.js][2]. It was built as a new underlying engine for | ||
[Mongolian DeadBeef][3]. | ||
|
||
The motivation is to make a fast and simple parser and serializer for BSON. | ||
|
||
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(bytes) // bytes should be a 12-byte Buffer, accessible via the bytes property | ||
exports.Timestamp // under construction | ||
|
||
The BSON types are mapped as follows: | ||
|
||
+ <code>0x01</code> - Floating point - mapped to <code>Number</code> | ||
+ <code>0x02</code> - UTF-8 string - mapped to <code>String</code> | ||
+ <code>0x03</code> - Embedded document - mapped to <code>Object</code> | ||
+ <code>0x04</code> - Array - mapped to <code>Array</code> | ||
+ <code>0x05</code> - Binary data - mapped to Node.js <code>Buffer</code> (with property <code>subtype</code>) | ||
+ <code>0x06</code> - Undefined - mapped to <code>undefined</code> | ||
+ <code>0x07</code> - ObjectId - mapped to <code>exports.ObjectId</code> | ||
+ <code>0x08</code> - Boolean - mapped to <code>true</code> or <code>false</code> | ||
+ <code>0x09</code> - UTC datetime - mapped to <code>Date</code> | ||
+ <code>0x0A</code> - Null value - mapped to <code>null</code> | ||
+ <code>0x0B</code> - Regular expression - mapped to <code>RegExp</code> (Note: only flags g, i, and m are supported) | ||
+ <code>0x0C</code> - DBPointer - currently unmapped | ||
+ <code>0x0D</code> - JavaScript code - mapped to <code>Function</code> or <code>Object</code> with property <code>code</code> | ||
+ <code>0x0E</code> - Symbol - mapped to <code>String</code> | ||
+ <code>0x0F</code> - JavaScript code w/ scope - mapped to <code>Function</code> or <code>Object</code> with properties <code>code</code> and <code>scope</code> | ||
+ <code>0x10</code> - 32-bit Integer - mapped to <code>Number</code> | ||
+ <code>0x11</code> - Timestamp - mapped to <code>exports.Timestamp</code> | ||
+ <code>0x12</code> - 64-bit integer - mapped to <code>exports.Long</code> | ||
+ <code>0xFF</code> - Min key - currently unmapped | ||
+ <code>0x7F</code> - 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][4]. | ||
|
||
[1]: http://bsonspec.org/#/specification | ||
[2]: http://nodejs.org/ | ||
[3]: https://github.com/marcello3d/node-mongolian | ||
[4]: https://github.com/marcello3d/node-buffalo/blob/master/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Mongolian DeadBeef by Marcello Bastea-Forte - zlib license */ | ||
|
||
module.exports = require('./lib/bson') |
Oops, something went wrong.