Introducing The @drink JSDoc Tag

Sebastian Carlos
3 min readJan 16, 2023
Photo by Adam Jaime on Unsplash

We’re excited to announce a new JSDoc tag: @drink.

This tag indicates what you should drink to power through reading the following piece of garbage code.

For example:

/**
* @drink whiskey
*/
function getFactoryImpl() {
// some hacky shit goes here
}

We’ve found that the vast majority of code can be powered through with a decent amount of whiskey.

However, for particularly gnarly code, you might need to up the ante and drink something stronger like vodka, absinthe, or bleach.

@drink 101

The JSDoc specification allows a variety of different parameters for the @drink tag.

The obvious one is the type of drink, but you can also specify the amount in milliliters (ml) or ounces (oz), the number of shots, the number of ice cubes, the mixers, the garnish, and any additional instructions surrounded by the <advanced-tip> HTML tags. Sure, JSDoc is not HTML, but mixing two standards fits the spirit of the @drink tag.

You can also designate an array of multiple drinks by using the @drink-array tag instead. Then, you can use the characters LMAO_NOW_THIS as a separator between drinks.

You can also add conditional logic by nesting the @drink-if operator. In which case you must provide one of the three hardcoded values: NOT_FEELING_A_THING, LITTLE_BIT_JUICED_UP or TIME_TO_PARTY.

To surround complex logical statements, you need to type all three kinds of brackets, in any order: {([ ... )}]

Let’s look at an advanced example showcasing all of the above:

/**
* @drink-array vodka, 1 oz
* LMAO_NOW_THIS absinthe, 3 shots
* <advanced-tip>add lime juice and a lime wheel</advanced-tip>
* LMAO_NOW_THIS
* {([
* @drink-if NOT_FEELING_A_THING
* whiskey, 2 shots
* @drink-if LITTLE_BIT_JUICED_UP
* tequila, 0.5 oz
* @drink-if TIME_TO_PARTY
* beer <advanced-tip>as much as you can</advanced-tip>
* )}]
*/
function magicFunction() {
// some really really really complicated shit here
}

Drinks for the Brave

For the code warriors willing to take on the most puzzling of challenges, there’s a special drink: A concoction of coffee, black tea, Red Bull, Club Mate, Peruvian Coca leaves, oxygenated water, Coke, maple syrup, Ritalin, and a shot of rum.

We recommend having a designated pair programmer nearby, in case your hands get too shaky to keep typing.

Drink responsibly, stay hydrated, and remember: Code drunk, refactor sober!

Thanks for reading! If you enjoy humorous tech stories like these and want to support me to keep writing forever, consider signing up to become a Medium member. It’s $5 a month, giving you unlimited access to stories on Medium. If you sign up using my link, I’ll earn a small commission. You can also follow me on Medium and Twitter.

--

--