[Feature Request] `format` should accept undefined as a valid value
See original GitHub issueDescribe the bug
I want to add a custom formatter, but only in production mode. What I tried is this:
format: process.env.environment !== `production` ? undefined : ctx => `...`,
This works in production mode, but not in any other mode, because undefined
isn’t a function.
TypeError: config.format is not a function
at Object.exports.formatMessage (...\node_modules\better-logging\dist\lib\formatMessage.js:44:37)
at ...\node_modules\better-logging\dist\lib\decorateObject.js:21:58
I’m guessing this is due to the use of something like Object.entries()
, which will yield the key format
with value undefined
if format is specified as such, instead of omitting it, like it does when it’s actually not defined.
Expected behavior
A simple error handling to check if the value of format
(or any other option, for that matter) is undefined
, and if it is, handle it the exact same way as if it we actually undefined 😃
Desktop (please complete the following information):
- Windows 10, Node.js 14.15.1
Additional context
The package is great! 😄
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Feature request: An "undefined" value in addition to "null" #385
In my practice no one cares if value is not setted at all or it's just an unusable value. If field is required...
Read more >PutItem - Amazon DynamoDB - AWS Documentation
Invalid Requests with empty values will be rejected with a ValidationException exception. ... The request accepts the following data in JSON format.
Read more >7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
A detailed article about 'undefined' keyword in JavaScript. 7 tips on how to handle correctly 'undefined' and increase code durability.
Read more >Places Library | Maps JavaScript API - Google Developers
To use the functionality contained within this library, you must first load it ... Requests to an API or SDK associated with the...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Implemented in release 4.5.0
@Chaphasilor I think I’ve decided that I don’t have any strong opinions either way. So might as well go with your idea. I’ll have a look at a clean implementation soon.