园林绿化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.7 KiB

  1. /**
  2. * Contains functions for checking that supplied arguments are of a specified type
  3. * or meet specified conditions
  4. */
  5. export const Check: {
  6. /**
  7. * Throws if test is not defined
  8. *
  9. * @param {string} name The name of the variable being tested
  10. * @param {*} test The value that is to be checked
  11. * @exception {DeveloperError} test must be defined
  12. */
  13. defined<T>(name: string, test: T): asserts test is NonNullable<T>;
  14. /**
  15. * Contains type checking functions, all using the typeof operator
  16. */
  17. typeOf: {
  18. /**
  19. * Throws if test is not typeof 'string'
  20. *
  21. * @param {string} name The name of the variable being tested
  22. * @param {*} test The value to test
  23. * @exception {DeveloperError} test must be typeof 'string'
  24. */
  25. string(name: string, test: any): asserts test is string;
  26. /**
  27. * Throws if test is not typeof 'function'
  28. *
  29. * @param {string} name The name of the variable being tested
  30. * @param {*} test The value to test
  31. * @exception {DeveloperError} test must be typeof 'function'
  32. */
  33. func(name: string, test: any): asserts test is Function;
  34. /**
  35. * Throws if test is not typeof 'object'
  36. *
  37. * @param {string} name The name of the variable being tested
  38. * @param {*} test The value to test
  39. * @exception {DeveloperError} test must be typeof 'object'
  40. */
  41. object(name: string, test: any): asserts test is object;
  42. /**
  43. * Throws if test is not typeof 'boolean'
  44. *
  45. * @param {string} name The name of the variable being tested
  46. * @param {*} test The value to test
  47. * @exception {DeveloperError} test must be typeof 'boolean'
  48. */
  49. bool(name: string, test: any): asserts test is boolean;
  50. /**
  51. * Throws if test is not typeof 'bigint'
  52. *
  53. * @param {string} name The name of the variable being tested
  54. * @param {*} test The value to test
  55. * @exception {DeveloperError} test must be typeof 'bigint'
  56. */
  57. bigint(name: string, test: any): asserts test is bigint;
  58. /**
  59. * Throws if test is not typeof 'number'
  60. *
  61. * @param {string} name The name of the variable being tested
  62. * @param {*} test The value to test
  63. * @exception {DeveloperError} test must be typeof 'number'
  64. */
  65. number: {
  66. (name: string, test: any): void;
  67. /**
  68. * Throws if test is not typeof 'number' and less than limit
  69. *
  70. * @param {string} name The name of the variable being tested
  71. * @param {*} test The value to test
  72. * @param {number} limit The limit value to compare against
  73. * @exception {DeveloperError} test must be typeof 'number' and less than limit
  74. */
  75. lessThan(name: string, test: any, limit: number): asserts test is number;
  76. /**
  77. * Throws if test is not typeof 'number' and less than or equal to limit
  78. *
  79. * @param {string} name The name of the variable being tested
  80. * @param {*} test The value to test
  81. * @param {number} limit The limit value to compare against
  82. * @exception {DeveloperError} test must be typeof 'number' and less than or equal to limit
  83. */
  84. lessThanOrEquals(
  85. name: string,
  86. test: any,
  87. limit: number
  88. ): asserts test is number;
  89. /**
  90. * Throws if test is not typeof 'number' and greater than limit
  91. *
  92. * @param {string} name The name of the variable being tested
  93. * @param {*} test The value to test
  94. * @param {number} limit The limit value to compare against
  95. * @exception {DeveloperError} test must be typeof 'number' and greater than limit
  96. */
  97. greaterThan(
  98. name: string,
  99. test: any,
  100. limit: number
  101. ): asserts test is number;
  102. /**
  103. * Throws if test is not typeof 'number' and greater than or equal to limit
  104. *
  105. * @param {string} name The name of the variable being tested
  106. * @param {*} test The value to test
  107. * @param {number} limit The limit value to compare against
  108. * @exception {DeveloperError} test must be typeof 'number' and greater than or equal to limit
  109. */
  110. greaterThanOrEquals(
  111. name: string,
  112. test: any,
  113. limit: number
  114. ): asserts test is number;
  115. /**
  116. * Throws if test1 and test2 is not typeof 'number' and not equal in value
  117. *
  118. * @param {string} name1 The name of the first variable being tested
  119. * @param {string} name2 The name of the second variable being tested against
  120. * @param {*} test1 The value to test
  121. * @param {*} test2 The value to test against
  122. * @exception {DeveloperError} test1 and test2 should be type of 'number' and be equal in value
  123. */
  124. equals(name1: string, name2: string, test1: any, test2: any): void;
  125. };
  126. };
  127. };