- From: Tobie Langel via GitHub <sysbot+gh@w3.org>
- Date: Mon, 20 Feb 2017 19:57:30 +0000
- To: public-device-apis-log@w3.org
> Any reason to not be explicit in the spec and throw if frequency <=
0?
Well from an API design perspective, the following behavior is
surprising:
1. If _frequency_ is smaller or equal to 0, then throw a RangeError.
1. If _frequency_ is greater than 0 yet smaller than MIN_FREQ, set
_frequency_ to MIN_FREQ.
1. If _frequency_ is greater than MAX_FREQ, then set _frequency_ to
MAX_FREQ.
```
-∞ 0 +∞
|----------------------------|---|------------------|---------|
MIN_FREQ MAX_FREQ
\___________________________/\___/ \________/
/ | \
throw RangeError clamp clamp
```
Contrast with:
1. If _frequency_ is smaller or equal than MIN_FREQ, set _frequency_
to MIN_FREQ.
1. If _frequency_ is greater than MAX_FREQ, then set _frequency_ to
MAX_FREQ.
```
-∞ 0 +∞
|----------------------------|---|------------------|---------|
MIN_FREQ MAX_FREQ
\________________________________/ \________/
/ \
clamp clamp
```
--
GitHub Notification of comment by tobie
Please view or discuss this issue at
https://github.com/w3c/sensors/issues/169#issuecomment-281168895 using
your GitHub account
Received on Monday, 20 February 2017 19:57:37 UTC