Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Add 'json' encoding to readFile/writeFile #1703

Closed
pfrazee opened this issue Jun 1, 2020 · 1 comment
Closed

Add 'json' encoding to readFile/writeFile #1703

pfrazee opened this issue Jun 1, 2020 · 1 comment
Assignees
Labels
enhancement Change that's on the roadmap

Comments

@pfrazee
Copy link
Member

pfrazee commented Jun 1, 2020

Reading and writing objects as json files is a really common pattern, and it's a small-but-notable pain to have to call JSON parse and stringify every time.

Let's add 'json' encoding to readFile and writeFile. If specified, the API will automatically parse (readFile) or stringify (writeFile) the json.

Example:

await beaker.hyperdrive.writeFile('/foo.json', {hello: 'world'}, 'json')
await beaker.hyperdrive.readFile('/foo.json', 'json')

Sugars may clutter the APIs a bit, but developers is users too, and this is an easy DX improvement.

@pfrazee pfrazee added the enhancement Change that's on the roadmap label Jun 1, 2020
@pfrazee pfrazee added this to the 1.0.0-prerelease.4 milestone Jun 1, 2020
@pfrazee pfrazee self-assigned this Jun 1, 2020
@pfrazee
Copy link
Member Author

pfrazee commented Jun 1, 2020

Implemented via the pauls-dat-api2 module

@pfrazee pfrazee closed this as completed Jun 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Change that's on the roadmap
Projects
None yet
Development

No branches or pull requests

1 participant