Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/typescord/ftee
Ftee is a fast encoder and decoder for the Erlang External Term Format (version 131) written in TypeScript.
https://github.com/typescord/ftee
discord erlang erlpack etf ftee node nodejs typescord
Last synced: 2 months ago
JSON representation
Ftee is a fast encoder and decoder for the Erlang External Term Format (version 131) written in TypeScript.
- Host: GitHub
- URL: https://github.com/typescord/ftee
- Owner: typescord
- License: mit
- Created: 2021-02-10T10:44:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-01T18:03:53.000Z (over 2 years ago)
- Last Synced: 2024-10-05T12:50:09.107Z (3 months ago)
- Topics: discord, erlang, erlpack, etf, ftee, node, nodejs, typescord
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@typescord/ftee
- Size: 3.15 MB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Ftee (Format Term External Erlang)
Ftee is a fast encoder and decoder for the Erlang External Term Format (version 131) written in TypeScript.
**Note:** the decoder does not check the lists' tail marker. _If this is inconvenient, feel free to make an issue/PR._
### Supported terms
- Atoms (decode-only)
- Booleans
- [Strings](https://erlang.org/doc/apps/erts/erl_ext_dist.html#binary_ext)
- Floats
- Integers
- Larges and smalls bigs
- [Map (objects)](https://erlang.org/doc/apps/erts/erl_ext_dist.html#map_ext)
- [Arrays](https://erlang.org/doc/apps/erts/erl_ext_dist.html#list_ext)
- Tuples (decode-only)
- ["Strings"](https://erlang.org/doc/apps/erts/erl_ext_dist.html#string_ext) (via Buffer, larges buffers are encoded as lists.)### How to encode
```js
const ftee = require('@typescord/ftee');const packed = ftee.encode({ a: true, list: ['of', 3, 'things', 'to', 'pack'] });
console.log(packed);
```### How to decode
**Note:** `LARGE_BIG_EXT` or `SMALL_BIG_EXT` are decoded as `string`s (instead of `bigint`s).
```js
const ftee = require('@typescord/ftee');const packed = Buffer.from('\u0083\u006d\u0000\u0000\u0000\u000bHello world', 'binary');
try {
const unpacked = ftee.decode(packed);
console.log(unpacked);
} catch (error) {
console.error(error);
}
```