Add rc.slice custom operator (#7505)
* Add rc.sortBy custom operator Orders an array by a key computed per item, ascending, with ties keeping their input order. Keys must be all strings or all numbers so the two engines never have to invent a cross-type ordering. Co-authored-by: Cursor <cursoragent@cursor.com> * Add rc.slice custom operator Takes a run of elements out of an array, with the start and length semantics substr already uses for strings. Pairs with rc.sortBy to express top-N without a reduce carrying a compound accumulator. Co-authored-by: Cursor <cursoragent@cursor.com> * Exempt the custom operator dispatcher from cyclomatic complexity The tenth operator pushed the switch past the limit. Operators.dispatch carries the same exemption for the same reason. Co-authored-by: Cursor <cursoragent@cursor.com> * Reject non-finite rc.sortBy keys A NaN key compares false in both directions, so every pair tied and the input came back unsorted with no error. Negating a string key to attempt a descending sort produced exactly that. Co-authored-by: Cursor <cursoragent@cursor.com> * Note ascending order in the rc.sortBy summary Co-authored-by: Cursor <cursoragent@cursor.com> * Trim the rc.sortBy doc comment Co-authored-by: Cursor <cursoragent@cursor.com> * Trim the rc.sortBy stability comment Co-authored-by: Cursor <cursoragent@cursor.com> * Drop the dispatcher comment above the lint annotation Co-authored-by: Cursor <cursoragent@cursor.com> * Scope the substr hint to string input in rc.slice Co-authored-by: Cursor <cursoragent@cursor.com> * Pin rc.slice index and source type strictness in fixtures Co-authored-by: Cursor <cursoragent@cursor.com> * Reach the float index branch through arithmetic in rc.slice fixtures Co-authored-by: Cursor <cursoragent@cursor.com> * Order rc.sortBy string keys by UTF-16 code unit Swift's < orders by Unicode scalar and treats canonically equivalent strings as equal, while JS and Kotlin order by UTF-16 code unit. The two disagree once a scalar above the surrogate range meets an astral one, so the same rule would sort differently on iOS and Android. Co-authored-by: Cursor <cursoragent@cursor.com> * Keep the rc.sortBy ordering fixtures platform-neutral The fixture files are byte-identical across the iOS and Android engines, so a description that explains the contract in terms of one host language's string comparison does not read correctly in the other repository. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
A
Antonio Pallares committed
0712031229db287a996480802bf397e3768cdbcc
Parent: 4bd110f
Committed by GitHub <noreply@github.com>
on 8/31/2026, 6:52:53 AM