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
- Host: GitHub
- URL: https://github.com/vladfrangu/etf.js
- Owner: vladfrangu
- License: mit
- Created: 2019-07-23T14:31:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T08:09:24.000Z (almost 3 years ago)
- Last Synced: 2025-06-26T03:49:16.322Z (3 months ago)
- Topics: etf, hacktoberfest
- Language: TypeScript
- Homepage:
- Size: 86.9 KB
- Stars: 8
- Watchers: 1
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etf.js
## 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
- [ ] ReferencesPlus 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