f99a9898d2ac03bc66f8684d49e5a7fa9cd87b3ad5f44d42aa78a2d4f1eb8d1da3dbecfc670aa6f2eb1338e58e1954819acdfe408d8711a9e2e60258f1ef01 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307
  1. # core-js
  2. [![Sponsors on Open Collective](https://opencollective.com/core-js/sponsors/badge.svg)](#raising-funds) [![Backers on Open Collective](https://opencollective.com/core-js/backers/badge.svg)](#raising-funds) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/zloirock/core-js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![npm downloads](https://img.shields.io/npm/dm/core-js.svg)](http://npm-stat.com/charts.html?package=core-js&author=&from=2014-11-18) [![Build Status](https://travis-ci.org/zloirock/core-js.svg)](https://travis-ci.org/zloirock/core-js) [![devDependency status](https://david-dm.org/zloirock/core-js/dev-status.svg)](https://david-dm.org/zloirock/core-js?type=dev)
  3. ## As advertising: the author is looking for a good job :)
  4. ## [core-js@3, babel and a look into the future](https://github.com/zloirock/core-js/tree/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md)
  5. ## Raising funds
  6. `core-js` isn't backed by a company, so the future of this project depends on you. Become a sponsor or a backer [**on Open Collective**](https://opencollective.com/core-js) or [**on Patreon**](https://www.patreon.com/zloirock) if you are interested in `core-js`.
  7. ---
  8. <a href="https://opencollective.com/core-js/sponsor/0/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/0/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/1/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/1/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/2/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/2/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/3/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/3/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/4/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/4/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/5/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/5/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/6/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/6/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/7/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/7/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/8/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/8/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/9/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/9/avatar.svg"></a>
  9. ---
  10. <a href="https://opencollective.com/core-js#backers" target="_blank"><img src="https://opencollective.com/core-js/backers.svg?width=890"></a>
  11. ---
  12. **It's documentation for obsolete `core-js@2`. If you looking documentation for actual `core-js` version, please, check [this branch](https://github.com/zloirock/core-js/tree/master).**
  13. Modular standard library for JavaScript. Includes polyfills for [ECMAScript 5](#ecmascript-5), [ECMAScript 6](#ecmascript-6): [promises](#ecmascript-6-promise), [symbols](#ecmascript-6-symbol), [collections](#ecmascript-6-collections), iterators, [typed arrays](#ecmascript-6-typed-arrays), [ECMAScript 7+ proposals](#ecmascript-7-proposals), [setImmediate](#setimmediate), etc. Some additional features such as [dictionaries](#dict) or [extended partial application](#partial-application). You can require only needed features or use it without global namespace pollution.
  14. [*Example*](http://goo.gl/a2xexl):
  15. ```js
  16. Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
  17. '*'.repeat(10); // => '**********'
  18. Promise.resolve(32).then(x => console.log(x)); // => 32
  19. setImmediate(x => console.log(x), 42); // => 42
  20. ```
  21. [*Without global namespace pollution*](http://goo.gl/paOHb0):
  22. ```js
  23. var core = require('core-js/library'); // With a modular system, otherwise use global `core`
  24. core.Array.from(new core.Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
  25. core.String.repeat('*', 10); // => '**********'
  26. core.Promise.resolve(32).then(x => console.log(x)); // => 32
  27. core.setImmediate(x => console.log(x), 42); // => 42
  28. ```
  29. ### Index
  30. - [Usage](#usage)
  31. - [Basic](#basic)
  32. - [CommonJS](#commonjs)
  33. - [Custom build](#custom-build-from-the-command-line)
  34. - [Supported engines](#supported-engines)
  35. - [Features](#features)
  36. - [ECMAScript 5](#ecmascript-5)
  37. - [ECMAScript 6](#ecmascript-6)
  38. - [ECMAScript 6: Object](#ecmascript-6-object)
  39. - [ECMAScript 6: Function](#ecmascript-6-function)
  40. - [ECMAScript 6: Array](#ecmascript-6-array)
  41. - [ECMAScript 6: String](#ecmascript-6-string)
  42. - [ECMAScript 6: RegExp](#ecmascript-6-regexp)
  43. - [ECMAScript 6: Number](#ecmascript-6-number)
  44. - [ECMAScript 6: Math](#ecmascript-6-math)
  45. - [ECMAScript 6: Date](#ecmascript-6-date)
  46. - [ECMAScript 6: Promise](#ecmascript-6-promise)
  47. - [ECMAScript 6: Symbol](#ecmascript-6-symbol)
  48. - [ECMAScript 6: Collections](#ecmascript-6-collections)
  49. - [ECMAScript 6: Typed Arrays](#ecmascript-6-typed-arrays)
  50. - [ECMAScript 6: Reflect](#ecmascript-6-reflect)
  51. - [ECMAScript 7+ proposals](#ecmascript-7-proposals)
  52. - [stage 4 proposals](#stage-4-proposals)
  53. - [stage 3 proposals](#stage-3-proposals)
  54. - [stage 2 proposals](#stage-2-proposals)
  55. - [stage 1 proposals](#stage-1-proposals)
  56. - [stage 0 proposals](#stage-0-proposals)
  57. - [pre-stage 0 proposals](#pre-stage-0-proposals)
  58. - [Web standards](#web-standards)
  59. - [setTimeout / setInterval](#settimeout--setinterval)
  60. - [setImmediate](#setimmediate)
  61. - [iterable DOM collections](#iterable-dom-collections)
  62. - [Non-standard](#non-standard)
  63. - [Object](#object)
  64. - [Dict](#dict)
  65. - [partial application](#partial-application)
  66. - [Number Iterator](#number-iterator)
  67. - [escaping strings](#escaping-strings)
  68. - [delay](#delay)
  69. - [helpers for iterators](#helpers-for-iterators)
  70. - [Missing polyfills](#missing-polyfills)
  71. - [Changelog](./CHANGELOG.md)
  72. ## Usage
  73. ### Basic
  74. ```
  75. npm i core-js
  76. bower install core.js
  77. ```
  78. ```js
  79. // Default
  80. require('core-js');
  81. // Without global namespace pollution
  82. var core = require('core-js/library');
  83. // Shim only
  84. require('core-js/shim');
  85. ```
  86. If you need complete build for browser, use builds from `core-js/client` path:
  87. * [default](https://raw.githack.com/zloirock/core-js/v2.6.12/client/core.min.js): Includes all features, standard and non-standard.
  88. * [as a library](https://raw.githack.com/zloirock/core-js/v2.6.12/client/library.min.js): Like "default", but does not pollute the global namespace (see [2nd example at the top](#core-js)).
  89. * [shim only](https://raw.githack.com/zloirock/core-js/v2.6.12/client/shim.min.js): Only includes the standard methods.
  90. Warning: if you use `core-js` with the extension of native objects, require all needed `core-js` modules at the beginning of entry point of your application, otherwise, conflicts may occur.
  91. ### CommonJS
  92. You can require only needed modules.
  93. ```js
  94. require('core-js/fn/set');
  95. require('core-js/fn/array/from');
  96. require('core-js/fn/array/find-index');
  97. Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
  98. [1, 2, NaN, 3, 4].findIndex(isNaN); // => 2
  99. // or, w/o global namespace pollution:
  100. var Set = require('core-js/library/fn/set');
  101. var from = require('core-js/library/fn/array/from');
  102. var findIndex = require('core-js/library/fn/array/find-index');
  103. from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
  104. findIndex([1, 2, NaN, 3, 4], isNaN); // => 2
  105. ```
  106. Available entry points for methods / constructors, as above examples, and namespaces: for example, `core-js/es6/array` (`core-js/library/es6/array`) contains all [ES6 `Array` features](#ecmascript-6-array), `core-js/es6` (`core-js/library/es6`) contains all ES6 features.
  107. ##### Caveats when using CommonJS API:
  108. * `modules` path is internal API, does not inject all required dependencies and can be changed in minor or patch releases. Use it only for a custom build and / or if you know what are you doing.
  109. * `core-js` is extremely modular and uses a lot of very tiny modules, because of that for usage in browsers bundle up `core-js` instead of usage loader for each file, otherwise, you will have hundreds of requests.
  110. #### CommonJS and prototype methods without global namespace pollution
  111. In the `library` version, we can't pollute prototypes of native constructors. Because of that, prototype methods transformed to static methods like in examples above. `babel` `runtime` transformer also can't transform them. But with transpilers we can use one more trick - [bind operator and virtual methods](https://github.com/zenparsing/es-function-bind). Special for that, available `/virtual/` entry points. Example:
  112. ```js
  113. import fill from 'core-js/library/fn/array/virtual/fill';
  114. import findIndex from 'core-js/library/fn/array/virtual/find-index';
  115. Array(10)::fill(0).map((a, b) => b * b)::findIndex(it => it && !(it % 8)); // => 4
  116. // or
  117. import {fill, findIndex} from 'core-js/library/fn/array/virtual';
  118. Array(10)::fill(0).map((a, b) => b * b)::findIndex(it => it && !(it % 8)); // => 4
  119. ```
  120. ### Custom build (from the command-line)
  121. ```
  122. npm i core-js && cd node_modules/core-js && npm i
  123. npm run grunt build:core.dict,es6 -- --blacklist=es6.promise,es6.math --library=on --path=custom uglify
  124. ```
  125. Where `core.dict` and `es6` are modules (namespaces) names, which will be added to the build, `es6.promise` and `es6.math` are modules (namespaces) names, which will be excluded from the build, `--library=on` is flag for build without global namespace pollution and `custom` is target file name.
  126. Available namespaces: for example, `es6.array` contains [ES6 `Array` features](#ecmascript-6-array), `es6` contains all modules whose names start with `es6`.
  127. ### Custom build (from external scripts)
  128. [`core-js-builder`](https://www.npmjs.com/package/core-js-builder) package exports a function that takes the same parameters as the `build` target from the previous section. This will conditionally include or exclude certain parts of `core-js`:
  129. ```js
  130. require('core-js-builder')({
  131. modules: ['es6', 'core.dict'], // modules / namespaces
  132. blacklist: ['es6.reflect'], // blacklist of modules / namespaces, by default - empty list
  133. library: false, // flag for build without global namespace pollution, by default - false
  134. umd: true // use UMD wrapper for export `core` object, by default - true
  135. }).then(code => {
  136. // ...
  137. }).catch(error => {
  138. // ...
  139. });
  140. ```
  141. ## Supported engines
  142. **Tested in:**
  143. - Chrome 26+
  144. - Firefox 4+
  145. - Safari 5+
  146. - Opera 12+
  147. - Internet Explorer 6+ (sure, IE8- with ES3 limitations)
  148. - Edge
  149. - Android Browser 2.3+
  150. - iOS Safari 5.1+
  151. - PhantomJS 1.9 / 2.1
  152. - NodeJS 0.8+
  153. ...and it doesn't mean `core-js` will not work in other engines, they just have not been tested.
  154. ## Features:
  155. [*CommonJS entry points:*](#commonjs)
  156. ```
  157. core-js(/library) <- all features
  158. core-js(/library)/shim <- only polyfills
  159. ```
  160. ### ECMAScript 5
  161. All features moved to the [`es6` namespace](#ecmascript-6), here just a list of features:
  162. ```js
  163. Object
  164. .create(proto | null, descriptors?) -> object
  165. .getPrototypeOf(object) -> proto | null
  166. .defineProperty(target, key, desc) -> target, cap for ie8-
  167. .defineProperties(target, descriptors) -> target, cap for ie8-
  168. .getOwnPropertyDescriptor(object, key) -> desc
  169. .getOwnPropertyNames(object) -> array
  170. .keys(object) -> array
  171. .seal(object) -> object, cap for ie8-
  172. .freeze(object) -> object, cap for ie8-
  173. .preventExtensions(object) -> object, cap for ie8-
  174. .isSealed(object) -> bool, cap for ie8-
  175. .isFrozen(object) -> bool, cap for ie8-
  176. .isExtensible(object) -> bool, cap for ie8-
  177. Array
  178. .isArray(var) -> bool
  179. #slice(start?, end?) -> array, fix for ie7-
  180. #join(string = ',') -> string, fix for ie7-
  181. #indexOf(var, from?) -> int
  182. #lastIndexOf(var, from?) -> int
  183. #every(fn(val, index, @), that) -> bool
  184. #some(fn(val, index, @), that) -> bool
  185. #forEach(fn(val, index, @), that) -> void
  186. #map(fn(val, index, @), that) -> array
  187. #filter(fn(val, index, @), that) -> array
  188. #reduce(fn(memo, val, index, @), memo?) -> var
  189. #reduceRight(fn(memo, val, index, @), memo?) -> var
  190. #sort(fn?) -> @, fixes for some engines
  191. Function
  192. #bind(object, ...args) -> boundFn(...args)
  193. String
  194. #split(separator, limit) -> array
  195. #trim() -> str
  196. RegExp
  197. #toString() -> str
  198. Number
  199. #toFixed(digits) -> string
  200. #toPrecision(precision) -> string
  201. parseInt(str, radix) -> int
  202. parseFloat(str) -> num
  203. Date
  204. .now() -> int
  205. #toISOString() -> string
  206. #toJSON() -> string
  207. ```
  208. [*CommonJS entry points:*](#commonjs)
  209. ```
  210. core-js(/library)/es5
  211. ```
  212. ### ECMAScript 6
  213. [*CommonJS entry points:*](#commonjs)
  214. ```
  215. core-js(/library)/es6
  216. ```
  217. #### ECMAScript 6: Object
  218. Modules [`es6.object.assign`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.assign.js), [`es6.object.is`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.is.js), [`es6.object.set-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.set-prototype-of.js) and [`es6.object.to-string`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.to-string.js).
  219. In ES6 most `Object` static methods should work with primitives. Modules [`es6.object.freeze`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.freeze.js), [`es6.object.seal`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.seal.js), [`es6.object.prevent-extensions`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.prevent-extensions.js), [`es6.object.is-frozen`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.is-frozen.js), [`es6.object.is-sealed`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.is-sealed.js), [`es6.object.is-extensible`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.is-extensible.js), [`es6.object.get-own-property-descriptor`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.get-own-property-descriptor.js), [`es6.object.get-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.get-prototype-of.js), [`es6.object.keys`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.keys.js) and [`es6.object.get-own-property-names`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.get-own-property-names.js).
  220. Just ES5 features: [`es6.object.create`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.create.js), [`es6.object.define-property`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.define-property.js) and [`es6.object.define-properties`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.object.es6.object.define-properties.js).
  221. ```js
  222. Object
  223. .assign(target, ...src) -> target
  224. .is(a, b) -> bool
  225. .setPrototypeOf(target, proto | null) -> target (required __proto__ - IE11+)
  226. .create(object | null, descriptors?) -> object
  227. .getPrototypeOf(var) -> object | null
  228. .defineProperty(object, key, desc) -> target
  229. .defineProperties(object, descriptors) -> target
  230. .getOwnPropertyDescriptor(var, key) -> desc | undefined
  231. .keys(var) -> array
  232. .getOwnPropertyNames(var) -> array
  233. .freeze(var) -> var
  234. .seal(var) -> var
  235. .preventExtensions(var) -> var
  236. .isFrozen(var) -> bool
  237. .isSealed(var) -> bool
  238. .isExtensible(var) -> bool
  239. #toString() -> string, ES6 fix: @@toStringTag support
  240. ```
  241. [*CommonJS entry points:*](#commonjs)
  242. ```
  243. core-js(/library)/es6/object
  244. core-js(/library)/fn/object/assign
  245. core-js(/library)/fn/object/is
  246. core-js(/library)/fn/object/set-prototype-of
  247. core-js(/library)/fn/object/get-prototype-of
  248. core-js(/library)/fn/object/create
  249. core-js(/library)/fn/object/define-property
  250. core-js(/library)/fn/object/define-properties
  251. core-js(/library)/fn/object/get-own-property-descriptor
  252. core-js(/library)/fn/object/keys
  253. core-js(/library)/fn/object/get-own-property-names
  254. core-js(/library)/fn/object/freeze
  255. core-js(/library)/fn/object/seal
  256. core-js(/library)/fn/object/prevent-extensions
  257. core-js(/library)/fn/object/is-frozen
  258. core-js(/library)/fn/object/is-sealed
  259. core-js(/library)/fn/object/is-extensible
  260. core-js/fn/object/to-string
  261. ```
  262. [*Examples*](http://goo.gl/ywdwPz):
  263. ```js
  264. var foo = {q: 1, w: 2}
  265. , bar = {e: 3, r: 4}
  266. , baz = {t: 5, y: 6};
  267. Object.assign(foo, bar, baz); // => foo = {q: 1, w: 2, e: 3, r: 4, t: 5, y: 6}
  268. Object.is(NaN, NaN); // => true
  269. Object.is(0, -0); // => false
  270. Object.is(42, 42); // => true
  271. Object.is(42, '42'); // => false
  272. function Parent(){}
  273. function Child(){}
  274. Object.setPrototypeOf(Child.prototype, Parent.prototype);
  275. new Child instanceof Child; // => true
  276. new Child instanceof Parent; // => true
  277. var O = {};
  278. O[Symbol.toStringTag] = 'Foo';
  279. '' + O; // => '[object Foo]'
  280. Object.keys('qwe'); // => ['0', '1', '2']
  281. Object.getPrototypeOf('qwe') === String.prototype; // => true
  282. ```
  283. #### ECMAScript 6: Function
  284. Modules [`es6.function.name`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.function.name.js), [`es6.function.has-instance`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.function.has-instance.js). Just ES5: [`es6.function.bind`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.function.bind.js).
  285. ```js
  286. Function
  287. #bind(object, ...args) -> boundFn(...args)
  288. #name -> string (IE9+)
  289. #@@hasInstance(var) -> bool
  290. ```
  291. [*CommonJS entry points:*](#commonjs)
  292. ```
  293. core-js/es6/function
  294. core-js/fn/function/name
  295. core-js/fn/function/has-instance
  296. core-js/fn/function/bind
  297. core-js/fn/function/virtual/bind
  298. ```
  299. [*Example*](http://goo.gl/zqu3Wp):
  300. ```js
  301. (function foo(){}).name // => 'foo'
  302. console.log.bind(console, 42)(43); // => 42 43
  303. ```
  304. #### ECMAScript 6: Array
  305. Modules [`es6.array.from`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.from.js), [`es6.array.of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.of.js), [`es6.array.copy-within`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.copy-within.js), [`es6.array.fill`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.fill.js), [`es6.array.find`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.find.js), [`es6.array.find-index`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.find-index.js), [`es6.array.iterator`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.iterator.js). ES5 features with fixes: [`es6.array.is-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.is-array.js), [`es6.array.slice`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.slice.js), [`es6.array.join`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.join.js), [`es6.array.index-of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.index-of.js), [`es6.array.last-index-of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.last-index-of.js), [`es6.array.every`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.every.js), [`es6.array.some`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.some.js), [`es6.array.for-each`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.for-each.js), [`es6.array.map`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.map.js), [`es6.array.filter`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.filter.js), [`es6.array.reduce`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.reduce.js), [`es6.array.reduce-right`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.reduce-right.js), [`es6.array.sort`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.array.sort.js).
  306. ```js
  307. Array
  308. .from(iterable | array-like, mapFn(val, index)?, that) -> array
  309. .of(...args) -> array
  310. .isArray(var) -> bool
  311. #copyWithin(target = 0, start = 0, end = @length) -> @
  312. #fill(val, start = 0, end = @length) -> @
  313. #find(fn(val, index, @), that) -> val
  314. #findIndex(fn(val, index, @), that) -> index | -1
  315. #values() -> iterator
  316. #keys() -> iterator
  317. #entries() -> iterator
  318. #join(string = ',') -> string, fix for ie7-
  319. #slice(start?, end?) -> array, fix for ie7-
  320. #indexOf(var, from?) -> index | -1
  321. #lastIndexOf(var, from?) -> index | -1
  322. #every(fn(val, index, @), that) -> bool
  323. #some(fn(val, index, @), that) -> bool
  324. #forEach(fn(val, index, @), that) -> void
  325. #map(fn(val, index, @), that) -> array
  326. #filter(fn(val, index, @), that) -> array
  327. #reduce(fn(memo, val, index, @), memo?) -> var
  328. #reduceRight(fn(memo, val, index, @), memo?) -> var
  329. #sort(fn?) -> @, invalid arguments fix
  330. #@@iterator() -> iterator (values)
  331. #@@unscopables -> object (cap)
  332. Arguments
  333. #@@iterator() -> iterator (values, available only in core-js methods)
  334. ```
  335. [*CommonJS entry points:*](#commonjs)
  336. ```
  337. core-js(/library)/es6/array
  338. core-js(/library)/fn/array/from
  339. core-js(/library)/fn/array/of
  340. core-js(/library)/fn/array/is-array
  341. core-js(/library)/fn/array/iterator
  342. core-js(/library)/fn/array/copy-within
  343. core-js(/library)/fn/array/fill
  344. core-js(/library)/fn/array/find
  345. core-js(/library)/fn/array/find-index
  346. core-js(/library)/fn/array/values
  347. core-js(/library)/fn/array/keys
  348. core-js(/library)/fn/array/entries
  349. core-js(/library)/fn/array/slice
  350. core-js(/library)/fn/array/join
  351. core-js(/library)/fn/array/index-of
  352. core-js(/library)/fn/array/last-index-of
  353. core-js(/library)/fn/array/every
  354. core-js(/library)/fn/array/some
  355. core-js(/library)/fn/array/for-each
  356. core-js(/library)/fn/array/map
  357. core-js(/library)/fn/array/filter
  358. core-js(/library)/fn/array/reduce
  359. core-js(/library)/fn/array/reduce-right
  360. core-js(/library)/fn/array/sort
  361. core-js(/library)/fn/array/virtual/iterator
  362. core-js(/library)/fn/array/virtual/copy-within
  363. core-js(/library)/fn/array/virtual/fill
  364. core-js(/library)/fn/array/virtual/find
  365. core-js(/library)/fn/array/virtual/find-index
  366. core-js(/library)/fn/array/virtual/values
  367. core-js(/library)/fn/array/virtual/keys
  368. core-js(/library)/fn/array/virtual/entries
  369. core-js(/library)/fn/array/virtual/slice
  370. core-js(/library)/fn/array/virtual/join
  371. core-js(/library)/fn/array/virtual/index-of
  372. core-js(/library)/fn/array/virtual/last-index-of
  373. core-js(/library)/fn/array/virtual/every
  374. core-js(/library)/fn/array/virtual/some
  375. core-js(/library)/fn/array/virtual/for-each
  376. core-js(/library)/fn/array/virtual/map
  377. core-js(/library)/fn/array/virtual/filter
  378. core-js(/library)/fn/array/virtual/reduce
  379. core-js(/library)/fn/array/virtual/reduce-right
  380. core-js(/library)/fn/array/virtual/sort
  381. ```
  382. [*Examples*](http://goo.gl/oaUFUf):
  383. ```js
  384. Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
  385. Array.from({0: 1, 1: 2, 2: 3, length: 3}); // => [1, 2, 3]
  386. Array.from('123', Number); // => [1, 2, 3]
  387. Array.from('123', function(it){
  388. return it * it;
  389. }); // => [1, 4, 9]
  390. Array.of(1); // => [1]
  391. Array.of(1, 2, 3); // => [1, 2, 3]
  392. var array = ['a', 'b', 'c'];
  393. for(var val of array)console.log(val); // => 'a', 'b', 'c'
  394. for(var val of array.values())console.log(val); // => 'a', 'b', 'c'
  395. for(var key of array.keys())console.log(key); // => 0, 1, 2
  396. for(var [key, val] of array.entries()){
  397. console.log(key); // => 0, 1, 2
  398. console.log(val); // => 'a', 'b', 'c'
  399. }
  400. function isOdd(val){
  401. return val % 2;
  402. }
  403. [4, 8, 15, 16, 23, 42].find(isOdd); // => 15
  404. [4, 8, 15, 16, 23, 42].findIndex(isOdd); // => 2
  405. [4, 8, 15, 16, 23, 42].find(isNaN); // => undefined
  406. [4, 8, 15, 16, 23, 42].findIndex(isNaN); // => -1
  407. Array(5).fill(42); // => [42, 42, 42, 42, 42]
  408. [1, 2, 3, 4, 5].copyWithin(0, 3); // => [4, 5, 3, 4, 5]
  409. ```
  410. #### ECMAScript 6: String
  411. Modules [`es6.string.from-code-point`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.from-code-point.js), [`es6.string.raw`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.raw.js), [`es6.string.iterator`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.iterator.js), [`es6.string.code-point-at`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.code-point-at.js), [`es6.string.ends-with`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.ends-with.js), [`es6.string.includes`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.includes.js), [`es6.string.repeat`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.repeat.js), [`es6.string.starts-with`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.starts-with.js) and [`es6.string.trim`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.trim.js).
  412. Annex B HTML methods. Ugly, but it's also the part of the spec. Modules [`es6.string.anchor`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.anchor.js), [`es6.string.big`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.big.js), [`es6.string.blink`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.blink.js), [`es6.string.bold`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.bold.js), [`es6.string.fixed`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.fixed.js), [`es6.string.fontcolor`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.fontcolor.js), [`es6.string.fontsize`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.fontsize.js), [`es6.string.italics`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.italics.js), [`es6.string.link`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.link.js), [`es6.string.small`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.small.js), [`es6.string.strike`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.strike.js), [`es6.string.sub`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.sub.js) and [`es6.string.sup`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.string.sup.js).
  413. ```js
  414. String
  415. .fromCodePoint(...codePoints) -> str
  416. .raw({raw}, ...substitutions) -> str
  417. #includes(str, from?) -> bool
  418. #startsWith(str, from?) -> bool
  419. #endsWith(str, from?) -> bool
  420. #repeat(num) -> str
  421. #codePointAt(pos) -> uint
  422. #trim() -> str, ES6 fix
  423. #anchor(name) -> str
  424. #big() -> str
  425. #blink() -> str
  426. #bold() -> str
  427. #fixed() -> str
  428. #fontcolor(color) -> str
  429. #fontsize(size) -> str
  430. #italics() -> str
  431. #link(url) -> str
  432. #small() -> str
  433. #strike() -> str
  434. #sub() -> str
  435. #sup() -> str
  436. #@@iterator() -> iterator (code points)
  437. ```
  438. [*CommonJS entry points:*](#commonjs)
  439. ```
  440. core-js(/library)/es6/string
  441. core-js(/library)/fn/string/from-code-point
  442. core-js(/library)/fn/string/raw
  443. core-js(/library)/fn/string/includes
  444. core-js(/library)/fn/string/starts-with
  445. core-js(/library)/fn/string/ends-with
  446. core-js(/library)/fn/string/repeat
  447. core-js(/library)/fn/string/code-point-at
  448. core-js(/library)/fn/string/trim
  449. core-js(/library)/fn/string/anchor
  450. core-js(/library)/fn/string/big
  451. core-js(/library)/fn/string/blink
  452. core-js(/library)/fn/string/bold
  453. core-js(/library)/fn/string/fixed
  454. core-js(/library)/fn/string/fontcolor
  455. core-js(/library)/fn/string/fontsize
  456. core-js(/library)/fn/string/italics
  457. core-js(/library)/fn/string/link
  458. core-js(/library)/fn/string/small
  459. core-js(/library)/fn/string/strike
  460. core-js(/library)/fn/string/sub
  461. core-js(/library)/fn/string/sup
  462. core-js(/library)/fn/string/iterator
  463. core-js(/library)/fn/string/virtual/includes
  464. core-js(/library)/fn/string/virtual/starts-with
  465. core-js(/library)/fn/string/virtual/ends-with
  466. core-js(/library)/fn/string/virtual/repeat
  467. core-js(/library)/fn/string/virtual/code-point-at
  468. core-js(/library)/fn/string/virtual/trim
  469. core-js(/library)/fn/string/virtual/anchor
  470. core-js(/library)/fn/string/virtual/big
  471. core-js(/library)/fn/string/virtual/blink
  472. core-js(/library)/fn/string/virtual/bold
  473. core-js(/library)/fn/string/virtual/fixed
  474. core-js(/library)/fn/string/virtual/fontcolor
  475. core-js(/library)/fn/string/virtual/fontsize
  476. core-js(/library)/fn/string/virtual/italics
  477. core-js(/library)/fn/string/virtual/link
  478. core-js(/library)/fn/string/virtual/small
  479. core-js(/library)/fn/string/virtual/strike
  480. core-js(/library)/fn/string/virtual/sub
  481. core-js(/library)/fn/string/virtual/sup
  482. core-js(/library)/fn/string/virtual/iterator
  483. ```
  484. [*Examples*](http://goo.gl/3UaQ93):
  485. ```js
  486. for(var val of 'a𠮷b'){
  487. console.log(val); // => 'a', '𠮷', 'b'
  488. }
  489. 'foobarbaz'.includes('bar'); // => true
  490. 'foobarbaz'.includes('bar', 4); // => false
  491. 'foobarbaz'.startsWith('foo'); // => true
  492. 'foobarbaz'.startsWith('bar', 3); // => true
  493. 'foobarbaz'.endsWith('baz'); // => true
  494. 'foobarbaz'.endsWith('bar', 6); // => true
  495. 'string'.repeat(3); // => 'stringstringstring'
  496. '𠮷'.codePointAt(0); // => 134071
  497. String.fromCodePoint(97, 134071, 98); // => 'a𠮷b'
  498. var name = 'Bob';
  499. String.raw`Hi\n${name}!`; // => 'Hi\\nBob!' (ES6 template string syntax)
  500. String.raw({raw: 'test'}, 0, 1, 2); // => 't0e1s2t'
  501. 'foo'.bold(); // => '<b>foo</b>'
  502. 'bar'.anchor('a"b'); // => '<a name="a&quot;b">bar</a>'
  503. 'baz'.link('http://example.com'); // => '<a href="http://example.com">baz</a>'
  504. ```
  505. #### ECMAScript 6: RegExp
  506. Modules [`es6.regexp.constructor`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.regexp.constructor.js) and [`es6.regexp.flags`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.regexp.flags.js).
  507. Support well-known [symbols](#ecmascript-6-symbol) `@@match`, `@@replace`, `@@search` and `@@split`, modules [`es6.regexp.match`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.regexp.match.js), [`es6.regexp.replace`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.regexp.replace.js), [`es6.regexp.search`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.regexp.search.js) and [`es6.regexp.split`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.regexp.split.js).
  508. ```
  509. [new] RegExp(pattern, flags?) -> regexp, ES6 fix: can alter flags (IE9+)
  510. #flags -> str (IE9+)
  511. #toString() -> str, ES6 fixes
  512. #@@match(str) -> array | null
  513. #@@replace(str, replacer) -> string
  514. #@@search(str) -> index
  515. #@@split(str, limit) -> array
  516. String
  517. #match(tpl) -> var, ES6 fix for support @@match
  518. #replace(tpl, replacer) -> var, ES6 fix for support @@replace
  519. #search(tpl) -> var, ES6 fix for support @@search
  520. #split(tpl, limit) -> var, ES6 fix for support @@split, some fixes for old engines
  521. ```
  522. [*CommonJS entry points:*](#commonjs)
  523. ```
  524. core-js/es6/regexp
  525. core-js/fn/regexp/constructor
  526. core-js(/library)/fn/regexp/flags
  527. core-js/fn/regexp/to-string
  528. core-js/fn/regexp/match
  529. core-js/fn/regexp/replace
  530. core-js/fn/regexp/search
  531. core-js/fn/regexp/split
  532. ```
  533. [*Examples*](http://goo.gl/PiJxBD):
  534. ```js
  535. RegExp(/./g, 'm'); // => /./m
  536. /foo/.flags; // => ''
  537. /foo/gim.flags; // => 'gim'
  538. 'foo'.match({[Symbol.match]: _ => 1}); // => 1
  539. 'foo'.replace({[Symbol.replace]: _ => 2}); // => 2
  540. 'foo'.search({[Symbol.search]: _ => 3}); // => 3
  541. 'foo'.split({[Symbol.split]: _ => 4}); // => 4
  542. RegExp.prototype.toString.call({source: 'foo', flags: 'bar'}); // => '/foo/bar'
  543. ```
  544. #### ECMAScript 6: Number
  545. Module [`es6.number.constructor`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.constructor.js). `Number` constructor support binary and octal literals, [*example*](http://goo.gl/jRd6b3):
  546. ```js
  547. Number('0b1010101'); // => 85
  548. Number('0o7654321'); // => 2054353
  549. ```
  550. Modules [`es6.number.epsilon`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.epsilon.js), [`es6.number.is-finite`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.is-finite.js), [`es6.number.is-integer`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.is-integer.js), [`es6.number.is-nan`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.is-nan.js), [`es6.number.is-safe-integer`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.is-safe-integer.js), [`es6.number.max-safe-integer`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.max-safe-integer.js), [`es6.number.min-safe-integer`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.min-safe-integer.js), [`es6.number.parse-float`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.parse-float.js), [`es6.number.parse-int`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.parse-int.js), [`es6.number.to-fixed`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.to-fixed.js), [`es6.number.to-precision`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.number.to-precision.js), [`es6.parse-int`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.parse-int.js), [`es6.parse-float`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.parse-float.js).
  551. ```js
  552. [new] Number(var) -> number | number object
  553. .isFinite(num) -> bool
  554. .isNaN(num) -> bool
  555. .isInteger(num) -> bool
  556. .isSafeInteger(num) -> bool
  557. .parseFloat(str) -> num
  558. .parseInt(str) -> int
  559. .EPSILON -> num
  560. .MAX_SAFE_INTEGER -> int
  561. .MIN_SAFE_INTEGER -> int
  562. #toFixed(digits) -> string, fixes
  563. #toPrecision(precision) -> string, fixes
  564. parseFloat(str) -> num, fixes
  565. parseInt(str) -> int, fixes
  566. ```
  567. [*CommonJS entry points:*](#commonjs)
  568. ```
  569. core-js(/library)/es6/number
  570. core-js/es6/number/constructor
  571. core-js(/library)/fn/number/is-finite
  572. core-js(/library)/fn/number/is-nan
  573. core-js(/library)/fn/number/is-integer
  574. core-js(/library)/fn/number/is-safe-integer
  575. core-js(/library)/fn/number/parse-float
  576. core-js(/library)/fn/number/parse-int
  577. core-js(/library)/fn/number/epsilon
  578. core-js(/library)/fn/number/max-safe-integer
  579. core-js(/library)/fn/number/min-safe-integer
  580. core-js(/library)/fn/number/to-fixed
  581. core-js(/library)/fn/number/to-precision
  582. core-js(/library)/fn/parse-float
  583. core-js(/library)/fn/parse-int
  584. ```
  585. #### ECMAScript 6: Math
  586. Modules [`es6.math.acosh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.acosh.js), [`es6.math.asinh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.asinh.js), [`es6.math.atanh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.atanh.js), [`es6.math.cbrt`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.cbrt.js), [`es6.math.clz32`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.clz32.js), [`es6.math.cosh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.cosh.js), [`es6.math.expm1`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.expm1.js), [`es6.math.fround`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.fround.js), [`es6.math.hypot`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.hypot.js), [`es6.math.imul`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.imul.js), [`es6.math.log10`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.log10.js), [`es6.math.log1p`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.log1p.js), [`es6.math.log2`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.log2.js), [`es6.math.sign`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.sign.js), [`es6.math.sinh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.sinh.js), [`es6.math.tanh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.tanh.js), [`es6.math.trunc`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.math.trunc.js).
  587. ```js
  588. Math
  589. .acosh(num) -> num
  590. .asinh(num) -> num
  591. .atanh(num) -> num
  592. .cbrt(num) -> num
  593. .clz32(num) -> uint
  594. .cosh(num) -> num
  595. .expm1(num) -> num
  596. .fround(num) -> num
  597. .hypot(...args) -> num
  598. .imul(num, num) -> int
  599. .log1p(num) -> num
  600. .log10(num) -> num
  601. .log2(num) -> num
  602. .sign(num) -> 1 | -1 | 0 | -0 | NaN
  603. .sinh(num) -> num
  604. .tanh(num) -> num
  605. .trunc(num) -> num
  606. ```
  607. [*CommonJS entry points:*](#commonjs)
  608. ```
  609. core-js(/library)/es6/math
  610. core-js(/library)/fn/math/acosh
  611. core-js(/library)/fn/math/asinh
  612. core-js(/library)/fn/math/atanh
  613. core-js(/library)/fn/math/cbrt
  614. core-js(/library)/fn/math/clz32
  615. core-js(/library)/fn/math/cosh
  616. core-js(/library)/fn/math/expm1
  617. core-js(/library)/fn/math/fround
  618. core-js(/library)/fn/math/hypot
  619. core-js(/library)/fn/math/imul
  620. core-js(/library)/fn/math/log1p
  621. core-js(/library)/fn/math/log10
  622. core-js(/library)/fn/math/log2
  623. core-js(/library)/fn/math/sign
  624. core-js(/library)/fn/math/sinh
  625. core-js(/library)/fn/math/tanh
  626. core-js(/library)/fn/math/trunc
  627. ```
  628. #### ECMAScript 6: Date
  629. Modules [`es6.date.to-string`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.date.to-string.js), ES5 features with fixes: [`es6.date.now`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.date.now.js), [`es6.date.to-iso-string`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.date.to-iso-string.js), [`es6.date.to-json`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.date.to-json.js) and [`es6.date.to-primitive`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.date.to-primitive.js).
  630. ```js
  631. Date
  632. .now() -> int
  633. #toISOString() -> string
  634. #toJSON() -> string
  635. #toString() -> string
  636. #@@toPrimitive(hint) -> primitive
  637. ```
  638. [*CommonJS entry points:*](#commonjs)
  639. ```
  640. core-js/es6/date
  641. core-js/fn/date/to-string
  642. core-js(/library)/fn/date/now
  643. core-js(/library)/fn/date/to-iso-string
  644. core-js(/library)/fn/date/to-json
  645. core-js(/library)/fn/date/to-primitive
  646. ```
  647. [*Example*](http://goo.gl/haeHLR):
  648. ```js
  649. new Date(NaN).toString(); // => 'Invalid Date'
  650. ```
  651. #### ECMAScript 6: Promise
  652. Module [`es6.promise`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.promise.js).
  653. ```js
  654. new Promise(executor(resolve(var), reject(var))) -> promise
  655. #then(resolved(var), rejected(var)) -> promise
  656. #catch(rejected(var)) -> promise
  657. .resolve(promise | var) -> promise
  658. .reject(var) -> promise
  659. .all(iterable) -> promise
  660. .race(iterable) -> promise
  661. ```
  662. [*CommonJS entry points:*](#commonjs)
  663. ```
  664. core-js(/library)/es6/promise
  665. core-js(/library)/fn/promise
  666. ```
  667. Basic [*example*](http://goo.gl/vGrtUC):
  668. ```js
  669. function sleepRandom(time){
  670. return new Promise(function(resolve, reject){
  671. setTimeout(resolve, time * 1e3, 0 | Math.random() * 1e3);
  672. });
  673. }
  674. console.log('Run'); // => Run
  675. sleepRandom(5).then(function(result){
  676. console.log(result); // => 869, after 5 sec.
  677. return sleepRandom(10);
  678. }).then(function(result){
  679. console.log(result); // => 202, after 10 sec.
  680. }).then(function(){
  681. console.log('immediately after'); // => immediately after
  682. throw Error('Irror!');
  683. }).then(function(){
  684. console.log('will not be displayed');
  685. }).catch(x => console.log(x)); // => => Error: Irror!
  686. ```
  687. `Promise.resolve` and `Promise.reject` [*example*](http://goo.gl/vr8TN3):
  688. ```js
  689. Promise.resolve(42).then(x => console.log(x)); // => 42
  690. Promise.reject(42).catch(x => console.log(x)); // => 42
  691. Promise.resolve($.getJSON('/data.json')); // => ES6 promise
  692. ```
  693. `Promise.all` [*example*](http://goo.gl/RdoDBZ):
  694. ```js
  695. Promise.all([
  696. 'foo',
  697. sleepRandom(5),
  698. sleepRandom(15),
  699. sleepRandom(10) // after 15 sec:
  700. ]).then(x => console.log(x)); // => ['foo', 956, 85, 382]
  701. ```
  702. `Promise.race` [*example*](http://goo.gl/L8ovkJ):
  703. ```js
  704. function timeLimit(promise, time){
  705. return Promise.race([promise, new Promise(function(resolve, reject){
  706. setTimeout(reject, time * 1e3, Error('Await > ' + time + ' sec'));
  707. })]);
  708. }
  709. timeLimit(sleepRandom(5), 10).then(x => console.log(x)); // => 853, after 5 sec.
  710. timeLimit(sleepRandom(15), 10).catch(x => console.log(x)); // Error: Await > 10 sec
  711. ```
  712. ECMAScript 7 [async functions](https://tc39.github.io/ecmascript-asyncawait) [example](http://goo.gl/wnQS4j):
  713. ```js
  714. var delay = time => new Promise(resolve => setTimeout(resolve, time))
  715. async function sleepRandom(time){
  716. await delay(time * 1e3);
  717. return 0 | Math.random() * 1e3;
  718. };
  719. async function sleepError(time, msg){
  720. await delay(time * 1e3);
  721. throw Error(msg);
  722. };
  723. (async () => {
  724. try {
  725. console.log('Run'); // => Run
  726. console.log(await sleepRandom(5)); // => 936, after 5 sec.
  727. var [a, b, c] = await Promise.all([
  728. sleepRandom(5),
  729. sleepRandom(15),
  730. sleepRandom(10)
  731. ]);
  732. console.log(a, b, c); // => 210 445 71, after 15 sec.
  733. await sleepError(5, 'Irror!');
  734. console.log('Will not be displayed');
  735. } catch(e){
  736. console.log(e); // => Error: 'Irror!', after 5 sec.
  737. }
  738. })();
  739. ```
  740. ##### Unhandled rejection tracking
  741. In Node.js, like in native implementation, available events [`unhandledRejection`](https://nodejs.org/api/process.html#process_event_unhandledrejection) and [`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled):
  742. ```js
  743. process.on('unhandledRejection', (reason, promise) => console.log('unhandled', reason, promise));
  744. process.on('rejectionHandled', (promise) => console.log('handled', promise));
  745. var p = Promise.reject(42);
  746. // unhandled 42 [object Promise]
  747. setTimeout(() => p.catch(_ => _), 1e3);
  748. // handled [object Promise]
  749. ```
  750. In a browser on rejection, by default, you will see notify in the console, or you can add a custom handler and a handler on handling unhandled, [*example*](http://goo.gl/Wozskl):
  751. ```js
  752. window.onunhandledrejection = e => console.log('unhandled', e.reason, e.promise);
  753. window.onrejectionhandled = e => console.log('handled', e.reason, e.promise);
  754. var p = Promise.reject(42);
  755. // unhandled 42 [object Promise]
  756. setTimeout(() => p.catch(_ => _), 1e3);
  757. // handled 42 [object Promise]
  758. ```
  759. #### ECMAScript 6: Symbol
  760. Module [`es6.symbol`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.symbol.js).
  761. ```js
  762. Symbol(description?) -> symbol
  763. .hasInstance -> @@hasInstance
  764. .isConcatSpreadable -> @@isConcatSpreadable
  765. .iterator -> @@iterator
  766. .match -> @@match
  767. .replace -> @@replace
  768. .search -> @@search
  769. .species -> @@species
  770. .split -> @@split
  771. .toPrimitive -> @@toPrimitive
  772. .toStringTag -> @@toStringTag
  773. .unscopables -> @@unscopables
  774. .for(key) -> symbol
  775. .keyFor(symbol) -> key
  776. .useSimple() -> void
  777. .useSetter() -> void
  778. Object
  779. .getOwnPropertySymbols(object) -> array
  780. ```
  781. Also wrapped some methods for correct work with `Symbol` polyfill.
  782. ```js
  783. Object
  784. .create(proto | null, descriptors?) -> object
  785. .defineProperty(target, key, desc) -> target
  786. .defineProperties(target, descriptors) -> target
  787. .getOwnPropertyDescriptor(var, key) -> desc | undefined
  788. .getOwnPropertyNames(var) -> array
  789. #propertyIsEnumerable(key) -> bool
  790. JSON
  791. .stringify(target, replacer?, space?) -> string | undefined
  792. ```
  793. [*CommonJS entry points:*](#commonjs)
  794. ```
  795. core-js(/library)/es6/symbol
  796. core-js(/library)/fn/symbol
  797. core-js(/library)/fn/symbol/has-instance
  798. core-js(/library)/fn/symbol/is-concat-spreadable
  799. core-js(/library)/fn/symbol/iterator
  800. core-js(/library)/fn/symbol/match
  801. core-js(/library)/fn/symbol/replace
  802. core-js(/library)/fn/symbol/search
  803. core-js(/library)/fn/symbol/species
  804. core-js(/library)/fn/symbol/split
  805. core-js(/library)/fn/symbol/to-primitive
  806. core-js(/library)/fn/symbol/to-string-tag
  807. core-js(/library)/fn/symbol/unscopables
  808. core-js(/library)/fn/symbol/for
  809. core-js(/library)/fn/symbol/key-for
  810. ```
  811. [*Basic example*](http://goo.gl/BbvWFc):
  812. ```js
  813. var Person = (function(){
  814. var NAME = Symbol('name');
  815. function Person(name){
  816. this[NAME] = name;
  817. }
  818. Person.prototype.getName = function(){
  819. return this[NAME];
  820. };
  821. return Person;
  822. })();
  823. var person = new Person('Vasya');
  824. console.log(person.getName()); // => 'Vasya'
  825. console.log(person['name']); // => undefined
  826. console.log(person[Symbol('name')]); // => undefined, symbols are uniq
  827. for(var key in person)console.log(key); // => only 'getName', symbols are not enumerable
  828. ```
  829. `Symbol.for` & `Symbol.keyFor` [*example*](http://goo.gl/0pdJjX):
  830. ```js
  831. var symbol = Symbol.for('key');
  832. symbol === Symbol.for('key'); // true
  833. Symbol.keyFor(symbol); // 'key'
  834. ```
  835. [*Example*](http://goo.gl/mKVOQJ) with methods for getting own object keys:
  836. ```js
  837. var O = {a: 1};
  838. Object.defineProperty(O, 'b', {value: 2});
  839. O[Symbol('c')] = 3;
  840. Object.keys(O); // => ['a']
  841. Object.getOwnPropertyNames(O); // => ['a', 'b']
  842. Object.getOwnPropertySymbols(O); // => [Symbol(c)]
  843. Reflect.ownKeys(O); // => ['a', 'b', Symbol(c)]
  844. ```
  845. ##### Caveats when using `Symbol` polyfill:
  846. * We can't add new primitive type, `Symbol` returns object.
  847. * `Symbol.for` and `Symbol.keyFor` can't be shimmed cross-realm.
  848. * By default, to hide the keys, `Symbol` polyfill defines setter in `Object.prototype`. For this reason, uncontrolled creation of symbols can cause memory leak and the `in` operator is not working correctly with `Symbol` polyfill: `Symbol() in {} // => true`.
  849. You can disable defining setters in `Object.prototype`. [Example](http://goo.gl/N5UD7J):
  850. ```js
  851. Symbol.useSimple();
  852. var s1 = Symbol('s1')
  853. , o1 = {};
  854. o1[s1] = true;
  855. for(var key in o1)console.log(key); // => 'Symbol(s1)_t.qamkg9f3q', w/o native Symbol
  856. Symbol.useSetter();
  857. var s2 = Symbol('s2')
  858. , o2 = {};
  859. o2[s2] = true;
  860. for(var key in o2)console.log(key); // nothing
  861. ```
  862. * Currently, `core-js` not adds setters to `Object.prototype` for well-known symbols for correct work something like `Symbol.iterator in foo`. It can cause problems with their enumerability.
  863. * Some problems possible with environment exotic objects (for example, IE `localStorage`).
  864. #### ECMAScript 6: Collections
  865. `core-js` uses native collections in most case, just fixes methods / constructor, if it's required, and in old environment uses fast polyfill (O(1) lookup).
  866. #### Map
  867. Module [`es6.map`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.map.js).
  868. ```js
  869. new Map(iterable (entries) ?) -> map
  870. #clear() -> void
  871. #delete(key) -> bool
  872. #forEach(fn(val, key, @), that) -> void
  873. #get(key) -> val
  874. #has(key) -> bool
  875. #set(key, val) -> @
  876. #size -> uint
  877. #values() -> iterator
  878. #keys() -> iterator
  879. #entries() -> iterator
  880. #@@iterator() -> iterator (entries)
  881. ```
  882. [*CommonJS entry points:*](#commonjs)
  883. ```
  884. core-js(/library)/es6/map
  885. core-js(/library)/fn/map
  886. ```
  887. [*Examples*](http://goo.gl/GWR7NI):
  888. ```js
  889. var a = [1];
  890. var map = new Map([['a', 1], [42, 2]]);
  891. map.set(a, 3).set(true, 4);
  892. console.log(map.size); // => 4
  893. console.log(map.has(a)); // => true
  894. console.log(map.has([1])); // => false
  895. console.log(map.get(a)); // => 3
  896. map.forEach(function(val, key){
  897. console.log(val); // => 1, 2, 3, 4
  898. console.log(key); // => 'a', 42, [1], true
  899. });
  900. map.delete(a);
  901. console.log(map.size); // => 3
  902. console.log(map.get(a)); // => undefined
  903. console.log(Array.from(map)); // => [['a', 1], [42, 2], [true, 4]]
  904. var map = new Map([['a', 1], ['b', 2], ['c', 3]]);
  905. for(var [key, val] of map){
  906. console.log(key); // => 'a', 'b', 'c'
  907. console.log(val); // => 1, 2, 3
  908. }
  909. for(var val of map.values())console.log(val); // => 1, 2, 3
  910. for(var key of map.keys())console.log(key); // => 'a', 'b', 'c'
  911. for(var [key, val] of map.entries()){
  912. console.log(key); // => 'a', 'b', 'c'
  913. console.log(val); // => 1, 2, 3
  914. }
  915. ```
  916. #### Set
  917. Module [`es6.set`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.set.js).
  918. ```js
  919. new Set(iterable?) -> set
  920. #add(key) -> @
  921. #clear() -> void
  922. #delete(key) -> bool
  923. #forEach(fn(el, el, @), that) -> void
  924. #has(key) -> bool
  925. #size -> uint
  926. #values() -> iterator
  927. #keys() -> iterator
  928. #entries() -> iterator
  929. #@@iterator() -> iterator (values)
  930. ```
  931. [*CommonJS entry points:*](#commonjs)
  932. ```
  933. core-js(/library)/es6/set
  934. core-js(/library)/fn/set
  935. ```
  936. [*Examples*](http://goo.gl/bmhLwg):
  937. ```js
  938. var set = new Set(['a', 'b', 'a', 'c']);
  939. set.add('d').add('b').add('e');
  940. console.log(set.size); // => 5
  941. console.log(set.has('b')); // => true
  942. set.forEach(function(it){
  943. console.log(it); // => 'a', 'b', 'c', 'd', 'e'
  944. });
  945. set.delete('b');
  946. console.log(set.size); // => 4
  947. console.log(set.has('b')); // => false
  948. console.log(Array.from(set)); // => ['a', 'c', 'd', 'e']
  949. var set = new Set([1, 2, 3, 2, 1]);
  950. for(var val of set)console.log(val); // => 1, 2, 3
  951. for(var val of set.values())console.log(val); // => 1, 2, 3
  952. for(var key of set.keys())console.log(key); // => 1, 2, 3
  953. for(var [key, val] of set.entries()){
  954. console.log(key); // => 1, 2, 3
  955. console.log(val); // => 1, 2, 3
  956. }
  957. ```
  958. #### WeakMap
  959. Module [`es6.weak-map`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.weak-map.js).
  960. ```js
  961. new WeakMap(iterable (entries) ?) -> weakmap
  962. #delete(key) -> bool
  963. #get(key) -> val
  964. #has(key) -> bool
  965. #set(key, val) -> @
  966. ```
  967. [*CommonJS entry points:*](#commonjs)
  968. ```
  969. core-js(/library)/es6/weak-map
  970. core-js(/library)/fn/weak-map
  971. ```
  972. [*Examples*](http://goo.gl/SILXyw):
  973. ```js
  974. var a = [1]
  975. , b = [2]
  976. , c = [3];
  977. var wmap = new WeakMap([[a, 1], [b, 2]]);
  978. wmap.set(c, 3).set(b, 4);
  979. console.log(wmap.has(a)); // => true
  980. console.log(wmap.has([1])); // => false
  981. console.log(wmap.get(a)); // => 1
  982. wmap.delete(a);
  983. console.log(wmap.get(a)); // => undefined
  984. // Private properties store:
  985. var Person = (function(){
  986. var names = new WeakMap;
  987. function Person(name){
  988. names.set(this, name);
  989. }
  990. Person.prototype.getName = function(){
  991. return names.get(this);
  992. };
  993. return Person;
  994. })();
  995. var person = new Person('Vasya');
  996. console.log(person.getName()); // => 'Vasya'
  997. for(var key in person)console.log(key); // => only 'getName'
  998. ```
  999. #### WeakSet
  1000. Module [`es6.weak-set`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.weak-set.js).
  1001. ```js
  1002. new WeakSet(iterable?) -> weakset
  1003. #add(key) -> @
  1004. #delete(key) -> bool
  1005. #has(key) -> bool
  1006. ```
  1007. [*CommonJS entry points:*](#commonjs)
  1008. ```
  1009. core-js(/library)/es6/weak-set
  1010. core-js(/library)/fn/weak-set
  1011. ```
  1012. [*Examples*](http://goo.gl/TdFbEx):
  1013. ```js
  1014. var a = [1]
  1015. , b = [2]
  1016. , c = [3];
  1017. var wset = new WeakSet([a, b, a]);
  1018. wset.add(c).add(b).add(c);
  1019. console.log(wset.has(b)); // => true
  1020. console.log(wset.has([2])); // => false
  1021. wset.delete(b);
  1022. console.log(wset.has(b)); // => false
  1023. ```
  1024. ##### Caveats when using collections polyfill:
  1025. * Weak-collections polyfill stores values as hidden properties of keys. It works correct and not leak in most cases. However, it is desirable to store a collection longer than its keys.
  1026. #### ECMAScript 6: Typed Arrays
  1027. Implementations and fixes `ArrayBuffer`, `DataView`, typed arrays constructors, static and prototype methods. Typed Arrays work only in environments with support descriptors (IE9+), `ArrayBuffer` and `DataView` should work anywhere.
  1028. Modules [`es6.typed.array-buffer`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.array-buffer.js), [`es6.typed.data-view`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.data-view.js), [`es6.typed.int8-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.int8-array.js), [`es6.typed.uint8-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.uint8-array.js), [`es6.typed.uint8-clamped-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.uint8-clamped-array.js), [`es6.typed.int16-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.int16-array.js), [`es6.typed.uint16-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.uint16-array.js), [`es6.typed.int32-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.int32-array.js), [`es6.typed.uint32-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.uint32-array.js), [`es6.typed.float32-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.float32-array.js) and [`es6.typed.float64-array`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.typed.float64-array.js).
  1029. ```js
  1030. new ArrayBuffer(length) -> buffer
  1031. .isView(var) -> bool
  1032. #slice(start = 0, end = @length) -> buffer
  1033. #byteLength -> uint
  1034. new DataView(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) -> view
  1035. #getInt8(offset) -> int8
  1036. #getUint8(offset) -> uint8
  1037. #getInt16(offset, littleEndian = false) -> int16
  1038. #getUint16(offset, littleEndian = false) -> uint16
  1039. #getInt32(offset, littleEndian = false) -> int32
  1040. #getUint32(offset, littleEndian = false) -> uint32
  1041. #getFloat32(offset, littleEndian = false) -> float32
  1042. #getFloat64(offset, littleEndian = false) -> float64
  1043. #setInt8(offset, value) -> void
  1044. #setUint8(offset, value) -> void
  1045. #setInt16(offset, value, littleEndian = false) -> void
  1046. #setUint16(offset, value, littleEndian = false) -> void
  1047. #setInt32(offset, value, littleEndian = false) -> void
  1048. #setUint32(offset, value, littleEndian = false) -> void
  1049. #setFloat32(offset, value, littleEndian = false) -> void
  1050. #setFloat64(offset, value, littleEndian = false) -> void
  1051. #buffer -> buffer
  1052. #byteLength -> uint
  1053. #byteOffset -> uint
  1054. {
  1055. Int8Array,
  1056. Uint8Array,
  1057. Uint8ClampedArray,
  1058. Int16Array,
  1059. Uint16Array,
  1060. Int32Array,
  1061. Uint32Array,
  1062. Float32Array,
  1063. Float64Array
  1064. }
  1065. new %TypedArray%(length) -> typed
  1066. new %TypedArray%(typed) -> typed
  1067. new %TypedArray%(arrayLike) -> typed
  1068. new %TypedArray%(iterable) -> typed
  1069. new %TypedArray%(buffer, byteOffset = 0, length = (buffer.byteLength - byteOffset) / @BYTES_PER_ELEMENT) -> typed
  1070. .BYTES_PER_ELEMENT -> uint
  1071. .from(arrayLike | iterable, mapFn(val, index)?, that) -> typed
  1072. .of(...args) -> typed
  1073. #BYTES_PER_ELEMENT -> uint
  1074. #copyWithin(target = 0, start = 0, end = @length) -> @
  1075. #every(fn(val, index, @), that) -> bool
  1076. #fill(val, start = 0, end = @length) -> @
  1077. #filter(fn(val, index, @), that) -> typed
  1078. #find(fn(val, index, @), that) -> val
  1079. #findIndex(fn(val, index, @), that) -> index
  1080. #forEach(fn(val, index, @), that) -> void
  1081. #indexOf(var, from?) -> int
  1082. #join(string = ',') -> string
  1083. #lastIndexOf(var, from?) -> int
  1084. #map(fn(val, index, @), that) -> typed
  1085. #reduce(fn(memo, val, index, @), memo?) -> var
  1086. #reduceRight(fn(memo, val, index, @), memo?) -> var
  1087. #reverse() -> @
  1088. #set(arrayLike, offset = 0) -> void
  1089. #slice(start = 0, end = @length) -> typed
  1090. #some(fn(val, index, @), that) -> bool
  1091. #sort(fn(a, b)?) -> @
  1092. #subarray(start = 0, end = @length) -> typed
  1093. #toString() -> string
  1094. #toLocaleString() -> string
  1095. #values() -> iterator
  1096. #keys() -> iterator
  1097. #entries() -> iterator
  1098. #@@iterator() -> iterator (values)
  1099. #buffer -> buffer
  1100. #byteLength -> uint
  1101. #byteOffset -> uint
  1102. #length -> uint
  1103. ```
  1104. [*CommonJS entry points:*](#commonjs)
  1105. ```
  1106. core-js(/library)/es6/typed
  1107. core-js(/library)/fn/typed
  1108. core-js(/library)/fn/typed/array-buffer
  1109. core-js(/library)/fn/typed/data-view
  1110. core-js(/library)/fn/typed/int8-array
  1111. core-js(/library)/fn/typed/uint8-array
  1112. core-js(/library)/fn/typed/uint8-clamped-array
  1113. core-js(/library)/fn/typed/int16-array
  1114. core-js(/library)/fn/typed/uint16-array
  1115. core-js(/library)/fn/typed/int32-array
  1116. core-js(/library)/fn/typed/uint32-array
  1117. core-js(/library)/fn/typed/float32-array
  1118. core-js(/library)/fn/typed/float64-array
  1119. ```
  1120. [*Examples*](http://goo.gl/yla75z):
  1121. ```js
  1122. new Int32Array(4); // => [0, 0, 0, 0]
  1123. new Uint8ClampedArray([1, 2, 3, 666]); // => [1, 2, 3, 255]
  1124. new Float32Array(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
  1125. var buffer = new ArrayBuffer(8);
  1126. var view = new DataView(buffer);
  1127. view.setFloat64(0, 123.456, true);
  1128. new Uint8Array(buffer.slice(4)); // => [47, 221, 94, 64]
  1129. Int8Array.of(1, 1.5, 5.7, 745); // => [1, 1, 5, -23]
  1130. Uint8Array.from([1, 1.5, 5.7, 745]); // => [1, 1, 5, 233]
  1131. var typed = new Uint8Array([1, 2, 3]);
  1132. var a = typed.slice(1); // => [2, 3]
  1133. typed.buffer === a.buffer; // => false
  1134. var b = typed.subarray(1); // => [2, 3]
  1135. typed.buffer === b.buffer; // => true
  1136. typed.filter(it => it % 2); // => [1, 3]
  1137. typed.map(it => it * 1.5); // => [1, 3, 4]
  1138. for(var val of typed)console.log(val); // => 1, 2, 3
  1139. for(var val of typed.values())console.log(val); // => 1, 2, 3
  1140. for(var key of typed.keys())console.log(key); // => 0, 1, 2
  1141. for(var [key, val] of typed.entries()){
  1142. console.log(key); // => 0, 1, 2
  1143. console.log(val); // => 1, 2, 3
  1144. }
  1145. ```
  1146. ##### Caveats when using typed arrays:
  1147. * Typed Arrays polyfills works completely how should work by the spec, but because of internal use getter / setters on each instance, is slow and consumes significant memory. However, typed arrays polyfills required mainly for IE9 (and for `Uint8ClampedArray` in IE10 and early IE11), all modern engines have native typed arrays and requires only constructors fixes and methods.
  1148. * The current version hasn't special entry points for methods, they can be added only with constructors. It can be added in the future.
  1149. * In the `library` version we can't pollute native prototypes, so prototype methods available as constructors static.
  1150. #### ECMAScript 6: Reflect
  1151. Modules [`es6.reflect.apply`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.apply.js), [`es6.reflect.construct`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.construct.js), [`es6.reflect.define-property`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.define-property.js), [`es6.reflect.delete-property`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.delete-property.js), [`es6.reflect.enumerate`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.enumerate.js), [`es6.reflect.get`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.get.js), [`es6.reflect.get-own-property-descriptor`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.get-own-property-descriptor.js), [`es6.reflect.get-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.get-prototype-of.js), [`es6.reflect.has`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.has.js), [`es6.reflect.is-extensible`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.is-extensible.js), [`es6.reflect.own-keys`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.own-keys.js), [`es6.reflect.prevent-extensions`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.prevent-extensions.js), [`es6.reflect.set`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.set.js), [`es6.reflect.set-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es6.reflect.set-prototype-of.js).
  1152. ```js
  1153. Reflect
  1154. .apply(target, thisArgument, argumentsList) -> var
  1155. .construct(target, argumentsList, newTarget?) -> object
  1156. .defineProperty(target, propertyKey, attributes) -> bool
  1157. .deleteProperty(target, propertyKey) -> bool
  1158. .enumerate(target) -> iterator (removed from the spec and will be removed from core-js@3)
  1159. .get(target, propertyKey, receiver?) -> var
  1160. .getOwnPropertyDescriptor(target, propertyKey) -> desc
  1161. .getPrototypeOf(target) -> object | null
  1162. .has(target, propertyKey) -> bool
  1163. .isExtensible(target) -> bool
  1164. .ownKeys(target) -> array
  1165. .preventExtensions(target) -> bool
  1166. .set(target, propertyKey, V, receiver?) -> bool
  1167. .setPrototypeOf(target, proto) -> bool (required __proto__ - IE11+)
  1168. ```
  1169. [*CommonJS entry points:*](#commonjs)
  1170. ```
  1171. core-js(/library)/es6/reflect
  1172. core-js(/library)/fn/reflect
  1173. core-js(/library)/fn/reflect/apply
  1174. core-js(/library)/fn/reflect/construct
  1175. core-js(/library)/fn/reflect/define-property
  1176. core-js(/library)/fn/reflect/delete-property
  1177. core-js(/library)/fn/reflect/enumerate (deprecated and will be removed from the next major release)
  1178. core-js(/library)/fn/reflect/get
  1179. core-js(/library)/fn/reflect/get-own-property-descriptor
  1180. core-js(/library)/fn/reflect/get-prototype-of
  1181. core-js(/library)/fn/reflect/has
  1182. core-js(/library)/fn/reflect/is-extensible
  1183. core-js(/library)/fn/reflect/own-keys
  1184. core-js(/library)/fn/reflect/prevent-extensions
  1185. core-js(/library)/fn/reflect/set
  1186. core-js(/library)/fn/reflect/set-prototype-of
  1187. ```
  1188. [*Examples*](http://goo.gl/gVT0cH):
  1189. ```js
  1190. var O = {a: 1};
  1191. Object.defineProperty(O, 'b', {value: 2});
  1192. O[Symbol('c')] = 3;
  1193. Reflect.ownKeys(O); // => ['a', 'b', Symbol(c)]
  1194. function C(a, b){
  1195. this.c = a + b;
  1196. }
  1197. var instance = Reflect.construct(C, [20, 22]);
  1198. instance.c; // => 42
  1199. ```
  1200. ### ECMAScript 7+ proposals
  1201. [The TC39 process.](https://tc39.github.io/process-document/)
  1202. [*CommonJS entry points:*](#commonjs)
  1203. ```
  1204. core-js(/library)/es7
  1205. core-js(/library)/es7/array
  1206. core-js(/library)/es7/global
  1207. core-js(/library)/es7/string
  1208. core-js(/library)/es7/map
  1209. core-js(/library)/es7/set
  1210. core-js(/library)/es7/error
  1211. core-js(/library)/es7/math
  1212. core-js(/library)/es7/system
  1213. core-js(/library)/es7/symbol
  1214. core-js(/library)/es7/reflect
  1215. core-js(/library)/es7/observable
  1216. ```
  1217. `core-js/stage/4` entry point contains only stage 4 proposals, `core-js/stage/3` - stage 3 and stage 4, etc.
  1218. #### Stage 4 proposals
  1219. [*CommonJS entry points:*](#commonjs)
  1220. ```js
  1221. core-js(/library)/stage/4
  1222. ```
  1223. * `{Array, %TypedArray%}#includes` [proposal](https://github.com/tc39/Array.prototype.includes) - module [`es7.array.includes`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.array.includes.js), `%TypedArray%` version in modules from [this section](#ecmascript-6-typed-arrays).
  1224. ```js
  1225. Array
  1226. #includes(var, from?) -> bool
  1227. {
  1228. Int8Array,
  1229. Uint8Array,
  1230. Uint8ClampedArray,
  1231. Int16Array,
  1232. Uint16Array,
  1233. Int32Array,
  1234. Uint32Array,
  1235. Float32Array,
  1236. Float64Array
  1237. }
  1238. #includes(var, from?) -> bool
  1239. ```
  1240. [*CommonJS entry points:*](#commonjs)
  1241. ```js
  1242. core-js(/library)/fn/array/includes
  1243. ```
  1244. [*Examples*](http://goo.gl/2Gq4ma):
  1245. ```js
  1246. [1, 2, 3].includes(2); // => true
  1247. [1, 2, 3].includes(4); // => false
  1248. [1, 2, 3].includes(2, 2); // => false
  1249. [NaN].indexOf(NaN); // => -1
  1250. [NaN].includes(NaN); // => true
  1251. Array(1).indexOf(undefined); // => -1
  1252. Array(1).includes(undefined); // => true
  1253. ```
  1254. * `Object.values`, `Object.entries` [proposal](https://github.com/tc39/proposal-object-values-entries) - modules [`es7.object.values`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.values.js), [`es7.object.entries`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.entries.js)
  1255. ```js
  1256. Object
  1257. .values(object) -> array
  1258. .entries(object) -> array
  1259. ```
  1260. [*CommonJS entry points:*](#commonjs)
  1261. ```js
  1262. core-js(/library)/fn/object/values
  1263. core-js(/library)/fn/object/entries
  1264. ```
  1265. [*Examples*](http://goo.gl/6kuGOn):
  1266. ```js
  1267. Object.values({a: 1, b: 2, c: 3}); // => [1, 2, 3]
  1268. Object.entries({a: 1, b: 2, c: 3}); // => [['a', 1], ['b', 2], ['c', 3]]
  1269. for(let [key, value] of Object.entries({a: 1, b: 2, c: 3})){
  1270. console.log(key); // => 'a', 'b', 'c'
  1271. console.log(value); // => 1, 2, 3
  1272. }
  1273. ```
  1274. * `Object.getOwnPropertyDescriptors` [proposal](https://github.com/tc39/proposal-object-getownpropertydescriptors) - module [`es7.object.get-own-property-descriptors`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.get-own-property-descriptors.js)
  1275. ```js
  1276. Object
  1277. .getOwnPropertyDescriptors(object) -> object
  1278. ```
  1279. [*CommonJS entry points:*](#commonjs)
  1280. ```js
  1281. core-js(/library)/fn/object/get-own-property-descriptors
  1282. ```
  1283. *Examples*:
  1284. ```js
  1285. // Shallow object cloning with prototype and descriptors:
  1286. var copy = Object.create(Object.getPrototypeOf(O), Object.getOwnPropertyDescriptors(O));
  1287. // Mixin:
  1288. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1289. ```
  1290. * `String#padStart`, `String#padEnd` [proposal](https://github.com/tc39/proposal-string-pad-start-end) - modules [`es7.string.pad-start`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.string.pad-start.js), [`es7.string.pad-end`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.string.pad-end.js)
  1291. ```js
  1292. String
  1293. #padStart(length, fillStr = ' ') -> string
  1294. #padEnd(length, fillStr = ' ') -> string
  1295. ```
  1296. [*CommonJS entry points:*](#commonjs)
  1297. ```js
  1298. core-js(/library)/fn/string/pad-start
  1299. core-js(/library)/fn/string/pad-end
  1300. core-js(/library)/fn/string/virtual/pad-start
  1301. core-js(/library)/fn/string/virtual/pad-end
  1302. ```
  1303. [*Examples*](http://goo.gl/hK5ccv):
  1304. ```js
  1305. 'hello'.padStart(10); // => ' hello'
  1306. 'hello'.padStart(10, '1234'); // => '12341hello'
  1307. 'hello'.padEnd(10); // => 'hello '
  1308. 'hello'.padEnd(10, '1234'); // => 'hello12341'
  1309. ```
  1310. * `Object#__(define|lookup)[GS]etter__`, [annex B ES2017](https://github.com/tc39/ecma262/pull/381), but we haven't special namespace for that - modules [`es7.object.define-setter`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.define-setter.js), [`es7.object.define-getter`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.define-getter.js), [`es7.object.lookup-setter`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.lookup-setter.js) and [`es7.object.lookup-getter`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.object.lookup-getter.js).
  1311. ```js
  1312. Object
  1313. #__defineSetter__(key, fn) -> void
  1314. #__defineGetter__(key, fn) -> void
  1315. #__lookupSetter__(key) -> fn | void
  1316. #__lookupGetter__(key) -> fn | void
  1317. ```
  1318. [*CommonJS entry points:*](#commonjs)
  1319. ```js
  1320. core-js(/library)/fn/object/define-getter
  1321. core-js(/library)/fn/object/define-setter
  1322. core-js(/library)/fn/object/lookup-getter
  1323. core-js(/library)/fn/object/lookup-setter
  1324. ```
  1325. #### Stage 3 proposals
  1326. [*CommonJS entry points:*](#commonjs)
  1327. ```js
  1328. core-js(/library)/stage/3
  1329. ```
  1330. * `global` [proposal](https://github.com/tc39/proposal-global) - modules [`es7.global`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.global.js) and [`es7.system.global`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.system.global.js) (obsolete)
  1331. ```js
  1332. global -> object
  1333. System
  1334. .global -> object (obsolete)
  1335. ```
  1336. [*CommonJS entry points:*](#commonjs)
  1337. ```js
  1338. core-js(/library)/fn/global
  1339. core-js(/library)/fn/system/global (obsolete)
  1340. ```
  1341. [*Examples*](http://goo.gl/gEqMl7):
  1342. ```js
  1343. global.Array === Array; // => true
  1344. ```
  1345. * `Promise#finally` [proposal](https://github.com/tc39/proposal-promise-finally) - module [`es7.promise.finally`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.promise.finally.js)
  1346. ```js
  1347. Promise
  1348. #finally(onFinally()) -> promise
  1349. ```
  1350. [*CommonJS entry points:*](#commonjs)
  1351. ```js
  1352. core-js(/library)/fn/promise/finally
  1353. ```
  1354. [*Examples*](https://goo.gl/AhyBbJ):
  1355. ```js
  1356. Promise.resolve(42).finally(() => console.log('You will see it anyway'));
  1357. Promise.reject(42).finally(() => console.log('You will see it anyway'));
  1358. #### Stage 2 proposals
  1359. [*CommonJS entry points:*](#commonjs)
  1360. ```js
  1361. core-js(/library)/stage/2
  1362. ```
  1363. * `String#trimLeft`, `String#trimRight` / `String#trimStart`, `String#trimEnd` [proposal](https://github.com/sebmarkbage/ecmascript-string-left-right-trim) - modules [`es7.string.trim-left`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.string.trim-right.js), [`es7.string.trim-right`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.string.trim-right.js)
  1364. ```js
  1365. String
  1366. #trimLeft() -> string
  1367. #trimRight() -> string
  1368. #trimStart() -> string
  1369. #trimEnd() -> string
  1370. ```
  1371. [*CommonJS entry points:*](#commonjs)
  1372. ```js
  1373. core-js(/library)/fn/string/trim-start
  1374. core-js(/library)/fn/string/trim-end
  1375. core-js(/library)/fn/string/trim-left
  1376. core-js(/library)/fn/string/trim-right
  1377. core-js(/library)/fn/string/virtual/trim-start
  1378. core-js(/library)/fn/string/virtual/trim-end
  1379. core-js(/library)/fn/string/virtual/trim-left
  1380. core-js(/library)/fn/string/virtual/trim-right
  1381. ```
  1382. [*Examples*](http://goo.gl/Er5lMJ):
  1383. ```js
  1384. ' hello '.trimLeft(); // => 'hello '
  1385. ' hello '.trimRight(); // => ' hello'
  1386. ```
  1387. ```
  1388. * `Symbol.asyncIterator` for [async iteration proposal](https://github.com/tc39/proposal-async-iteration) - module [`es7.symbol.async-iterator`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.symbol.async-iterator.js)
  1389. ```js
  1390. Symbol
  1391. .asyncIterator -> @@asyncIterator
  1392. ```
  1393. [*CommonJS entry points:*](#commonjs)
  1394. ```js
  1395. core-js(/library)/fn/symbol/async-iterator
  1396. ```
  1397. #### Stage 1 proposals
  1398. [*CommonJS entry points:*](#commonjs)
  1399. ```js
  1400. core-js(/library)/stage/1
  1401. ```
  1402. * `Promise.try` [proposal](https://github.com/tc39/proposal-promise-try) - module [`es7.promise.try`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.promise.try.js)
  1403. ```js
  1404. Promise
  1405. .try(function()) -> promise
  1406. ```
  1407. [*CommonJS entry points:*](#commonjs)
  1408. ```js
  1409. core-js(/library)/fn/promise/try
  1410. ```
  1411. [*Examples*](https://goo.gl/k5GGRo):
  1412. ```js
  1413. Promise.try(() => 42).then(it => console.log(`Promise, resolved as ${it}`));
  1414. Promise.try(() => { throw 42; }).catch(it => console.log(`Promise, rejected as ${it}`));
  1415. ```
  1416. * `Array#flatten` and `Array#flatMap` [proposal](https://tc39.github.io/proposal-flatMap) - modules [`es7.array.flatten`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.array.flatten.js) and [`es7.array.flat-map`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.array.flat-map.js)
  1417. ```js
  1418. Array
  1419. #flatten(depthArg = 1) -> array
  1420. #flatMap(fn(val, key, @), that) -> array
  1421. ```
  1422. [*CommonJS entry points:*](#commonjs)
  1423. ```js
  1424. core-js(/library)/fn/array/flatten
  1425. core-js(/library)/fn/array/flat-map
  1426. core-js(/library)/fn/array/virtual/flatten
  1427. core-js(/library)/fn/array/virtual/flat-map
  1428. ```
  1429. [*Examples*](https://goo.gl/jTXsZi):
  1430. ```js
  1431. [1, [2, 3], [4, 5]].flatten(); // => [1, 2, 3, 4, 5]
  1432. [1, [2, [3, [4]]], 5].flatten(); // => [1, 2, [3, [4]], 5]
  1433. [1, [2, [3, [4]]], 5].flatten(3); // => [1, 2, 3, 4, 5]
  1434. [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].flatMap(it => [it.a, it.b]); // => [1, 2, 3, 4, 5, 6]
  1435. ```
  1436. * `.of` and `.from` methods on collection constructors [proposal](https://github.com/tc39/proposal-setmap-offrom) - modules [`es7.set.of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.set.of.js), [`es7.set.from`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.set.from.js), [`es7.map.of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.map.of.js), [`es7.map.from`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.map.from.js), [`es7.weak-set.of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.weak-set.of.js), [`es7.weak-set.from`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.weak-set.from.js), [`es7.weak-map.of`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.weak-map.of.js), [`es7.weak-map.from`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.weak-map.from.js)
  1437. ```js
  1438. Set
  1439. .of(...args) -> set
  1440. .from(iterable, mapFn(val, index)?, that?) -> set
  1441. Map
  1442. .of(...args) -> map
  1443. .from(iterable, mapFn(val, index)?, that?) -> map
  1444. WeakSet
  1445. .of(...args) -> weakset
  1446. .from(iterable, mapFn(val, index)?, that?) -> weakset
  1447. WeakMap
  1448. .of(...args) -> weakmap
  1449. .from(iterable, mapFn(val, index)?, that?) -> weakmap
  1450. ```
  1451. [*CommonJS entry points:*](#commonjs)
  1452. ```js
  1453. core-js(/library)/fn/set/of
  1454. core-js(/library)/fn/set/from
  1455. core-js(/library)/fn/map/of
  1456. core-js(/library)/fn/map/from
  1457. core-js(/library)/fn/weak-set/of
  1458. core-js(/library)/fn/weak-set/from
  1459. core-js(/library)/fn/weak-map/of
  1460. core-js(/library)/fn/weak-map/from
  1461. ```
  1462. [*Examples*](https://goo.gl/mSC7eU):
  1463. ```js
  1464. Set.of(1, 2, 3, 2, 1); // => Set {1, 2, 3}
  1465. Map.from([[1, 2], [3, 4]], ([key, val]) => [key ** 2, val ** 2]); // => Map {1: 4, 9: 16}
  1466. ```
  1467. * `String#matchAll` [proposal](https://github.com/tc39/String.prototype.matchAll) - module [`es7.string.match-all`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.string.match-all.js)
  1468. ```js
  1469. String
  1470. #matchAll(regexp) -> iterator
  1471. ```
  1472. [*CommonJS entry points:*](#commonjs)
  1473. ```js
  1474. core-js(/library)/fn/string/match-all
  1475. core-js(/library)/fn/string/virtual/match-all
  1476. ```
  1477. [*Examples*](http://goo.gl/6kp9EB):
  1478. ```js
  1479. for(let [_, d, D] of '1111a2b3cccc'.matchAll(/(\d)(\D)/)){
  1480. console.log(d, D); // => 1 a, 2 b, 3 c
  1481. }
  1482. ```
  1483. * `Observable` [proposal](https://github.com/zenparsing/es-observable) - modules [`es7.observable`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.observable.js) and [`es7.symbol.observable`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.symbol.observable.js)
  1484. ```js
  1485. new Observable(fn) -> observable
  1486. #subscribe(observer) -> subscription
  1487. #forEach(fn) -> promise
  1488. #@@observable() -> @
  1489. .of(...items) -> observable
  1490. .from(observable | iterable) -> observable
  1491. .@@species -> @
  1492. Symbol
  1493. .observable -> @@observable
  1494. ```
  1495. [*CommonJS entry points:*](#commonjs)
  1496. ```js
  1497. core-js(/library)/fn/observable
  1498. core-js(/library)/fn/symbol/observable
  1499. ```
  1500. [*Examples*](http://goo.gl/1LDywi):
  1501. ```js
  1502. new Observable(observer => {
  1503. observer.next('hello');
  1504. observer.next('world');
  1505. observer.complete();
  1506. }).forEach(it => console.log(it))
  1507. .then(_ => console.log('!'));
  1508. ```
  1509. * `Math.{clamp, DEG_PER_RAD, degrees, fscale, rad-per-deg, radians, scale}`
  1510. [proposal](https://github.com/rwaldron/proposal-math-extensions) - modules
  1511. [`es7.math.clamp`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.clamp.js),
  1512. [`es7.math.DEG_PER_RAD`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.DEG_PER_RAD.js),
  1513. [`es7.math.degrees`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.degrees.js),
  1514. [`es7.math.fscale`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.fscale.js),
  1515. [`es7.math.RAD_PER_DEG`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.RAD_PER_DEG.js),
  1516. [`es7.math.radians`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.radians.js) and
  1517. [`es7.math.scale`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.scale.js)
  1518. ```js
  1519. Math
  1520. .DEG_PER_RAD -> number
  1521. .RAD_PER_DEG -> number
  1522. .clamp(x, lower, upper) -> number
  1523. .degrees(radians) -> number
  1524. .fscale(x, inLow, inHigh, outLow, outHigh) -> number
  1525. .radians(degrees) -> number
  1526. .scale(x, inLow, inHigh, outLow, outHigh) -> number
  1527. ```
  1528. [*CommonJS entry points:*](#commonjs)
  1529. ```js
  1530. core-js(/library)/fn/math/clamp
  1531. core-js(/library)/fn/math/deg-per-rad
  1532. core-js(/library)/fn/math/degrees
  1533. core-js(/library)/fn/math/fscale
  1534. core-js(/library)/fn/math/rad-per-deg
  1535. core-js(/library)/fn/math/radians
  1536. core-js(/library)/fn/math/scale
  1537. ```
  1538. * `Math.signbit` [proposal](http://jfbastien.github.io/papers/Math.signbit.html) - module [`es7.math.signbit`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.signbit.js)
  1539. ```js
  1540. Math
  1541. .signbit(x) -> bool
  1542. ```
  1543. [*CommonJS entry points:*](#commonjs)
  1544. ```js
  1545. core-js(/library)/fn/math/signbit
  1546. ```
  1547. [*Examples*](http://es6.zloirock.ru/):
  1548. ```js
  1549. Math.signbit(NaN); // => NaN
  1550. Math.signbit(1); // => true
  1551. Math.signbit(-1); // => false
  1552. Math.signbit(0); // => true
  1553. Math.signbit(-0); // => false
  1554. ```
  1555. #### Stage 0 proposals
  1556. [*CommonJS entry points:*](#commonjs)
  1557. ```js
  1558. core-js(/library)/stage/0
  1559. ```
  1560. * `String#at` [proposal](https://github.com/mathiasbynens/String.prototype.at) - module [`es7.string.at`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.string.at.js)
  1561. ```js
  1562. String
  1563. #at(index) -> string
  1564. ```
  1565. [*CommonJS entry points:*](#commonjs)
  1566. ```js
  1567. core-js(/library)/fn/string/at
  1568. core-js(/library)/fn/string/virtual/at
  1569. ```
  1570. [*Examples*](http://goo.gl/XluXI8):
  1571. ```js
  1572. 'a𠮷b'.at(1); // => '𠮷'
  1573. 'a𠮷b'.at(1).length; // => 2
  1574. ```
  1575. * `Map#toJSON`, `Set#toJSON` [proposal](https://github.com/DavidBruant/Map-Set.prototype.toJSON) - modules [`es7.map.to-json`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.map.to-json.js), [`es7.set.to-json`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.set.to-json.js) (rejected and will be removed from `core-js@3`)
  1576. ```js
  1577. Map
  1578. #toJSON() -> array (rejected and will be removed from core-js@3)
  1579. Set
  1580. #toJSON() -> array (rejected and will be removed from core-js@3)
  1581. ```
  1582. [*CommonJS entry points:*](#commonjs)
  1583. ```js
  1584. core-js(/library)/fn/map
  1585. core-js(/library)/fn/set
  1586. ```
  1587. * `Error.isError` [proposal](https://github.com/ljharb/proposal-is-error) - module [`es7.error.is-error`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.error.is-error.js) (withdrawn and will be removed from `core-js@3`)
  1588. ```js
  1589. Error
  1590. .isError(it) -> bool (withdrawn and will be removed from core-js@3)
  1591. ```
  1592. [*CommonJS entry points:*](#commonjs)
  1593. ```js
  1594. core-js(/library)/fn/error/is-error
  1595. ```
  1596. * `Math.{iaddh, isubh, imulh, umulh}` [proposal](https://gist.github.com/BrendanEich/4294d5c212a6d2254703) - modules [`es7.math.iaddh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.iaddh.js), [`es7.math.isubh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.isubh.js), [`es7.math.imulh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.imulh.js) and [`es7.math.umulh`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.math.umulh.js)
  1597. ```js
  1598. Math
  1599. .iaddh(lo0, hi0, lo1, hi1) -> int32
  1600. .isubh(lo0, hi0, lo1, hi1) -> int32
  1601. .imulh(a, b) -> int32
  1602. .umulh(a, b) -> uint32
  1603. ```
  1604. [*CommonJS entry points:*](#commonjs)
  1605. ```js
  1606. core-js(/library)/fn/math/iaddh
  1607. core-js(/library)/fn/math/isubh
  1608. core-js(/library)/fn/math/imulh
  1609. core-js(/library)/fn/math/umulh
  1610. ```
  1611. * `global.asap`, [TC39 discussion](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask), module [`es7.asap`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.asap.js)
  1612. ```js
  1613. asap(fn) -> void
  1614. ```
  1615. [*CommonJS entry points:*](#commonjs)
  1616. ```js
  1617. core-js(/library)/fn/asap
  1618. ```
  1619. [*Examples*](http://goo.gl/tx3SRK):
  1620. ```js
  1621. asap(() => console.log('called as microtask'));
  1622. ```
  1623. #### Pre-stage 0 proposals
  1624. [*CommonJS entry points:*](#commonjs)
  1625. ```js
  1626. core-js(/library)/stage/pre
  1627. ```
  1628. * `Reflect` metadata [proposal](https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md) - modules [`es7.reflect.define-metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.define-metadata.js), [`es7.reflect.delete-metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.delete-metadata.js), [`es7.reflect.get-metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.get-metadata.js), [`es7.reflect.get-metadata-keys`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.get-metadata-keys.js), [`es7.reflect.get-own-metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.get-own-metadata.js), [`es7.reflect.get-own-metadata-keys`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.get-own-metadata-keys.js), [`es7.reflect.has-metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.has-metadata.js), [`es7.reflect.has-own-metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.has-own-metadata.js) and [`es7.reflect.metadata`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/es7.reflect.metadata.js).
  1629. ```js
  1630. Reflect
  1631. .defineMetadata(metadataKey, metadataValue, target, propertyKey?) -> void
  1632. .getMetadata(metadataKey, target, propertyKey?) -> var
  1633. .getOwnMetadata(metadataKey, target, propertyKey?) -> var
  1634. .hasMetadata(metadataKey, target, propertyKey?) -> bool
  1635. .hasOwnMetadata(metadataKey, target, propertyKey?) -> bool
  1636. .deleteMetadata(metadataKey, target, propertyKey?) -> bool
  1637. .getMetadataKeys(target, propertyKey?) -> array
  1638. .getOwnMetadataKeys(target, propertyKey?) -> array
  1639. .metadata(metadataKey, metadataValue) -> decorator(target, targetKey?) -> void
  1640. ```
  1641. [*CommonJS entry points:*](#commonjs)
  1642. ```js
  1643. core-js(/library)/fn/reflect/define-metadata
  1644. core-js(/library)/fn/reflect/delete-metadata
  1645. core-js(/library)/fn/reflect/get-metadata
  1646. core-js(/library)/fn/reflect/get-metadata-keys
  1647. core-js(/library)/fn/reflect/get-own-metadata
  1648. core-js(/library)/fn/reflect/get-own-metadata-keys
  1649. core-js(/library)/fn/reflect/has-metadata
  1650. core-js(/library)/fn/reflect/has-own-metadata
  1651. core-js(/library)/fn/reflect/metadata
  1652. ```
  1653. [*Examples*](http://goo.gl/KCo3PS):
  1654. ```js
  1655. var O = {};
  1656. Reflect.defineMetadata('foo', 'bar', O);
  1657. Reflect.ownKeys(O); // => []
  1658. Reflect.getOwnMetadataKeys(O); // => ['foo']
  1659. Reflect.getOwnMetadata('foo', O); // => 'bar'
  1660. ```
  1661. ### Web standards
  1662. [*CommonJS entry points:*](#commonjs)
  1663. ```js
  1664. core-js(/library)/web
  1665. ```
  1666. #### setTimeout / setInterval
  1667. Module [`web.timers`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/web.timers.js). Additional arguments fix for IE9-.
  1668. ```js
  1669. setTimeout(fn(...args), time, ...args) -> id
  1670. setInterval(fn(...args), time, ...args) -> id
  1671. ```
  1672. [*CommonJS entry points:*](#commonjs)
  1673. ```js
  1674. core-js(/library)/web/timers
  1675. core-js(/library)/fn/set-timeout
  1676. core-js(/library)/fn/set-interval
  1677. ```
  1678. ```js
  1679. // Before:
  1680. setTimeout(log.bind(null, 42), 1000);
  1681. // After:
  1682. setTimeout(log, 1000, 42);
  1683. ```
  1684. #### setImmediate
  1685. Module [`web.immediate`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/web.immediate.js). [`setImmediate` proposal](https://developer.mozilla.org/en-US/docs/Web/API/Window.setImmediate) polyfill.
  1686. ```js
  1687. setImmediate(fn(...args), ...args) -> id
  1688. clearImmediate(id) -> void
  1689. ```
  1690. [*CommonJS entry points:*](#commonjs)
  1691. ```js
  1692. core-js(/library)/web/immediate
  1693. core-js(/library)/fn/set-immediate
  1694. core-js(/library)/fn/clear-immediate
  1695. ```
  1696. [*Examples*](http://goo.gl/6nXGrx):
  1697. ```js
  1698. setImmediate(function(arg1, arg2){
  1699. console.log(arg1, arg2); // => Message will be displayed with minimum delay
  1700. }, 'Message will be displayed', 'with minimum delay');
  1701. clearImmediate(setImmediate(function(){
  1702. console.log('Message will not be displayed');
  1703. }));
  1704. ```
  1705. #### Iterable DOM collections
  1706. Some DOM collections should have [iterable interface](https://heycam.github.io/webidl/#idl-iterable) or should be [inherited from `Array`](https://heycam.github.io/webidl/#LegacyArrayClass). That mean they should have `keys`, `values`, `entries` and `@@iterator` methods for iteration. So add them. Module [`web.dom.iterable`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/web.dom.iterable.js):
  1707. ```js
  1708. {
  1709. CSSRuleList,
  1710. CSSStyleDeclaration,
  1711. CSSValueList,
  1712. ClientRectList,
  1713. DOMRectList,
  1714. DOMStringList,
  1715. DOMTokenList,
  1716. DataTransferItemList,
  1717. FileList,
  1718. HTMLAllCollection,
  1719. HTMLCollection,
  1720. HTMLFormElement,
  1721. HTMLSelectElement,
  1722. MediaList,
  1723. MimeTypeArray,
  1724. NamedNodeMap,
  1725. NodeList,
  1726. PaintRequestList,
  1727. Plugin,
  1728. PluginArray,
  1729. SVGLengthList,
  1730. SVGNumberList,
  1731. SVGPathSegList,
  1732. SVGPointList,
  1733. SVGStringList,
  1734. SVGTransformList,
  1735. SourceBufferList,
  1736. StyleSheetList,
  1737. TextTrackCueList,
  1738. TextTrackList,
  1739. TouchList
  1740. }
  1741. #@@iterator() -> iterator (values)
  1742. {
  1743. DOMTokenList,
  1744. NodeList
  1745. }
  1746. #values() -> iterator
  1747. #keys() -> iterator
  1748. #entries() -> iterator
  1749. ```
  1750. [*CommonJS entry points:*](#commonjs)
  1751. ```js
  1752. core-js(/library)/web/dom-collections
  1753. core-js(/library)/fn/dom-collections/iterator
  1754. ```
  1755. [*Examples*](http://goo.gl/lfXVFl):
  1756. ```js
  1757. for(var {id} of document.querySelectorAll('*')){
  1758. if(id)console.log(id);
  1759. }
  1760. for(var [index, {id}] of document.querySelectorAll('*').entries()){
  1761. if(id)console.log(index, id);
  1762. }
  1763. ```
  1764. ### Non-standard
  1765. [*CommonJS entry points:*](#commonjs)
  1766. ```js
  1767. core-js(/library)/core
  1768. ```
  1769. #### Object
  1770. Modules [`core.object.is-object`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.object.is-object.js), [`core.object.classof`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.object.classof.js), [`core.object.define`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.object.define.js), [`core.object.make`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.object.make.js).
  1771. ```js
  1772. Object
  1773. .isObject(var) -> bool
  1774. .classof(var) -> string
  1775. .define(target, mixin) -> target
  1776. .make(proto | null, mixin?) -> object
  1777. ```
  1778. [*CommonJS entry points:*](#commonjs)
  1779. ```js
  1780. core-js(/library)/core/object
  1781. core-js(/library)/fn/object/is-object
  1782. core-js(/library)/fn/object/define
  1783. core-js(/library)/fn/object/make
  1784. ```
  1785. Object classify [*examples*](http://goo.gl/YZQmGo):
  1786. ```js
  1787. Object.isObject({}); // => true
  1788. Object.isObject(isNaN); // => true
  1789. Object.isObject(null); // => false
  1790. var classof = Object.classof;
  1791. classof(null); // => 'Null'
  1792. classof(undefined); // => 'Undefined'
  1793. classof(1); // => 'Number'
  1794. classof(true); // => 'Boolean'
  1795. classof('string'); // => 'String'
  1796. classof(Symbol()); // => 'Symbol'
  1797. classof(new Number(1)); // => 'Number'
  1798. classof(new Boolean(true)); // => 'Boolean'
  1799. classof(new String('string')); // => 'String'
  1800. var fn = function(){}
  1801. , list = (function(){return arguments})(1, 2, 3);
  1802. classof({}); // => 'Object'
  1803. classof(fn); // => 'Function'
  1804. classof([]); // => 'Array'
  1805. classof(list); // => 'Arguments'
  1806. classof(/./); // => 'RegExp'
  1807. classof(new TypeError); // => 'Error'
  1808. classof(new Set); // => 'Set'
  1809. classof(new Map); // => 'Map'
  1810. classof(new WeakSet); // => 'WeakSet'
  1811. classof(new WeakMap); // => 'WeakMap'
  1812. classof(new Promise(fn)); // => 'Promise'
  1813. classof([].values()); // => 'Array Iterator'
  1814. classof(new Set().values()); // => 'Set Iterator'
  1815. classof(new Map().values()); // => 'Map Iterator'
  1816. classof(Math); // => 'Math'
  1817. classof(JSON); // => 'JSON'
  1818. function Example(){}
  1819. Example.prototype[Symbol.toStringTag] = 'Example';
  1820. classof(new Example); // => 'Example'
  1821. ```
  1822. `Object.define` and `Object.make` [*examples*](http://goo.gl/rtpD5Z):
  1823. ```js
  1824. // Before:
  1825. Object.defineProperty(target, 'c', {
  1826. enumerable: true,
  1827. configurable: true,
  1828. get: function(){
  1829. return this.a + this.b;
  1830. }
  1831. });
  1832. // After:
  1833. Object.define(target, {
  1834. get c(){
  1835. return this.a + this.b;
  1836. }
  1837. });
  1838. // Shallow object cloning with prototype and descriptors:
  1839. var copy = Object.make(Object.getPrototypeOf(src), src);
  1840. // Simple inheritance:
  1841. function Vector2D(x, y){
  1842. this.x = x;
  1843. this.y = y;
  1844. }
  1845. Object.define(Vector2D.prototype, {
  1846. get xy(){
  1847. return Math.hypot(this.x, this.y);
  1848. }
  1849. });
  1850. function Vector3D(x, y, z){
  1851. Vector2D.apply(this, arguments);
  1852. this.z = z;
  1853. }
  1854. Vector3D.prototype = Object.make(Vector2D.prototype, {
  1855. constructor: Vector3D,
  1856. get xyz(){
  1857. return Math.hypot(this.x, this.y, this.z);
  1858. }
  1859. });
  1860. var vector = new Vector3D(9, 12, 20);
  1861. console.log(vector.xy); // => 15
  1862. console.log(vector.xyz); // => 25
  1863. vector.y++;
  1864. console.log(vector.xy); // => 15.811388300841896
  1865. console.log(vector.xyz); // => 25.495097567963924
  1866. ```
  1867. #### Dict
  1868. Module [`core.dict`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.dict.js). Based on [TC39 discuss](https://github.com/rwaldron/tc39-notes/blob/master/es6/2012-11/nov-29.md#collection-apis-review) / [strawman](http://wiki.ecmascript.org/doku.php?id=harmony:modules_standard#dictionaries).
  1869. ```js
  1870. [new] Dict(iterable (entries) | object ?) -> dict
  1871. .isDict(var) -> bool
  1872. .values(object) -> iterator
  1873. .keys(object) -> iterator
  1874. .entries(object) -> iterator (entries)
  1875. .has(object, key) -> bool
  1876. .get(object, key) -> val
  1877. .set(object, key, value) -> object
  1878. .forEach(object, fn(val, key, @), that) -> void
  1879. .map(object, fn(val, key, @), that) -> new @
  1880. .mapPairs(object, fn(val, key, @), that) -> new @
  1881. .filter(object, fn(val, key, @), that) -> new @
  1882. .some(object, fn(val, key, @), that) -> bool
  1883. .every(object, fn(val, key, @), that) -> bool
  1884. .find(object, fn(val, key, @), that) -> val
  1885. .findKey(object, fn(val, key, @), that) -> key
  1886. .keyOf(object, var) -> key
  1887. .includes(object, var) -> bool
  1888. .reduce(object, fn(memo, val, key, @), memo?) -> var
  1889. ```
  1890. [*CommonJS entry points:*](#commonjs)
  1891. ```js
  1892. core-js(/library)/core/dict
  1893. core-js(/library)/fn/dict
  1894. ```
  1895. `Dict` create object without prototype from iterable or simple object.
  1896. [*Examples*](http://goo.gl/pnp8Vr):
  1897. ```js
  1898. var map = new Map([['a', 1], ['b', 2], ['c', 3]]);
  1899. Dict(); // => {__proto__: null}
  1900. Dict({a: 1, b: 2, c: 3}); // => {__proto__: null, a: 1, b: 2, c: 3}
  1901. Dict(map); // => {__proto__: null, a: 1, b: 2, c: 3}
  1902. Dict([1, 2, 3].entries()); // => {__proto__: null, 0: 1, 1: 2, 2: 3}
  1903. var dict = Dict({a: 42});
  1904. dict instanceof Object; // => false
  1905. dict.a; // => 42
  1906. dict.toString; // => undefined
  1907. 'a' in dict; // => true
  1908. 'hasOwnProperty' in dict; // => false
  1909. Dict.isDict({}); // => false
  1910. Dict.isDict(Dict()); // => true
  1911. ```
  1912. `Dict.keys`, `Dict.values` and `Dict.entries` returns iterators for objects.
  1913. [*Examples*](http://goo.gl/xAvECH):
  1914. ```js
  1915. var dict = {a: 1, b: 2, c: 3};
  1916. for(var key of Dict.keys(dict))console.log(key); // => 'a', 'b', 'c'
  1917. for(var val of Dict.values(dict))console.log(val); // => 1, 2, 3
  1918. for(var [key, val] of Dict.entries(dict)){
  1919. console.log(key); // => 'a', 'b', 'c'
  1920. console.log(val); // => 1, 2, 3
  1921. }
  1922. new Map(Dict.entries(dict)); // => Map {a: 1, b: 2, c: 3}
  1923. ```
  1924. Basic dict operations for objects with prototype [*examples*](http://goo.gl/B28UnG):
  1925. ```js
  1926. 'q' in {q: 1}; // => true
  1927. 'toString' in {}; // => true
  1928. Dict.has({q: 1}, 'q'); // => true
  1929. Dict.has({}, 'toString'); // => false
  1930. ({q: 1})['q']; // => 1
  1931. ({}).toString; // => function toString(){ [native code] }
  1932. Dict.get({q: 1}, 'q'); // => 1
  1933. Dict.get({}, 'toString'); // => undefined
  1934. var O = {};
  1935. O['q'] = 1;
  1936. O['q']; // => 1
  1937. O['__proto__'] = {w: 2};
  1938. O['__proto__']; // => {w: 2}
  1939. O['w']; // => 2
  1940. var O = {};
  1941. Dict.set(O, 'q', 1);
  1942. O['q']; // => 1
  1943. Dict.set(O, '__proto__', {w: 2});
  1944. O['__proto__']; // => {w: 2}
  1945. O['w']; // => undefined
  1946. ```
  1947. Other methods of `Dict` module are static equivalents of `Array.prototype` methods for dictionaries.
  1948. [*Examples*](http://goo.gl/xFi1RH):
  1949. ```js
  1950. var dict = {a: 1, b: 2, c: 3};
  1951. Dict.forEach(dict, console.log, console);
  1952. // => 1, 'a', {a: 1, b: 2, c: 3}
  1953. // => 2, 'b', {a: 1, b: 2, c: 3}
  1954. // => 3, 'c', {a: 1, b: 2, c: 3}
  1955. Dict.map(dict, function(it){
  1956. return it * it;
  1957. }); // => {a: 1, b: 4, c: 9}
  1958. Dict.mapPairs(dict, function(val, key){
  1959. if(key != 'b')return [key + key, val * val];
  1960. }); // => {aa: 1, cc: 9}
  1961. Dict.filter(dict, function(it){
  1962. return it % 2;
  1963. }); // => {a: 1, c: 3}
  1964. Dict.some(dict, function(it){
  1965. return it === 2;
  1966. }); // => true
  1967. Dict.every(dict, function(it){
  1968. return it === 2;
  1969. }); // => false
  1970. Dict.find(dict, function(it){
  1971. return it > 2;
  1972. }); // => 3
  1973. Dict.find(dict, function(it){
  1974. return it > 4;
  1975. }); // => undefined
  1976. Dict.findKey(dict, function(it){
  1977. return it > 2;
  1978. }); // => 'c'
  1979. Dict.findKey(dict, function(it){
  1980. return it > 4;
  1981. }); // => undefined
  1982. Dict.keyOf(dict, 2); // => 'b'
  1983. Dict.keyOf(dict, 4); // => undefined
  1984. Dict.includes(dict, 2); // => true
  1985. Dict.includes(dict, 4); // => false
  1986. Dict.reduce(dict, function(memo, it){
  1987. return memo + it;
  1988. }); // => 6
  1989. Dict.reduce(dict, function(memo, it){
  1990. return memo + it;
  1991. }, ''); // => '123'
  1992. ```
  1993. #### Partial application
  1994. Module [`core.function.part`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.function.part.js).
  1995. ```js
  1996. Function
  1997. #part(...args | _) -> fn(...args)
  1998. ```
  1999. [*CommonJS entry points:*](#commonjs)
  2000. ```js
  2001. core-js/core/function
  2002. core-js(/library)/fn/function/part
  2003. core-js(/library)/fn/function/virtual/part
  2004. core-js(/library)/fn/_
  2005. ```
  2006. `Function#part` partial apply function without `this` binding. Uses global variable `_` (`core._` for builds without global namespace pollution) as placeholder and not conflict with `Underscore` / `LoDash`.
  2007. [*Examples*](http://goo.gl/p9ZJ8K):
  2008. ```js
  2009. var fn1 = log.part(1, 2);
  2010. fn1(3, 4); // => 1, 2, 3, 4
  2011. var fn2 = log.part(_, 2, _, 4);
  2012. fn2(1, 3); // => 1, 2, 3, 4
  2013. var fn3 = log.part(1, _, _, 4);
  2014. fn3(2, 3); // => 1, 2, 3, 4
  2015. fn2(1, 3, 5); // => 1, 2, 3, 4, 5
  2016. fn2(1); // => 1, 2, undefined, 4
  2017. ```
  2018. #### Number Iterator
  2019. Module [`core.number.iterator`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.number.iterator.js).
  2020. ```js
  2021. Number
  2022. #@@iterator() -> iterator
  2023. ```
  2024. [*CommonJS entry points:*](#commonjs)
  2025. ```js
  2026. core-js(/library)/core/number
  2027. core-js(/library)/fn/number/iterator
  2028. core-js(/library)/fn/number/virtual/iterator
  2029. ```
  2030. [*Examples*](http://goo.gl/o45pCN):
  2031. ```js
  2032. for(var i of 3)console.log(i); // => 0, 1, 2
  2033. [...10]; // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  2034. Array.from(10, Math.random); // => [0.9817775336559862, 0.02720663254149258, ...]
  2035. Array.from(10, function(it){
  2036. return this + it * it;
  2037. }, .42); // => [0.42, 1.42, 4.42, 9.42, 16.42, 25.42, 36.42, 49.42, 64.42, 81.42]
  2038. ```
  2039. #### Escaping strings
  2040. Modules [`core.regexp.escape`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.regexp.escape.js), [`core.string.escape-html`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.string.escape-html.js) and [`core.string.unescape-html`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.string.unescape-html.js).
  2041. ```js
  2042. RegExp
  2043. .escape(str) -> str
  2044. String
  2045. #escapeHTML() -> str
  2046. #unescapeHTML() -> str
  2047. ```
  2048. [*CommonJS entry points:*](#commonjs)
  2049. ```js
  2050. core-js(/library)/core/regexp
  2051. core-js(/library)/core/string
  2052. core-js(/library)/fn/regexp/escape
  2053. core-js(/library)/fn/string/escape-html
  2054. core-js(/library)/fn/string/unescape-html
  2055. core-js(/library)/fn/string/virtual/escape-html
  2056. core-js(/library)/fn/string/virtual/unescape-html
  2057. ```
  2058. [*Examples*](http://goo.gl/6bOvsQ):
  2059. ```js
  2060. RegExp.escape('Hello, []{}()*+?.\\^$|!'); // => 'Hello, \[\]\{\}\(\)\*\+\?\.\\\^\$\|!'
  2061. '<script>doSomething();</script>'.escapeHTML(); // => '&lt;script&gt;doSomething();&lt;/script&gt;'
  2062. '&lt;script&gt;doSomething();&lt;/script&gt;'.unescapeHTML(); // => '<script>doSomething();</script>'
  2063. ```
  2064. #### delay
  2065. Module [`core.delay`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.delay.js). [Promise](#ecmascript-6-promise)-returning delay function, [esdiscuss](https://esdiscuss.org/topic/promise-returning-delay-function).
  2066. ```js
  2067. delay(ms) -> promise
  2068. ```
  2069. [*CommonJS entry points:*](#commonjs)
  2070. ```js
  2071. core-js(/library)/core/delay
  2072. core-js(/library)/fn/delay
  2073. ```
  2074. [*Examples*](http://goo.gl/lbucba):
  2075. ```js
  2076. delay(1e3).then(() => console.log('after 1 sec'));
  2077. (async () => {
  2078. await delay(3e3);
  2079. console.log('after 3 sec');
  2080. while(await delay(3e3))console.log('each 3 sec');
  2081. })();
  2082. ```
  2083. #### Helpers for iterators
  2084. Modules [`core.is-iterable`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.is-iterable.js), [`core.get-iterator`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.get-iterator.js), [`core.get-iterator-method`](https://github.com/zloirock/core-js/blob/v2.6.12/modules/core.get-iterator-method.js) - helpers for check iterability / get iterator in the `library` version or, for example, for `arguments` object:
  2085. ```js
  2086. core
  2087. .isIterable(var) -> bool
  2088. .getIterator(iterable) -> iterator
  2089. .getIteratorMethod(var) -> function | undefined
  2090. ```
  2091. [*CommonJS entry points:*](#commonjs)
  2092. ```js
  2093. core-js(/library)/fn/is-iterable
  2094. core-js(/library)/fn/get-iterator
  2095. core-js(/library)/fn/get-iterator-method
  2096. ```
  2097. [*Examples*](http://goo.gl/SXsM6D):
  2098. ```js
  2099. var list = (function(){
  2100. return arguments;
  2101. })(1, 2, 3);
  2102. console.log(core.isIterable(list)); // true;
  2103. var iter = core.getIterator(list);
  2104. console.log(iter.next().value); // 1
  2105. console.log(iter.next().value); // 2
  2106. console.log(iter.next().value); // 3
  2107. console.log(iter.next().value); // undefined
  2108. core.getIterator({}); // TypeError: [object Object] is not iterable!
  2109. var iterFn = core.getIteratorMethod(list);
  2110. console.log(typeof iterFn); // 'function'
  2111. var iter = iterFn.call(list);
  2112. console.log(iter.next().value); // 1
  2113. console.log(iter.next().value); // 2
  2114. console.log(iter.next().value); // 3
  2115. console.log(iter.next().value); // undefined
  2116. console.log(core.getIteratorMethod({})); // undefined
  2117. ```
  2118. ## Missing polyfills
  2119. - ES5 `JSON` is missing now only in IE7- and never will it be added to `core-js`, if you need it in these old browsers, many implementations are available, for example, [json3](https://github.com/bestiejs/json3).
  2120. - ES6 `String#normalize` is not a very useful feature, but this polyfill will be very large. If you need it, you can use [unorm](https://github.com/walling/unorm/).
  2121. - ES6 `Proxy` can't be polyfilled, but for Node.js / Chromium with additional flags you can try [harmony-reflect](https://github.com/tvcutsem/harmony-reflect) for adapt old style `Proxy` API to final ES6 version.
  2122. - ES6 logic for `@@isConcatSpreadable` and `@@species` (in most places) can be polyfilled without problems, but it will cause a serious slowdown in popular cases in some engines. It will be polyfilled when it will be implemented in modern engines.
  2123. - ES7 `SIMD`. `core-js` doesn't add polyfill of this feature because of large size and some other reasons. You can use [this polyfill](https://github.com/tc39/ecmascript_simd/blob/master/src/ecmascript_simd.js).
  2124. - `window.fetch` is not a cross-platform feature, in some environments it makes no sense. For this reason, I don't think it should be in `core-js`. Looking at a large number of requests it *may be* added in the future. Now you can use, for example, [this polyfill](https://github.com/github/fetch).
  2125. - ECMA-402 `Intl` is missed because of size. You can use [this polyfill](https://github.com/andyearnshaw/Intl.js/).