Function
nonNegative
(
name: string,
field: string,
input: Duration.Input
)
Source from the content-addressed store, hash-verified
| 2680 | const quote = (name: string): string => JSON.stringify(name) |
| 2681 | |
| 2682 | const nonNegative = ( |
| 2683 | name: string, |
| 2684 | field: string, |
| 2685 | input: Duration.Input |
| 2686 | ): number => { |
| 2687 | const duration = Duration.fromInputUnsafe(input) |
| 2688 | if (Duration.isNegative(duration)) { |
| 2689 | throw new Error( |
| 2690 | "[Query] " + quote(name) + ": " + field + " can't be negative" |
| 2691 | ) |
| 2692 | } |
| 2693 | return Duration.toMillis(duration) |
| 2694 | } |
| 2695 | |
| 2696 | const subSecondHint = "A bare number is milliseconds: write a sub-second interval as a Duration string, such as " + |
| 2697 | "\"500 millis\"." |
Tested by
no test coverage detected