Browse Source

[flow] A minimal demonstration of flow in action

j8
Lyubomir Marinov 8 years ago
parent
commit
f6c914f6f0

+ 6
- 4
react/features/base/util/randomUtil.js View File

1
+/* @flow */
2
+
1
 /**
3
 /**
2
  * Alphanumeric characters.
4
  * Alphanumeric characters.
3
  * @const
5
  * @const
18
  * @returns {string} A string of random alphanumeric characters with the
20
  * @returns {string} A string of random alphanumeric characters with the
19
  * specified length.
21
  * specified length.
20
  */
22
  */
21
-export function randomAlphanumString(length) {
23
+export function randomAlphanumString(length: number) {
22
     return _randomString(length, ALPHANUM);
24
     return _randomString(length, ALPHANUM);
23
 }
25
 }
24
 
26
 
28
  * @param {Array|string} arr - Source.
30
  * @param {Array|string} arr - Source.
29
  * @returns {Array|string} Array element or string character.
31
  * @returns {Array|string} Array element or string character.
30
  */
32
  */
31
-export function randomElement(arr) {
33
+export function randomElement(arr: Array<any> | string) {
32
     return arr[randomInt(0, arr.length - 1)];
34
     return arr[randomInt(0, arr.length - 1)];
33
 }
35
 }
34
 
36
 
48
  * @returns {string} A string of random hexadecimal digits with the specified
50
  * @returns {string} A string of random hexadecimal digits with the specified
49
  * length.
51
  * length.
50
  */
52
  */
51
-export function randomHexString(length) {
53
+export function randomHexString(length: number) {
52
     return _randomString(length, HEX_DIGITS);
54
     return _randomString(length, HEX_DIGITS);
53
 }
55
 }
54
 
56
 
59
  * @param {number} max - The maximum value for the generated number.
61
  * @param {number} max - The maximum value for the generated number.
60
  * @returns {number} Random int number.
62
  * @returns {number} Random int number.
61
  */
63
  */
62
-export function randomInt(min, max) {
64
+export function randomInt(min: number, max: number) {
63
     return Math.floor(Math.random() * (max - min + 1)) + min;
65
     return Math.floor(Math.random() * (max - min + 1)) + min;
64
 }
66
 }
65
 
67
 

+ 2
- 0
react/features/base/util/roomnameGenerator.js View File

1
+/* @flow */
2
+
1
 import { randomElement } from './randomUtil';
3
 import { randomElement } from './randomUtil';
2
 
4
 
3
 /*
5
 /*

Loading…
Cancel
Save