๐Ÿงพ $from() Cheat Sheet (OpenAF Array Superpowers)

๐Ÿ” Filtering

$from(arr).equals("key", "value").select()
$from(arr).greater("size", 1024).select()
$from(arr).contains("tags", "urgent").select()
$from(arr).where(r => r.name.startsWith("A")).select()

๐Ÿ“Š Sorting

$from(arr).sort("name").select()
$from(arr).sort("-date", "priority").select()  // "-" for descending

๐Ÿท๏ธ Selecting/Mapping

$from(arr).select(r => ({ id: r.id, label: r.name.toUpperCase() }))

๐Ÿงฎ Aggregation

$from(arr).sum("amount")       // total of amount fields
$from(arr).count()             // count all
$from(arr).avg("score")        // average score
$from(arr).max("age")          // max age

๐Ÿงฉ Grouping

$from(arr).group("type").select()

Result: a list of { key: type, values: [โ€ฆ] }

๐Ÿงน Distinct

$from(arr).distinct("category").select()

๐Ÿ”— Combining Sets

$from(arr1).intersect(arr2).select()
$from(arr1).except(arr2).select()
$from(arr1).cartesian(arr2).select()

๐Ÿงฐ Common Patterns

Get first match

$from(arr).equals("status", "active").at(0)

Chain filters

$from(arr).greater("price", 10).less("price", 100).select()

Use custom logic

$from(arr).where(r => r.date < now()).select()

This site uses Just the Docs, a documentation theme for Jekyll.