Axel Rauschmayer on Nostr: Computing the “length” of a #JavaScript iterator: > ['a', ...
Computing the “length” of a #JavaScript iterator:
> ['a', 'b'].values().reduce((_acc, _cur, index) => index + 1)
2
Use case: How many code points does a string have?
> Iterator.from('🙈🙉🙊').reduce((_acc, _cur, index) => index + 1)
3
Published at
2026-05-27 10:56:28 UTCEvent JSON
{
"id": "c1f7f56615685aaf2ba59e45ddcbf03131e5650358ed5e8629d19ceac1bde371",
"pubkey": "7a7a0978cc46ef7fd548fb125e51c04de7d4ca639417a21b56aa95e3711c0b38",
"created_at": 1779879388,
"kind": 1,
"tags": [
[
"t",
"javascript"
],
[
"proxy",
"https://fosstodon.org/@rauschma/116646175625897520",
"web"
],
[
"proxy",
"https://fosstodon.org/users/rauschma/statuses/116646175625897520",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://fosstodon.org/users/rauschma/statuses/116646175625897520",
"pink.momostr"
],
[
"-"
]
],
"content": "Computing the “length” of a #JavaScript iterator:\n\n\u003e ['a', 'b'].values().reduce((_acc, _cur, index) =\u003e index + 1)\n2\n\nUse case: How many code points does a string have?\n\n\u003e Iterator.from('🙈🙉🙊').reduce((_acc, _cur, index) =\u003e index + 1)\n3",
"sig": "3380b80ac201a9da29266b16187a82d2fe745c0977dc13079c4a3a1b0704375356458da2426b8e6726da9372c6ee4bc5050cff8ad409c7a6e945eeacd6c9c85f"
}