New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

binarytf

Package Overview
Dependencies
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binarytf - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

dist/index.d.ts

30

package.json
{
"name": "binarytf",
"version": "0.0.2",
"version": "0.1.0",
"description": "Binary Term Format",
"main": "dist/src/index",
"main": "dist/index.js",
"scripts": {
"prepublishOnly": "yarn compile",
"prepublishOnly": "yarn build",
"build:browser": "webpack",
"lint": "tslint --fix '{test,src}/**/*.ts'",
"test:lint": "tslint '{test,src}/**/*.ts'",
"test:suite": "yarn compile && node dist/test/suite.js",
"compile": "tsc -p .",
"watch": "tsc -p . -w"
"lint": "eslint --ext ts src --fix",
"test:lint": "eslint --ext ts src",
"test": "yarn build && node dist/test/suite.js",
"build": "tsc.cmd -p .",
"watch": "tsc.cmd -p . -w"
},
"keywords": [
"binary",
"term",
"format",
"serializer",

@@ -26,9 +28,11 @@ "deserializer",

"devDependencies": {
"@types/node": "^11.11.3",
"@types/node": "^12.0.8",
"@types/tape": "^4.2.33",
"tape": "^4.10.1",
"ts-node": "^8.0.3",
"tslint": "^5.14.0",
"typescript": "^3.3.3333"
"@typescript-eslint/eslint-plugin": "^1.10.2",
"@typescript-eslint/parser": "^1.10.2",
"eslint": "^5.16.0",
"eslint-config-bamboo": "^1.3.0",
"tape": "^4.10.2",
"typescript": "^3.5.2"
}
}
# binarytf
<div align="center">
<p>
<a href="https://discord.gg/pE5sfxK">
<img src="https://discordapp.com/api/guilds/582495121698717696/embed.png" alt="Discord" />
</a>
<a href="https://www.npmjs.com/package/binarytf">
<img src="https://img.shields.io/npm/v/binarytf.svg?maxAge=3600" alt="NPM version" />
</a>
<a href="https://www.npmjs.com/package/binarytf">
<img src="https://img.shields.io/npm/dt/binarytf.svg?maxAge=3600" alt="NPM downloads" />
</a>
<a href="https://dev.azure.com/kyranet/kyranet.public/_build/latest?definitionId=1&branchName=master">
<img src="https://dev.azure.com/kyranet/kyranet.public/_apis/build/status/kyranet.binarytf?branchName=master" alt="Build status" />
</a>
<a href="https://lgtm.com/projects/g/kyranet/binarytf/alerts/">
<img src="https://img.shields.io/lgtm/alerts/g/kyranet/binarytf.svg?logo=lgtm&logoWidth=18" alt="Total alerts">
</a>
<a href="https://dependabot.com">
<img src="https://api.dependabot.com/badges/status?host=github&repo=kyranet/binarytf" alt="Dependabot Status">
</a>
<a href="https://www.patreon.com/kyranet">
<img src="https://img.shields.io/badge/donate-patreon-F96854.svg" alt="Patreon" />
</a>
</p>
<p>
<a href="https://nodei.co/npm/binarytf/"><img src="https://nodei.co/npm/binarytf.png?downloads=true&stars=true" alt="npm installnfo" /></a>
</p>
</div>
## About
`Binary Term Format` is a term format inspired in ETF with more types and circular reference serialization and deserialization.
This term format is designed to fix one of ETF's flaws: byte size.
[![npm](https://nodei.co/npm/binarytf.png?downloads=true&stars=true)](https://nodei.co/npm/binarytf/)
Serializing this object:
[![npm](https://img.shields.io/npm/v/binarytf.svg?maxAge=3600)](https://www.npmjs.com/package/binarytf)
[![npm](https://img.shields.io/npm/dt/binarytf.svg?maxAge=3600)](https://www.npmjs.com/package/binarytf)
```json
{ "test": ["hello", "world"], "more": { "nested": "objects", "do": ["you", "like", "it?"] } }
```
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/kyranet/binarytf.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kyranet/binarytf/context:javascript)
Takes `80` bytes as `JSON.stringify()`'d, `116` bytes as `ETF` using [`devsnek/earl`][earl], and just `71` bytes in `BTF`.
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=kyranet/binarytf)](https://dependabot.com)
The extreme compression is achieved by delimiting the bytes using a technique similar to [null delimited string](https://en.wikipedia.org/wiki/Null-terminated_string)s. Allowing every string, array, set, map, and object, to trim the byte size by 3 (4 bytes for length/size -> 1 byte to delimit the field). TypedArrays do not get this feature, since they have a type for all elements instead of a type for each element, `[0]` works because it is encoded as `ArrayType` + `NumberByteLiteralType` + `0x00` + `NullDelimiter`, but this technique would not work in `Uint8Array[0]` (`Uint8ArrayType` + `0x00 + 0x00 + 0x00 + 0x01` + `0x00`).
And this is also achieved by using special types for empty collections, `[null]` takes 3 bytes (`ArrayType` + `NullType` + `NullDelimiter`), but `[]` takes a single byte (`EmptyArrayType`). This also applies to empty objects, sets, and maps.
## Usage
This module is meant to be plug-and-play, it exposes two functions, `serialize` and `deserialize`, and would be used in the following way:
This module is [plug-and-play](https://en.wikipedia.org/wiki/Plug_and_play), it exposes two functions, `serialize` and `deserialize`, and would be used in the following way:

@@ -28,10 +63,22 @@ ```javascript

`binarytf` is heavily based on [`devsnek/earl`](https://github.com/devsnek/earl), this module wouldn't be possible without it's author:
`binarytf` is heavily based on [`devsnek/earl`][earl], this module wouldn't be possible without it's author:
- [Gus Caplan](https://github.com/devsnek)
## License
## Contributing
Licensed under MIT
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!
Copyright (c) 2019 [kyranet](https://github.com/kyranet)
## Author
**binarytf** © [kyranet](https://github.com/kyranet), released under the
[MIT](https://github.com/kyranet/binarytf/blob/master/LICENSE) License.
Authored and maintained by kyranet.
> Github [kyranet](https://github.com/kyranet) - Twitter [@kyranet_](https://twitter.com/kyranet_)
[earl]: https://github.com/devsnek/earl
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc