Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fgasper/gawk-web
GNU AWK compiled for web use.
https://github.com/fgasper/gawk-web
Last synced: 18 days ago
JSON representation
GNU AWK compiled for web use.
- Host: GitHub
- URL: https://github.com/fgasper/gawk-web
- Owner: FGasper
- License: mit
- Created: 2024-05-16T19:51:37.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-19T19:51:43.000Z (7 months ago)
- Last Synced: 2024-10-22T07:41:51.522Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gawk-web: [GNU AWK](https://www.gnu.org/software/gawk/) for the Web
This package builds GNU AWK to WebAssembly and JavaScript via [Emscripten](https://emscripten.org/).
Usage:
```
const gawk = require('./gawk.js');// "barbaz\n23\n"
gawk().then( gawk => {
console.log(
gawk(
["foo bar baz", "1 2 3"].join("\n"), // the text to process
"{print $2 $3}", // your AWK code
),
);
);
```
Specifically: `require()` returns a single function. When called, that function
compiles AWK and returns (via a promise) a function that actually runs AWK.
You can call that function over & over.The above tracks closely with typical command-line usage:
```
{ echo foo bar baz; echo 1 2 3 } | awk '{print $2 $3}'
```## Notes
- Be sure to initialize the submodules (e.g., `git clone --recurse-submodules`)
when cloning this repository.- This build optimizes for ease of use by packing the WebAssembly into the
JavaScript file. You can shrink the output significantly by removing
the `SINGLE_FILE` flag from the build (see the Makefile). You’ll need to
grab `gawk.wasm` from the `gawk` directory and ensure that it’s available
wherever your `gawk.js` runs.- This copies a number of usage patterns from
[jq-web](https://github.com/fiatjaf/jq-web).- GNU AWK’s build seems to give the LDFLAGS twice when building. For us that
causes `pre.js` and friends to be included twice. To work around that, those
files eschew root-level `let` and `const` in favor of `var`.