@tree-key-cache/protobuf
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Actions Status Actions Status Actions Status Test Coverage Maintainability Packages npm version

Protobuf tree serializer fot tree-key-cache

How to Install

npm i @tree-key-cache/protobuf

How to use it

First, declare the proto file for the object you want to be the cache value:

syntax = "proto3";
package codibre.test_value;

message Value {
  int32 value = 1;
}

Then, instantiate TreeKeyCache passing the proto path to getProtobufjsSerializers with the full lookup type path:

const protoPath = join(process.cwd(), 'proto/value.proto');
const lookupType = 'codibre.test_value.Value';

target = new TreeKeyCache<{ value: number }, Uint8Array>(
			map,
			{
				keyLevelNodes: 4,
				...(await getProtobufjsSerializers(protoPath, lookupType)),
			},
		);

And that's it! You now have a TreeKeyCache instance that serializes and deserializes using protobuf, which will save you a lot of space!

License

Licensed under MIT.

Readme

Keywords

none

Package Sidebar

Install

npm i @tree-key-cache/protobuf

Weekly Downloads

12

Version

0.1.3

License

MIT

Unpacked Size

12.4 kB

Total Files

15

Last publish

Collaborators

  • farenheith