Update: I just chucked this up on npm so you can use it with:

npm i @small-tech/required

(See what I did there?) ;)

Blog post: ar.al/2020/03/23/fail-fast-on-


I stay away from JS, but thought Typescript would do this already

Clever solution though

@aral cool trick, if you haven't done it already you should add a call to Error.captureStackTrace so your util functions aren't included in the stack trace

@aral See also freecodecamp.org/news/elegant- where they use that technique.

[Not related to the main topic ->] the RORO pattern can be useful on the long term when you need to add, rename or remove arguments to or from your functions.

@severo_bo Neat – thanks for the heads up :) I did do a cursory search to see if there was anything else out there but didn’t stumble on that :)

@severo_bo (I’m also a big fan of using parameter objects once you’re past a couple of paramaters for most things) :)

@severo_bo RORO looks like something that is pretty old - namely passing records (tuples) are in or out parameters. Looks like Java Value Types to me.

[ @aral won't be able to see this alas ]

Sign in to participate in the conversation
Aral’s Mastodon

This is my personal Mastodon.