Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/victorqueiroz/binary-transfer
- Owner: VictorQueiroz
- License: mit
- Created: 2017-01-28T14:35:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T02:13:36.000Z (almost 6 years ago)
- Last Synced: 2024-12-12T05:36:28.809Z (27 days ago)
- Topics: binary, javascript, schema
- Language: JavaScript
- Homepage:
- Size: 191 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```