alexreardon / tiny-invariant

A tiny invariant function
MIT License
1.67k stars 47 forks source link

Feat/allow production message #200

Open MarlonPassos-git opened 1 month ago

MarlonPassos-git commented 1 month ago

Description

As discussed in PR #172, the best approach might be to create a variant of the original function that retains error messages in production. This PR introduces a new version of the function. The original function remains unchanged; a copy was made to include this feature. This approach avoids any breaking changes, requiring only a minor release.

Inspired by the library's author, I named this new variant keep-messages. The final import looks like this:

import invariant from 'tiny-invariant/keep-messages';

invariant(condition, 'This message will be available in production');

Related

172

198

176