core-js 0.8.0 → 0.8.4

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 (101) hide show
  1. package/README.md +61 -25
  2. package/bower.json +1 -1
  3. package/build/build.ls +22 -12
  4. package/client/core.js +3376 -2951
  5. package/client/core.min.js +3 -3
  6. package/client/core.min.js.map +1 -1
  7. package/client/library.js +3294 -2877
  8. package/client/library.min.js +3 -4
  9. package/client/library.min.js.map +1 -1
  10. package/client/shim.js +2775 -2402
  11. package/client/shim.min.js +3 -3
  12. package/client/shim.min.js.map +1 -1
  13. package/es7/index.js +1 -0
  14. package/es7/set.js +2 -0
  15. package/fn/set.js +1 -0
  16. package/library/es7/index.js +1 -0
  17. package/library/es7/set.js +2 -0
  18. package/library/fn/set.js +1 -0
  19. package/library/modules/$.assign.js +3 -1
  20. package/library/modules/$.collection-strong.js +3 -3
  21. package/library/modules/$.collection-weak.js +5 -5
  22. package/library/modules/$.collection.js +1 -3
  23. package/library/modules/$.iter-detect.js +19 -0
  24. package/library/modules/$.iter.js +0 -26
  25. package/library/modules/$.own-keys.js +1 -1
  26. package/library/modules/$.set-proto.js +22 -16
  27. package/library/modules/$.task.js +9 -6
  28. package/library/modules/es5.js +2 -1
  29. package/library/modules/es6.array.copy-within.js +1 -1
  30. package/library/modules/es6.array.fill.js +1 -1
  31. package/library/modules/es6.array.from.js +2 -2
  32. package/library/modules/es6.array.of.js +1 -1
  33. package/library/modules/es6.map.js +2 -2
  34. package/library/modules/es6.math.js +34 -20
  35. package/library/modules/es6.number.statics.js +6 -5
  36. package/library/modules/es6.object.is.js +1 -1
  37. package/library/modules/es6.object.set-prototype-of.js +1 -1
  38. package/library/modules/es6.object.statics-accept-primitives.js +2 -2
  39. package/library/modules/es6.object.to-string.js +1 -1
  40. package/library/modules/es6.promise.js +113 -107
  41. package/library/modules/es6.reflect.js +24 -19
  42. package/library/modules/es6.set.js +1 -1
  43. package/library/modules/es6.string.ends-with.js +1 -1
  44. package/library/modules/es6.string.from-code-point.js +1 -1
  45. package/library/modules/es6.string.includes.js +1 -1
  46. package/library/modules/es6.string.raw.js +4 -4
  47. package/library/modules/es6.string.repeat.js +1 -1
  48. package/library/modules/es6.string.starts-with.js +1 -1
  49. package/library/modules/es6.symbol.js +7 -4
  50. package/library/modules/es6.weak-map.js +2 -2
  51. package/library/modules/es6.weak-set.js +1 -1
  52. package/library/modules/es7.object.get-own-property-descriptors.js +1 -1
  53. package/library/modules/es7.object.to-array.js +1 -1
  54. package/library/modules/es7.set.to-json.js +10 -0
  55. package/library/modules/js.array.statics.js +2 -2
  56. package/library/modules/web.dom.iterable.js +7 -6
  57. package/library/modules/web.timers.js +8 -7
  58. package/library/shim.js +1 -0
  59. package/modules/$.assign.js +3 -1
  60. package/modules/$.collection-strong.js +3 -3
  61. package/modules/$.collection-weak.js +5 -5
  62. package/modules/$.collection.js +1 -3
  63. package/modules/$.iter-detect.js +19 -0
  64. package/modules/$.iter.js +0 -26
  65. package/modules/$.own-keys.js +1 -1
  66. package/modules/$.set-proto.js +22 -16
  67. package/modules/$.task.js +9 -6
  68. package/modules/es5.js +2 -1
  69. package/modules/es6.array.copy-within.js +1 -1
  70. package/modules/es6.array.fill.js +1 -1
  71. package/modules/es6.array.from.js +2 -2
  72. package/modules/es6.array.of.js +1 -1
  73. package/modules/es6.map.js +2 -2
  74. package/modules/es6.math.js +34 -20
  75. package/modules/es6.number.statics.js +6 -5
  76. package/modules/es6.object.is.js +1 -1
  77. package/modules/es6.object.set-prototype-of.js +1 -1
  78. package/modules/es6.object.statics-accept-primitives.js +2 -2
  79. package/modules/es6.object.to-string.js +1 -1
  80. package/modules/es6.promise.js +113 -107
  81. package/modules/es6.reflect.js +24 -19
  82. package/modules/es6.set.js +1 -1
  83. package/modules/es6.string.ends-with.js +1 -1
  84. package/modules/es6.string.from-code-point.js +1 -1
  85. package/modules/es6.string.includes.js +1 -1
  86. package/modules/es6.string.raw.js +4 -4
  87. package/modules/es6.string.repeat.js +1 -1
  88. package/modules/es6.string.starts-with.js +1 -1
  89. package/modules/es6.symbol.js +7 -4
  90. package/modules/es6.weak-map.js +2 -2
  91. package/modules/es6.weak-set.js +1 -1
  92. package/modules/es7.object.get-own-property-descriptors.js +1 -1
  93. package/modules/es7.object.to-array.js +1 -1
  94. package/modules/es7.set.to-json.js +10 -0
  95. package/modules/js.array.statics.js +2 -2
  96. package/modules/web.dom.iterable.js +7 -6
  97. package/modules/web.timers.js +8 -7
  98. package/package.json +8 -6
  99. package/shim.js +1 -0
  100. package/library/modules/core.iterator.js +0 -146
  101. package/modules/core.iterator.js +0 -146
package/README.md CHANGED
@@ -227,7 +227,7 @@ String
227
227
  #endsWith(str, from?) -> bool
228
228
  #repeat(num) -> str
229
229
  #codePointAt(pos) -> uint
230
- [new] RegExp(pattern, flags?) -> regexp, ES6 fix: can alter flags
230
+ [new] RegExp(pattern, flags?) -> regexp, ES6 fix: can alter flags (IE9+)
231
231
  #flags -> str (IE9+)
232
232
  ```
233
233
  [Example](http://goo.gl/sdNGeJ):
@@ -279,7 +279,7 @@ Math
279
279
  .clz32(num) -> uint
280
280
  .cosh(num) -> num
281
281
  .expm1(num) -> num
282
- .fround(num) -> num (IE10+)
282
+ .fround(num) -> num
283
283
  .hypot(...args) -> num
284
284
  .imul(num, num) -> int
285
285
  .log1p(num) -> num
@@ -370,6 +370,7 @@ o2[s2] = true;
370
370
  for(var key in o2)log(key); // nothing
371
371
  ```
372
372
  ### ECMAScript 6: Collections
373
+ `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).
373
374
  #### Map
374
375
  Module `es6.map`. About iterators from this module [here](#ecmascript-6-iterators).
375
376
  ```javascript
@@ -506,18 +507,18 @@ Array
506
507
  Arguments
507
508
  #@@iterator() -> iterator (sham, available only in core-js methods)
508
509
  ```
509
- Module `es6.collections`:
510
+ Modules `es6.map` and `es6.set`:
510
511
  ```javascript
511
- Set
512
+ Map
512
513
  #values() -> iterator
513
514
  #keys() -> iterator
514
515
  #entries() -> iterator (entries)
515
- #@@iterator() -> iterator
516
- Map
516
+ #@@iterator() -> iterator (entries)
517
+ Set
517
518
  #values() -> iterator
518
519
  #keys() -> iterator
519
520
  #entries() -> iterator (entries)
520
- #@@iterator() -> iterator (entries)
521
+ #@@iterator() -> iterator
521
522
  ```
522
523
  Module `web.dom.iterable`:
523
524
  ```javascript
@@ -567,7 +568,7 @@ for(var x of document.querySelectorAll('*')){
567
568
  log(x.id);
568
569
  }
569
570
  ```
570
- Module `core.iter-helpers` - helpers for check iterable / get iterator in `library` version or, for rxample, for `arguments` object:
571
+ Module `core.iter-helpers` - helpers for check iterable / get iterator in `library` version or, for example, for `arguments` object:
571
572
  ```javascript
572
573
  core
573
574
  .isIterable(var) -> bool
@@ -769,6 +770,7 @@ instance.c; // => 42
769
770
  * `Object.values`, `Object.entries` [tc39 discuss](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-04/apr-9.md#51-objectentries-objectvalues) - module `es7.object.to-array`
770
771
  * `Object.getOwnPropertyDescriptors` [proposal](https://gist.github.com/WebReflection/9353781) - module `es7.object.get-own-property-descriptors`
771
772
  * `RegExp.escape` [proposal](https://gist.github.com/kangax/9698100) - module `es7.regexp.escape`
773
+ * `Set#toJSON` [proposal](https://github.com/DavidBruant/Map-Set.prototype.toJSON) - module `es7.set.to-json`
772
774
 
773
775
  ```javascript
774
776
  Array
@@ -781,8 +783,10 @@ Object
781
783
  .getOwnPropertyDescriptors(object) -> object
782
784
  RegExp
783
785
  .escape(str) -> str
786
+ Set
787
+ #toJSON() -> array
784
788
  ```
785
- [Examples](http://goo.gl/4HcpLK):
789
+ [Examples](http://goo.gl/inyWkw):
786
790
  ```javascript
787
791
  [1, 2, 3].includes(2); // => true
788
792
  [1, 2, 3].includes(4); // => false
@@ -805,6 +809,8 @@ var copy = Object.create(Object.getPrototypeOf(O), Object.getOwnPropertyDescript
805
809
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
806
810
 
807
811
  RegExp.escape('Hello -[]{}()*+?.,\\^$|'); // => 'Hello \-\[\]\{\}\(\)\*\+\?\.\,\\\^\$\|'
812
+
813
+ JSON.stringify(new Set([1, 2, 3, 2, 1])); // => '[1,2,3]'
808
814
  ```
809
815
  ### Mozilla JavaScript: Array generics
810
816
  Module `js.array.statics`.
@@ -1029,23 +1035,51 @@ dict.toString; // => undefined
1029
1035
  Dict.isDict({}); // => false
1030
1036
  Dict.isDict(Dict()); // => true
1031
1037
  ```
1032
- `Dict.keys`, `Dict.values` and `Dict.entries` returns iterators for objects, [examples](http://goo.gl/JRkgM8):
1038
+ `Dict.keys`, `Dict.values` and `Dict.entries` returns iterators for objects, [examples](http://goo.gl/4u8UDK):
1033
1039
  ```javascript
1034
1040
  var dict = {a: 1, b: 2, c: 3};
1035
1041
 
1036
1042
  for(var key of Dict.keys(dict))log(key); // => 'a', 'b', 'c'
1037
1043
 
1044
+ for(var val of Dict.values(dict))log(val); // => 1, 2, 3
1045
+
1038
1046
  for(var [key, val] of Dict.entries(dict)){
1039
1047
  log(key); // => 'a', 'b', 'c'
1040
1048
  log(val); // => 1, 2, 3
1041
1049
  }
1042
1050
 
1043
- $for(Dict.values(dict)).of(log); // => 1, 2, 3
1044
-
1045
1051
  new Map(Dict.entries(dict)); // => Map {a: 1, b: 2, c: 3}
1046
1052
 
1047
1053
  new Map((for([k, v] of Dict.entries(dict))if(v % 2)[k + k, v * v])); // => Map {aa: 1, cc: 9}
1048
1054
  ```
1055
+ Basic dict operations for objects with prototype [example](http://goo.gl/B28UnG):
1056
+ ```js
1057
+ 'q' in {q: 1}; // => true
1058
+ 'toString' in {}; // => true
1059
+
1060
+ Dict.has({q: 1}, 'q'); // => true
1061
+ Dict.has({}, 'toString'); // => false
1062
+
1063
+ ({q: 1})['q']; // => 1
1064
+ ({}).toString; // => function toString(){ [native code] }
1065
+
1066
+ Dict.get({q: 1}, 'q'); // => 1
1067
+ Dict.get({}, 'toString'); // => undefined
1068
+
1069
+ var O = {};
1070
+ O['q'] = 1;
1071
+ O['q']; // => 1
1072
+ O['__proto__'] = {w: 2};
1073
+ O['__proto__']; // => {w: 2}
1074
+ O['w']; // => 2
1075
+
1076
+ var O = {};
1077
+ Dict.set(O, 'q', 1);
1078
+ O['q']; // => 1
1079
+ Dict.set(O, '__proto__', {w: 2});
1080
+ O['__proto__']; // => {w: 2}
1081
+ O['w']; // => undefined
1082
+ ```
1049
1083
  Other methods of `Dict` module are static equialents of `Array.prototype` methods for dictionaries, [examples](http://goo.gl/yARYXR):
1050
1084
  ```javascript
1051
1085
  var dict = {a: 1, b: 2, c: 3};
@@ -1225,12 +1259,10 @@ Number
1225
1259
  #random(lim = 0) -> num
1226
1260
  #{...Math}
1227
1261
  ```
1228
- Number Iterator [examples](http://goo.gl/mkReUE):
1262
+ Number Iterator [examples](http://goo.gl/RI60Ot):
1229
1263
  ```javascript
1230
1264
  for(var i of 3)log(i); // => 0, 1, 2
1231
1265
 
1232
- $for(3).of(log); // => 0, 1, 2
1233
-
1234
1266
  Array.from(10, Math.random); // => [0.9817775336559862, 0.02720663254149258, ...]
1235
1267
 
1236
1268
  Array.from(10); // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@@ -1243,16 +1275,6 @@ Array.from(10, function(it){
1243
1275
  [for(i of 10)if(i % 2)i * i]; // => [1, 9, 25, 49, 81]
1244
1276
 
1245
1277
  Dict((for(i of 3)['key' + i, !(i % 2)])); // => {key0: true, key1: false, key2: true}
1246
-
1247
- $for(10).filter(function(i){
1248
- return i % 2;
1249
- }).array(function(i){
1250
- return i * i;
1251
- }); // => [1, 9, 25, 49, 81]
1252
-
1253
- Dict($for(3).map(function(i){
1254
- return ['key' + i, !(i % 2)];
1255
- })); // => {key0: true, key1: false, key2: true}
1256
1278
  ```
1257
1279
  `Math` methods in `Number.prototype` [examples](http://goo.gl/06bs1k):
1258
1280
  ```javascript
@@ -1291,6 +1313,20 @@ delay(1e3).then(() => log('after 1 sec'));
1291
1313
  ```
1292
1314
 
1293
1315
  ## Changelog
1316
+ ##### 0.8.4 - 2015.04.18
1317
+ * uses `webpack` instead of `browserify` for browser builds - more compression-friendly result
1318
+
1319
+ ##### 0.8.3 - 2015.04.14
1320
+ * fixed `Array` statics with single entry points
1321
+
1322
+ ##### 0.8.2 - 2015.04.13
1323
+ * [`Math.fround`](#ecmascript-6-number--math) now also works in IE9-
1324
+ * added [`Set#toJSON`](#ecmascript-7)
1325
+ * some optimizations and fixes
1326
+
1327
+ ##### 0.8.1 - 2015.04.03
1328
+ * fixed `Symbol.keyFor`
1329
+
1294
1330
  ##### 0.8.0 - 2015.04.02
1295
1331
  * changed [CommonJS API](#commonjs)
1296
1332
  * splitted and renamed some modules
package/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "core.js",
3
3
  "main": "client/core.js",
4
- "version": "0.8.0",
4
+ "version": "0.8.4",
5
5
  "description": "Standard Library",
6
6
  "keywords": [
7
7
  "ES6",
package/build/build.ls CHANGED
@@ -1,4 +1,4 @@
1
- require! {'./config': {banner}, fs: {readFile, writeFile, unlink}, browserify, '../': core}
1
+ require! {'./config': {banner}, fs: {readFile, writeFile, unlink}, webpack, '../': core}
2
2
  list = <[
3
3
  es5
4
4
  es6.symbol
@@ -11,7 +11,6 @@ list = <[
11
11
  es6.number.constructor
12
12
  es6.number.statics
13
13
  es6.math
14
- core.iterator
15
14
  es6.string.from-code-point
16
15
  es6.string.raw
17
16
  es6.string.iterator
@@ -40,6 +39,7 @@ list = <[
40
39
  es7.regexp.escape
41
40
  es7.object.get-own-property-descriptors
42
41
  es7.object.to-array
42
+ es7.set.to-json
43
43
  web.immediate
44
44
  web.dom.iterable
45
45
  web.timers
@@ -59,11 +59,15 @@ list = <[
59
59
  js.array.statics
60
60
  ]>
61
61
 
62
- exp = <[
63
- core.iterator
64
- ]>
62
+ exp = <[ ]>
65
63
 
66
64
  x78 = '*'repeat 78
65
+
66
+ check = (err)!->
67
+ if err
68
+ console.error err
69
+ process.exit 1
70
+
67
71
  module.exports = ({modules, blacklist, library}, next)-> let @ = modules.turn ((memo, it)-> memo[it] = on), {}
68
72
  if @exp => for exp => @[..] = on
69
73
  for ns of @
@@ -76,13 +80,19 @@ module.exports = ({modules, blacklist, library}, next)-> let @ = modules.turn ((
76
80
  if name is ns or name.startsWith "#ns."
77
81
  @[name] = no
78
82
  if library => @ <<< {-\es6.object.prototype, -\es6.function, -\es6.regexp, -\es6.number.constructor, -\core.iterator}
79
- PATH = ".#{ if library => '/library' else '' }/modules/__tmp#{ Math.random! }__"
80
- err <-! writeFile "#PATH.js", list.filter(~> @[it]).map(-> "require('./#it');" ).join '\n'
81
- if err => console.error err
82
- err, script <-! browserify(entries: [PATH], detectGlobals: no).bundle
83
- if err => console.error err
84
- err <-! unlink "#PATH.js"
85
- if err => console.error err
83
+ ENTRY = "./__tmp#{ Math.random! }__.js"
84
+ PATH = ".#{ if library => '/library' else '' }/modules/"
85
+ err <-! writeFile ENTRY, list.filter(~> @[it]).map(-> "require('#PATH#it');" ).join '\n'
86
+ check err
87
+ TARGET = "./__tmp#{ Math.random! }__.js"
88
+ err, info <-! webpack entry: ENTRY, output: { path: '', filename: TARGET }
89
+ check err
90
+ err, script <-! readFile TARGET
91
+ check err
92
+ err <-! unlink ENTRY
93
+ check err
94
+ err <-! unlink TARGET
95
+ check err
86
96
  next """
87
97
  #banner
88
98
  !function(undefined){