Hacker Newsnew | past | comments | ask | show | jobs | submit | aleclarsoniv's commentslogin

Hey HN, I wrote this little library a while back. This may be a bit of a niche thing, since there hasn't been much prior art tackling this problem. Before making json-qs, I was using my fork of juri [1], but it valued compression too much for my taste and, IIRC, I had some issues with it (can't remember the specifics).

If anyone has any feedback on the design, I'd be interested in hearing it. Or if you have questions about design choices, I can answer them. Thanks for reading!

[1]: https://github.com/scrollback/juri


I think it'd be worth looking at what's already out there before you put a lot of effort into this, unless of course this is merely for fun/learning.


I used this initially in a browser extension I'm building. Ended up migrating to a JSX library instead, because jQuery turns into hard-to-reason-about code pretty quickly once you're past “simple app” territory (and I say this as someone who wrote my own jQuery-inspired library[1]). Right tool for the job, as they say.

[1]: https://github.com/aleclarson/dough

P.S. If you can cope with jQuery in a medium/large app, good for you. But it's not my cup of tea.



The most common case is probably complex search queries. It's really nice not having to flatten your data just to get network level caching.

In my case, building an RPC library with REST semantics, it's important to me to not place any restrictions on how developers pass their data to the backend. So removing that arbitrary flattening requirement is a big win. The json-qs specification does it in a way that balances readability and compactness.


The home feed is a poor experience, IMO. Adding a tagline to each product would help me know if I want to learn more, without having to decide to click based on a logo and name alone. I think categories would also help me find what I'm interested in.


I'd love to get everyone's feedback on this library I made.

I've found it helps a lot when writing a library that takes advantage of compile-time code generation. In the future, I think it could be cool to try and integrate jumpgen with bundlers, like Vite or Rollup, so your file generator can be used as a bundler plugin. Currently, jumpgen “generators” only have a programmatic API, but jumpgen will have a CLI as well, if you think that could be useful. Mostly though, jumpgen is intended as a “white label” library that is contained by your own CLI, if you have one.

# Motivation

Code generation can be useful for many tasks. I'm using code generation in my own libraries, pg-nano[1] and alien-rpc (in development). In pg-nano, I'm generating TypeScript functions that mirror Postgres functions (aka UDFs). In alien-rpc, I'm generating runtime metadata for RPC-style API routing.

I could not find a library that simplifies the task of writing a code generator, so I made jumpgen.

# What It Does

It's designed to handle the burdens of implementing a “watch mode” for your generators. It also returns an event emitter, especially useful for logging. Your generator is free to work in relative paths, since jumpgen handles path resolution according to a user-provided root directory.

It tracks which files your generator has read into memory and which directories your generator has listed. When those files/directories are changed or have files added/removed, your generator will rerun automatically (if watch mode is enabled). This even works with globs!

I've also included a "dedent" helper function so you can indent any template literal without that excess indentation carrying over into the emitted files.

# Feedback Wanted

If this sounds interesting to you, I'd love to hear any comments or criticisms about the API, the readme, or whatever else. Thanks!

[1]: https://github.com/pg-nano/pg-nano


That's not entirely true. Tree-shaking algorithms could have a “noDynamicAccess” option that errors on such use (only viable for applications, not libraries). Alternatively, the algorithm could be integrated with the TypeScript compiler API to allow dynamic access in some cases (e.g. where the `anything` function in your example only returns a “string literal” constant type or a union thereof, instead of the `string` type).


TypeBox[1] also supports bi-directional transforms.

[1]: https://github.com/sinclairzx81/typebox


Thank you for the pointer! I will certainly consider TypeBox as well when the time comes to migrate.


TypeBox[1] differentiates between optional and undefined.

[1]: https://github.com/sinclairzx81/typebox


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: