There is a whole example that produces a string, like join does, using the
second argument iterable to fill the "junctions" ... which part is not
clear in the test case?

```js
console.log(['a', 'b', 'c', 'd'].joinWith([1, 2]));
// a1b2c1d

function tag2str(template, ...values) {
  return template.joinWith(values);
}

tag2str`a${1}b${2}c`;
// "a1b2c"
```

On Thu, Aug 15, 2019 at 7:39 PM Naveen Chawla <naveen.c...@gmail.com> wrote:

> "weave"? (I've likely missed the purpose of the method)
>
> On Thu, 15 Aug 2019, 18:12 Andrea Giammarchi, <andrea.giammar...@gmail.com>
> wrote:
>
>> That;s not useful for template literals tags though
>>
>> _.zip(['a', 'b', 'c'], [1, 2]);
>> [["a", 1], ["b", 2], ["c", undefined]]
>>
>> it basically does nothing I've proposed ... any other name suggestion?
>>
>> On Thu, Aug 15, 2019 at 3:40 PM Michał Wadas <michalwa...@gmail.com>
>> wrote:
>>
>>> https://lodash.com/docs/#zip
>>> https://docs.python.org/3/library/functions.html#zip
>>>
>>> On Thu, 15 Aug 2019, 15:34 Andrea Giammarchi, <
>>> andrea.giammar...@gmail.com> wrote:
>>>
>>>>
>>>>    1. the suggested name is just ... suggested, I don't have strong
>>>>    opinion on it, it just `join` values through other values
>>>>    2. what's `Array.zip` ? I've no idea
>>>>
>>>>
>>>> On Thu, Aug 15, 2019 at 12:53 PM Michał Wadas <michalwa...@gmail.com>
>>>> wrote:
>>>>
>>>>> I would rather see Array.zip, it covers this use case.
>>>>>
>>>>> On Thu, 15 Aug 2019, 10:50 Andrea Giammarchi, <
>>>>> andrea.giammar...@gmail.com> wrote:
>>>>>
>>>>>>
>>>>>> I wonder if there's any interest in adding another handy Array method
>>>>>> as joinWith could be:
>>>>>>
>>>>>> ```js
>>>>>> // proposal example
>>>>>> Array.prototype.joinWith = function (values) {
>>>>>>   const {length} = this;
>>>>>>   if (length < 2)
>>>>>>     return this.join('');
>>>>>>   const out = [this[0]];
>>>>>>   const len = values.length;
>>>>>>   for (let i = 1; i < length; i++) {
>>>>>>     console.log(i, len);
>>>>>>     out.push(values[(i - 1) % len], this[i]);
>>>>>>   }
>>>>>>   return out.join('');
>>>>>> };
>>>>>> ```
>>>>>>
>>>>>> The goal is to simplify joining array entries through not the same
>>>>>> value, example:
>>>>>>
>>>>>> ```js
>>>>>> console.log(['a', 'b', 'c', 'd'].joinWith([1, 2]));
>>>>>> // a1b2c1d
>>>>>>
>>>>>> function tag2str(template, ...values) {
>>>>>>   return template.joinWith(values);
>>>>>> }
>>>>>>
>>>>>> tag2str`a${1}b${2}c`;
>>>>>> // "a1b2c"
>>>>>> ```
>>>>>>
>>>>>> Throughts?
>>>>>> _______________________________________________
>>>>>> 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