<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p><font face="Helvetica, Arial, sans-serif">It's impossible to add
        new methods on Object.prototype because it would be web-breaking
        - I have seen code that test for </font><tt>typeof arr.</tt><tt>map
        === 'function'</tt><font face="Helvetica, Arial, sans-serif"><br>
        <br>
        On Set topic, I have written <a
          href="https://github.com/Ginden/set-methods">basic proposal
          for this</a>, but it was ignored so I didn't write formal
        spec.<br>
      </font></p>
    <br>
    <div class="moz-cite-prefix">On 17/03/17 13:36, James Treworgy
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFwXF_PMm9-U1-Xn4npfiO5nS3j_rUD19QsLw2=edJtxWw4wZQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">I think a good solution that doesn't require new
        syntax would be map/filter methods on the Object prototype that
        return a new object, e.g. 
        <div><br>
        </div>
        <div>
          <div><font face="monospace, monospace">let subset = { a:1,
              b:2, c:3 }.filter(([key])=>['b'].includes(key))<br>
            </font></div>
        </div>
        <div><font face="monospace, monospace">// subset = { b: 2 }</font></div>
        <div><font face="monospace, monospace"><br>
          </font></div>
        <div>
          <div><font face="monospace, monospace">let subset = { 1:1,
              b:2, c:3 }.map(([key, value])=>[key, value * 2])<br>
            </font></div>
          <div><font face="monospace, monospace">// subset = { a:2, b:4.
              c:6</font><span style="font-family:monospace,monospace"> }</span></div>
        </div>
        <div><br>
        </div>
        <div>Actually I'd like this to be available on Map too. I've
          always thought it was interesting that the Map and Set objects
          do not natively include map/filter operations -- or maybe even
          most of the Array prototype methods as applicable. And for
          Sets, basic set operations like except/distinct/union. <br>
        </div>
        <div><br>
        </div>
        <div>But a Javascript object is just a Map, really, or I guess
          one could say that a Map is just an object with a few
          enhancements. It's surprising that there is no native
          operation built in to directly convert between Maps and
          objects given their conceptual similarity. In either case
          though it would be nice to be able to apply standard
          processing rules that one applies to Maps conceptually to an
          Object (and a Map) natively, like filter and map.</div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Mar 17, 2017 at 8:04 AM, Felipe
          Nascimento de Moura <span dir="ltr"><<a
              moz-do-not-send="true"
              href="mailto:felipenmoura@gmail.com" target="_blank">felipenmoura@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hi.
              <div>Interesting to know that it has already been
                discussed.</div>
              <div><br>
              </div>
              <div>I know we could create a function to do similar
                things, but I think the language itself has evolved so
                well, this is a use case it could fit somehow.</div>
              <div><br>
              </div>
              <div>I think there could be different approaches for that,
                like</div>
              <div><br>
              </div>
              <div>Object.pick([ 'a', 'c' ], { a: 1, b: 2, c: 3 })</div>
              <div><br>
              </div>
              <div>or</div>
              <div><br>
              </div>
              <div>let x = {a, c}{ a: 1, b: 2, c: 3 }</div>
              <div><br>
              </div>
              <div>or</div>
              <div><br>
              </div>
              <div>let {a, c} as x = { a: 1, b: 2, c: 3 }</div>
              <div><br>
              </div>
              <div>or</div>
              <div><br>
              </div>
              <div><br>
              </div>
              <div>let x = { a: 1, b: 2, c: 3 }{a, c}<br>
              </div>
              <div><br>
              </div>
              <div>or</div>
              <div><br>
              </div>
              <div>let x = { a: 1, b: 2, c: 3 }['a', 'c']<br>
              </div>
              <div><br>
              </div>
              <div>Would you consider any of those as an interesting
                option?</div>
              <div><br>
              </div>
              <div>thanks.</div>
              <div><br>
              </div>
              <div><br>
              </div>
            </div>
            <div class="gmail_extra"><br>
              <div class="gmail_quote">On Fri, Mar 17, 2017 at 7:25 AM,
                peter miller <span dir="ltr"><<a
                    moz-do-not-send="true"
                    href="mailto:fuchsia.groan@virgin.net"
                    target="_blank">fuchsia.groan@virgin.net</a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<span><br>
                    <br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      There seems to be little appetite for taking it
                      up, in spite of it being<br>
                      (IMHO) a very common use case.<br>
                    </blockquote>
                    <br>
                  </span>
                  I'll second it being common in my code. My personal
                  highlights would be assigning to this:<br>
                  <br>
                  ```<br>
                  this.{x,y,z} = a;<br>
                  ```<br>
                  <br>
                  and combining it with property spreading:<br>
                  <br>
                  ```<br>
                  const result = { a, b, ...x.{ y, z }, ...p.{ q, r } };<br>
                  ```<span class="m_3326435042010292381HOEnZb"><font
                      color="#888888"><br>
                      <br>
                      Peter<br>
                      <br>
                      -- <br>
                      "There were drawings, and sheets of paper with
                      writing on them, and it seemed that they were the
                      sustenance of life, that here were the warlocks,
                      almost the vehicles of destruction of man's life,
                      but at the same time the very reason for his
                      living." --- Maeve Gilmore/Titus Awakes.</font></span>
                  <div class="m_3326435042010292381HOEnZb">
                    <div class="m_3326435042010292381h5"><br>
                      ______________________________<wbr>_________________<br>
                      es-discuss mailing list<br>
                      <a moz-do-not-send="true"
                        href="mailto:es-discuss@mozilla.org"
                        target="_blank">es-discuss@mozilla.org</a><br>
                      <a moz-do-not-send="true"
                        href="https://mail.mozilla.org/listinfo/es-discuss"
                        rel="noreferrer" target="_blank">https://mail.mozilla.org/listi<wbr>nfo/es-discuss</a><br>
                    </div>
                  </div>
                </blockquote>
              </div>
              <br>
              <br clear="all">
              <div><br>
              </div>
              -- <br>
              <div class="m_3326435042010292381gmail_signature"
                data-smartmail="gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div>
                            <div dir="ltr">
                              <div>
                                <div dir="ltr">
                                  <div dir="ltr">
                                    <div><span style="font-size:12.8px"><span
style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,51)">[ ]s</span></span></div>
                                    <div dir="ltr"><b><br>
                                      </b></div>
                                    <div dir="ltr"><b
                                        style="font-size:12.8px"><span
                                          style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,51)">--</span></b></div>
                                    <div dir="ltr"><b
                                        style="font-size:12.8px"><span
                                          style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,51)"><br>
                                        </span></b></div>
                                    <div dir="ltr"><b
                                        style="font-size:12.8px"><span
                                          style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,51)">Felipe
                                          N. Moura</span></b><br>
                                    </div>
                                    <div dir="ltr"><span
                                        style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)">Web
                                        Developer, </span><span
style="color:rgb(0,0,153);font-family:arial,helvetica,sans-serif;font-size:small"><a
                                          moz-do-not-send="true"
                                          href="https://developers.google.com/experts/people/felipe-moura"
                                          target="_blank">Google
                                          Developer Expert</a>, </span><span
style="font-size:12.8px;font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)">Founder
                                        of </span><a
                                        moz-do-not-send="true"
                                        href="https://braziljs.org/"
                                        style="font-size:12.8px"
                                        target="_blank">BrazilJS</a><span
style="font-size:12.8px;font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)"> and </span><a
                                        moz-do-not-send="true"
                                        href="http://nasc.io/"
                                        style="font-size:12.8px"
                                        target="_blank">Nasc</a><span
style="font-size:12.8px;font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)">.</span></div>
                                    <div dir="ltr"><br
                                        style="color:rgb(0,0,153)">
                                      <span style="color:rgb(0,0,153)">
                                        Website:  </span><span
                                        style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)"><a
                                          moz-do-not-send="true"
                                          href="http://felipenmoura.com/"
                                          target="_blank">http://felipenmoura.com</a> /
                                        <a moz-do-not-send="true"
                                          href="http://nasc.io/"
                                          target="_blank">http://nasc.io/</a> </span><br
                                        style="color:rgb(0,0,153)">
                                      <span style="color:rgb(0,0,153)">
                                        Twitter:    </span><span
                                        style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)"><a
                                          moz-do-not-send="true"
                                          href="http://twitter.com/felipenmoura"
                                          target="_blank">@felipenmoura</a></span></div>
                                    <div dir="ltr"><font color="#000099"
                                        face="arial, helvetica,
                                        sans-serif">Facebook: <a
                                          moz-do-not-send="true"
                                          href="http://fb.com/felipenmoura"
                                          target="_blank">http://fb.com/felipenmoura</a><br>
                                      </font><span
                                        style="color:rgb(0,0,153);font-size:12.8px">LinkedIn: </span><a
                                        moz-do-not-send="true"
                                        href="http://goo.gl/qGmq"
                                        style="font-size:12.8px"
                                        target="_blank">http://goo.gl/qGmq</a></div>
                                    <div dir="ltr">
                                      <div><span
                                          style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,153)">------------------------------<wbr>---</span><br
style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,153)">
                                        <b>Changing  the  world</b>  is
                                        the least I expect from  myself!</div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <br>
            ______________________________<wbr>_________________<br>
            es-discuss mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a><br>
            <a moz-do-not-send="true"
              href="https://mail.mozilla.org/listinfo/es-discuss"
              rel="noreferrer" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
es-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a>
<a class="moz-txt-link-freetext" href="https://mail.mozilla.org/listinfo/es-discuss">https://mail.mozilla.org/listinfo/es-discuss</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>