core-js 0.9.14 → 0.9.18

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 (38) hide show
  1. package/README.md +22 -5
  2. package/bower.json +1 -1
  3. package/build/build.ls +2 -1
  4. package/build/index.js +2 -2
  5. package/client/core.js +60 -44
  6. package/client/core.min.js +3 -3
  7. package/client/core.min.js.map +1 -1
  8. package/client/library.js +71 -78
  9. package/client/library.min.js +3 -3
  10. package/client/library.min.js.map +1 -1
  11. package/client/shim.js +60 -44
  12. package/client/shim.min.js +3 -3
  13. package/client/shim.min.js.map +1 -1
  14. package/library/modules/$.collection.js +22 -43
  15. package/library/modules/$.iter-define.js +1 -1
  16. package/library/modules/$.shared.js +1 -1
  17. package/library/modules/$.task.js +3 -5
  18. package/library/modules/$.unscope.js +1 -7
  19. package/library/modules/es6.math.js +11 -8
  20. package/library/modules/es6.promise.js +27 -9
  21. package/library/modules/es6.weak-map.js +1 -1
  22. package/library/modules/es7.observable.js +158 -0
  23. package/library/modules/es7.regexp.escape.js +3 -3
  24. package/library/modules/library/modules/$.collection.js +49 -0
  25. package/library/modules/library/modules/$.unscope.js +1 -0
  26. package/modules/$.collection.js +9 -12
  27. package/modules/$.iter-define.js +1 -1
  28. package/modules/$.shared.js +1 -1
  29. package/modules/$.task.js +3 -5
  30. package/modules/$.unscope.js +3 -4
  31. package/modules/es6.math.js +11 -8
  32. package/modules/es6.promise.js +27 -9
  33. package/modules/es6.weak-map.js +1 -1
  34. package/modules/es7.observable.js +158 -0
  35. package/modules/es7.regexp.escape.js +3 -3
  36. package/modules/library/modules/$.collection.js +49 -0
  37. package/modules/library/modules/$.unscope.js +1 -0
  38. package/package.json +3 -3
@@ -13,6 +13,7 @@ var $ = require('./$')
13
13
  , PROMISE = 'Promise'
14
14
  , global = $.g
15
15
  , process = global.process
16
+ , isNode = cof(process) == 'process'
16
17
  , asap = process && process.nextTick || require('./$.task').set
17
18
  , P = global[PROMISE]
18
19
  , isFunction = $.isFunction
@@ -42,6 +43,14 @@ var useNative = function(){
42
43
  if(!(P2.resolve(5).then(function(){}) instanceof P2)){
43
44
  works = false;
44
45
  }
46
+ // actual V8 bug, https://code.google.com/p/v8/issues/detail?id=4162
47
+ if(works && $.DESC){
48
+ var thenableThenGotten = false;
49
+ P.resolve($.setDesc({}, 'then', {
50
+ get: function(){ thenableThenGotten = true; }
51
+ }));
52
+ works = thenableThenGotten;
53
+ }
45
54
  } catch(e){ works = false; }
46
55
  return works;
47
56
  }();
@@ -66,7 +75,8 @@ function isThenable(it){
66
75
  }
67
76
  function notify(record){
68
77
  var chain = record.c;
69
- if(chain.length)asap(function(){
78
+ // strange IE + webpack dev server bug - use .call(global)
79
+ if(chain.length)asap.call(global, function(){
70
80
  var value = record.v
71
81
  , ok = record.s == 1
72
82
  , i = 0;
@@ -112,11 +122,12 @@ function $reject(value){
112
122
  record.s = 2;
113
123
  record.a = record.c.slice();
114
124
  setTimeout(function(){
115
- asap(function(){
125
+ // strange IE + webpack dev server bug - use .call(global)
126
+ asap.call(global, function(){
116
127
  if(isUnhandled(promise = record.p)){
117
- if(cof(process) == 'process'){
128
+ if(isNode){
118
129
  process.emit('unhandledRejection', value, promise);
119
- } else if(global.console && isFunction(console.error)){
130
+ } else if(global.console && console.error){
120
131
  console.error('Unhandled promise rejection', value);
121
132
  }
122
133
  }
@@ -127,21 +138,28 @@ function $reject(value){
127
138
  }
128
139
  function $resolve(value){
129
140
  var record = this
130
- , then, wrapper;
141
+ , then;
131
142
  if(record.d)return;
132
143
  record.d = true;
133
144
  record = record.r || record; // unwrap
134
145
  try {
135
146
  if(then = isThenable(value)){
136
- wrapper = {r: record, d: false}; // wrap
137
- then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
147
+ // strange IE + webpack dev server bug - use .call(global)
148
+ asap.call(global, function(){
149
+ var wrapper = {r: record, d: false}; // wrap
150
+ try {
151
+ then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
152
+ } catch(e){
153
+ $reject.call(wrapper, e);
154
+ }
155
+ });
138
156
  } else {
139
157
  record.v = value;
140
158
  record.s = 1;
141
159
  notify(record);
142
160
  }
143
- } catch(err){
144
- $reject.call(wrapper || {r: record, d: false}, err); // wrap
161
+ } catch(e){
162
+ $reject.call({r: record, d: false}, e); // wrap
145
163
  }
146
164
  }
147
165
 
@@ -27,7 +27,7 @@ var $WeakMap = require('./$.collection')('WeakMap', function(get){
27
27
  }, weak, true, true);
28
28
 
29
29
  // IE11 WeakMap frozen keys fix
30
- if($.FW && new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
30
+ if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
31
31
  $.each.call(['delete', 'has', 'get', 'set'], function(key){
32
32
  var proto = $WeakMap.prototype
33
33
  , method = proto[key];
@@ -0,0 +1,158 @@
1
+ // Based on https://github.com/zenparsing/es-observable/blob/master/src/Observable.js
2
+ var $ = require('./$')
3
+ , $def = require('./$.def')
4
+ , $redef = require('./$.redef')
5
+ , $mix = require('./$.mix')
6
+ , asap = require('./$.task').set
7
+ , assert = require('./$.assert')
8
+ , OBSERVER = require('./$.wks')('observer')
9
+ , isFunction = $.isFunction
10
+ , assertObject = assert.obj
11
+ , assertFunction = assert.fn;
12
+
13
+ // === Abstract Operations ===
14
+ function cancelSubscription(observer){
15
+ var subscription = observer._subscription;
16
+ if(!subscription)return;
17
+ // Drop the reference to the subscription so that we don't unsubscribe
18
+ // more than once
19
+ observer._subscription = undefined;
20
+ try {
21
+ // Call the unsubscribe function
22
+ subscription.unsubscribe();
23
+ } finally {
24
+ // Drop the reference to the inner observer so that no more notifications
25
+ // will be sent
26
+ observer._observer = undefined;
27
+ }
28
+ }
29
+
30
+ function closeSubscription(observer){
31
+ observer._observer = undefined;
32
+ cancelSubscription(observer);
33
+ }
34
+
35
+ function hasUnsubscribe(x){
36
+ return $.isObject(x) && isFunction(x.unsubscribe);
37
+ }
38
+
39
+ function SubscriptionObserver(observer){
40
+ this._observer = observer;
41
+ this._subscription = undefined;
42
+ }
43
+ $mix(SubscriptionObserver.prototype, {
44
+ next: function(value){
45
+ var observer = this._observer
46
+ , result;
47
+ // If the stream if closed, then return a "done" result
48
+ if(!observer)return { value: undefined, done: true };
49
+ try {
50
+ // Send the next value to the sink
51
+ result = observer.next(value);
52
+ } catch (e) {
53
+ // If the observer throws, then close the stream and rethrow the error
54
+ closeSubscription(this);
55
+ throw e;
56
+ }
57
+ // Cleanup if sink is closed
58
+ if(result && result.done)closeSubscription(this);
59
+ return result;
60
+ },
61
+ 'throw': function(value){
62
+ var observer = this._observer;
63
+ // If the stream is closed, throw the error to the caller
64
+ if(!observer)throw value;
65
+ this._observer = undefined;
66
+ try {
67
+ // If the sink does not support "throw", then throw the error to the caller
68
+ if(!('throw' in observer))throw value;
69
+ return observer['throw'](value);
70
+ } finally {
71
+ cancelSubscription(this);
72
+ }
73
+ },
74
+ 'return': function(value){
75
+ var observer = this._observer;
76
+ // If the stream is closed, then return a done result
77
+ if (!observer)return {value: value, done: true};
78
+ this._observer = undefined;
79
+ try {
80
+ // If the sink does not support "return", then return a done result
81
+ if (!('return' in observer))return {value: value, done: true};
82
+ return observer['return'](value);
83
+ } finally {
84
+ cancelSubscription(this);
85
+ }
86
+ }
87
+ });
88
+
89
+ function Observable(subscriber){
90
+ // The stream subscriber must be a function
91
+ this._subscriber = assertFunction(subscriber);
92
+ }
93
+ $mix(Observable.prototype, {
94
+ subscribe: function(observer){
95
+ // The sink must be an object
96
+ assertObject(observer);
97
+ var unsubscribed = false
98
+ , that = this
99
+ , subscription;
100
+ asap.call(global, function(){
101
+ if(!unsubscribed)subscription = that[OBSERVER](observer);
102
+ });
103
+ return {
104
+ unsubscribe: function(){
105
+ if(unsubscribed)return;
106
+ unsubscribed = true;
107
+ if(subscription)subscription.unsubscribe();
108
+ }
109
+ };
110
+ },
111
+ forEach: function(fn, thisArg){
112
+ var that = this;
113
+ return new ($.core.Promise || $.g.Promise)(function(resolve, reject){
114
+ assertFunction(fn);
115
+ that.subscribe({
116
+ next: function(value){ fn.call(thisArg, value); },
117
+ 'throw': function(value){ reject(value); },
118
+ 'return': function(){ resolve(undefined); }
119
+ });
120
+ });
121
+ }
122
+ });
123
+ $redef(Observable.prototype, OBSERVER, function(observer){
124
+ // The sink must be an object
125
+ // Wrap the observer in order to maintain observation invariants
126
+ observer = new SubscriptionObserver(assertObject(observer));
127
+ var subscription;
128
+ try {
129
+ // Call the subscriber function
130
+ subscription = this._subscriber.call(undefined, observer);
131
+ if(!hasUnsubscribe(subscription)){
132
+ var unsubscribe = isFunction(subscription)
133
+ ? subscription
134
+ : function(){ observer['return'](); };
135
+ subscription = {unsubscribe: unsubscribe};
136
+ }
137
+ } catch(e){
138
+ // If an error occurs during startup, then attempt to send the error
139
+ // to the observer
140
+ observer['throw'](e);
141
+ }
142
+ observer._subscription = subscription;
143
+ // If the stream is already finished, then perform cleanup
144
+ if(!observer._observer)cancelSubscription(observer);
145
+ // Return the subscription object
146
+ return subscription;
147
+ });
148
+ $redef(Observable, 'from', function(x){
149
+ if(assertObject(x)._subscriber && x.constructor === this)return x;
150
+ var subscribeFunction = assertFunction(x[OBSERVER]);
151
+ return new this(function(sink){
152
+ subscribeFunction.call(x, sink);
153
+ });
154
+ });
155
+
156
+
157
+ $def($def.G + $def.F, {Observable: Observable});
158
+ $def($def.S, 'Symbol', {observer: OBSERVER});
@@ -1,5 +1,5 @@
1
- // https://gist.github.com/kangax/9698100
1
+ // https://github.com/benjamingr/RexExp.escape
2
2
  var $def = require('./$.def');
3
3
  $def($def.S, 'RegExp', {
4
- escape: require('./$.replacer')(/([\\\-[\]{}()*+?.,^$|])/g, '\\$1', true)
5
- });
4
+ escape: require('./$.replacer')(/[\\^$*+?.()|[\]{}]/g, '\\$&', true)
5
+ });
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+ var $ = require('./$')
3
+ , $def = require('./$.def')
4
+ , $iter = require('./$.iter')
5
+ , BUGGY = $iter.BUGGY
6
+ , forOf = require('./$.for-of')
7
+ , assertInstance = require('./$.assert').inst
8
+ , INTERNAL = require('./$.uid').safe('internal');
9
+
10
+ module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
11
+ var Base = $.g[NAME]
12
+ , C = Base
13
+ , ADDER = IS_MAP ? 'set' : 'add'
14
+ , proto = C && C.prototype
15
+ , O = {};
16
+ if(!$.DESC || !$.isFunction(C) || !(IS_WEAK || !BUGGY && proto.forEach && proto.entries)){
17
+ // create collection constructor
18
+ C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
19
+ require('./$.mix')(C.prototype, methods);
20
+ } else {
21
+ C = wrapper(function(target, iterable){
22
+ assertInstance(target, C, NAME);
23
+ target[INTERNAL] = new Base;
24
+ if(iterable != undefined)forOf(iterable, IS_MAP, target[ADDER], target);
25
+ });
26
+ $.each.call('add,clear,delete,forEach,get,has,set,keys,values,entries'.split(','),function(KEY){
27
+ var chain = KEY == 'add' || KEY == 'set';
28
+ if(KEY in proto)$.hide(C.prototype, KEY, function(a, b){
29
+ var result = this[INTERNAL][KEY](a === 0 ? 0 : a, b);
30
+ return chain ? this : result;
31
+ });
32
+ });
33
+ if('size' in proto)$.setDesc(C.prototype, 'size', {
34
+ get: function(){
35
+ return this[INTERNAL].size;
36
+ }
37
+ });
38
+ }
39
+
40
+ require('./$.cof').set(C, NAME);
41
+
42
+ O[NAME] = C;
43
+ $def($def.G + $def.W + $def.F, O);
44
+ require('./$.species')(C);
45
+
46
+ if(!IS_WEAK)common.setIter(C, NAME, IS_MAP);
47
+
48
+ return C;
49
+ };
@@ -0,0 +1 @@
1
+ module.exports = function(){ /* empty */ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "core-js",
3
3
  "description": "Standard library",
4
- "version": "0.9.14",
4
+ "version": "0.9.18",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/zloirock/core-js.git"
@@ -21,12 +21,12 @@
21
21
  "karma": "0.12.x",
22
22
  "karma-qunit": "0.1.x",
23
23
  "karma-chrome-launcher": "0.1.x",
24
- "karma-ie-launcher": "0.1.x",
24
+ "karma-ie-launcher": "0.2.x",
25
25
  "karma-firefox-launcher": "0.1.x",
26
26
  "karma-opera-launcher": "0.1.x",
27
27
  "karma-phantomjs-launcher": "0.2.x",
28
28
  "promises-aplus-tests": "2.1.x",
29
- "eslint": "^0.22.1"
29
+ "eslint": "0.23.x"
30
30
  },
31
31
  "scripts": {
32
32
  "grunt": "grunt",