Skip to content

Remove is-close dependency#1295

Merged
minggangw merged 2 commits into
RobotWebTools:developfrom
minggangw:fix-1294
Oct 17, 2025
Merged

Remove is-close dependency#1295
minggangw merged 2 commits into
RobotWebTools:developfrom
minggangw:fix-1294

Conversation

@minggangw

@minggangw minggangw commented Oct 17, 2025

Copy link
Copy Markdown
Member

This PR removes the external is-close dependency and replaces it with a custom implementation in the project's utility module. The change eliminates a third-party dependency while maintaining the same floating-point comparison functionality.

Key changes:

  • Implemented a custom isClose function in lib/utils.js that matches the behavior of the is-close npm package
  • Updated all imports across test files and production code to use the new internal implementation
  • Removed the is-close dependency from package.json

Fix: #1294

Copilot AI review requested due to automatic review settings October 17, 2025 06:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the external is-close dependency and replaces it with a custom implementation in the project's utility module. The change eliminates a third-party dependency while maintaining the same floating-point comparison functionality.

Key changes:

  • Implemented a custom isClose function in lib/utils.js that matches the behavior of the is-close npm package
  • Updated all imports across test files and production code to use the new internal implementation
  • Removed the is-close dependency from package.json

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/utils.js Added custom isClose function implementation with comprehensive documentation
lib/parameter.js Updated imports to use internal isClose function instead of external dependency
test/test-parameters.js Updated imports and function calls to use internal implementation
test/test-node.js Updated imports and function calls to use internal implementation
test/test-node-oo.js Updated imports and function calls to use internal implementation
package.json Removed is-close dependency from dependencies list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lib/utils.js Outdated
*
* @example
* isClose(1.0, 1.0) // true
* isClose(1.0, 1.1, 0.01) // false - difference 0.1 > 0.01 * max(1.0, 1.1) = 0.011

Copilot AI Oct 17, 2025

Copy link

Choose a reason for hiding this comment

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

The calculation in the comment is incorrect. The difference 0.1 is compared against relative tolerance 0.01 * max(1.0, 1.1) = 0.011, but the actual comparison in the code divides the absolute difference by the maximum absolute value: 0.1 / 1.1 = 0.091, which is greater than 0.01.

Copilot uses AI. Check for mistakes.
Comment thread lib/utils.js
}

// Check relative tolerance
const relativeScaler = Math.max(Math.abs(a), Math.abs(b));

Copilot AI Oct 17, 2025

Copy link

Choose a reason for hiding this comment

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

Division by zero will occur when both a and b are zero. When a === b === 0, the function should return true (handled by line 57), but if there are floating-point precision issues, relativeScaler could be zero, causing division by zero.

Suggested change
const relativeScaler = Math.max(Math.abs(a), Math.abs(b));
const relativeScaler = Math.max(Math.abs(a), Math.abs(b));
// Prevent division by zero if both a and b are (close to) zero
if (relativeScaler === 0) {
// Only absolute tolerance matters in this case
return absDiff <= atol;
}

Copilot uses AI. Check for mistakes.
@coveralls

coveralls commented Oct 17, 2025

Copy link
Copy Markdown

Coverage Status

coverage: 83.18% (-0.06%) from 83.239%
when pulling 1984693 on minggangw:fix-1294
into 898c8dc on RobotWebTools:develop.

@minggangw minggangw merged commit 2622779 into RobotWebTools:develop Oct 17, 2025
25 of 26 checks passed
minggangw added a commit that referenced this pull request Oct 30, 2025
This PR removes the external `is-close` dependency and replaces it with a custom implementation in the project's utility module. The change eliminates a third-party dependency while maintaining the same floating-point comparison functionality.

Key changes:
- Implemented a custom `isClose` function in `lib/utils.js` that matches the behavior of the `is-close` npm package
- Updated all imports across test files and production code to use the new internal implementation
- Removed the `is-close` dependency from `package.json`

Fix: #1294
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.

Remove is-close dependency

3 participants