I agree map is not really a good fit for strings but this looks like yet
another use case for `::` operator

```js
const map = [].map;

str::map(codeUnits);
[...str]::map(codePoints);
```

Why didn't that proposal made it again? It would make *every* request to
add prototypal methods redundant!

Regards


On Thu, May 17, 2018 at 7:12 PM, Jordan Harband <ljh...@gmail.com> wrote:

> What's the use case where you'd want to map over every (character / code
> point / grapheme / whatever) in a string, and apply the same callback logic
> to each one?
>
> On Thu, May 17, 2018 at 9:21 AM, kdex <k...@kdex.de> wrote:
>
>> Yeah; I am aware that ES2015 added measures that make it possible iterate
>> over
>> codepoints, but that was not quite my point. The problem that I see is
>> that in
>> some scenarios it makes sense to think of a string as an array of bytes,
>> and
>> sometimes you need to iterate over a string in terms of its codepoints.
>> Some
>> might even want to iterate in terms of visible glyphs, taking combining
>> marks
>> into account.
>>
>> This ambiguity makes `String.prototype.map` moot, as it remains
>> questionable
>> what exactly should be iterated. Bytes? Codepoints? Entire glyphs?
>>
>> On Thursday, May 17, 2018 5:41:32 PM CEST you wrote:
>> > Yeah; I am aware that ES2015 added measures that make it possible
>> iterate
>> > over codepoints, but that was not quite my point. The problem that I
>> see is
>> > that in some scenarios it makes sense to think of a string as an array
>> of
>> > bytes, and sometimes you need to iterate over a string in terms of its
>> > codepoints. Some might even want to iterate in terms of visible glyphs,
>> > taking combining marks into account.
>> >
>> > This ambiguity makes `String.prototype.map` moot, as it remains
>> questionable
>> > what exactly should be iterated. Bytes? Codepoints? Entire glyphs?
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to