node-flatbuffers

0.0.1 • Public • Published

node-flatbuffers

PRs Welcome

node-flatbuffers is simple flatbuffers wrapper

Install

npm i node-flatbuffers

Usage example

    const fb = require('node-flatbuffers')
    const flatbuffers = require('flatbuffers').flatbuffers
    const fs = require('fs')
    const Game = require('../samples/monster_generated.js').MyGame
    const fbs = fs.readFileSync(__dirname + '/../samples/monster.fbs').toString()
    const assert = require('assert')
 
    const monster = { name: 'hello', hp: 3, mana: 23 }
    const bin = fb.serialize(monster, fbs)
 
 
    const buf = new flatbuffers.ByteBuffer(new Uint8Array(bin))
    const res = Game.Sample.Monster.getRootAsMonster(buf)
 
    assert(monster.name === res.name())
    assert(monster.hp === res.hp())
    assert(monster.mana === res.mana())

Package Sidebar

Install

npm i node-flatbuffers

Weekly Downloads

1

Version

0.0.1

License

Apache License 2.0

Unpacked Size

454 kB

Total Files

28

Last publish

Collaborators

  • you-think-you-are-special