moleculejs

This is command line tool for serializing structured binary data. It is implemented via typescript with a prebuilt moleculec
as dependency. moleculec
is an official compiler for molecule schema, its repository is @nervosnetwork/molecule.
You may get the detailed encoding spec in there.
Installation
The recommended way is installing as global package, then you may use the command moleculejs
wherever you want.
npm i -g @linkdesu/moleculejs
After package installed, you need to download moleculec
manually, with the following command:
moleculejs -d
⚠️ Download prebuilt from untrusted source is really dangerous, so I also provide a option to download from a custom source:
moleculejs -d --download-from https://url_to_a_prebuilt_moleculec
Usage
- First, write molecule schema files with
.mol
suffix.
- Then, select a directory to store output typescript files.
Now, you could start compiling with the following commands:
moleculejs -i <path_of_schema_inputs> -f <path_of_ts_outputs>
For more options please try moleculejs -h
.
Typescript Keywords
Here we have a simple convention which the name of types must be PascalCase, so moleculejs will not rename any of type's name.
But if any field of struct or table conflict with typescript keywords, then moleculejs will add a underline at the end of it.
For example: new
will be rename to new_
.
TODO