-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlist.d.lua
More file actions
950 lines (893 loc) · 22.5 KB
/
Copy pathlist.d.lua
File metadata and controls
950 lines (893 loc) · 22.5 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
---@meta _
---
---A list class for creating, transforming, and querying sequences of values.
---
---## Usage
---
---```lua
---List = mods.list
---
---ls = List({ "a" }):append("b")
---print(ls:contains("b")) --> true
---print(ls:index("b")) --> 2
---```
---
---> [!NOTE]
--->
---> `List(t)` wraps `t` with the `List` metatable in place. It does not copy or
---> filter table values. `List(t):copy()` or `List.copy(t)` both copy only
---> `1..#t` and wrap `t` as a List.
---
---@class mods.List<T>:table<integer,T>
---@operator add(mods.List):mods.List
---@operator mul(integer):mods.List
---@operator sub(mods.List):mods.List
---@overload fun(t?:{}):mods.List
local List = {}
List.__index = List
---
---Return `true` if all values match the predicate.
---
---```lua
---is_even = function(v) return v % 2 == 0 end
---ok = List({ 2, 4 }):all(is_even) --> true
---```
---
---> [!NOTE]
--->
---> Empty lists return `true`.
---
---@section Predicates
---@param self mods.List|any[] Current list.
---@param pred fun(v:any):boolean Predicate function.
---@return boolean allMatch Whether the condition is met.
---@nodiscard
function List:all(pred) end
---
---Return `true` if any value matches the predicate.
---
---```lua
---has_len_2 = function(v) return #v == 2 end
---ok = List({ "a", "bb" }):any(has_len_2) --> true
---```
---
---@section Predicates
---@param self mods.List|any[] Current list.
---@param pred fun(v:any):boolean Predicate function.
---@return boolean anyMatch Whether the condition is met.
---@nodiscard
function List:any(pred) end
---
---Compare two lists using shallow element equality.
---
---```lua
---a = List({ "x", "y" })
---b = List({ "x", "y" })
---ok = a:equals(b) --> true
---```
---
---> [!NOTE]
--->
---> * `equals` is also available through the `==` operator when both
---> operands are `List`.
--->
---> ```lua
---> a = List({ "a", 1 })
---> b = List({ "a", 1 })
---> ok = (a == b) --> true
---> ```
--->
---> * Unlike `==`, this method also works when `ls` is a plain array table.
--->
---> ```lua
---> a = List({ "a", 1 })
---> b = { "a", 1 }
---> ok = a:equals(b) --> true
---> ```
--->
---> * `equals` checks only array positions (`1..#list`), so extra non-array
---> keys are ignored:
--->
---> ```lua
---> t = {}
---> a = List({ "a", t })
---> b = { "a", t, a = 1 }
---> ok = a:equals(b) --> true
---> ```
---
---@section Predicates
---@param self mods.List|any[] Current list.
---@param ls mods.List|any[] Other list value.
---@return boolean isEqual Whether the condition is met.
---@nodiscard
function List:equals(ls) end
---
---Compare two lists lexicographically.
---
---```lua
---ok = List({ 1, 2 }):lt({ 1, 3 }) --> true
---ok = List({ 1, 2 }):lt({ 1, 2, 0 }) --> true
---```
---
---> [!NOTE]
--->
---> `lt` is also available through the `<` operator.
---
---@section Predicates
---@param self mods.List|any[] Current list.
---@param ls mods.List|any[] Other list value.
---@return boolean isLess Whether the condition is met.
---@nodiscard
function List:lt(ls) end
---
---Compare two lists lexicographically.
---
---```lua
---ok = List({ 1, 2 }):le({ 1, 2 }) --> true
---ok = List({ 1, 2 }):le({ 1, 1 }) --> false
---```
---
---> [!NOTE]
--->
---> `le` is also available through the `<=` operator.
---
---@section Predicates
---@param self mods.List|any[] Current list.
---@param ls mods.List|any[] Other list value.
---@return boolean isLessOrEqual Whether the condition is met.
---@nodiscard
function List:le(ls) end
---
---Append a value to the end of the list.
---
---```lua
---ls = List({ "a" }):append("b") --> { "a", "b" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@return T self Current list.
function List:append(v) end
---
---Remove all elements from the list.
---
---```lua
---ls = List({ "a", "b" }):clear() --> { }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@return T self Current list.
function List:clear() end
---
---Extend the list with another list or set.
---
---```lua
---ls = List({ "a" }):extend({ "b", "c" }) --> { "a", "b", "c" }
---ls = List({ "a" }):extend(Set({ "b", "c" })) --> { "a", "b", "c" }
---```
---
---> [!NOTE]
--->
---> `extend` is also available through the `+` operator.
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param t mods.List|mods.Set|any[] Values to append.
---@return T self Current list.
function List:extend(t) end
---
---Extract values matching the predicate and remove them from the list.
---
---```lua
---ls = List({ "a", "bb", "c" })
---is_len_1 = function(v) return #v == 1 end
---ex = ls:extract(is_len_1) --> ex = { "a", "c" }, ls = { "bb" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param pred fun(v:any):boolean Predicate function.
---@return mods.List ls Extracted values.
---@nodiscard
function List:extract(pred) end
---
---Insert a value at the given position.
---
---```lua
---ls = List({ "a", "c" }):insert(2, "b") --> { "a", "b", "c" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param pos integer Insert position.
---@param v any Value to insert.
---@return T self Current list.
function List:insert(pos, v) end
---
---Append a value to the end of the list.
---
---```lua
---ls = List({ "a", "b" }):insert("c") --> { "a", "b", "c" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param v any Value to append.
---@return T self Current list.
function List:insert(v) end
---
---Remove and return the last element.
---
---```lua
---ls = List({ "a", "b" })
---v = ls:pop() --> v == "b"; ls is { "a" }
---```
---
---@section Mutation
---@param self mods.List|any[] Current list.
---@return any removedValue Removed value.
function List:pop() end
---
---Remove and return the element at the given position.
---
---```lua
---ls = List({ "a", "b", "c" })
---v = ls:pop(2) --> v == "b"; ls is { "a", "c" }
---```
---
---@section Mutation
---@param self mods.List|any[] Current list.
---@param pos integer Numeric value.
---@return any removedValue Removed value.
function List:pop(pos) end
---
---Insert a value at the start of the list.
---
---```lua
---ls = List({ "b", "c" })
---ls:prepend("a") --> { "a", "b", "c" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param v any Value to validate.
---@return T self Current list.
function List:prepend(v) end
---
---Remove the first matching value.
---
---```lua
---ls = List({ "a", "b", "b" })
---ls:remove("b") --> { "a", "b" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param v any Value to validate.
---@return T self Current list.
function List:remove(v) end
---
---Sort the list in place.
---
---```lua
---ls = List({ 3, 1, 2 })
---ls:sort() --> { 1, 2, 3 }
---
---words = List({ "ccc", "a", "bb" })
---words:sort(function(a, b)
--- return #a < #b
---end) --> { "a", "bb", "ccc" }
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param comp? fun(a:any, b:any):boolean Optional comparison function (defaults to `nil`).
---@return T self Current list.
function List:sort(comp) end
---
---Shuffle the list in place.
---
---```lua
---ls = List({ "a", "b", "c" }):shuffle() --> { "b", "c", "a" } -- order varies
---```
---
---@section Mutation
---@generic T:mods.List|any[]
---@param self T Current list.
---@param rng? fun(lo:integer, hi:integer):integer Optional random index picker; defaults to `math.random`.
---@return T self Current list.
function List:shuffle(rng) end
---
---Return a shallow copy of the list.
---
---```lua
---c = List({ "a", "b" }):copy() --> { "a", "b" }
---```
---
---@section Copies
---@param self mods.List|any[] Current list.
---@return mods.List ls New list.
---@nodiscard
function List:copy() end
---
---Return `true` if the list contains the value.
---
---```lua
---ok = List({ "a", "b" }):contains("b") --> true
---```
---
---@section Queries
---@param self mods.List|any[] Current list.
---@param v any Value to validate.
---@return boolean isPresent True when `v` is present in the list.
---@nodiscard
function List:contains(v) end
---
---Count how many times a value appears.
---
---```lua
---n = List({ "a", "b", "b" }):count("b") --> 2
---```
---
---@section Queries
---@param self mods.List|any[] Current list.
---@param v any Value to validate.
---@return integer res Result count.
---@nodiscard
function List:count(v) end
---
---Return the index of the first matching value.
---
---```lua
---i = List({ "a", "b", "c", "b" }):index("b") --> 2
---```
---
---@section Queries
---@param self mods.List|any[] Current list.
---@param v any Value to validate.
---@return integer? index Result index, or nil when not found.
---@nodiscard
function List:index(v) end
---
---Return the index of the first value matching the predicate.
---
---```lua
---gt_1 = function(x) return x > 1 end
---i = List({ 1, 2, 3 }):index_if(gt_1) --> 2
---```
---
---@section Queries
---@param self mods.List|any[] Current list.
---@param pred fun(v:any):boolean Predicate function.
---@return integer? index Result index, or nil when no value matches.
---@nodiscard
function List:index_if(pred) end
---
---Return the length of the list, defined by its maximum positive integer index.
---
---```lua
---n = List({ "a", nil, "c" }):len() --> 3
---```
---
---@section Queries
---@param self mods.List|any[] Current list.
---@return integer length List length.
---@nodiscard
function List:len() end
---
---Return whether the list has no elements.
---
---```lua
---ok = List():isempty() --> true
---```
---
---@section Queries
---@param self mods.List|any[] Current list.
---@return boolean empty `true` when the list has no elements.
---@nodiscard
function List:isempty() end
---
---Return the first element or `nil` if empty.
---
---```lua
---v = List({ "a", "b" }):first() --> "a"
---```
---
---@section Access
---@param self mods.List|any[] Current list.
---@return any firstValue First value, or `nil` if empty.
---@nodiscard
function List:first() end
---
---Return the last element or `nil` if empty.
---
---```lua
---v = List({ "a", "b" }):last() --> "b"
---```
---
---@section Access
---@param self mods.List|any[] Current list.
---@return any lastValue Last value, or `nil` if empty.
---@nodiscard
function List:last() end
---
---Return a new list with values not in the given list or set.
---
---```lua
---d = List({ "a", "b", "c" }):difference({ "b" }) --> { "a", "c" }
---```
---
---> [!NOTE]
--->
---> `difference` is also available through the `-` operator.
---
---@section Transforms
---@generic T:mods.List|any[]
---@param self T Current list.
---@param t mods.List|mods.Set|any[] Values to remove.
---@return T ls New list.
---@nodiscard
function List:difference(t) end
---
---Return a new list without the first n elements.
---
---```lua
---t = List({ "a", "b", "c" }):drop(1) --> { "b", "c" }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param n integer Numeric value.
---@return mods.List ls New list.
---@nodiscard
function List:drop(n) end
---
---Return a new list with values matching the predicate.
---
---```lua
---is_len_1 = function(v) return #v == 1 end
---f = List({ "a", "bb", "c" }):filter(is_len_1) --> { "a", "c" }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param pred fun(v:any):boolean Predicate function.
---@return mods.List ls New list.
---@nodiscard
function List:filter(pred) end
---
---Flatten one level of nested lists.
---
---```lua
---f = List({ { "a", "b" }, { "c" } }):flatten() --> { "a", "b", "c" }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@return mods.List ls New list.
---@nodiscard
function List:flatten() end
---
---Apply a function to each element (for side effects).
---
---```lua
---List({ "a", "b" }):foreach(print)
-----> prints -> a
-----> prints -> b
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param fn fun(v:any) Callback function.
---@return nil none
function List:foreach(fn) end
---
---Group list values by a computed key.
---
---```lua
---words = { "aa", "b", "ccc", "dd" }
---g = List(words):group_by(string.len) --> { {"b"}, { "aa", "dd" }, { "ccc" } }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param fn fun(v:any):any Callback function.
---@return table groups Groups keyed by the callback result.
---@nodiscard
function List:group_by(fn) end
---
---Return values that are also present in the given list or set.
---
---```lua
---i = List({ "a", "b", "a", "c" }):intersection({ "a", "c" })
-----> { "a", "a", "c" }
---```
---
---> [!NOTE]
--->
---> Order is preserved from the original list.
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param t mods.List|mods.Set|any[] Other list/set.
---@return mods.List ls New list.
---@nodiscard
function List:intersection(t) end
---
---Invert values to indices in a new table.
---
---```lua
---t = List({ "a", "b", "c" }):invert() --> { a = 1, b = 2, c = 3 }
---```
---
---@section Transforms
---@generic K, V
---@param self mods.List|any[] Current list.
---@return table<V,K> idxByValue Table mapping each value to its last index.
---@nodiscard
function List:invert() end
---
---Mirror values into a new table as both keys and values.
---
---```lua
---t = List({ "a", "b", "c" }):mirror() --> { a = "a", b = "b", c = "c" }
---```
---
---@section Transforms
---@generic T
---@param self mods.List|T[] Current list.
---@return table<T,T> mirroredValues Table mapping each value to itself.
---@nodiscard
function List:mirror() end
---
---Concatenate list values using Lua's native `table.concat` behavior.
---
---```lua
---s = List({ "a", "b", "c" }):concat(",") --> "a,b,c"
---```
---
---> [!NOTE]
--->
---> This method forwards to `table.concat` directly and keeps its strict
---> element rules.
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param sep? string Optional separator value (defaults to `""`).
---@param i? integer Optional start index (defaults to `1`).
---@param j? integer Optional end index (defaults to `#self`).
---@return string concatenated Concatenated string.
---@nodiscard
function List:concat(sep, i, j) end
---
---Join list values into a string.
---
---```lua
---s = List({ "a", "b", "c" }):join(",") --> "a,b,c"
---s = List({ "a", "b", "c" }):join(", ", true) --> '"a", "b", "c"'
---```
---
---> [!NOTE]
--->
---> Values are converted with `tostring` before joining.
---> Set `quoted = true` to quote string values.
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param sep? string Optional separator value (defaults to `""`).
---@param quoted? boolean Optional boolean flag (defaults to `false`).
---@return string joined Joined string.
---@nodiscard
function List:join(sep, quoted) end
---
---Render the list to a string via the regular method form.
---
---```lua
---s = List({ "a", "b", 1 }):tostring() --> '{ "a", "b", 1 }'
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@return string renderedList Rendered list string.
---@nodiscard
function List:tostring() end
---
---Render list items as a table-access key path.
---
---```lua
---p = List({ "ctx", "users", 1, "name" }):keypath() --> "ctx.users[1].name"
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@return string keyPath Key-path string.
---@nodiscard
function List:keypath() end
---
---Return a new list by mapping each value.
---
---```lua
---to_upper = function(v) return v:upper() end
---m = List({ "a", "b" }):map(to_upper) --> { "A", "B" }
---```
---
---@section Transforms
---@generic T
---@param self mods.List<T>|T[] Current list.
---@param fn fun(value:T):any Callback function.
---@return mods.List ls New list.
---@nodiscard
function List:map(fn) end
---
---Return a new list repeated `n` times (list multiplication behavior).
---
---```lua
---ls = List({ "a", "b" }):mul(3) --> { "a", "b", "a", "b", "a", "b" }
---```
---
---> [!NOTE]
--->
---> `mul` is also available through the `*` operator.
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param n integer Numeric value.
---@return mods.List ls New list.
---@nodiscard
function List:mul(n) end
---
---Reduce the list to a single value using an accumulator.
---
---```lua
---add = function(acc, v) return acc + v end
---sum = List({ 1, 2, 3 }):reduce(add, 0) --> 6
---sum = List({ 1, 2, 3 }):reduce(add, 10) --> 16
---```
---
---> [!NOTE]
--->
---> For empty lists, returns `init` unchanged (or `nil` when omitted).
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param fn fun(acc:any, v:any):any Reducer function.
---@param init? any Optional initial accumulator; for non-empty lists, `nil` or omitted uses the first item.
---@return any reducedValue Reduced value.
---@nodiscard
function List:reduce(fn, init) end
---
---Reverse the list in place.
---
---```lua
---r = List({ "a", "b", "c" }):reverse() --> { "c", "b", "a" }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@return mods.List ls Same list, reversed in place.
function List:reverse() end
---
---Convert the list to a set.
---
---```lua
---s = List({ "a", "b", "a" }):toset() --> { a = true, b = true }
---```
---
---> [!NOTE]
--->
---> Order is preserved from the original list.
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@return mods.Set set New set.
---@nodiscard
function List:toset() end
---
---Return a new list containing items from i to j (inclusive).
---
---```lua
---t = List({ "a", "b", "c", "d" }):slice(2, 3) --> { "b", "c" }
---```
---
---> [!NOTE]
--->
---> Supports negative indices (-1 is last element).
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param i? integer Optional start index (defaults to `1`).
---@param j? integer Optional end index (defaults to `#self`).
---@return mods.List ls New list.
---@nodiscard
function List:slice(i, j) end
---
---Return the first n elements as a new list.
---
---```lua
---t = List({ "a", "b", "c" }):take(2) --> { "a", "b" }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param n integer Numeric value.
---@return mods.List ls New list.
---@nodiscard
function List:take(n) end
---
---Return a new list with duplicates removed (first occurrence kept).
---
---```lua
---u = List({ "a", "b", "a", "c" }):uniq() --> { "a", "b", "c" }
---```
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@return mods.List ls New list.
---@nodiscard
function List:uniq() end
---
---Zip two collections into a list of 2-element tables.
---
---```lua
---z = List({ "a", "b" }):zip({ 1, 2 }) --> { {"a",1}, {"b",2} }
---z = List({ "a", "b" }):zip(Set({ 1, 2 })) --> { {"a",1}, {"b",2} }
---```
---
---> [!NOTE]
--->
---> Length is the minimum of both tables' lengths.
---
---@section Transforms
---@param self mods.List|any[] Current list.
---@param t mods.List|mods.Set|any[] Values to pair with.
---@return mods.List ls New list.
---@nodiscard
function List:zip(t) end
---Compare two lists using shallow element equality (`==`).
---
---```lua
---a = List({ "a", { 1 } })
---b = List({ "a", { 1 } })
---ok = a == b --> false (different nested table references)
---
---t = { 1 }
---a = List({ "a", t })
---b = List({ "a", t })
---ok = a == b --> true (same nested table reference)
---```
---
---> [!NOTE]
--->
---> * `==` returns `false` for `List` vs plain-table comparisons.
---> Use `:equals(ls)` for `List` vs plain-table comparisons.
--->
---> ```lua
---> t = { "a", 1 }
---> a = List(t)
---> b = { "a", 1 }
---> ok = (a == b) --> false
---> ok = a:equals(b) --> true
---> ```
--->
---> * Like `:equals(ls)`, `==` compares only array positions (`1..#list`), so
---> extra non-array keys are ignored when both operands are `List`.
--->
---> ```lua
---> a = List({ "a", t })
---> b = List({ "a", t, extra = 1 })
---> ok = (a == b) --> true
---> ```
---
---@section Metamethods
---@param self mods.List Current list.
---@param ls mods.List|any[] Other list value.
---@return boolean isEqual Whether the condition is met.
function List.__eq(self, ls) end
---
---Compare two lists lexicographically (`<`).
---
---```lua
---ok = List({ 1, 2 }) < List({ 1, 3 }) --> true
---```
---
---> [!NOTE]
--->
---> `<` is equivalent to `:lt(ls)`.
---
---@section Metamethods
---@param self mods.List Current list.
---@param ls mods.List|any[] Other list value.
---@return boolean isLess Whether the condition is met.
function List.__lt(self, ls) end
---
---Compare two lists lexicographically (`<=`).
---
---```lua
---ok = List({ 1, 2 }) <= List({ 1, 2 }) --> true
---```
---
---> [!NOTE]
--->
---> `<=` is equivalent to `:le(ls)`.
---
---@section Metamethods
---@param self mods.List Current list.
---@param ls mods.List|any[] Other list value.
---@return boolean isLessOrEqual Whether the condition is met.
function List.__le(self, ls) end
---
---Repeat a list `n` times (`*`).
---
---```lua
---l1 = List({ "a", "b" }) * 3 --> { "a", "b", "a", "b", "a", "b" }
---l2 = 3 * List({ "a", "b" }) --> { "a", "b", "a", "b", "a", "b" }
---```
---
---> [!NOTE]
--->
---> `*` is equivalent to `:mul(n)`.
---
---@section Metamethods
---@param self integer|mods.List Left operand.
---@param n integer|mods.List Right operand.
---@return mods.List ls New list.
function List.__mul(self, n) end
---
---Extend the left-hand list in place with right-hand values, then return the
---same left-hand list reference (`+`).
---
---```lua
---a = List({ "a", "b" })
---b = { "c", "d" }
---c = a + b --> c and a are the same reference: { "a", "b", "c", "d" }
---```
---
---> [!NOTE]
--->
---> `+` operator is equivalent to `:extend(ls)`.
---
---@section Metamethods
---@param self mods.List Current list.
---@param ls mods.List|any[] Other list value.
---@return mods.List|any[] self Current list.
function List.__add(self, ls) end
---
---Return values from the left list that are not present in the right list (`-`).
---
---```lua
---a = List({ "a", "b", "c" })
---b = { "b" }
---d = a - b --> { "a", "c" }
---```
---
---> [!NOTE]
--->
---> `-` operator is equivalent to `:difference(ls)`.
---
---@section Metamethods
---@param self mods.List Current list.
---@param ls mods.List|any[] Other list value.
---@return mods.List ls New list.
function List.__sub(self, ls) end
---
---Render the list to a string like `{ "a", "b", 1 }`.
---
---```lua
---s = tostring(List({ "a", "b", 1 })) --> '{ "a", "b", 1 }'
---```
---
---@section Metamethods
---@param self mods.List Current list.
---@return string renderedList Rendered list string.
function List.__tostring(self) end
return List