binary-transfer

2.2.1 • Public • Published

binary-transfer

Travel your data very fast using binary serialization.

This project is based on Telegram Type Language.

About the project

The aim of this project is:

  • A very small library that can travel data very fast
  • A scheme of how your data looks like to increase productivity between teams
  • To create a data model that can be easily be understood, changed or mantained

Schema

Account account -> id: int, username: string, email: string;

Usage

import { Schema, language } from 'binary-transfer';
 
const parser = new language.SchemaParser();
const schema = new Schema([
    {containers: parser.parse(`
        type Account {
            account -> id: int,
                        username: string,
                        email: string,
                        posts: Vector<Post>
        }
        type Post {
            post -> id: int,
                    title: string,
                    body: string
        }
    `)}
]);
 
const buffer = schema.encode('account', {
    id: 3,
    username: '',
    email: '',
    posts: []
});
 
assert.deepEqual(schema.decode(buffer), {
    id: 3,
    username: '',
    email: '',
    posts: [{
        id: 100,
        title: 'This is my first post',
        body: 'Empty body, please edit it',
        _name: 'post',
        _type: 'Post',
        _traits: []
    }],
    _name: 'account',
    _type: 'Account',
    _traits: []
});

Testing

git clone https://github.com/VictorQueiroz/binary-transfer
cd binary-transfer/
npm install
make test

Package Sidebar

Install

npm i binary-transfer

Weekly Downloads

14

Version

2.2.1

License

MIT

Unpacked Size

275 kB

Total Files

69

Last publish

Collaborators

  • vqueiroz