Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/palette-docs-improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"node-version": patch
---

Improve JSDoc for `is`, `isAtLeast` and other comparison methods to clarify strictness and fail-closed behavior.
5 changes: 5 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Palette's Journal

## 2026-01-01 - strict vs loose comparison confusion
**Learning:** Developers might assume `is()` behaves like `isAtLeast()` regarding normalization (e.g. stripping 'v' prefix), but it performs strict equality. This is a potential DX pitfall.
**Action:** Explicitly document the strictness of `is()` and the fail-closed behavior of comparison methods in JSDoc to prevent confusion.
20 changes: 11 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,42 @@ export interface NodeVersion {
build: string;
/**
* Check if the current Node version is at least the specified version.
* @param version The version to compare against (e.g., '20.0.0').
* @returns {boolean} True if current version >= target version.
* @param version The version to compare against (e.g., '20.0.0' or 'v20.0.0').
* @returns {boolean} True if current version >= target version. Returns false for invalid version strings.
* @example
* version.isAtLeast('18.0.0'); // true if current is 20.0.0
*/
isAtLeast(version: string): boolean;
/**
* Check if the current Node version matches the specified version.
* Check if the current Node version exactly matches the specified version.
* @param version The version to compare against (e.g., '20.0.0').
* @returns {boolean} True if current version === target version.
* @note This performs a strict equality check and does NOT strip 'v' prefixes.
* @example
* version.is('20.0.0'); // true if current is 20.0.0
* version.is('v20.0.0'); // false if current is 20.0.0
*/
is(version: string): boolean;
/**
* Check if the current Node version is strictly greater than the specified version.
* @param version The version to compare against (e.g., '20.0.0').
* @returns {boolean} True if current version > target version.
* @param version The version to compare against (e.g., '20.0.0' or 'v20.0.0').
* @returns {boolean} True if current version > target version. Returns false for invalid version strings.
* @example
* version.isAbove('18.0.0'); // true if current is 20.0.0
*/
isAbove(version: string): boolean;
/**
* Check if the current Node version is strictly less than the specified version.
* @param version The version to compare against (e.g., '20.0.0').
* @returns {boolean} True if current version < target version.
* @param version The version to compare against (e.g., '20.0.0' or 'v20.0.0').
* @returns {boolean} True if current version < target version. Returns false for invalid version strings.
* @example
* version.isBelow('22.0.0'); // true if current is 20.0.0
*/
isBelow(version: string): boolean;
/**
* Check if the current Node version is at most the specified version.
* @param version The version to compare against (e.g., '20.0.0').
* @returns {boolean} True if current version <= target version.
* @param version The version to compare against (e.g., '20.0.0' or 'v20.0.0').
* @returns {boolean} True if current version <= target version. Returns false for invalid version strings.
* @example
* version.isAtMost('22.0.0'); // true if current is 20.0.0
*/
Expand Down