Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 4e586cd

Browse files
committed
cleanup
1 parent 3a61844 commit 4e586cd

3 files changed

Lines changed: 13 additions & 161 deletions

File tree

pkg/coalescing/classic.go

Lines changed: 0 additions & 157 deletions
This file was deleted.

pkg/coalescing/humane.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ func (humane) ToString(val any) (string, error) {
144144
}
145145
}
146146

147+
func formatFloat(f float64) string {
148+
formatted := fmt.Sprintf("%f", f)
149+
for strings.HasSuffix(formatted, "0") {
150+
formatted = strings.TrimSuffix(formatted, "0")
151+
}
152+
153+
return strings.TrimSuffix(formatted, ".")
154+
}
155+
147156
func (humane) ToVector(val any) ([]any, error) {
148157
switch v := deliteral(val).(type) {
149158
case nil:

pkg/equality/loose.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func nullishEqualEnough(left ast.Literal, right ast.Literal) (matched bool, equa
7171
b = left
7272
}
7373

74-
bValue, err := coalescing.ToBool(b)
74+
bValue, err := coalescing.NewHumane().ToBool(b)
7575
if err != nil {
7676
return matched, false, ErrIncompatibleTypes
7777
}
@@ -106,7 +106,7 @@ func boolishEqualEnough(left ast.Literal, right ast.Literal) (matched bool, equa
106106
b = left
107107
}
108108

109-
bValue, err := coalescing.ToBool(b)
109+
bValue, err := coalescing.NewHumane().ToBool(b)
110110
if err != nil {
111111
return matched, false, ErrIncompatibleTypes
112112
}
@@ -141,7 +141,7 @@ func numberishEqualEnough(left ast.Literal, right ast.Literal) (matched bool, eq
141141
b = left
142142
}
143143

144-
bValue, err := coalescing.ToFloat64(b)
144+
bValue, err := coalescing.NewHumane().ToFloat64(b)
145145
if err != nil {
146146
return matched, false, ErrIncompatibleTypes
147147
}
@@ -176,7 +176,7 @@ func stringishEqualEnough(left ast.Literal, right ast.Literal) (matched bool, eq
176176
b = left
177177
}
178178

179-
bValue, err := coalescing.ToString(b)
179+
bValue, err := coalescing.NewHumane().ToString(b)
180180
if err != nil {
181181
return matched, false, ErrIncompatibleTypes
182182
}

0 commit comments

Comments
 (0)