Skip to content

Commit

Permalink
also async iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Jul 17, 2024
1 parent d428162 commit 311e718
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion normative-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NB: This convention is new as of 2024, and most earlier parts of the language do

## Reject primitives in iterable-taking positions

Any time an iterable value (a value that has a `Symbol.iterator` method) is expected, primitives should be treated as if they were not iterable. Usually, this will mean throwing a `TypeError`. Primitive wrapper Objects such as String Objects, however, should be treated like any other Object.
Any time an iterable or async-iterable value (a value that has a `Symbol.iterator` or `Symbol.asyncIterator` method) is expected, primitives should be treated as if they were not iterable. Usually, this will mean throwing a `TypeError`. Primitive wrapper Objects such as String Objects, however, should be treated like any other Object.

Although primitive Strings are default iterable (`String.prototype` has a `Symbol.iterator` method which enumerates code points), it is now considered a mistake to iterate a String without specifying whether the String is providing an abstraction over code units, code points, grapheme clusters, or something else.

Expand Down

0 comments on commit 311e718

Please sign in to comment.