Krinkle added a project: MediaWiki-ResourceLoader. Krinkle added a comment. Restricted Application added a project: MediaWiki-Platform-Team.
> mw.Map is an ES3-compatible re-implementation of Map from ES6. It is not. The naming similarity between `mw.Map` and ES6 Map is a coincidence and predates our awareness of ES6 by many years. The two are not related to each other. In the past we did ship inlined ES6 polyfills and we could have (and still can) implement one atop the other. The reason mw.Map is written in a few lines of plain JavaScript, is that mw.Map would be larger, slower, and more complicated if we wrote it any other way. We did simplify the code over the years by adopting modern `Object.create( null );`, `for-in` and `Array.isArray`. If there's ways to simplify the implementation further, patches are welcome! Note that it isn't a general-purpose public API, rather it exists primarily as backend for the public `mw.config` and `mw.user.options` APIs. Last I tried, I found trying to put ES6 Map underneath, I didn't help in size, speed, or simplicity, so I didn't. Some examples of features are are incompatible with ES6 Map: - `mw.Map#get()` returns an object of all values. - `mw.Map#get(key, default)` takes a `default` parameter, widely used, e.g. `mw.config.get( 'wgUserGroups', [] )`. - `mw.Map#get(keys)` takes an array `keys` parameter for returning a subset of keys, widely used, e.g. `mw.config.get( [ 'wgTitle', 'wgNamespaceId' ])`. - `mw.Map#set(values)` takes an Object `values` parameter to set multiple key-value pairs in one go, or two separate key-value arguments, widely used. - `mw.Map#exists(key)` is a boolean method for checking key existence. The coincidental overlap with ES6 starts and stops at `.get(key)` and `.set(key, value)`. TASK DETAIL https://phabricator.wikimedia.org/T353076 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Krinkle Cc: Krinkle, Michael, simon04, SD0001, Jdlrobson, Novem_Linguae, Soda, Chlod, DannyS712, Aklapper, Jdforrester-WMF, Danny_Benjafield_WMDE, Isabelladantes1983, Themindcoder, Adamm71, Hey_man_im_josh, Jersione, HuanNguyen, Hellket777, MPGuy2824, LisafBia6531, IAmChaos, Astuthiodit_1, STH, G1964j, 786, Zekwn, Sgs, Biggs657, karapayneWMDE, the0001, Invadibot, Zabe, Selby, AndreCstr, maantietaja, XeroS_SkalibuR, GhostInTheMachine, Juan90264, Alter-paule, Beast1978, ItamarWMDE, Un1tY, Akuckartz, Demian, Hook696, Kent7301, joker88john, 94rain, CucyNoiD, Nandana, Mirahamira, Gaboe420, Jony, lucamauri, Giuliamocci, Force_Radical, Cpaulf30, Lahi, Gq86, Af420, Bsandipan, Markhalsey, GoranSMilovanovic, QZanden, KimKelting, LawExplorer, Flycatchr, Lewizho99, Maathavan, _jensen, rosalieper, xSavitar, Neuronton, Scott_WUaS, Volker_E, Izno, SBisson, Samwalton9-WMF, Nirmos, Wikidata-bugs, aude, Dinoguy1000, Mbch331, Jay8g, Tgr
_______________________________________________ Wikidata-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected]
