https://github.com/aunyks/caber
Embed binary data into JavaScript and TypeScript projects.
https://github.com/aunyks/caber
Last synced: 3 months ago
JSON representation
Embed binary data into JavaScript and TypeScript projects.
- Host: GitHub
- URL: https://github.com/aunyks/caber
- Owner: aunyks
- License: other
- Created: 2022-09-05T03:41:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-05T18:37:19.000Z (almost 3 years ago)
- Last Synced: 2025-03-18T15:52:00.746Z (3 months ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# caber
Embed binary data into JavaScript and TypeScript projects.
## Install
```shell
cargo install caber --features cli
```## How-to
```shell
> caber --help
caber 0.1.1
Gerald Nash (aunyks)
Embed binary data into JavaScript and TypeScript projects.USAGE:
caber [OPTIONS]ARGS:
The binary to be embeddedOPTIONS:
-h, --help Print help information
-l, --output-lang The output language of the binary (javascript / ecmascript,
typescript, etc)
-m, --export-mode The export mode of the typed array (default, object, or none)
-o, --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.
```shell
> 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 ...`.
```shell
> 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.
```shell
> 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.
```shell
> 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