safeInt validates a given JSON number ensures it lies within the minimum and maximum representable JSON numbers
(f float64)
| 2805 | // safeInt validates a given JSON number |
| 2806 | // ensures it lies within the minimum and maximum representable JSON numbers |
| 2807 | func safeInt(f float64) (n int64, ok bool) { |
| 2808 | // https://tc39.es/ecma262/#sec-number.min_safe_integer |
| 2809 | // https://tc39.es/ecma262/#sec-number.max_safe_integer |
| 2810 | if f < -9007199254740991 || f > 9007199254740991 { |
| 2811 | return 0, false |
| 2812 | } |
| 2813 | return int64(f), true |
| 2814 | } |
| 2815 | |
| 2816 | // execStatic parses the path to find a static value. |
| 2817 | // The input expects that the path already starts with a '!' |