anymanylists: An array into a sentence — sorted and joined the way the locale does it, not the way English does.

anymany
about anymany

Joins items into a sentence the way the locale does — "a, b, and c", "a, b или c" — sorted with the locale's collation and capped with a "+N" overflow.

wraps
Intl.ListFormat, with Intl.Collator for sorting
install
npm install anymany
runtime
Node 18+, every modern browser, Deno, Bun, edge runtimes.
docs
anyfamily.site/docs/anymany
playground
run the family on StackBlitz

why

array.join(", ") has no "and", no localized conjunction and no Oxford-comma logic, and sort() puts "Öl" after "Zebra". anymany does the list, the sort and the overflow in one call, ~0.7 kB, from any iterable.

usage

anymany(["banana", "apple", "cherry"])                          // "banana, apple, and cherry"
anymany(["S", "M", "L"], { type: "disjunction" })               // "S, M, or L"
anymany(["Öl", "Zebra", "Apfel"], { sort: true, locale: "de" }) // "Apfel, Öl und Zebra"
anymany(tags, { max: 3 })                                       // "x, y, z, and +4"
anymany(new Set(["read", "write"]))                             // "read and write"

not for

Comparing, deduplicating or searching strings — it returns one joined string and nothing else.