caber 0.1.1

Embed binary data into JavaScript and TypeScript projects.
Documentation
  • Coverage
  • 0%
    0 out of 16 items documented0 out of 9 items with examples
  • Size
  • Source code size: 18.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 462.11 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • aunyks/caber
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • aunyks

caber

Embed binary data into JavaScript and TypeScript projects.

Install

cargo install caber --features cli

How-to

> caber --help
caber 0.1.1
Gerald Nash (aunyks)
Embed binary data into JavaScript and TypeScript projects.

USAGE:
    caber [OPTIONS] <INPUT_FILE>

ARGS:
    <INPUT_FILE>    The binary to be embedded

OPTIONS:
    -h, --help                         Print help information
    -l, --output-lang <OUTPUT_LANG>    The output language of the binary (javascript / ecmascript,
                                       typescript, etc)
    -m, --export-mode <EXPORT_MODE>    The export mode of the typed array (default, object, or none)
    -o, --output-file <OUTPUT_FILE>    The output file containing the embedded file
    -V, --version                      Print version information

Examples

Embed a file.bin file and export the typed array with export default .... The result is written to stdout.

> caber ./file.bin
const binary = new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);

export { binary };

Embed a file.bin file into a file.ts TypeScript file and export the typed array with export default ....

> caber ./file.bin --output-lang typescript --export-mode default --output-file file.ts

Embed a file.bin file as JavaScript and export the typed array with export { ... }. The result is written to stdout.

> caber ./file.bin --output-lang javascript --export-mode object
const binary = new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);

export { binary };

Embed a file.bin file as JavaScript and export the typed array with export default .... The result is written to stdout.

> caber ./file.bin --output-lang javascript --export-mode default
const binary = new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);

export default binary;

License

Fair Source License, Version 0.9
Copyright © 2022 Gerald Nash