4.0.1 • Published 1 year ago

@scale-codec/definition-runtime v4.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@scale-codec/definition-runtime build status version license

Runtime for @scale-codec/definition-compiler. Includes standard codecs (such as U8, Str, Bool, Unit etc), codec factories and logging facilities.

Installation

Available on NPM:

npm i @scale-codec/definition-compiler

Usage

Usually, this package is paired with the output of the compiler. It is the library that the compiled code imports utilities from.

For advanced usage you can explore @scale-codec/definition-runtime API.

Tracking and Logging

All codecs use tracking API. For now, there is no need to track encoding, but you can use this API to track the decoding process. This might be useful for debugging purposes. To see what is happening, a tracker should be mounted. Trackers are not mounted by default, and the runtime cost in that case is minimal.

This library provides Logger^1, a tracker implementation that logs decoding to the console. The following code creates a logger instance and "mounts" it as a current tracker:

import { Logger } from '@scale-codec/definition-runtime'

// some options could be passed
new Logger().mount()

^1: While Logger has quite large amount of code within it (more than the rest of the runtime library), it is tree-shakeable, i.e. if you bundle the code that doesn't use Logger, it will be tree-shaken.

After the tracker is mounted, it will print debug information on how encoding/decoding is going. Here are screenshots of how it looks in Node.js and in Browser:

in Node.js

in Firefox Devtools

Tracking API is exposed from the library and could be used for custom implementations as well.

3.0.0

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

2.2.1

2 years ago

2.2.2

2 years ago

2.2.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.2

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago