-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoperator.d.lua
More file actions
328 lines (304 loc) · 6.25 KB
/
Copy pathoperator.d.lua
File metadata and controls
328 lines (304 loc) · 6.25 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
---@meta _
---
---Lua operators exposed as functions.
---
---## Usage
---
---```lua
---operator = mods.operator
---
---print(operator.add(1, 2)) --> 3
---```
---
---@class mods.operator
local M = {}
---
---Add two numbers.
---
---```lua
---add(1, 2) --> 3
---```
---
---@section Arithmetic
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return number sum Sum of `a` and `b`.
---@nodiscard
function M.add(a, b) end
---
---Subtract `b` from `a`.
---
---```lua
---sub(5, 3) --> 2
---```
---
---@section Arithmetic
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return number difference Difference `a - b`.
---@nodiscard
function M.sub(a, b) end
---
---Multiply two numbers.
---
---```lua
---mul(3, 4) --> 12
---```
---
---@section Arithmetic
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return number product Product `a * b`.
---@nodiscard
function M.mul(a, b) end
---
---Divide `a` by `b` using Lua's floating-point division.
---
---```lua
---div(10, 4) --> 2.5
---```
---
---@section Arithmetic
---@param a number Dividend value.
---@param b number Divisor value.
---@return number quotient Quotient `a / b`.
---@nodiscard
function M.div(a, b) end
---
---Divide `a` by `b` and return the floor-division quotient.
---
---```lua
---idiv(5, 2) --> 2
---```
---
---@section Arithmetic
---@param a number Dividend value.
---@param b number Divisor value.
---@return integer quotient Floor-division result.
---@nodiscard
function M.idiv(a, b) end
---
---Return the modulo remainder of `a` divided by `b`.
---
---```lua
---mod(5, 2) --> 1
---```
---
---@section Arithmetic
---@param a number Dividend value.
---@param b number Divisor value.
---@return number remainder Remainder of `a % b`.
---@nodiscard
function M.mod(a, b) end
---
---Raise `a` to the power of `b`.
---
---```lua
---pow(2, 4) --> 16
---```
---
---@section Arithmetic
---@param a number Base value.
---@param b number Exponent value.
---@return number power Result of `a ^ b`.
---@nodiscard
function M.pow(a, b) end
---
---Negate a number.
---
---```lua
---unm(3) --> -3
---```
---
---@section Arithmetic
---@param a number Input numeric value.
---@return number negated Result of `-a`.
---@nodiscard
function M.unm(a) end
---
---Check whether two values are equal.
---
---```lua
---eq(1, 1) --> true
---```
---
---@section Comparison
---@param a any Left value.
---@param b any Right value.
---@return boolean isEqual True when `a == b`.
---@nodiscard
function M.eq(a, b) end
---
---Check whether two values are not equal.
---
---```lua
---neq(1, 2) --> true
---```
---
---@section Comparison
---@param a any Left value.
---@param b any Right value.
---@return boolean isNotEqual True when `a ~= b`.
---@nodiscard
function M.neq(a, b) end
---
---Check whether `a` is strictly less than `b`.
---
---```lua
---lt(1, 2) --> true
---```
---
---@section Comparison
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return boolean isLess True when `a < b`.
---@nodiscard
function M.lt(a, b) end
---
---Check whether `a` is less than or equal to `b`.
---
---```lua
---le(2, 2) --> true
---```
---
---@section Comparison
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return boolean isLessOrEqual True when `a <= b`.
---@nodiscard
function M.le(a, b) end
---
---Check whether `a` is strictly greater than `b`.
---
---```lua
---gt(3, 2) --> true
---```
---
---@section Comparison
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return boolean isGreater True when `a > b`.
---@nodiscard
function M.gt(a, b) end
---
---Check whether `a` is greater than or equal to `b`.
---
---```lua
---ge(2, 2) --> true
---```
---
---@section Comparison
---@param a number Left numeric value.
---@param b number Right numeric value.
---@return boolean isGreaterOrEqual True when `a >= b`.
---@nodiscard
function M.ge(a, b) end
---
---Evaluate `a and b` with Lua short-circuit semantics.
---
---```lua
---land(true, false) --> false
---```
---
---@section Logical
---@generic T1,T2
---@param a T1 First operand.
---@param b T2 Second operand.
---@return T1|T2 andValue Result of `a and b`.
---@nodiscard
function M.land(a, b) end
---
---Evaluate `a or b` with Lua short-circuit semantics.
---
---```lua
---lor(false, true) --> true
---```
---
---@section Logical
---@generic T1,T2
---@param a T1 First operand.
---@param b T2 Second operand.
---@return T1|T2 orValue Result of `a or b`.
---@nodiscard
function M.lor(a, b) end
---
---Return the boolean negation of `a`.
---
---```lua
---lnot(true) --> false
---```
---
---@section Logical
---@param a any Input value.
---@return boolean isNot Result of `not a`.
---@nodiscard
function M.lnot(a) end
---
---Concatenate two strings.
---
---```lua
---concat("a", "b") --> "ab"
---```
---
---@section String & Length
---@param a string Left string.
---@param b string Right string.
---@return string concatenated Concatenated result `a .. b`.
---@nodiscard
function M.concat(a, b) end
---
---Return the length of a string or table using Lua's `#` operator.
---
---```lua
---len("abc") --> 3
---```
---
---@section String & Length
---@param a string|table Value supporting Lua's `#` operator.
---@return integer length Length computed by `#a`.
---@nodiscard
function M.len(a) end
---
---Return the value at key/index `k` in table `t`.
---
---```lua
---index({ a = 1 }, "a") --> 1
---```
---
---@section Tables & Calls
---@generic T
---@param t table Source table.
---@param k T Key/index value.
---@return T indexedValue Value stored at `t[k]`.
---@nodiscard
function M.index(t, k) end
---
---Set `t[k] = v` and return the assigned value.
---
---```lua
---setindex({}, "a", 1) --> 1
---```
---
---@section Tables & Calls
---@generic T
---@param t table Target table.
---@param k any Key/index value.
---@param v T Value to set.
---@return T assignedValue Assigned value `v`.
---@nodiscard
function M.setindex(t, k, v) end
---
---Call a function with variadic arguments and return its result.
---
---```lua
---call(math.max, 1, 2) --> 2
---```
---
---@section Tables & Calls
---@generic T1,T2
---@param f fun(...:T1):T2 Function to call.
---@param ... T1 Additional arguments.
---@return T2 callResult Return value(s) from `f(...)`.
---@nodiscard
function M.call(f, ...) end
return M