core-js 2.2.1 → 2.4.1

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