版博士V2.0程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

52 líneas
1.3 KiB

  1. /**
  2. * The `Bounded` type class represents totally ordered types that have an upper and lower boundary.
  3. *
  4. * Instances should satisfy the following law in addition to the `Ord` laws:
  5. *
  6. * - Bounded: `bottom <= a <= top`
  7. *
  8. * @since 2.0.0
  9. */
  10. import * as O from './Ord';
  11. // -------------------------------------------------------------------------------------
  12. // utils
  13. // -------------------------------------------------------------------------------------
  14. /**
  15. * Clamp a value between bottom and top values.
  16. *
  17. * @category utils
  18. * @since 2.12.0
  19. */
  20. export var clamp = function (B) { return O.clamp(B)(B.bottom, B.top); };
  21. /**
  22. * Reverses the Ord of a bound and swaps top and bottom values.
  23. *
  24. * @category utils
  25. * @since 2.12.0
  26. */
  27. export var reverse = function (B) {
  28. var R = O.reverse(B);
  29. return {
  30. equals: R.equals,
  31. compare: R.compare,
  32. top: B.bottom,
  33. bottom: B.top
  34. };
  35. };
  36. // -------------------------------------------------------------------------------------
  37. // deprecated
  38. // -------------------------------------------------------------------------------------
  39. /**
  40. * Use [`Bounded`](./number.ts.html#bounded) instead.
  41. *
  42. * @category zone of death
  43. * @since 2.0.0
  44. * @deprecated
  45. */
  46. export var boundedNumber = {
  47. equals: O.ordNumber.equals,
  48. compare: O.ordNumber.compare,
  49. top: Infinity,
  50. bottom: -Infinity
  51. };