We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02e20de commit b1bfc08Copy full SHA for b1bfc08
packages/common/utils/src/clamp.spec.ts
@@ -2,7 +2,7 @@ import { clamp } from './clamp';
2
3
describe('clamp', () => {
4
it('should work well when only given max value', () => {
5
- expect(clamp(3, 5)).toBe(3);
+ expect(clamp(3, 5)).toBe(5);
6
expect(clamp(10, 6)).toBe(6);
7
expect(clamp(6, 10)).toBe(6);
8
});
packages/common/utils/src/clamp.ts
@@ -1,7 +1,7 @@
1
/** @tossdocs-ignore */
export function clamp(value: number, bound1: number, bound2?: number) {
if (bound2 == null) {
- return Math.min(value, bound1);
+ return Math.max(value, bound1);
}
if (bound2 < bound1) {
0 commit comments