node compat

This commit is contained in:
Anton Nesterov 2024-10-18 01:05:46 +02:00
parent 61e63987d1
commit 5f6944faaf
No known key found for this signature in database
GPG key ID: 59121E8AE2851FB5
3 changed files with 4 additions and 5 deletions

View file

@ -66,7 +66,6 @@ const res = await grip(
if (res.fail()) {
// handle error
return;
}
const json = await grip(
@ -75,7 +74,6 @@ const json = await grip(
if (json.of(SyntaxError)) {
// handle parse error
return;
}
```
@ -88,17 +86,17 @@ The result can also be received as a tuple if you want to handle errors in Go'is
const [res, fetchStatus] = await grip(
fetch('https://api.example.com')
);
if (fetchStatus.fail()) {
// handle error
return;
}
const [json, parseStatus] = await grip(
res.json()
);
if (parseStatus.of(SyntaxError)) {
// handle parse error
return;
}
```
@ -139,4 +137,5 @@ for await (let [value, status] of res.iter()) {
```
## License
MIT

View file

@ -9,7 +9,7 @@
"typescript": "^5.0.0"
},
"scripts": {
"bundle": "bun build ./grip.ts --outdir ./dist",
"bundle": "bun build ./grip.ts --outfile=index.js",
"test": "bun test"
}
}