0.1.3 • Published 7 months ago

@tree-key-cache/protobuf v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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.

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

8 months ago

0.1.0

8 months ago