Bläddra i källkod

[flow] A minimal demonstration of flow in action

j8
Lyubomir Marinov 8 år sedan
förälder
incheckning
f6c914f6f0

+ 6
- 4
react/features/base/util/randomUtil.js Visa fil

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

+ 2
- 0
react/features/base/util/roomnameGenerator.js Visa fil

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

Laddar…
Avbryt
Spara