-
Notifications
You must be signed in to change notification settings - Fork 486
/
Copy pathparams.input.js
121 lines (111 loc) · 2.76 KB
/
params.input.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* This function returns the number one.
* @param {number} b the second param
*/
function addThem(a, b, c, { d, e, f }) {
return a + b + c + d + e + f;
}
/**
* This method has partially inferred params
* @param {Object} options
* @param {String} options.fishes number of kinds of fish
*/
function fishesAndFoxes({ fishes, foxes }) {
return fishes + foxes;
}
/**
* This method has inline documentation for a param
* @param {Object} options
*/
function fishesAndFoxesInline(
{ fishes /** number of kinds of fish */, foxes }
) {
return fishes + foxes;
}
/**
* This method has a type in the description and a default in the code
* @param {number} x
*/
function withDefault(x = 2) {
return x;
}
/**
* This is foo's documentation
*/
class Foo {
/**
* The method
* @param {number} x Param to method
*/
method(x) {}
}
/**
* Traditional object
*/
var TraditionalObject = {
/**
* This method should acquire the param x
*/
traditionalMethod: function(x) {
return x;
}
};
/**
* Represents an IPv6 address
*
* This tests our support of optional parameters
* @class Address6
* @param {string} address - An IPv6 address string
* @param {number} [groups=8] - How many octets to parse
* @param {?number} third - A third argument
* @param {Array} [foo=[1]] to properly be parsed
* @example
* var address = new Address6('2001::/32');
*/
function Address6() {}
/**
* Create a GeoJSON data source instance given an options object
*
* This tests our support of nested parameters
* @class GeoJSONSource
* @param {Object} [options] optional options
* @param {Object|string} options.data A GeoJSON data object or URL to it.
* The latter is preferable in case of large GeoJSON files.
* @param {number} [options.maxzoom=14] Maximum zoom to preserve detail at.
* @param {number} [options.buffer] Tile buffer on each side.
* @param {number} [options.tolerance] Simplification tolerance (higher means simpler).
*/
function GeoJSONSource(options) {
this.options = options;
}
/**
* This tests our support for parameters with explicit types but with default
* values specified in code.
*
* @param {number} x an argument
*
* @returns {number} some
*/
export const myfunc = (x = 123) => x;
/**
* This tests our support of JSDoc param tags without type information,
* or any type information we could infer from annotations.
*
* @param address - An IPv6 address string
*/
function foo(address) {
return address;
}
/**
* This tests our support for iterator rest inside an
* iterator destructure (RestElement)
*
* @param {Array} input
* @param {any} input.0 head of iterator
* @param {...any} input.xs body of iterator
*
* @returns {any[]} rotated such that the last element was the first
*/
export function rotate([x, ...xs]) {
return [...xs, x];
}