Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/victorqueiroz/binary-transfer

Travel your data very fast using binary serialization.
https://github.com/victorqueiroz/binary-transfer

binary javascript schema

Last synced: 22 days ago
JSON representation

Travel your data very fast using binary serialization.

Awesome Lists containing this project

README

        

# binary-transfer (This module is deprecated in order of [message-ff](https://www.npmjs.com/package/message-ff))

Travel your data very fast using binary serialization.

This project is based on [Telegram Type Language](https://core.telegram.org/).

### 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
```js
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
}
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
```