node-semver
node-semver copied to clipboard
[BUG] remove extraneous this.format() from SemVerConstructor
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
https://github.com/npm/node-semver/blob/e9a1f26e616b2e7a3e14e1803364229980142789/classes/semver.js#L76 calls this.format()
Expected Behavior
https://github.com/npm/node-semver/blob/e9a1f26e616b2e7a3e14e1803364229980142789/classes/semver.js#L76 should not call this.format()
Steps To Reproduce
https://github.com/npm/node-semver/blob/e9a1f26e616b2e7a3e14e1803364229980142789/classes/semver.js#L76 calls this.format()
Environment
All Environments
Actually, format writes to this.version :( I'm hunting down spurious allocations in my project and the call to this.format came up in my debugging.
I'm surprised that this function both reads and writes to a property. It may be better to turn version into a getter that calculates the value on the fly but that might impact people who are relying for it to be calculated?
I don't see this.format()
specifically as a performance issue. As you said, it is required to write this.version
. I'm going to close this but keep open #458 to track overall reuse of instances.