@htptp/hurl-parser
The Hurl file parser, compiled to WASM and callable from JavaScript!
- Simple af
- Works in Node.js and the browser
- Output is the same as
hurlfmt --format json
Usage
import { parse } from "@htptp/hurl-parser";
const result = parse(`
GET http://example.com
HTTP/* 200
`);
The returned data will be as follows
{
"entries": [
{
"request": {
"method": "GET",
"url": "http://example.com"
},
"response": {
"status": 200
}
}
]
}
The module also exports TypeScript types for these structures.
import type { Hurl } from "@htptp/hurl-parser";
const result: Hurl.Document = parse(/* ... */);
Installation
Just install to your dependencies
$ yarn add @htptp/hurl-parser # if you use yarn
$ npm install @htptp/hurl-parser # if you use npm
And import normally
Limitations
- The target environment or bundler must support ES Modules, WASM and top-level await. (Chrome 89+, Firefox 89+, Safari 15+, Node.js 14.8+, Webpack 5+).