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

https://github.com/vladfrangu/etf.js

An External Term Format Encoder/Decoder, written in pure JavaScript
https://github.com/vladfrangu/etf.js

etf hacktoberfest

Last synced: 3 months ago
JSON representation

An External Term Format Encoder/Decoder, written in pure JavaScript

Awesome Lists containing this project

README

          

# etf.js




NPM version


NPM downloads


Build status


Azure DevOps coverage


Total alerts


Dependabot Status


Patreon



npm installnfo


## About

[`External Text Format`][etf] is the format Erlang uses when sending and receiving data. This module implements packing and unpacking of said format in pure, native JavaScript.

## Usage

This module is [plug-and-play](https://en.wikipedia.org/wiki/Plug_and_play), it exposes two functions, `pack` and `unpack`, and would be used in the following way:

```javascript
const { pack, unpack } = require('etf.js');
const serialized = pack({ hello: 'world' });
const deserialized = unpack(serialized);
console.log(deserialized); // { hello: 'world' }
```

### What can be packed

- [x] Null ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Booleans ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Strings ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Atoms ([Atom Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/atoms.ts))
- [x] Unicode Strings ([String Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/strings.ts))
- [x] Floats ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Integers ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Longs ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Longs over 64 bits ([Primitive Tests](https://github.com/vladfrangu/etf.js/blob/master/src/test/primitives.ts))
- [x] Objects
- [x] Arrays
- [ ] Tuples
- [ ] PIDs
- [ ] Ports
- [ ] Exports
- [ ] References

Plus added support for Maps (will be converted into Objects) and Sets (will be converted into Arrays)

## Credits

`etf.js` is heavily based of [`binarytf`][binarytf] for the structure, and could not have been done without the help from it's author:

- [Aura Román](https://kyra.dev)

## Contributing

1. Fork it!
1. Create your feature branch: `git checkout -b my-new-feature`
1. Commit your changes: `git commit -am 'Add some feature'`
1. Push to the branch: `git push origin my-new-feature`
1. Submit a pull request!

## Author

**etf.js** © [vladfrangu][githubvlad], released under the
[MIT](https://github.com/vladfrangu/etf.js/blob/master/LICENSE) License.
Authored and maintained by vladfrangu.
> Github [vladfrangu][githubvlad] - Twitter [@KingDGrizzle](https://twitter.com/KingDGrizzle)

[etf]: http://erlang.org/doc/apps/erts/erl_ext_dist.html
[binarytf]: https://github.com/binarytf/binarytf
[githubvlad]: https://github.com/vladfrangu