Skip to content

Conversation

@dynst
Copy link

@dynst dynst commented Nov 24, 2025

var isIP = require('node:net').isIP;

Reduce redundancy by replacing lines like this with a destructuring assignment, and consolidate the multiple references to exports into just one or two, assigning all the exported values in one line.

Copy link
Member

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your contribution. Is there any actual issue with this approach, or are these purely stylistic changes?

@dynst
Copy link
Author

dynst commented Nov 26, 2025

They're stylistic changes, but in the long term, they're also potentially useful, because these are the same changes to the code that would be needed to convert the library to ESM ( const { ... } = require('x') maps perfectly to import { ... } from 'x'; module.exports = app on its own line becomes export default app; etc).

After the style changes, it would be fairly trivial to someday convert between the 2 formats with a very simple script, so even dual-packaging CJS/ESM would become feasible by running a script at build time, instead of needing to maintain 2 identical codebases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants