Skip to content

Commit 3ad138f

Browse files
Functs: Add optional params, async, named arguments, extension function, multiple return types
1 parent a31f1d3 commit 3ad138f

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

web/thesauruses/_meta/functions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,39 @@
88
"void_function_no_parameters": "Function that does not return a value and takes no parameters",
99
"void_function_with_parameters": "Function that does not return a value and that takes 1 or more defined parameters",
1010
"void_function_with_keyword_parameters": "Function that does not return a value and that takes 0 or more defined keyword parameters",
11+
"void_function_with_optional_parameters": "Function that does not return a value and that takes 1 or more optional parameters (with default values)",
1112
"void_function_variable_parameters": "Function that does not return a value and function that takes an unknown number of parameters"
1213
},
1314
"Return Value Functions": {
1415
"return_value_function_no_parameters": "Function that returns a value and takes no parameters",
1516
"return_value_function_with_parameters": "Function that returns a value and takes 1 or more defined parameters",
1617
"return_value_function_with_keyword_parameters": "Function that returns a value and takes 0 or more defined keyword parameters",
18+
"return_value_function_with_optional_parameters": "Function that returns a value and takes 1 or more optional parameters (with default values)",
1719
"return_value_function_variable_parameters": "Function that returns a value and takes an unknown number of parameters"
1820
},
1921
"Lambda/Anonymous Functions": {
2022
"anonymous_function_no_parameters": "Anonymous function that takes no parameters",
2123
"anonymous_function_with_parameters": "Anonymous function that takes 1 or more defined parameters",
2224
"anonymous_function_with_keyword_parameters": "Anonymous function that takes 0 or more defined keyword parameters",
25+
"anonymous_function_with_optional_parameters": "Anonymous function that takes 1 or more optional parameters (with default values)",
2326
"anonymous_function_variable_parameters": "Anonymous function that takes an unknown number of parameters"
2427
},
2528
"Lambda/Anonymous Functions with Return Value": {
2629
"anonymous_function_no_parameters_with_return": "Anonymous function that takes no parameters and returns a value",
2730
"anonymous_function_with_parameters_with_return": "Anonymous function that takes 1 or more defined parameters and returns a value",
2831
"anonymous_function_with_keyword_parameters_with_return": "Anonymous function that takes 0 or more defined keyword parameters and returns a value",
32+
"anonymous_function_with_optional_parameters_with_return": "Anonymous function that takes 1 or more optional parameters (with default values) and returns a value",
2933
"anonymous_function_variable_parameters_with_return": "Anonymous function that takes an unknown number of parameters and returns a value"
3034
},
3135
"Subroutines": {
3236
"call_subroutine": "Call subroutine",
3337
"return_from_subroutine": "Return from subroutine"
38+
},
39+
"Modern Function Features": {
40+
"async_function": "Asynchronous function (async/await)",
41+
"named_arguments": "Named arguments in function calls",
42+
"extension_function": "Extension functions",
43+
"multiple_return_values": "Multiple return values"
3444
}
3545
}
3646
}

web/thesauruses/javascript/ECMAScript 2023/functions.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"name": "Function that does not return a value and that takes 0 or more defined keyword parameters",
1919
"code": "function method({param1, param2}) {\n}"
2020
},
21+
"void_function_with_optional_parameters": {
22+
"name": "Function that does not return a value and that takes 1 or more optional parameters (with default values)",
23+
"code": "function method(param1, param2 = 'default') {\n}"
24+
},
2125
"void_function_variable_parameters": {
2226
"name": "Function that does not return a value and function that takes an unknown number of parameters",
2327
"code": "function method(...params) {\n}"
@@ -34,6 +38,10 @@
3438
"name": "Function that returns a value and takes 0 or more defined keyword parameters",
3539
"code": "function method({param1, param2}) {\n return true;\n}"
3640
},
41+
"return_value_function_with_optional_parameters": {
42+
"name": "Function that returns a value and takes 1 or more optional parameters (with default values)",
43+
"code": "function method(param1, param2 = 'default') {\n return true;\n}"
44+
},
3745
"return_value_function_variable_parameters": {
3846
"name": "Function that returns a value and takes an unknown number of parameters",
3947
"code": "function method(...params) {\n return true;\n}"
@@ -59,6 +67,13 @@
5967
"const method = ({param1, param2}) => {\n}"
6068
]
6169
},
70+
"anonymous_function_with_optional_parameters": {
71+
"name": "Anonymous function that takes 1 or more optional parameters (with default values)",
72+
"code": [
73+
"const method = function(param1, param2 = 'default') {\n}",
74+
"const method = (param1, param2 = 'default') => {\n}"
75+
]
76+
},
6277
"anonymous_function_variable_parameters": {
6378
"name": "Anonymous function that takes an unknown number of parameters",
6479
"code": [
@@ -87,6 +102,13 @@
87102
"const method = ({param1, param2}) => true"
88103
]
89104
},
105+
"anonymous_function_with_optional_parameters_with_return": {
106+
"name": "Anonymous function that takes 1 or more optional parameters (with default values) and returns a value",
107+
"code": [
108+
"const method = function(param1, param2 = 'default') {\n return true;\n}",
109+
"const method = (param1, param2 = 'default') => true"
110+
]
111+
},
90112
"anonymous_function_variable_parameters_with_return": {
91113
"name": "Anonymous function that takes an unknown number of parameters and returns a value",
92114
"code": [

web/thesauruses/python/3/functions.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"code": "def function_name(parameter, parameter_1):\n statements",
1515
"name": "Function that does not return a value and that takes 1 or more defined parameters"
1616
},
17+
"void_function_with_optional_parameters": {
18+
"code": "def function_name(param1, param2=default_value):\n statements",
19+
"name": "Function that does not return a value and that takes 1 or more optional parameters (with default values)"
20+
},
1721
"void_function_variable_parameters": {
1822
"code": "def function_name(*parameter_name):\n statements",
1923
"name": "Function that does not return a value and function that takes an unknown number of parameters"
@@ -26,6 +30,10 @@
2630
"code": "def function_name(parameter, parameter_1):\n statements\n return expression",
2731
"name": "Function that returns a value and takes 1 or more defined parameters"
2832
},
33+
"return_value_function_with_optional_parameters": {
34+
"code": "def function_name(param1, param2=default_value):\n statements\n return expression",
35+
"name": "Function that returns a value and takes 1 or more optional parameters (with default values)"
36+
},
2937
"return_value_function_variable_parameters": {
3038
"code": "def function_name(*parameter_name):\n statements\n return expression",
3139
"name": "Function that returns a value and takes an unknown number of parameters"
@@ -38,9 +46,29 @@
3846
"name": "Anonymous function that takes 1 or more defined parameters",
3947
"code": "lambda parameter,parameter_1 : expression"
4048
},
49+
"anonymous_function_with_optional_parameters": {
50+
"name": "Anonymous function that takes 1 or more optional parameters (with default values)",
51+
"code": "lambda param1, param2=default_value: expression"
52+
},
4153
"anonymous_function_variable_parameters": {
4254
"name": "Anonymous function that takes an unknown number of parameters",
4355
"code": "lambda *parameter : expression"
56+
},
57+
"anonymous_function_no_parameters_with_return": {
58+
"name": "Anonymous function that takes no parameters and returns a value",
59+
"code": "lambda: expression"
60+
},
61+
"anonymous_function_with_parameters_with_return": {
62+
"name": "Anonymous function that takes 1 or more defined parameters and returns a value",
63+
"code": "lambda parameter,parameter_1 : expression"
64+
},
65+
"anonymous_function_with_optional_parameters_with_return": {
66+
"name": "Anonymous function that takes 1 or more optional parameters (with default values) and returns a value",
67+
"code": "lambda param1, param2=default_value: expression"
68+
},
69+
"anonymous_function_variable_parameters_with_return": {
70+
"name": "Anonymous function that takes an unknown number of parameters and returns a value",
71+
"code": "lambda *parameter : expression"
4472
}
4573
}
4674
}

web/thesauruses/swift/5/functions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
"code": "return",
5656
"comment": "If entire function body is a single expression, no return keyword needed to return expression.",
5757
"name": "Return from subroutine"
58+
},
59+
"extension_function": {
60+
"code": "extension SomeType {\n func newFunction() {\n // statements\n }\n}",
61+
"comment": "Extensions add new functionality to an existing class, structure, enumeration, or protocol type.",
62+
"name": "Extension functions"
5863
}
5964
}
6065
}

0 commit comments

Comments
 (0)