├── .gitignore
├── .travis.yml
├── README.md
├── lib
├── core-js-no-number.js
└── runtime.js
├── package.js
├── plugin
└── compile-6to5.js
├── tests
└── basic_test.es6.js
└── update-bundled-libs.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | .npm
2 | .versions
3 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "0.10.33"
4 |
5 | before_install:
6 | - "curl https://install.meteor.com | /bin/sh"
7 | - "npm install -g spacejam"
8 |
9 | sudo: required
10 | script: "spacejam test-packages ./"
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WARNING: this package is deprecated and no longer supported
2 |
3 | I suggest users migrate to the native `ecmascript` package. Here is how one user accomplished this recently:
4 |
5 | https://github.com/pbastowski/angular-meteor-babel/issues/33
6 |
7 | # Babel and ng-annotate in one package
8 |
9 | > **Important information** if you have recently updated to v1.0.3 or higher, which introduced configuration through `.babelrc`. Please rename `.babelrc` to `babel.json`, because under certain circumstances Babel reports errors when it encounters a custom keys in `babel.rc`, such as "verbose". Thus, I have reverted to using `babel.json` from v1.0.5 onwards. Apologies for any inconvenience.
10 |
11 | This package is meant to be used with [Angular-Meteor](http://angular-meteor.com) and the corresponding `angular` package.
12 |
13 | If you are not working with angular-meteor then consider using Meteor's own `ecmascript` package. However, if you do need the extra bits of goodness that this package provides over and above what `ecmascript` does, then it's ok to use this package also. Even if you're not using AngularJS, it will not harm your code.
14 |
15 | ## Install
16 |
17 | ```bash
18 | meteor add pbastowski:angular-babel
19 | ```
20 |
21 | ## What's in this package that's not in the ecmascript package?
22 |
23 | > The discussion here is for Meteor 1.2 only.
24 |
25 | Here is the list of Babel transformers in this package that are not in the `ecmascript` package:
26 |
27 | - es5.properties.mutators
28 | - es6.modules
29 | - es6.regex.sticky
30 | - es6.regex.unicode
31 | - es6.tailCall
32 | - es6.templateLiterals
33 | - es7.decorators (stage 1)
34 | - es7.classProperties (stage 0)
35 | - es7.exportExtensions (stage 1)
36 | - es7.comprehensions (stage 0)
37 | - es7.asyncFunctions (stage 2)
38 | - es7.doExpressions (stage 0)
39 | - es7.exponentiationOperator (stage 3)
40 |
41 | Please note that all es7 transformers are considered experimental, especially those at Stage 0 and 1.
42 |
43 |
44 | ## Custom configuration with babel.json
45 |
46 | Place `babel.json` at the root of your project to override certain default settings. This file is completely optional and may contain the following in JSON format. The values below are the default configuration.
47 |
48 | ```
49 | {
50 | "verbose": false, // true shows files being compiled
51 | "debug": false, // true displays this config file
52 | "modules": "common", // what module format Babel should use. See
53 | // Babel documentation for "modules" option.
54 | "blacklist": ['useStrict'], // Do not change this unless you know
55 | // very well what you are doing.
56 | "stage": 0, // see Babel documentation for stage option.
57 | "extensions": ["js"] // "js" means compile all ".js" files.
58 | }
59 | ```
60 |
61 | ## Using `import ... from`
62 |
63 | Babel does not include a module loader, so statements such as below, will not work out of the box
64 |
65 | ```javascript
66 | import {x, y, z} from "modulename";
67 | ```
68 |
69 | However, if your `modules` setting is `{ "modules": "system" }` then we can use `pbastowski:systemjs` to load modules compiled with Babel. For CommonJS modules, which is the default "modules" setting, we can use `pbastowski:require`.
70 |
71 | ### SystemJS
72 |
73 | > **Meteor 1.2** or higher
74 |
75 | So, you have configured Babel through `babel.json` to output SystemJS modules, like this:
76 |
77 | { "modules": "system" }
78 |
79 | Well done! Now you need to know how to use these modules in your code.
80 |
81 | SystemJS modules are assigned a name based on their file name within your project. Below are some examples that show how a file name is converted to a module name, which you can import:
82 |
83 | file name | module name
84 | ----------|------------
85 | client/app/app.js | client/app/app
86 | client/feature1/feature1.js | client/feature1/feature1
87 | client/feature1/lib/xxx.js | client/feature1/lib/xxx
88 | client/lib/angular-messages.min.js | client/lib/angular-messages.min
89 |
90 | #### Add SystemJS to your Meteor project
91 |
92 | meteor add pbastowski:systemjs
93 |
94 | #### Use `System.import` to kick off your app
95 |
96 | Next, in the body section of your `index.html` file you need to import the JS file that kicks off your application. For our example that file is `client/index.js`.
97 |
98 | ```html
99 |
100 | My App
101 |
102 |
103 | Loading...
104 |
107 |
108 | ```
109 |
110 | Below is a sample `client/index.js` file. Remember that the innermost imports, those inside `app` and `feature1`, will be executed first. Then, the rest of the code in `index.js` will be executed in the order it is listed in the file.
111 |
112 | In the example below, first `client/app/app` will be imported and executed followed by `client/feature1/feature1`.
113 |
114 |
115 | ```javascript
116 | import 'client/app/app';
117 | import 'client/feature1/feature1';
118 | ```
119 |
120 | ### CommonJS
121 |
122 | > **Meteor 1.1** or higher
123 |
124 | When the module format is `common`, which is the default for this Babel plugin, you don't actually have to do anything special as long as you don't `import` or `export` in your ES6 files. Babel will compile your code and output files that will be loaded and executed just like any normal non-compiled JS files would be.
125 |
126 | #### But I really want to import and export
127 |
128 | If you use `import ... from` or `export` syntax in your ES6 code you may see errors in your dev console complaining about a missing `require`. To get around that, I have created the package `pbastowski:require`, which implements just enough of `require` and `module.exports` to enable you to export and import in Meteor apps.
129 |
130 | Try it and see if it works for you:
131 |
132 | meteor add pbastowski:require
133 |
134 |
135 | ## More info about Babel please...
136 |
137 | See the [Babel](http://babeljs.io/) website
138 |
139 | ## Troubleshooting
140 |
141 | ### Meteor refuses to install the latest version of this package
142 | If Meteor refuses to update your package to the latest Meteor 1.2 version, you may have to convince it to do so like shown below. Change the version number to whatever version that you actually want.
143 |
144 | ```bash
145 | meteor add pbastowski:angular-babel@1.0.4
146 | ```
147 |
148 | ### For Meteor 1.1, what is the latest version of this package?
149 |
150 | The latest version of `pbastowski:angular-babel` for Meteor 1.1 is `0.1.10`
151 |
--------------------------------------------------------------------------------
/lib/core-js-no-number.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Core.js 0.7.1
3 | * https://github.com/zloirock/core-js
4 | * License: http://rock.mit-license.org
5 | * © 2015 Denis Pushkarev
6 | */
7 | !function(undefined){
8 | var __e = null, __g = null;
9 |
10 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o indexOf
36 | // true -> includes
37 | var $ = require('./$')
38 | , isNaN = $.isNaN;
39 | module.exports = function(IS_CONTAINS){
40 | return function(el /*, fromIndex = 0 */){
41 | var O = $.toObject(this)
42 | , length = $.toLength(O.length)
43 | , index = $.toIndex(arguments[1], length);
44 | if(IS_CONTAINS && el != el)for(;length > index; index++){
45 | if(isNaN(O[index]))return true;
46 | } else for(;length > index; index++)if(IS_CONTAINS || index in O){
47 | if(O[index] === el)return IS_CONTAINS || index;
48 | } return !IS_CONTAINS && -1;
49 | }
50 | }
51 | },{"./$":10}],3:[function(require,module,exports){
52 | 'use strict';
53 | // 0 -> forEach
54 | // 1 -> map
55 | // 2 -> filter
56 | // 3 -> some
57 | // 4 -> every
58 | // 5 -> find
59 | // 6 -> findIndex
60 | var $ = require('./$');
61 | module.exports = function(TYPE){
62 | var IS_MAP = TYPE == 1
63 | , IS_FILTER = TYPE == 2
64 | , IS_SOME = TYPE == 3
65 | , IS_EVERY = TYPE == 4
66 | , IS_FIND_INDEX = TYPE == 6
67 | , NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
68 | return function(callbackfn/*, that = undefined */){
69 | var O = Object($.assert.def(this))
70 | , self = $.ES5Object(O)
71 | , f = $.ctx(callbackfn, arguments[1], 3)
72 | , length = $.toLength(self.length)
73 | , index = 0
74 | , result = IS_MAP ? Array(length) : IS_FILTER ? [] : undefined
75 | , val, res;
76 | for(;length > index; index++)if(NO_HOLES || index in self){
77 | val = self[index];
78 | res = f(val, index, O);
79 | if(TYPE){
80 | if(IS_MAP)result[index] = res; // map
81 | else if(res)switch(TYPE){
82 | case 3: return true; // some
83 | case 5: return val; // find
84 | case 6: return index; // findIndex
85 | case 2: result.push(val); // filter
86 | } else if(IS_EVERY)return false; // every
87 | }
88 | }
89 | return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
90 | }
91 | }
92 | },{"./$":10}],4:[function(require,module,exports){
93 | var $ = require('./$');
94 | // 19.1.2.1 Object.assign(target, source, ...)
95 | module.exports = Object.assign || function(target, source){
96 | var T = Object($.assert.def(target))
97 | , l = arguments.length
98 | , i = 1;
99 | while(l > i){
100 | var S = $.ES5Object(arguments[i++])
101 | , keys = $.getKeys(S)
102 | , length = keys.length
103 | , j = 0
104 | , key;
105 | while(length > j)T[key = keys[j++]] = S[key];
106 | }
107 | return T;
108 | }
109 | },{"./$":10}],5:[function(require,module,exports){
110 | var $ = require('./$')
111 | , TAG = require('./$.wks')('toStringTag')
112 | , toString = {}.toString;
113 | function cof(it){
114 | return toString.call(it).slice(8, -1);
115 | }
116 | cof.classof = function(it){
117 | var O, T;
118 | return it == undefined ? it === undefined ? 'Undefined' : 'Null'
119 | : typeof (T = (O = Object(it))[TAG]) == 'string' ? T : cof(O);
120 | }
121 | cof.set = function(it, tag, stat){
122 | if(it && !$.has(it = stat ? it : it.prototype, TAG))$.hide(it, TAG, tag);
123 | }
124 | module.exports = cof;
125 | },{"./$":10,"./$.wks":19}],6:[function(require,module,exports){
126 | var $ = require('./$')
127 | , global = $.g
128 | , core = $.core
129 | , isFunction = $.isFunction;
130 | if(typeof __e != 'undefined')__e = core;
131 | if(typeof __g != 'undefined')__g = global;
132 | if($.FW)global.core = core;
133 | // type bitmap
134 | $def.F = 1; // forced
135 | $def.G = 2; // global
136 | $def.S = 4; // static
137 | $def.P = 8; // proto
138 | $def.B = 16; // bind
139 | $def.W = 32; // wrap
140 | function $def(type, name, source){
141 | var key, own, out, exp
142 | , isGlobal = type & $def.G
143 | , target = isGlobal ? global : (type & $def.S)
144 | ? global[name] : (global[name] || {}).prototype
145 | , exports = isGlobal ? core : core[name] || (core[name] = {});
146 | if(isGlobal)source = name;
147 | for(key in source){
148 | // there is a similar native
149 | own = !(type & $def.F) && target && key in target;
150 | // export native or passed
151 | out = (own ? target : source)[key];
152 | // prevent global pollution for namespaces
153 | if(!$.FW && isGlobal && !isFunction(target[key]))exp = source[key];
154 | // bind timers to global for call from export context
155 | else if(type & $def.B && own)exp = $.ctx(out, global);
156 | // wrap global constructors for prevent change them in library
157 | else if(type & $def.W && !$.FW && target[key] == out)!function(out){
158 | exp = function(param){
159 | return this instanceof out ? new out(param) : out(param);
160 | }
161 | exp.prototype = out.prototype;
162 | }(out);
163 | else exp = type & $def.P && isFunction(out) ? $.ctx(Function.call, out) : out;
164 | // extend global
165 | if($.FW && target && !own){
166 | if(isGlobal)target[key] = out;
167 | else delete target[key] && $.hide(target, key, out);
168 | }
169 | // export
170 | if(exports[key] != out)$.hide(exports, key, exp);
171 | }
172 | }
173 | module.exports = $def;
174 | },{"./$":10}],7:[function(require,module,exports){
175 | module.exports = typeof self != 'undefined' ? self : Function('return this')();
176 | },{}],8:[function(require,module,exports){
177 | // Fast apply
178 | // http://jsperf.lnkit.com/fast-apply/5
179 | module.exports = function(fn, args, that){
180 | var un = that === undefined;
181 | switch(args.length){
182 | case 0: return un ? fn()
183 | : fn.call(that);
184 | case 1: return un ? fn(args[0])
185 | : fn.call(that, args[0]);
186 | case 2: return un ? fn(args[0], args[1])
187 | : fn.call(that, args[0], args[1]);
188 | case 3: return un ? fn(args[0], args[1], args[2])
189 | : fn.call(that, args[0], args[1], args[2]);
190 | case 4: return un ? fn(args[0], args[1], args[2], args[3])
191 | : fn.call(that, args[0], args[1], args[2], args[3]);
192 | case 5: return un ? fn(args[0], args[1], args[2], args[3], args[4])
193 | : fn.call(that, args[0], args[1], args[2], args[3], args[4]);
194 | } return fn.apply(that, args);
195 | }
196 | },{}],9:[function(require,module,exports){
197 | 'use strict';
198 | var $ = require('./$')
199 | , cof = require('./$.cof')
200 | , $def = require('./$.def')
201 | , invoke = require('./$.invoke')
202 | // Safari has byggy iterators w/o `next`
203 | , BUGGY = 'keys' in [] && !('next' in [].keys())
204 | , SYMBOL_ITERATOR = require('./$.wks')('iterator') || Symbol.iterator
205 | , FF_ITERATOR = '@@iterator'
206 | , Iterators = {}
207 | , IteratorPrototype = {};
208 | // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
209 | setIterator(IteratorPrototype, $.that);
210 | function setIterator(O, value){
211 | $.hide(O, SYMBOL_ITERATOR, value);
212 | // Add iterator for FF iterator protocol
213 | if(FF_ITERATOR in [])$.hide(O, FF_ITERATOR, value);
214 | }
215 | function createIterator(Constructor, NAME, next, proto){
216 | Constructor.prototype = $.create(proto || $iter.prototype, {next: $.desc(1, next)});
217 | cof.set(Constructor, NAME + ' Iterator');
218 | }
219 | function defineIterator(Constructor, NAME, value, DEFAULT){
220 | var proto = Constructor.prototype
221 | , iter = proto[SYMBOL_ITERATOR] || proto[FF_ITERATOR] || (DEFAULT && proto[DEFAULT]) || value;
222 | if($.FW){
223 | // Define iterator
224 | setIterator(proto, iter);
225 | if(iter !== value){
226 | var iterProto = $.getProto(iter.call(new Constructor));
227 | // Set @@toStringTag to native iterators
228 | cof.set(iterProto, NAME + ' Iterator', true);
229 | // FF fix
230 | $.has(proto, FF_ITERATOR) && setIterator(iterProto, $.that);
231 | }
232 | }
233 | // Plug for library
234 | Iterators[NAME] = iter;
235 | // FF & v8 fix
236 | Iterators[NAME + ' Iterator'] = $.that;
237 | return iter;
238 | }
239 | function getIterator(it){
240 | var Symbol = $.g.Symbol
241 | , ext = it[Symbol && Symbol.iterator || FF_ITERATOR]
242 | , getIter = ext || it[SYMBOL_ITERATOR] || Iterators[cof.classof(it)];
243 | return $.assert.obj(getIter.call(it));
244 | }
245 | function stepCall(fn, value, entries){
246 | return entries ? invoke(fn, value) : fn(value);
247 | }
248 | function closeIterator(iterator){
249 | var ret = iterator['return'];
250 | if(ret !== undefined)ret.call(iterator);
251 | }
252 | function safeIterExec(exec, iterator){
253 | try {
254 | return exec(iterator);
255 | } catch(e){
256 | closeIterator(iterator);
257 | throw e;
258 | }
259 | }
260 | var DANGER_CLOSING = true;
261 | try {
262 | var iter = [1].keys();
263 | iter['return'] = function(){ DANGER_CLOSING = false };
264 | Array.from(iter, function(){ throw 2 });
265 | } catch(e){}
266 | var $iter = {
267 | BUGGY: BUGGY,
268 | DANGER_CLOSING: DANGER_CLOSING,
269 | Iterators: Iterators,
270 | prototype: IteratorPrototype,
271 | step: function(done, value){
272 | return {value: value, done: !!done};
273 | },
274 | stepCall: stepCall,
275 | close: closeIterator,
276 | exec: safeIterExec,
277 | is: function(it){
278 | var O = Object(it)
279 | , Symbol = $.g.Symbol
280 | , SYM = Symbol && Symbol.iterator || FF_ITERATOR;
281 | return SYM in O || SYMBOL_ITERATOR in O || $.has(Iterators, cof.classof(O));
282 | },
283 | get: getIterator,
284 | set: setIterator,
285 | create: createIterator,
286 | define: defineIterator,
287 | std: function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE){
288 | function createIter(kind){
289 | return function(){
290 | return new Constructor(this, kind);
291 | }
292 | }
293 | createIterator(Constructor, NAME, next);
294 | var entries = createIter('key+value')
295 | , values = createIter('value')
296 | , proto = Base.prototype
297 | , methods, key;
298 | if(DEFAULT == 'value')values = defineIterator(Base, NAME, values, 'values');
299 | else entries = defineIterator(Base, NAME, entries, 'entries');
300 | if(DEFAULT){
301 | methods = {
302 | entries: entries,
303 | keys: IS_SET ? values : createIter('key'),
304 | values: values
305 | }
306 | $def($def.P + $def.F * BUGGY, NAME, methods);
307 | if(FORCE)for(key in methods){
308 | if(!(key in proto))$.hide(proto, key, methods[key]);
309 | }
310 | }
311 | },
312 | forOf: function(iterable, entries, fn, that){
313 | safeIterExec(function(iterator){
314 | var f = $.ctx(fn, that, entries ? 2 : 1)
315 | , step;
316 | while(!(step = iterator.next()).done)if(stepCall(f, step.value, entries) === false){
317 | return closeIterator(iterator);
318 | }
319 | }, getIterator(iterable));
320 | }
321 | };
322 | module.exports = $iter;
323 | },{"./$":10,"./$.cof":5,"./$.def":6,"./$.invoke":8,"./$.wks":19}],10:[function(require,module,exports){
324 | 'use strict';
325 | var global = require('./$.global')
326 | , defineProperty = Object.defineProperty
327 | , hasOwnProperty = {}.hasOwnProperty
328 | , ceil = Math.ceil
329 | , floor = Math.floor
330 | , max = Math.max
331 | , min = Math.min
332 | , trunc = Math.trunc || function(it){
333 | return (it > 0 ? floor : ceil)(it);
334 | }
335 | // 7.1.4 ToInteger
336 | function toInteger(it){
337 | return isNaN(it) ? 0 : trunc(it);
338 | }
339 | function desc(bitmap, value){
340 | return {
341 | enumerable : !(bitmap & 1),
342 | configurable: !(bitmap & 2),
343 | writable : !(bitmap & 4),
344 | value : value
345 | }
346 | }
347 | function simpleSet(object, key, value){
348 | object[key] = value;
349 | return object;
350 | }
351 | function createDefiner(bitmap){
352 | return DESC ? function(object, key, value){
353 | return $.setDesc(object, key, desc(bitmap, value));
354 | } : simpleSet;
355 | }
356 | // The engine works fine with descriptors? Thank's IE8 for his funny defineProperty.
357 | var DESC = !!function(){try {
358 | return defineProperty({}, 'a', {get: function(){ return 2 }}).a == 2;
359 | } catch(e){}}();
360 | var hide = createDefiner(1)
361 | , core = {};
362 |
363 | function isObject(it){
364 | return it !== null && (typeof it == 'object' || typeof it == 'function');
365 | }
366 | function isFunction(it){
367 | return typeof it == 'function';
368 | }
369 |
370 | function assert(condition, msg1, msg2){
371 | if(!condition)throw TypeError(msg2 ? msg1 + msg2 : msg1);
372 | };
373 | assert.def = function(it){
374 | if(it == undefined)throw TypeError('Function called on null or undefined');
375 | return it;
376 | };
377 | assert.fn = function(it){
378 | if(!isFunction(it))throw TypeError(it + ' is not a function!');
379 | return it;
380 | };
381 | assert.obj = function(it){
382 | if(!isObject(it))throw TypeError(it + ' is not an object!');
383 | return it;
384 | };
385 | assert.inst = function(it, Constructor, name){
386 | if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!");
387 | return it;
388 | };
389 | assert.REDUCE = 'Reduce of empty object with no initial value';
390 |
391 | var $ = {
392 | g: global,
393 | FW: true,
394 | path: global,
395 | core: core,
396 | html: global.document && document.documentElement,
397 | // http://jsperf.com/core-js-isobject
398 | isObject: isObject,
399 | isFunction: isFunction,
400 | // Optional / simple context binding
401 | ctx: function(fn, that, length){
402 | assert.fn(fn);
403 | if(~length && that === undefined)return fn;
404 | switch(length){
405 | case 1: return function(a){
406 | return fn.call(that, a);
407 | }
408 | case 2: return function(a, b){
409 | return fn.call(that, a, b);
410 | }
411 | case 3: return function(a, b, c){
412 | return fn.call(that, a, b, c);
413 | }
414 | } return function(/* ...args */){
415 | return fn.apply(that, arguments);
416 | }
417 | },
418 | it: function(it){
419 | return it;
420 | },
421 | that: function(){
422 | return this;
423 | },
424 | // 7.1.4 ToInteger
425 | toInteger: toInteger,
426 | // 7.1.15 ToLength
427 | toLength: function(it){
428 | return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
429 | },
430 | toIndex: function(index, length){
431 | var index = toInteger(index);
432 | return index < 0 ? max(index + length, 0) : min(index, length);
433 | },
434 | trunc: trunc,
435 | // 20.1.2.4 Number.isNaN(number)
436 | isNaN: function(number){
437 | return number != number;
438 | },
439 | has: function(it, key){
440 | return hasOwnProperty.call(it, key);
441 | },
442 | create: Object.create,
443 | getProto: Object.getPrototypeOf,
444 | DESC: DESC,
445 | desc: desc,
446 | getDesc: Object.getOwnPropertyDescriptor,
447 | setDesc: defineProperty,
448 | getKeys: Object.keys,
449 | getNames: Object.getOwnPropertyNames,
450 | getSymbols: Object.getOwnPropertySymbols,
451 | ownKeys: function(it){
452 | assert.obj(it);
453 | return $.getSymbols ? $.getNames(it).concat($.getSymbols(it)) : $.getNames(it);
454 | },
455 | // Dummy, fix for not array-like ES3 string in es5 module
456 | ES5Object: Object,
457 | toObject: function(it){
458 | return $.ES5Object(assert.def(it));
459 | },
460 | hide: hide,
461 | def: createDefiner(0),
462 | set: global.Symbol ? simpleSet : hide,
463 | mix: function(target, src){
464 | for(var key in src)hide(target, key, src[key]);
465 | return target;
466 | },
467 | // $.a('str1,str2,str3') => ['str1', 'str2', 'str3']
468 | a: function(it){
469 | return String(it).split(',');
470 | },
471 | each: [].forEach,
472 | assert: assert
473 | };
474 | module.exports = $;
475 | },{"./$.global":7}],11:[function(require,module,exports){
476 | var $ = require('./$');
477 | module.exports = function(object, el){
478 | var O = $.toObject(object)
479 | , keys = $.getKeys(O)
480 | , length = keys.length
481 | , index = 0
482 | , key;
483 | while(length > index)if(O[key = keys[index++]] === el)return key;
484 | }
485 | },{"./$":10}],12:[function(require,module,exports){
486 | 'use strict';
487 | var $ = require('./$')
488 | , invoke = require('./$.invoke');
489 | module.exports = function(/* ...pargs */){
490 | var fn = $.assert.fn(this)
491 | , length = arguments.length
492 | , pargs = Array(length)
493 | , i = 0
494 | , _ = $.path._
495 | , holder = false;
496 | while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
497 | return function(/* ...args */){
498 | var that = this
499 | , _length = arguments.length
500 | , i = 0, j = 0, args;
501 | if(!holder && !_length)return invoke(fn, pargs, that);
502 | args = pargs.slice();
503 | if(holder)for(;length > i; i++)if(args[i] === _)args[i] = arguments[j++];
504 | while(_length > j)args.push(arguments[j++]);
505 | return invoke(fn, args, that);
506 | }
507 | }
508 | },{"./$":10,"./$.invoke":8}],13:[function(require,module,exports){
509 | 'use strict';
510 | module.exports = function(regExp, replace, isStatic){
511 | var replacer = replace === Object(replace) ? function(part){
512 | return replace[part];
513 | } : replace;
514 | return function(it){
515 | return String(isStatic ? it : this).replace(regExp, replacer);
516 | }
517 | }
518 | },{}],14:[function(require,module,exports){
519 | // Works with __proto__ only. Old v8 can't works with null proto objects.
520 | var $ = require('./$')
521 | , assert = $.assert;
522 | module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function(buggy, set){
523 | try {
524 | set = $.ctx(Function.call, $.getDesc(Object.prototype, '__proto__').set, 2);
525 | set({}, []);
526 | } catch(e){ buggy = true }
527 | return function(O, proto){
528 | assert.obj(O);
529 | assert(proto === null || $.isObject(proto), proto, ": can't set as prototype!");
530 | if(buggy)O.__proto__ = proto;
531 | else set(O, proto);
532 | return O;
533 | }
534 | }() : undefined);
535 | },{"./$":10}],15:[function(require,module,exports){
536 | var $ = require('./$');
537 | module.exports = function(C){
538 | if($.DESC && $.FW)$.setDesc(C, require('./$.wks')('species'), {
539 | configurable: true,
540 | get: $.that
541 | });
542 | }
543 | },{"./$":10,"./$.wks":19}],16:[function(require,module,exports){
544 | 'use strict';
545 | var $ = require('./$');
546 | module.exports = function(toString){
547 | return function(pos){
548 | var s = String($.assert.def(this))
549 | , i = $.toInteger(pos)
550 | , l = s.length
551 | , a, b;
552 | if(i < 0 || i >= l)return toString ? '' : undefined;
553 | a = s.charCodeAt(i);
554 | return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
555 | ? toString ? s.charAt(i) : a
556 | : toString ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
557 | }
558 | }
559 | },{"./$":10}],17:[function(require,module,exports){
560 | 'use strict';
561 | var $ = require('./$')
562 | , cof = require('./$.cof')
563 | , invoke = require('./$.invoke')
564 | , global = $.g
565 | , isFunction = $.isFunction
566 | , ctx = $.ctx
567 | , setTask = global.setImmediate
568 | , clearTask = global.clearImmediate
569 | , postMessage = global.postMessage
570 | , addEventListener = global.addEventListener
571 | , MessageChannel = global.MessageChannel
572 | , counter = 0
573 | , queue = {}
574 | , ONREADYSTATECHANGE = 'onreadystatechange'
575 | , defer, channel, port;
576 | function run(){
577 | var id = +this;
578 | if($.has(queue, id)){
579 | var fn = queue[id];
580 | delete queue[id];
581 | fn();
582 | }
583 | }
584 | function listner(event){
585 | run.call(event.data);
586 | }
587 | // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
588 | if(!isFunction(setTask) || !isFunction(clearTask)){
589 | setTask = function(fn){
590 | var args = [], i = 1;
591 | while(arguments.length > i)args.push(arguments[i++]);
592 | queue[++counter] = function(){
593 | invoke(isFunction(fn) ? fn : Function(fn), args);
594 | }
595 | defer(counter);
596 | return counter;
597 | }
598 | clearTask = function(id){
599 | delete queue[id];
600 | }
601 | // Node.js 0.8-
602 | if(cof(global.process) == 'process'){
603 | defer = function(id){
604 | global.process.nextTick(ctx(run, id, 1));
605 | }
606 | // Modern browsers, skip implementation for WebWorkers
607 | // IE8 has postMessage, but it's sync & typeof its postMessage is object
608 | } else if(addEventListener && isFunction(postMessage) && !$.g.importScripts){
609 | defer = function(id){
610 | postMessage(id, '*');
611 | }
612 | addEventListener('message', listner, false);
613 | // WebWorkers
614 | } else if(isFunction(MessageChannel)){
615 | channel = new MessageChannel;
616 | port = channel.port2;
617 | channel.port1.onmessage = listner;
618 | defer = ctx(port.postMessage, port, 1);
619 | // IE8-
620 | } else if($.g.document && ONREADYSTATECHANGE in document.createElement('script')){
621 | defer = function(id){
622 | $.html.appendChild(document.createElement('script'))[ONREADYSTATECHANGE] = function(){
623 | $.html.removeChild(this);
624 | run.call(id);
625 | }
626 | }
627 | // Rest old browsers
628 | } else {
629 | defer = function(id){
630 | setTimeout(ctx(run, id, 1), 0);
631 | }
632 | }
633 | }
634 | module.exports = {
635 | set: setTask,
636 | clear: clearTask
637 | };
638 | },{"./$":10,"./$.cof":5,"./$.invoke":8}],18:[function(require,module,exports){
639 | var sid = 0
640 | function uid(key){
641 | return 'Symbol(' + key + ')_' + (++sid + Math.random()).toString(36);
642 | }
643 | uid.safe = require('./$.global').Symbol || uid;
644 | module.exports = uid;
645 | },{"./$.global":7}],19:[function(require,module,exports){
646 | var global = require('./$.global')
647 | , store = {};
648 | module.exports = function(name){
649 | return store[name] || (store[name] =
650 | (global.Symbol && global.Symbol[name]) || require('./$.uid').safe('Symbol.' + name));
651 | }
652 | },{"./$.global":7,"./$.uid":18}],20:[function(require,module,exports){
653 | var $ = require('./$')
654 | , cof = require('./$.cof')
655 | , $def = require('./$.def')
656 | , invoke = require('./$.invoke')
657 | , arrayMethod = require('./$.array-methods')
658 | , IE_PROTO = require('./$.uid').safe('__proto__')
659 | , assert = $.assert
660 | , assertObject = assert.obj
661 | , ObjectProto = Object.prototype
662 | , A = []
663 | , slice = A.slice
664 | , indexOf = A.indexOf
665 | , classof = cof.classof
666 | , defineProperties = Object.defineProperties
667 | , has = $.has
668 | , defineProperty = $.setDesc
669 | , getOwnDescriptor = $.getDesc
670 | , isFunction = $.isFunction
671 | , toObject = $.toObject
672 | , toLength = $.toLength
673 | , IE8_DOM_DEFINE = false;
674 |
675 | if(!$.DESC){
676 | try {
677 | IE8_DOM_DEFINE = defineProperty(document.createElement('div'), 'x',
678 | {get: function(){return 8}}
679 | ).x == 8;
680 | } catch(e){}
681 | $.setDesc = function(O, P, A){
682 | if(IE8_DOM_DEFINE)try {
683 | return defineProperty(O, P, A);
684 | } catch(e){}
685 | if('get' in A || 'set' in A)throw TypeError('Accessors not supported!');
686 | if('value' in A)assertObject(O)[P] = A.value;
687 | return O;
688 | };
689 | $.getDesc = function(O, P){
690 | if(IE8_DOM_DEFINE)try {
691 | return getOwnDescriptor(O, P);
692 | } catch(e){}
693 | if(has(O, P))return $.desc(!ObjectProto.propertyIsEnumerable.call(O, P), O[P]);
694 | };
695 | defineProperties = function(O, Properties){
696 | assertObject(O);
697 | var keys = $.getKeys(Properties)
698 | , length = keys.length
699 | , i = 0
700 | , P;
701 | while(length > i)$.setDesc(O, P = keys[i++], Properties[P]);
702 | return O;
703 | };
704 | }
705 | $def($def.S + $def.F * !$.DESC, 'Object', {
706 | // 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P)
707 | getOwnPropertyDescriptor: $.getDesc,
708 | // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
709 | defineProperty: $.setDesc,
710 | // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
711 | defineProperties: defineProperties
712 | });
713 |
714 | // IE 8- don't enum bug keys
715 | var keys1 = $.a('constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf')
716 | // Additional keys for getOwnPropertyNames
717 | , keys2 = keys1.concat('length', 'prototype')
718 | , keysLen1 = keys1.length;
719 |
720 | // Create object with `null` prototype: use iframe Object with cleared prototype
721 | function createDict(){
722 | // Thrash, waste and sodomy: IE GC bug
723 | var iframe = document.createElement('iframe')
724 | , i = keysLen1
725 | , iframeDocument;
726 | iframe.style.display = 'none';
727 | $.html.appendChild(iframe);
728 | iframe.src = 'javascript:';
729 | // createDict = iframe.contentWindow.Object;
730 | // html.removeChild(iframe);
731 | iframeDocument = iframe.contentWindow.document;
732 | iframeDocument.open();
733 | iframeDocument.write('');
734 | iframeDocument.close();
735 | createDict = iframeDocument.F;
736 | while(i--)delete createDict.prototype[keys1[i]];
737 | return createDict();
738 | }
739 | function createGetKeys(names, length, isNames){
740 | return function(object){
741 | var O = toObject(object)
742 | , i = 0
743 | , result = []
744 | , key;
745 | for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
746 | // Don't enum bug & hidden keys
747 | while(length > i)if(has(O, key = names[i++])){
748 | ~indexOf.call(result, key) || result.push(key);
749 | }
750 | return result;
751 | }
752 | }
753 | function isPrimitive(it){ return !$.isObject(it) }
754 | function Empty(){}
755 | $def($def.S, 'Object', {
756 | // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
757 | getPrototypeOf: $.getProto = $.getProto || function(O){
758 | O = Object(assert.def(O));
759 | if(has(O, IE_PROTO))return O[IE_PROTO];
760 | if(isFunction(O.constructor) && O instanceof O.constructor){
761 | return O.constructor.prototype;
762 | } return O instanceof Object ? ObjectProto : null;
763 | },
764 | // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
765 | getOwnPropertyNames: $.getNames = $.getNames || createGetKeys(keys2, keys2.length, true),
766 | // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
767 | create: $.create = $.create || function(O, /*?*/Properties){
768 | var result
769 | if(O !== null){
770 | Empty.prototype = assertObject(O);
771 | result = new Empty();
772 | Empty.prototype = null;
773 | // add "__proto__" for Object.getPrototypeOf shim
774 | result[IE_PROTO] = O;
775 | } else result = createDict();
776 | return Properties === undefined ? result : defineProperties(result, Properties);
777 | },
778 | // 19.1.2.14 / 15.2.3.14 Object.keys(O)
779 | keys: $.getKeys = $.getKeys || createGetKeys(keys1, keysLen1, false),
780 | // 19.1.2.17 / 15.2.3.8 Object.seal(O)
781 | seal: $.it, // <- cap
782 | // 19.1.2.5 / 15.2.3.9 Object.freeze(O)
783 | freeze: $.it, // <- cap
784 | // 19.1.2.15 / 15.2.3.10 Object.preventExtensions(O)
785 | preventExtensions: $.it, // <- cap
786 | // 19.1.2.13 / 15.2.3.11 Object.isSealed(O)
787 | isSealed: isPrimitive, // <- cap
788 | // 19.1.2.12 / 15.2.3.12 Object.isFrozen(O)
789 | isFrozen: isPrimitive, // <- cap
790 | // 19.1.2.11 / 15.2.3.13 Object.isExtensible(O)
791 | isExtensible: $.isObject // <- cap
792 | });
793 |
794 | // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
795 | $def($def.P, 'Function', {
796 | bind: function(that /*, args... */){
797 | var fn = assert.fn(this)
798 | , partArgs = slice.call(arguments, 1);
799 | function bound(/* args... */){
800 | var args = partArgs.concat(slice.call(arguments));
801 | return invoke(fn, args, this instanceof bound ? $.create(fn.prototype) : that);
802 | }
803 | if(fn.prototype)bound.prototype = fn.prototype;
804 | return bound;
805 | }
806 | });
807 |
808 | // Fix for not array-like ES3 string
809 | function arrayMethodFix(fn){
810 | return function(){
811 | return fn.apply($.ES5Object(this), arguments);
812 | }
813 | }
814 | if(!(0 in Object('z') && 'z'[0] == 'z')){
815 | $.ES5Object = function(it){
816 | return cof(it) == 'String' ? it.split('') : Object(it);
817 | }
818 | }
819 | $def($def.P + $def.F * ($.ES5Object != Object), 'Array', {
820 | slice: arrayMethodFix(slice),
821 | join: arrayMethodFix(A.join)
822 | });
823 |
824 | // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
825 | $def($def.S, 'Array', {
826 | isArray: function(arg){
827 | return cof(arg) == 'Array'
828 | }
829 | });
830 | function createArrayReduce(isRight){
831 | return function(callbackfn, memo){
832 | assert.fn(callbackfn);
833 | var O = toObject(this)
834 | , length = toLength(O.length)
835 | , index = isRight ? length - 1 : 0
836 | , i = isRight ? -1 : 1;
837 | if(2 > arguments.length)for(;;){
838 | if(index in O){
839 | memo = O[index];
840 | index += i;
841 | break;
842 | }
843 | index += i;
844 | assert(isRight ? index >= 0 : length > index, assert.REDUCE);
845 | }
846 | for(;isRight ? index >= 0 : length > index; index += i)if(index in O){
847 | memo = callbackfn(memo, O[index], index, this);
848 | }
849 | return memo;
850 | }
851 | }
852 | $def($def.P, 'Array', {
853 | // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
854 | forEach: $.each = $.each || arrayMethod(0),
855 | // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
856 | map: arrayMethod(1),
857 | // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
858 | filter: arrayMethod(2),
859 | // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
860 | some: arrayMethod(3),
861 | // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
862 | every: arrayMethod(4),
863 | // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
864 | reduce: createArrayReduce(false),
865 | // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
866 | reduceRight: createArrayReduce(true),
867 | // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
868 | indexOf: indexOf = indexOf || require('./$.array-includes')(false),
869 | // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
870 | lastIndexOf: function(el, fromIndex /* = @[*-1] */){
871 | var O = toObject(this)
872 | , length = toLength(O.length)
873 | , index = length - 1;
874 | if(arguments.length > 1)index = Math.min(index, $.toInteger(fromIndex));
875 | if(index < 0)index = toLength(length + index);
876 | for(;index >= 0; index--)if(index in O)if(O[index] === el)return index;
877 | return -1;
878 | }
879 | });
880 |
881 | // 21.1.3.25 / 15.5.4.20 String.prototype.trim()
882 | $def($def.P, 'String', {trim: require('./$.replacer')(/^\s*([\s\S]*\S)?\s*$/, '$1')});
883 |
884 | // 20.3.3.1 / 15.9.4.4 Date.now()
885 | $def($def.S, 'Date', {now: function(){
886 | return +new Date;
887 | }});
888 |
889 | function lz(num){
890 | return num > 9 ? num : '0' + num;
891 | }
892 | // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
893 | $def($def.P, 'Date', {toISOString: function(){
894 | if(!isFinite(this))throw RangeError('Invalid time value');
895 | var d = this
896 | , y = d.getUTCFullYear()
897 | , m = d.getUTCMilliseconds()
898 | , s = y < 0 ? '-' : y > 9999 ? '+' : '';
899 | return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
900 | '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
901 | 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
902 | ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
903 | }});
904 |
905 | if(classof(function(){return arguments}()) == 'Object')cof.classof = function(it){
906 | var cof = classof(it);
907 | return cof == 'Object' && isFunction(it.callee) ? 'Arguments' : cof;
908 | }
909 | },{"./$":10,"./$.array-includes":2,"./$.array-methods":3,"./$.cof":5,"./$.def":6,"./$.invoke":8,"./$.replacer":13,"./$.uid":18}],21:[function(require,module,exports){
910 | 'use strict';
911 | var $ = require('./$')
912 | , $def = require('./$.def')
913 | , arrayMethod = require('./$.array-methods')
914 | , UNSCOPABLES = require('./$.wks')('unscopables')
915 | , assertDefined = $.assert.def
916 | , toIndex = $.toIndex
917 | , toLength = $.toLength
918 | , ArrayProto = Array.prototype
919 | , ArrayUnscopables = ArrayProto[UNSCOPABLES] || {};
920 | $def($def.P, 'Array', {
921 | // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
922 | copyWithin: function(target /* = 0 */, start /* = 0, end = @length */){
923 | var O = Object(assertDefined(this))
924 | , len = toLength(O.length)
925 | , to = toIndex(target, len)
926 | , from = toIndex(start, len)
927 | , end = arguments[2]
928 | , fin = end === undefined ? len : toIndex(end, len)
929 | , count = Math.min(fin - from, len - to)
930 | , inc = 1;
931 | if(from < to && to < from + count){
932 | inc = -1;
933 | from = from + count - 1;
934 | to = to + count - 1;
935 | }
936 | while(count-- > 0){
937 | if(from in O)O[to] = O[from];
938 | else delete O[to];
939 | to += inc;
940 | from += inc;
941 | } return O;
942 | },
943 | // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
944 | fill: function(value /*, start = 0, end = @length */){
945 | var O = Object(assertDefined(this))
946 | , length = toLength(O.length)
947 | , index = toIndex(arguments[1], length)
948 | , end = arguments[2]
949 | , endPos = end === undefined ? length : toIndex(end, length);
950 | while(endPos > index)O[index++] = value;
951 | return O;
952 | },
953 | // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
954 | find: arrayMethod(5),
955 | // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
956 | findIndex: arrayMethod(6)
957 | });
958 |
959 | if($.FW){
960 | // 22.1.3.31 Array.prototype[@@unscopables]
961 | $.each.call($.a('find,findIndex,fill,copyWithin,entries,keys,values'), function(it){
962 | ArrayUnscopables[it] = true;
963 | });
964 | UNSCOPABLES in ArrayProto || $.hide(ArrayProto, UNSCOPABLES, ArrayUnscopables);
965 | }
966 | },{"./$":10,"./$.array-methods":3,"./$.def":6,"./$.wks":19}],22:[function(require,module,exports){
967 | require('./es6.iterators');
968 | var $ = require('./$')
969 | , $def = require('./$.def')
970 | , $iter = require('./$.iter');
971 | function generic(A, B){
972 | // strange IE quirks mode bug -> use typeof instead of isFunction
973 | return typeof A == 'function' ? A : B;
974 | }
975 | $def($def.S + $def.F * $iter.DANGER_CLOSING, 'Array', {
976 | // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
977 | from: function(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
978 | var O = Object($.assert.def(arrayLike))
979 | , mapfn = arguments[1]
980 | , mapping = mapfn !== undefined
981 | , f = mapping ? $.ctx(mapfn, arguments[2], 2) : undefined
982 | , index = 0
983 | , length, result, step;
984 | if($iter.is(O)){
985 | result = new (generic(this, Array));
986 | $iter.exec(function(iterator){
987 | for(; !(step = iterator.next()).done; index++){
988 | result[index] = mapping ? f(step.value, index) : step.value;
989 | }
990 | }, $iter.get(O));
991 | } else {
992 | result = new (generic(this, Array))(length = $.toLength(O.length));
993 | for(; length > index; index++){
994 | result[index] = mapping ? f(O[index], index) : O[index];
995 | }
996 | }
997 | result.length = index;
998 | return result;
999 | }
1000 | });
1001 |
1002 | $def($def.S, 'Array', {
1003 | // 22.1.2.3 Array.of( ...items)
1004 | of: function(/* ...args */){
1005 | var index = 0
1006 | , length = arguments.length
1007 | , result = new (generic(this, Array))(length);
1008 | while(length > index)result[index] = arguments[index++];
1009 | result.length = length;
1010 | return result;
1011 | }
1012 | });
1013 |
1014 | require('./$.species')(Array);
1015 | },{"./$":10,"./$.def":6,"./$.iter":9,"./$.species":15,"./es6.iterators":25}],23:[function(require,module,exports){
1016 | 'use strict';
1017 | require('./es6.iterators');
1018 | var $ = require('./$')
1019 | , cof = require('./$.cof')
1020 | , $def = require('./$.def')
1021 | , safe = require('./$.uid').safe
1022 | , $iter = require('./$.iter')
1023 | , step = $iter.step
1024 | , assert = $.assert
1025 | , isFrozen = Object.isFrozen || $.core.Object.isFrozen
1026 | , CID = safe('cid')
1027 | , O1 = safe('O1')
1028 | , WEAK = safe('weak')
1029 | , LEAK = safe('leak')
1030 | , LAST = safe('last')
1031 | , FIRST = safe('first')
1032 | , ITER = safe('iter')
1033 | , SIZE = $.DESC ? safe('size') : 'size'
1034 | , cid = 0
1035 | , tmp = {};
1036 |
1037 | function getCollection(NAME, methods, commonMethods, isMap, isWeak){
1038 | var Base = $.g[NAME]
1039 | , C = Base
1040 | , ADDER = isMap ? 'set' : 'add'
1041 | , proto = C && C.prototype
1042 | , O = {};
1043 | function initFromIterable(that, iterable){
1044 | if(iterable != undefined)$iter.forOf(iterable, isMap, that[ADDER], that);
1045 | return that;
1046 | }
1047 | function fixSVZ(key, chain){
1048 | var method = proto[key];
1049 | if($.FW)proto[key] = function(a, b){
1050 | var result = method.call(this, a === 0 ? 0 : a, b);
1051 | return chain ? this : result;
1052 | };
1053 | }
1054 | function checkIter(){
1055 | var done = false;
1056 | var O = {next: function(){
1057 | done = true;
1058 | return step(1);
1059 | }};
1060 | var SYMBOL_ITERATOR=SYMBOL_ITERATOR || Symbol.iterator;
1061 | O[SYMBOL_ITERATOR] = $.that;
1062 | try { new C(O) } catch(e){}
1063 | return done;
1064 | }
1065 | if(!$.isFunction(C) || !(isWeak || (!$iter.BUGGY && proto.forEach && proto.entries))){
1066 | // create collection constructor
1067 | C = isWeak
1068 | ? function(iterable){
1069 | $.set(assert.inst(this, C, NAME), CID, cid++);
1070 | initFromIterable(this, iterable);
1071 | }
1072 | : function(iterable){
1073 | var that = assert.inst(this, C, NAME);
1074 | $.set(that, O1, $.create(null));
1075 | $.set(that, SIZE, 0);
1076 | $.set(that, LAST, undefined);
1077 | $.set(that, FIRST, undefined);
1078 | initFromIterable(that, iterable);
1079 | };
1080 | $.mix($.mix(C.prototype, methods), commonMethods);
1081 | isWeak || !$.DESC || $.setDesc(C.prototype, 'size', {get: function(){
1082 | return assert.def(this[SIZE]);
1083 | }});
1084 | } else {
1085 | var Native = C
1086 | , inst = new C
1087 | , chain = inst[ADDER](isWeak ? {} : -0, 1)
1088 | , buggyZero;
1089 | // wrap to init collections from iterable
1090 | if($iter.DANGER_CLOSING || !checkIter()){
1091 | C = function(iterable){
1092 | assert.inst(this, C, NAME);
1093 | return initFromIterable(new Native, iterable);
1094 | }
1095 | C.prototype = proto;
1096 | if($.FW)proto.constructor = C;
1097 | }
1098 | isWeak || inst.forEach(function(val, key){
1099 | buggyZero = 1 / key === -Infinity;
1100 | });
1101 | // fix converting -0 key to +0
1102 | if(buggyZero){
1103 | fixSVZ('delete');
1104 | fixSVZ('has');
1105 | isMap && fixSVZ('get');
1106 | }
1107 | // + fix .add & .set for chaining
1108 | if(buggyZero || chain !== inst)fixSVZ(ADDER, true);
1109 | }
1110 | cof.set(C, NAME);
1111 | require('./$.species')(C);
1112 |
1113 | O[NAME] = C;
1114 | $def($def.G + $def.W + $def.F * (C != Base), O);
1115 |
1116 | // add .keys, .values, .entries, [@@iterator]
1117 | // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
1118 | isWeak || $iter.std(C, NAME, function(iterated, kind){
1119 | $.set(this, ITER, {o: iterated, k: kind});
1120 | }, function(){
1121 | var iter = this[ITER]
1122 | , kind = iter.k
1123 | , entry = iter.l;
1124 | // revert to the last existing entry
1125 | while(entry && entry.r)entry = entry.p;
1126 | // get next entry
1127 | if(!iter.o || !(iter.l = entry = entry ? entry.n : iter.o[FIRST])){
1128 | // or finish the iteration
1129 | iter.o = undefined;
1130 | return step(1);
1131 | }
1132 | // return step by kind
1133 | if(kind == 'key') return step(0, entry.k);
1134 | if(kind == 'value') return step(0, entry.v);
1135 | return step(0, [entry.k, entry.v]);
1136 | }, isMap ? 'key+value' : 'value', !isMap, true);
1137 |
1138 | return C;
1139 | }
1140 |
1141 | function fastKey(it, create){
1142 | // return primitive with prefix
1143 | if(!$.isObject(it))return (typeof it == 'string' ? 'S' : 'P') + it;
1144 | // can't set id to frozen object
1145 | if(isFrozen(it))return 'F';
1146 | if(!$.has(it, CID)){
1147 | // not necessary to add id
1148 | if(!create)return 'E';
1149 | // add missing object id
1150 | $.hide(it, CID, ++cid);
1151 | // return object id with prefix
1152 | } return 'O' + it[CID];
1153 | }
1154 | function getEntry(that, key){
1155 | // fast case
1156 | var index = fastKey(key), entry;
1157 | if(index != 'F')return that[O1][index];
1158 | // frozen object case
1159 | for(entry = that[FIRST]; entry; entry = entry.n){
1160 | if(entry.k == key)return entry;
1161 | }
1162 | }
1163 | function def(that, key, value){
1164 | var entry = getEntry(that, key)
1165 | , prev, index;
1166 | // change existing entry
1167 | if(entry)entry.v = value;
1168 | // create new entry
1169 | else {
1170 | that[LAST] = entry = {
1171 | i: index = fastKey(key, true), // <- index
1172 | k: key, // <- key
1173 | v: value, // <- value
1174 | p: prev = that[LAST], // <- previous entry
1175 | n: undefined, // <- next entry
1176 | r: false // <- removed
1177 | };
1178 | if(!that[FIRST])that[FIRST] = entry;
1179 | if(prev)prev.n = entry;
1180 | that[SIZE]++;
1181 | // add to index
1182 | if(index != 'F')that[O1][index] = entry;
1183 | } return that;
1184 | }
1185 |
1186 | var collectionMethods = {
1187 | // 23.1.3.1 Map.prototype.clear()
1188 | // 23.2.3.2 Set.prototype.clear()
1189 | clear: function(){
1190 | for(var that = this, data = that[O1], entry = that[FIRST]; entry; entry = entry.n){
1191 | entry.r = true;
1192 | if(entry.p)entry.p = entry.p.n = undefined;
1193 | delete data[entry.i];
1194 | }
1195 | that[FIRST] = that[LAST] = undefined;
1196 | that[SIZE] = 0;
1197 | },
1198 | // 23.1.3.3 Map.prototype.delete(key)
1199 | // 23.2.3.4 Set.prototype.delete(value)
1200 | 'delete': function(key){
1201 | var that = this
1202 | , entry = getEntry(that, key);
1203 | if(entry){
1204 | var next = entry.n
1205 | , prev = entry.p;
1206 | delete that[O1][entry.i];
1207 | entry.r = true;
1208 | if(prev)prev.n = next;
1209 | if(next)next.p = prev;
1210 | if(that[FIRST] == entry)that[FIRST] = next;
1211 | if(that[LAST] == entry)that[LAST] = prev;
1212 | that[SIZE]--;
1213 | } return !!entry;
1214 | },
1215 | // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
1216 | // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
1217 | forEach: function(callbackfn /*, that = undefined */){
1218 | var f = $.ctx(callbackfn, arguments[1], 3)
1219 | , entry;
1220 | while(entry = entry ? entry.n : this[FIRST]){
1221 | f(entry.v, entry.k, this);
1222 | // revert to the last existing entry
1223 | while(entry && entry.r)entry = entry.p;
1224 | }
1225 | },
1226 | // 23.1.3.7 Map.prototype.has(key)
1227 | // 23.2.3.7 Set.prototype.has(value)
1228 | has: function(key){
1229 | return !!getEntry(this, key);
1230 | }
1231 | }
1232 |
1233 | // 23.1 Map Objects
1234 | var Map = getCollection('Map', {
1235 | // 23.1.3.6 Map.prototype.get(key)
1236 | get: function(key){
1237 | var entry = getEntry(this, key);
1238 | return entry && entry.v;
1239 | },
1240 | // 23.1.3.9 Map.prototype.set(key, value)
1241 | set: function(key, value){
1242 | return def(this, key === 0 ? 0 : key, value);
1243 | }
1244 | }, collectionMethods, true);
1245 |
1246 | // 23.2 Set Objects
1247 | getCollection('Set', {
1248 | // 23.2.3.1 Set.prototype.add(value)
1249 | add: function(value){
1250 | return def(this, value = value === 0 ? 0 : value, value);
1251 | }
1252 | }, collectionMethods);
1253 |
1254 | function defWeak(that, key, value){
1255 | if(isFrozen(assert.obj(key)))leakStore(that).set(key, value);
1256 | else {
1257 | $.has(key, WEAK) || $.hide(key, WEAK, {});
1258 | key[WEAK][that[CID]] = value;
1259 | } return that;
1260 | }
1261 | function leakStore(that){
1262 | return that[LEAK] || $.hide(that, LEAK, new Map)[LEAK];
1263 | }
1264 |
1265 | var weakMethods = {
1266 | // 23.3.3.2 WeakMap.prototype.delete(key)
1267 | // 23.4.3.3 WeakSet.prototype.delete(value)
1268 | 'delete': function(key){
1269 | if(!$.isObject(key))return false;
1270 | if(isFrozen(key))return leakStore(this)['delete'](key);
1271 | return $.has(key, WEAK) && $.has(key[WEAK], this[CID]) && delete key[WEAK][this[CID]];
1272 | },
1273 | // 23.3.3.4 WeakMap.prototype.has(key)
1274 | // 23.4.3.4 WeakSet.prototype.has(value)
1275 | has: function(key){
1276 | if(!$.isObject(key))return false;
1277 | if(isFrozen(key))return leakStore(this).has(key);
1278 | return $.has(key, WEAK) && $.has(key[WEAK], this[CID]);
1279 | }
1280 | };
1281 |
1282 | // 23.3 WeakMap Objects
1283 | var WeakMap = getCollection('WeakMap', {
1284 | // 23.3.3.3 WeakMap.prototype.get(key)
1285 | get: function(key){
1286 | if($.isObject(key)){
1287 | if(isFrozen(key))return leakStore(this).get(key);
1288 | if($.has(key, WEAK))return key[WEAK][this[CID]];
1289 | }
1290 | },
1291 | // 23.3.3.5 WeakMap.prototype.set(key, value)
1292 | set: function(key, value){
1293 | return defWeak(this, key, value);
1294 | }
1295 | }, weakMethods, true, true);
1296 |
1297 | // IE11 WeakMap frozen keys fix
1298 | if($.FW && new WeakMap().set(Object.freeze(tmp), 7).get(tmp) != 7){
1299 | $.each.call($.a('delete,has,get,set'), function(key){
1300 | var method = WeakMap.prototype[key];
1301 | WeakMap.prototype[key] = function(a, b){
1302 | // store frozen objects on leaky map
1303 | if($.isObject(a) && isFrozen(a)){
1304 | var result = leakStore(this)[key](a, b);
1305 | return key == 'set' ? this : result;
1306 | // store all the rest on native weakmap
1307 | } return method.call(this, a, b);
1308 | };
1309 | });
1310 | }
1311 |
1312 | // 23.4 WeakSet Objects
1313 | getCollection('WeakSet', {
1314 | // 23.4.3.1 WeakSet.prototype.add(value)
1315 | add: function(value){
1316 | return defWeak(this, value, true);
1317 | }
1318 | }, weakMethods, false, true);
1319 | },{"./$":10,"./$.cof":5,"./$.def":6,"./$.iter":9,"./$.species":15,"./$.uid":18,"./es6.iterators":25}],24:[function(require,module,exports){
1320 | 'use strict';
1321 | var $ = require('./$')
1322 | , NAME = 'name'
1323 | , FnProto = Function.prototype;
1324 | // 19.2.4.2 name
1325 | NAME in FnProto || ($.FW && $.DESC && $.setDesc(FnProto, NAME, {
1326 | configurable: true,
1327 | get: function(){
1328 | var match = String(this).match(/^\s*function ([^ (]*)/)
1329 | , name = match ? match[1] : '';
1330 | $.has(this, NAME) || $.setDesc(this, NAME, $.desc(5, name));
1331 | return name;
1332 | },
1333 | set: function(value){
1334 | $.has(this, NAME) || $.setDesc(this, NAME, $.desc(0, value));
1335 | }
1336 | }));
1337 | },{"./$":10}],25:[function(require,module,exports){
1338 | var $ = require('./$')
1339 | , at = require('./$.string-at')(true)
1340 | , ITER = require('./$.uid').safe('iter')
1341 | , $iter = require('./$.iter')
1342 | , step = $iter.step
1343 | , Iterators = $iter.Iterators;
1344 | // 22.1.3.4 Array.prototype.entries()
1345 | // 22.1.3.13 Array.prototype.keys()
1346 | // 22.1.3.29 Array.prototype.values()
1347 | // 22.1.3.30 Array.prototype[@@iterator]()
1348 | $iter.std(Array, 'Array', function(iterated, kind){
1349 | $.set(this, ITER, {o: $.toObject(iterated), i: 0, k: kind});
1350 | // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
1351 | }, function(){
1352 | var iter = this[ITER]
1353 | , O = iter.o
1354 | , kind = iter.k
1355 | , index = iter.i++;
1356 | if(!O || index >= O.length){
1357 | iter.o = undefined;
1358 | return step(1);
1359 | }
1360 | if(kind == 'key') return step(0, index);
1361 | if(kind == 'value') return step(0, O[index]);
1362 | return step(0, [index, O[index]]);
1363 | }, 'value');
1364 |
1365 | // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
1366 | Iterators.Arguments = Iterators.Array;
1367 |
1368 | // 21.1.3.27 String.prototype[@@iterator]()
1369 | $iter.std(String, 'String', function(iterated){
1370 | $.set(this, ITER, {o: String(iterated), i: 0});
1371 | // 21.1.5.2.1 %StringIteratorPrototype%.next()
1372 | }, function(){
1373 | var iter = this[ITER]
1374 | , O = iter.o
1375 | , index = iter.i
1376 | , point;
1377 | if(index >= O.length)return step(1);
1378 | point = at.call(O, index);
1379 | iter.i += point.length;
1380 | return step(0, point);
1381 | });
1382 | },{"./$":10,"./$.iter":9,"./$.string-at":16,"./$.uid":18}],26:[function(require,module,exports){
1383 | var $ = require('./$')
1384 | , $def = require('./$.def')
1385 | , Math = $.g.Math
1386 | , E = Math.E
1387 | , pow = Math.pow
1388 | , abs = Math.abs
1389 | , exp = Math.exp
1390 | , log = Math.log
1391 | , sqrt = Math.sqrt
1392 | , Infinity = 1 / 0
1393 | , sign = Math.sign || function(x){
1394 | return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
1395 | };
1396 |
1397 | // 20.2.2.5 Math.asinh(x)
1398 | function asinh(x){
1399 | return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));
1400 | }
1401 | // 20.2.2.14 Math.expm1(x)
1402 | function expm1(x){
1403 | return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;
1404 | }
1405 |
1406 | $def($def.S, 'Math', {
1407 | // 20.2.2.3 Math.acosh(x)
1408 | acosh: function(x){
1409 | return (x = +x) < 1 ? NaN : isFinite(x) ? log(x / E + sqrt(x + 1) * sqrt(x - 1) / E) + 1 : x;
1410 | },
1411 | // 20.2.2.5 Math.asinh(x)
1412 | asinh: asinh,
1413 | // 20.2.2.7 Math.atanh(x)
1414 | atanh: function(x){
1415 | return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;
1416 | },
1417 | // 20.2.2.9 Math.cbrt(x)
1418 | cbrt: function(x){
1419 | return sign(x = +x) * pow(abs(x), 1 / 3);
1420 | },
1421 | // 20.2.2.11 Math.clz32(x)
1422 | clz32: function(x){
1423 | return (x >>>= 0) ? 32 - x.toString(2).length : 32;
1424 | },
1425 | // 20.2.2.12 Math.cosh(x)
1426 | cosh: function(x){
1427 | return (exp(x = +x) + exp(-x)) / 2;
1428 | },
1429 | // 20.2.2.14 Math.expm1(x)
1430 | expm1: expm1,
1431 | // 20.2.2.16 Math.fround(x)
1432 | // TODO: fallback for IE9-
1433 | fround: function(x){
1434 | return new Float32Array([x])[0];
1435 | },
1436 | // 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
1437 | hypot: function(value1, value2){
1438 | var sum = 0
1439 | , len1 = arguments.length
1440 | , len2 = len1
1441 | , args = Array(len1)
1442 | , larg = -Infinity
1443 | , arg;
1444 | while(len1--){
1445 | arg = args[len1] = +arguments[len1];
1446 | if(arg == Infinity || arg == -Infinity)return Infinity;
1447 | if(arg > larg)larg = arg;
1448 | }
1449 | larg = arg || 1;
1450 | while(len2--)sum += pow(args[len2] / larg, 2);
1451 | return larg * sqrt(sum);
1452 | },
1453 | // 20.2.2.18 Math.imul(x, y)
1454 | imul: function(x, y){
1455 | var UInt16 = 0xffff
1456 | , xn = +x
1457 | , yn = +y
1458 | , xl = UInt16 & xn
1459 | , yl = UInt16 & yn;
1460 | return 0 | xl * yl + ((UInt16 & xn >>> 16) * yl + xl * (UInt16 & yn >>> 16) << 16 >>> 0);
1461 | },
1462 | // 20.2.2.20 Math.log1p(x)
1463 | log1p: function(x){
1464 | return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);
1465 | },
1466 | // 20.2.2.21 Math.log10(x)
1467 | log10: function(x){
1468 | return log(x) / Math.LN10;
1469 | },
1470 | // 20.2.2.22 Math.log2(x)
1471 | log2: function(x){
1472 | return log(x) / Math.LN2;
1473 | },
1474 | // 20.2.2.28 Math.sign(x)
1475 | sign: sign,
1476 | // 20.2.2.30 Math.sinh(x)
1477 | sinh: function(x){
1478 | return (abs(x = +x) < 1) ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
1479 | },
1480 | // 20.2.2.33 Math.tanh(x)
1481 | tanh: function(x){
1482 | var a = expm1(x = +x)
1483 | , b = expm1(-x);
1484 | return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
1485 | },
1486 | // 20.2.2.34 Math.trunc(x)
1487 | trunc: $.trunc
1488 | });
1489 | },{"./$":10,"./$.def":6}],27:[function(require,module,exports){
1490 | var $ = require('./$')
1491 | , $def = require('./$.def')
1492 | , abs = Math.abs
1493 | , floor = Math.floor
1494 | , MAX_SAFE_INTEGER = 0x1fffffffffffff // pow(2, 53) - 1 == 9007199254740991;
1495 | // 20.1.2.3 Number.isInteger(number)
1496 | function isInteger(it){
1497 | return !$.isObject(it) && isFinite(it) && floor(it) === it;
1498 | }
1499 | $def($def.S, 'Number', {
1500 | // 20.1.2.1 Number.EPSILON
1501 | EPSILON: Math.pow(2, -52),
1502 | // 20.1.2.2 Number.isFinite(number)
1503 | isFinite: function(it){
1504 | return typeof it == 'number' && isFinite(it);
1505 | },
1506 | // 20.1.2.3 Number.isInteger(number)
1507 | isInteger: isInteger,
1508 | // 20.1.2.4 Number.isNaN(number)
1509 | isNaN: $.isNaN,
1510 | // 20.1.2.5 Number.isSafeInteger(number)
1511 | isSafeInteger: function(number){
1512 | return isInteger(number) && abs(number) <= MAX_SAFE_INTEGER;
1513 | },
1514 | // 20.1.2.6 Number.MAX_SAFE_INTEGER
1515 | MAX_SAFE_INTEGER: MAX_SAFE_INTEGER,
1516 | // 20.1.2.10 Number.MIN_SAFE_INTEGER
1517 | MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER,
1518 | // 20.1.2.12 Number.parseFloat(string)
1519 | parseFloat: parseFloat,
1520 | // 20.1.2.13 Number.parseInt(string, radix)
1521 | parseInt: parseInt
1522 | });
1523 | },{"./$":10,"./$.def":6}],28:[function(require,module,exports){
1524 | 'use strict';
1525 | // 19.1.3.6 Object.prototype.toString()
1526 | var $ = require('./$')
1527 | , cof = require('./$.cof')
1528 | , tmp = {};
1529 | tmp[require('./$.wks')('toStringTag')] = 'z';
1530 | if($.FW && cof(tmp) != 'z')$.hide(Object.prototype, 'toString', function(){
1531 | return '[object ' + cof.classof(this) + ']';
1532 | });
1533 | },{"./$":10,"./$.cof":5,"./$.wks":19}],29:[function(require,module,exports){
1534 | var $ = require('./$')
1535 | , $def = require('./$.def')
1536 | , isObject = $.isObject
1537 | , toObject = $.toObject;
1538 | function wrapObjectMethod(key, MODE){
1539 | var fn = ($.core.Object || {})[key] || Object[key]
1540 | , f = 0
1541 | , o = {};
1542 | o[key] = MODE == 1 ? function(it){
1543 | return isObject(it) ? fn(it) : it;
1544 | } : MODE == 2 ? function(it){
1545 | return isObject(it) ? fn(it) : true;
1546 | } : MODE == 3 ? function(it){
1547 | return isObject(it) ? fn(it) : false;
1548 | } : MODE == 4 ? function(it, key){
1549 | return fn(toObject(it), key);
1550 | } : function(it){
1551 | return fn(toObject(it));
1552 | };
1553 | try { fn('z') }
1554 | catch(e){ f = 1 }
1555 | $def($def.S + $def.F * f, 'Object', o);
1556 | }
1557 | wrapObjectMethod('freeze', 1);
1558 | wrapObjectMethod('seal', 1);
1559 | wrapObjectMethod('preventExtensions', 1);
1560 | wrapObjectMethod('isFrozen', 2);
1561 | wrapObjectMethod('isSealed', 2);
1562 | wrapObjectMethod('isExtensible', 3);
1563 | wrapObjectMethod('getOwnPropertyDescriptor', 4);
1564 | wrapObjectMethod('getPrototypeOf');
1565 | wrapObjectMethod('keys');
1566 | wrapObjectMethod('getOwnPropertyNames');
1567 | },{"./$":10,"./$.def":6}],30:[function(require,module,exports){
1568 | var $def = require('./$.def')
1569 | , setProto = require('./$.set-proto');
1570 | var objectStatic = {
1571 | // 19.1.3.1 Object.assign(target, source)
1572 | assign: require('./$.assign'),
1573 | // 19.1.3.10 Object.is(value1, value2)
1574 | is: function(x, y){
1575 | return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
1576 | }
1577 | };
1578 | // 19.1.3.19 Object.setPrototypeOf(O, proto)
1579 | if(setProto)objectStatic.setPrototypeOf = setProto;
1580 | $def($def.S, 'Object', objectStatic);
1581 | },{"./$.assign":4,"./$.def":6,"./$.set-proto":14}],31:[function(require,module,exports){
1582 | 'use strict';
1583 | require('./es6.iterators');
1584 | var $ = require('./$')
1585 | , cof = require('./$.cof')
1586 | , $def = require('./$.def')
1587 | , forOf = require('./$.iter').forOf
1588 | , SPECIES = require('./$.wks')('species')
1589 | , RECORD = require('./$.uid').safe('record')
1590 | , PROMISE = 'Promise'
1591 | , global = $.g
1592 | , assert = $.assert
1593 | , ctx = $.ctx
1594 | , process = global.process
1595 | , asap = process && process.nextTick || require('./$.task').set
1596 | , Promise = global[PROMISE]
1597 | , Base = Promise
1598 | , isFunction = $.isFunction
1599 | , isObject = $.isObject
1600 | , assertFn = assert.fn
1601 | , assertObj = assert.obj
1602 | , test;
1603 | isFunction(Promise) && isFunction(Promise.resolve)
1604 | && Promise.resolve(test = new Promise(function(){})) == test
1605 | || function(){
1606 | function isThenable(it){
1607 | var then;
1608 | if(isObject(it))then = it.then;
1609 | return isFunction(then) ? then : false;
1610 | }
1611 | function handledRejectionOrHasOnRejected(promise){
1612 | var record = promise[RECORD]
1613 | , chain = record.c
1614 | , i = 0
1615 | , react;
1616 | if(record.h)return true;
1617 | while(chain.length > i){
1618 | react = chain[i++];
1619 | if(react.fail || handledRejectionOrHasOnRejected(react.P))return true;
1620 | }
1621 | }
1622 | function notify(record, reject){
1623 | var chain = record.c;
1624 | if(reject || chain.length)asap(function(){
1625 | var promise = record.p
1626 | , value = record.v
1627 | , ok = record.s == 1
1628 | , i = 0;
1629 | if(reject && !handledRejectionOrHasOnRejected(promise)){
1630 | setTimeout(function(){
1631 | if(!handledRejectionOrHasOnRejected(promise)){
1632 | if(cof(process) == 'process'){
1633 | if(!process.emit('unhandledRejection', value, promise)){
1634 | // default node.js behavior
1635 | }
1636 | } else if(global.console && isFunction(console.error)){
1637 | console.error('Unhandled promise rejection', value);
1638 | }
1639 | }
1640 | }, 1e3);
1641 | } else while(chain.length > i)!function(react){
1642 | var cb = ok ? react.ok : react.fail
1643 | , ret, then;
1644 | try {
1645 | if(cb){
1646 | if(!ok)record.h = true;
1647 | ret = cb === true ? value : cb(value);
1648 | if(ret === react.P){
1649 | react.rej(TypeError(PROMISE + '-chain cycle'));
1650 | } else if(then = isThenable(ret)){
1651 | then.call(ret, react.res, react.rej);
1652 | } else react.res(ret);
1653 | } else react.rej(value);
1654 | } catch(err){
1655 | react.rej(err);
1656 | }
1657 | }(chain[i++]);
1658 | chain.length = 0;
1659 | });
1660 | }
1661 | function resolve(value){
1662 | var record = this
1663 | , then, wrapper;
1664 | if(record.d)return;
1665 | record.d = true;
1666 | record = record.r || record; // unwrap
1667 | try {
1668 | if(then = isThenable(value)){
1669 | wrapper = {r: record, d: false}; // wrap
1670 | then.call(value, ctx(resolve, wrapper, 1), ctx(reject, wrapper, 1));
1671 | } else {
1672 | record.v = value;
1673 | record.s = 1;
1674 | notify(record);
1675 | }
1676 | } catch(err){
1677 | reject.call(wrapper || {r: record, d: false}, err); // wrap
1678 | }
1679 | }
1680 | function reject(value){
1681 | var record = this;
1682 | if(record.d)return;
1683 | record.d = true;
1684 | record = record.r || record; // unwrap
1685 | record.v = value;
1686 | record.s = 2;
1687 | notify(record, true);
1688 | }
1689 | function getConstructor(C){
1690 | var S = assertObj(C)[SPECIES];
1691 | return S != undefined ? S : C;
1692 | }
1693 | // 25.4.3.1 Promise(executor)
1694 | Promise = function(executor){
1695 | assertFn(executor);
1696 | var record = {
1697 | p: assert.inst(this, Promise, PROMISE), // <- promise
1698 | c: [], // <- chain
1699 | s: 0, // <- state
1700 | d: false, // <- done
1701 | v: undefined, // <- value
1702 | h: false // <- handled rejection
1703 | };
1704 | $.hide(this, RECORD, record);
1705 | try {
1706 | executor(ctx(resolve, record, 1), ctx(reject, record, 1));
1707 | } catch(err){
1708 | reject.call(record, err);
1709 | }
1710 | }
1711 | $.mix(Promise.prototype, {
1712 | // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
1713 | then: function(onFulfilled, onRejected){
1714 | var S = assertObj(assertObj(this).constructor)[SPECIES];
1715 | var react = {
1716 | ok: isFunction(onFulfilled) ? onFulfilled : true,
1717 | fail: isFunction(onRejected) ? onRejected : false
1718 | } , P = react.P = new (S != undefined ? S : Promise)(function(resolve, reject){
1719 | react.res = assertFn(resolve);
1720 | react.rej = assertFn(reject);
1721 | }), record = this[RECORD];
1722 | record.c.push(react);
1723 | record.s && notify(record);
1724 | return P;
1725 | },
1726 | // 25.4.5.1 Promise.prototype.catch(onRejected)
1727 | 'catch': function(onRejected){
1728 | return this.then(undefined, onRejected);
1729 | }
1730 | });
1731 | $.mix(Promise, {
1732 | // 25.4.4.1 Promise.all(iterable)
1733 | all: function(iterable){
1734 | var Promise = getConstructor(this)
1735 | , values = [];
1736 | return new Promise(function(resolve, reject){
1737 | forOf(iterable, false, values.push, values);
1738 | var remaining = values.length
1739 | , results = Array(remaining);
1740 | if(remaining)$.each.call(values, function(promise, index){
1741 | Promise.resolve(promise).then(function(value){
1742 | results[index] = value;
1743 | --remaining || resolve(results);
1744 | }, reject);
1745 | });
1746 | else resolve(results);
1747 | });
1748 | },
1749 | // 25.4.4.4 Promise.race(iterable)
1750 | race: function(iterable){
1751 | var Promise = getConstructor(this);
1752 | return new Promise(function(resolve, reject){
1753 | forOf(iterable, false, function(promise){
1754 | Promise.resolve(promise).then(resolve, reject);
1755 | });
1756 | });
1757 | },
1758 | // 25.4.4.5 Promise.reject(r)
1759 | reject: function(r){
1760 | return new (getConstructor(this))(function(resolve, reject){
1761 | reject(r);
1762 | });
1763 | },
1764 | // 25.4.4.6 Promise.resolve(x)
1765 | resolve: function(x){
1766 | return isObject(x) && RECORD in x && $.getProto(x) === this.prototype
1767 | ? x : new (getConstructor(this))(function(resolve, reject){
1768 | resolve(x);
1769 | });
1770 | }
1771 | });
1772 | }();
1773 | cof.set(Promise, PROMISE);
1774 | require('./$.species')(Promise);
1775 | $def($def.G + $def.F * (Promise != Base), {Promise: Promise});
1776 | },{"./$":10,"./$.cof":5,"./$.def":6,"./$.iter":9,"./$.species":15,"./$.task":17,"./$.uid":18,"./$.wks":19,"./es6.iterators":25}],32:[function(require,module,exports){
1777 | var $ = require('./$')
1778 | , $def = require('./$.def')
1779 | , setProto = require('./$.set-proto')
1780 | , $iter = require('./$.iter')
1781 | , ITER = require('./$.uid').safe('iter')
1782 | , step = $iter.step
1783 | , assert = $.assert
1784 | , assertObj = assert.obj
1785 | , isObject = $.isObject
1786 | , getDesc = $.getDesc
1787 | , setDesc = $.setDesc
1788 | , getProto = $.getProto
1789 | , apply = Function.apply
1790 | , isExtensible = Object.isExtensible || $.it;
1791 | function Enumerate(iterated){
1792 | var keys = [], key;
1793 | for(key in iterated)keys.push(key);
1794 | $.set(this, ITER, {o: iterated, a: keys, i: 0});
1795 | }
1796 | $iter.create(Enumerate, 'Object', function(){
1797 | var iter = this[ITER]
1798 | , keys = iter.a
1799 | , key;
1800 | do {
1801 | if(iter.i >= keys.length)return step(1);
1802 | } while(!((key = keys[iter.i++]) in iter.o));
1803 | return step(0, key);
1804 | });
1805 |
1806 | function wrap(fn){
1807 | return function(it){
1808 | assertObj(it);
1809 | try {
1810 | return fn.apply(undefined, arguments), true;
1811 | } catch(e){
1812 | return false;
1813 | }
1814 | }
1815 | }
1816 |
1817 | function reflectGet(target, propertyKey/*, receiver*/){
1818 | var receiver = arguments.length < 3 ? target : arguments[2]
1819 | , desc = getDesc(assertObj(target), propertyKey), proto;
1820 | if(desc)return $.has(desc, 'value')
1821 | ? desc.value
1822 | : desc.get === undefined
1823 | ? undefined
1824 | : desc.get.call(receiver);
1825 | return isObject(proto = getProto(target))
1826 | ? reflectGet(proto, propertyKey, receiver)
1827 | : undefined;
1828 | }
1829 | function reflectSet(target, propertyKey, V/*, receiver*/){
1830 | var receiver = arguments.length < 4 ? target : arguments[3]
1831 | , ownDesc = getDesc(assertObj(target), propertyKey)
1832 | , existingDescriptor, proto;
1833 | if(!ownDesc){
1834 | if(isObject(proto = getProto(target))){
1835 | return reflectSet(proto, propertyKey, V, receiver);
1836 | }
1837 | ownDesc = $.desc(0);
1838 | }
1839 | if($.has(ownDesc, 'value')){
1840 | if(ownDesc.writable === false || !isObject(receiver))return false;
1841 | existingDescriptor = getDesc(receiver, propertyKey) || $.desc(0);
1842 | existingDescriptor.value = V;
1843 | return setDesc(receiver, propertyKey, existingDescriptor), true;
1844 | }
1845 | return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
1846 | }
1847 |
1848 | var reflect = {
1849 | // 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
1850 | apply: $.ctx(Function.call, apply, 3),
1851 | // 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
1852 | construct: function(target, argumentsList /*, newTarget*/){
1853 | var proto = assert.fn(arguments.length < 3 ? target : arguments[2]).prototype
1854 | , instance = $.create(isObject(proto) ? proto : Object.prototype)
1855 | , result = apply.call(target, instance, argumentsList);
1856 | return isObject(result) ? result : instance;
1857 | },
1858 | // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
1859 | defineProperty: wrap(setDesc),
1860 | // 26.1.4 Reflect.deleteProperty(target, propertyKey)
1861 | deleteProperty: function(target, propertyKey){
1862 | var desc = getDesc(assertObj(target), propertyKey);
1863 | return desc && !desc.configurable ? false : delete target[propertyKey];
1864 | },
1865 | // 26.1.5 Reflect.enumerate(target)
1866 | enumerate: function(target){
1867 | return new Enumerate(assertObj(target));
1868 | },
1869 | // 26.1.6 Reflect.get(target, propertyKey [, receiver])
1870 | get: reflectGet,
1871 | // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
1872 | getOwnPropertyDescriptor: function(target, propertyKey){
1873 | return getDesc(assertObj(target), propertyKey);
1874 | },
1875 | // 26.1.8 Reflect.getPrototypeOf(target)
1876 | getPrototypeOf: function(target){
1877 | return getProto(assertObj(target));
1878 | },
1879 | // 26.1.9 Reflect.has(target, propertyKey)
1880 | has: function(target, propertyKey){
1881 | return propertyKey in target;
1882 | },
1883 | // 26.1.10 Reflect.isExtensible(target)
1884 | isExtensible: function(target){
1885 | return !!isExtensible(assertObj(target));
1886 | },
1887 | // 26.1.11 Reflect.ownKeys(target)
1888 | ownKeys: $.ownKeys,
1889 | // 26.1.12 Reflect.preventExtensions(target)
1890 | preventExtensions: wrap(Object.preventExtensions || $.it),
1891 | // 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
1892 | set: reflectSet
1893 | }
1894 | // 26.1.14 Reflect.setPrototypeOf(target, proto)
1895 | if(setProto)reflect.setPrototypeOf = function(target, proto){
1896 | return setProto(assertObj(target), proto), true;
1897 | }
1898 |
1899 | $def($def.G, {Reflect: {}});
1900 | $def($def.S, 'Reflect', reflect);
1901 | },{"./$":10,"./$.def":6,"./$.iter":9,"./$.set-proto":14,"./$.uid":18}],33:[function(require,module,exports){
1902 | var $ = require('./$')
1903 | , cof = require('./$.cof')
1904 | , RegExp = $.g.RegExp
1905 | , Base = RegExp
1906 | , proto = RegExp.prototype;
1907 | if($.FW && $.DESC){
1908 | // RegExp allows a regex with flags as the pattern
1909 | if(!function(){try{return RegExp(/a/g, 'i') == '/a/i'}catch(e){}}()){
1910 | RegExp = function RegExp(pattern, flags){
1911 | return new Base(cof(pattern) == 'RegExp' && flags !== undefined
1912 | ? pattern.source : pattern, flags);
1913 | }
1914 | $.each.call($.getNames(Base), function(key){
1915 | key in RegExp || $.setDesc(RegExp, key, {
1916 | configurable: true,
1917 | get: function(){ return Base[key] },
1918 | set: function(it){ Base[key] = it }
1919 | });
1920 | });
1921 | proto.constructor = RegExp;
1922 | RegExp.prototype = proto;
1923 | $.hide($.g, 'RegExp', RegExp);
1924 | }
1925 |
1926 | // 21.2.5.3 get RegExp.prototype.flags()
1927 | if(/./g.flags != 'g')$.setDesc(proto, 'flags', {
1928 | configurable: true,
1929 | get: require('./$.replacer')(/^.*\/(\w*)$/, '$1')
1930 | });
1931 | }
1932 | require('./$.species')(RegExp);
1933 | },{"./$":10,"./$.cof":5,"./$.replacer":13,"./$.species":15}],34:[function(require,module,exports){
1934 | 'use strict';
1935 | var $ = require('./$')
1936 | , cof = require('./$.cof')
1937 | , $def = require('./$.def')
1938 | , assertDef = $.assert.def
1939 | , toLength = $.toLength
1940 | , min = Math.min
1941 | , STRING = 'String'
1942 | , String = $.g[STRING]
1943 | , fromCharCode = String.fromCharCode;
1944 | function assertNotRegExp(it){
1945 | if(cof(it) == 'RegExp')throw TypeError();
1946 | }
1947 |
1948 | $def($def.S, STRING, {
1949 | // 21.1.2.2 String.fromCodePoint(...codePoints)
1950 | fromCodePoint: function(x){
1951 | var res = []
1952 | , len = arguments.length
1953 | , i = 0
1954 | , code
1955 | while(len > i){
1956 | code = +arguments[i++];
1957 | if($.toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
1958 | res.push(code < 0x10000
1959 | ? fromCharCode(code)
1960 | : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
1961 | );
1962 | } return res.join('');
1963 | },
1964 | // 21.1.2.4 String.raw(callSite, ...substitutions)
1965 | raw: function(callSite){
1966 | var raw = $.toObject(callSite.raw)
1967 | , len = toLength(raw.length)
1968 | , sln = arguments.length
1969 | , res = []
1970 | , i = 0;
1971 | while(len > i){
1972 | res.push(String(raw[i++]));
1973 | if(i < sln)res.push(String(arguments[i]));
1974 | } return res.join('');
1975 | }
1976 | });
1977 |
1978 | $def($def.P, STRING, {
1979 | // 21.1.3.3 String.prototype.codePointAt(pos)
1980 | codePointAt: require('./$.string-at')(false),
1981 | // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
1982 | endsWith: function(searchString /*, endPosition = @length */){
1983 | assertNotRegExp(searchString);
1984 | var that = String(assertDef(this))
1985 | , endPosition = arguments[1]
1986 | , len = toLength(that.length)
1987 | , end = endPosition === undefined ? len : min(toLength(endPosition), len);
1988 | searchString += '';
1989 | return that.slice(end - searchString.length, end) === searchString;
1990 | },
1991 | // 21.1.3.7 String.prototype.includes(searchString, position = 0)
1992 | includes: function(searchString /*, position = 0 */){
1993 | assertNotRegExp(searchString);
1994 | return !!~String(assertDef(this)).indexOf(searchString, arguments[1]);
1995 | },
1996 | // 21.1.3.13 String.prototype.repeat(count)
1997 | repeat: function(count){
1998 | var str = String(assertDef(this))
1999 | , res = ''
2000 | , n = $.toInteger(count);
2001 | if(0 > n || n == Infinity)throw RangeError("Count can't be negative");
2002 | for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
2003 | return res;
2004 | },
2005 | // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
2006 | startsWith: function(searchString /*, position = 0 */){
2007 | assertNotRegExp(searchString);
2008 | var that = String(assertDef(this))
2009 | , index = toLength(min(arguments[1], that.length));
2010 | searchString += '';
2011 | return that.slice(index, index + searchString.length) === searchString;
2012 | }
2013 | });
2014 | },{"./$":10,"./$.cof":5,"./$.def":6,"./$.string-at":16}],35:[function(require,module,exports){
2015 | 'use strict';
2016 | // ECMAScript 6 symbols shim
2017 | var $ = require('./$')
2018 | , setTag = require('./$.cof').set
2019 | , uid = require('./$.uid')
2020 | , $def = require('./$.def')
2021 | , assert = $.assert
2022 | , has = $.has
2023 | , hide = $.hide
2024 | , getNames = $.getNames
2025 | , toObject = $.toObject
2026 | , Symbol = $.g.Symbol
2027 | , Base = Symbol
2028 | , setter = true
2029 | , TAG = uid.safe('tag')
2030 | , SymbolRegistry = {}
2031 | , AllSymbols = {};
2032 | // 19.4.1.1 Symbol([description])
2033 | if(!$.isFunction(Symbol)){
2034 | Symbol = function(description){
2035 | $.assert(!(this instanceof Symbol), 'Symbol is not a constructor');
2036 | var tag = uid(description)
2037 | , sym = $.set($.create(Symbol.prototype), TAG, tag);
2038 | AllSymbols[tag] = sym;
2039 | $.DESC && setter && $.setDesc(Object.prototype, tag, {
2040 | configurable: true,
2041 | set: function(value){
2042 | hide(this, tag, value);
2043 | }
2044 | });
2045 | return sym;
2046 | }
2047 | hide(Symbol.prototype, 'toString', function(){
2048 | return this[TAG];
2049 | });
2050 | }
2051 | $def($def.G + $def.W, {Symbol: Symbol});
2052 |
2053 | var symbolStatics = {
2054 | // 19.4.2.1 Symbol.for(key)
2055 | 'for': function(key){
2056 | return has(SymbolRegistry, key += '')
2057 | ? SymbolRegistry[key]
2058 | : SymbolRegistry[key] = Symbol(key);
2059 | },
2060 | // 19.4.2.5 Symbol.keyFor(sym)
2061 | keyFor: require('./$.partial').call(require('./$.keyof'), SymbolRegistry, 0),
2062 | pure: uid.safe,
2063 | set: $.set,
2064 | useSetter: function(){ setter = true },
2065 | useSimple: function(){ setter = false }
2066 | };
2067 | // 19.4.2.2 Symbol.hasInstance
2068 | // 19.4.2.3 Symbol.isConcatSpreadable
2069 | // 19.4.2.4 Symbol.iterator
2070 | // 19.4.2.6 Symbol.match
2071 | // 19.4.2.8 Symbol.replace
2072 | // 19.4.2.9 Symbol.search
2073 | // 19.4.2.10 Symbol.species
2074 | // 19.4.2.11 Symbol.split
2075 | // 19.4.2.12 Symbol.toPrimitive
2076 | // 19.4.2.13 Symbol.toStringTag
2077 | // 19.4.2.14 Symbol.unscopables
2078 | $.each.call($.a('hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'),
2079 | function(it){
2080 | symbolStatics[it] = require('./$.wks')(it);
2081 | }
2082 | );
2083 |
2084 | $def($def.S, 'Symbol', symbolStatics);
2085 |
2086 | $def($def.S + $def.F * (Symbol != Base), 'Object', {
2087 | // 19.1.2.7 Object.getOwnPropertyNames(O)
2088 | getOwnPropertyNames: function(it){
2089 | var names = getNames(toObject(it)), result = [], key, i = 0;
2090 | while(names.length > i)has(AllSymbols, key = names[i++]) || result.push(key);
2091 | return result;
2092 | },
2093 | // 19.1.2.8 Object.getOwnPropertySymbols(O)
2094 | getOwnPropertySymbols: function(it){
2095 | var names = getNames(toObject(it)), result = [], key, i = 0;
2096 | while(names.length > i)has(AllSymbols, key = names[i++]) && result.push(AllSymbols[key]);
2097 | return result;
2098 | }
2099 | });
2100 |
2101 | setTag(Symbol, 'Symbol');
2102 | // 20.2.1.9 Math[@@toStringTag]
2103 | setTag(Math, 'Math', true);
2104 | // 24.3.3 JSON[@@toStringTag]
2105 | setTag($.g.JSON, 'JSON', true);
2106 | },{"./$":10,"./$.cof":5,"./$.def":6,"./$.keyof":11,"./$.partial":12,"./$.uid":18,"./$.wks":19}],36:[function(require,module,exports){
2107 | // https://github.com/zenparsing/es-abstract-refs
2108 | var $ = require('./$')
2109 | , wks = require('./$.wks')
2110 | , $def = require('./$.def')
2111 | , REFERENCE_GET = wks('referenceGet')
2112 | , REFERENCE_SET = wks('referenceSet')
2113 | , REFERENCE_DELETE = wks('referenceDelete')
2114 | , hide = $.hide;
2115 |
2116 | $def($def.S, 'Symbol', {
2117 | referenceGet: REFERENCE_GET,
2118 | referenceSet: REFERENCE_SET,
2119 | referenceDelete: REFERENCE_DELETE
2120 | });
2121 |
2122 | hide(Function.prototype, REFERENCE_GET, $.that);
2123 |
2124 | function setMapMethods(Constructor){
2125 | if(Constructor){
2126 | var MapProto = Constructor.prototype;
2127 | hide(MapProto, REFERENCE_GET, MapProto.get);
2128 | hide(MapProto, REFERENCE_SET, MapProto.set);
2129 | hide(MapProto, REFERENCE_DELETE, MapProto['delete']);
2130 | }
2131 | }
2132 | setMapMethods($.core.Map || $.g.Map);
2133 | setMapMethods($.core.WeakMap || $.g.WeakMap);
2134 | },{"./$":10,"./$.def":6,"./$.wks":19}],37:[function(require,module,exports){
2135 | var $ = require('./$')
2136 | , $def = require('./$.def')
2137 | , toObject = $.toObject;
2138 |
2139 | $def($def.P, 'Array', {
2140 | // https://github.com/domenic/Array.prototype.includes
2141 | includes: require('./$.array-includes')(true)
2142 | });
2143 | $def($def.P, 'String', {
2144 | // https://github.com/mathiasbynens/String.prototype.at
2145 | at: require('./$.string-at')(true)
2146 | });
2147 |
2148 | function createObjectToArray(isEntries){
2149 | return function(object){
2150 | var O = toObject(object)
2151 | , keys = $.getKeys(object)
2152 | , length = keys.length
2153 | , i = 0
2154 | , result = Array(length)
2155 | , key;
2156 | if(isEntries)while(length > i)result[i] = [key = keys[i++], O[key]];
2157 | else while(length > i)result[i] = O[keys[i++]];
2158 | return result;
2159 | }
2160 | }
2161 | $def($def.S, 'Object', {
2162 | // https://gist.github.com/WebReflection/9353781
2163 | getOwnPropertyDescriptors: function(object){
2164 | var O = toObject(object)
2165 | , result = {};
2166 | $.each.call($.ownKeys(O), function(key){
2167 | $.setDesc(result, key, $.desc(0, $.getDesc(O, key)));
2168 | });
2169 | return result;
2170 | },
2171 | // https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-04/apr-9.md#51-objectentries-objectvalues
2172 | values: createObjectToArray(false),
2173 | entries: createObjectToArray(true)
2174 | });
2175 | $def($def.S, 'RegExp', {
2176 | // https://gist.github.com/kangax/9698100
2177 | escape: require('./$.replacer')(/([\\\-[\]{}()*+?.,^$|])/g, '\\$1', true)
2178 | });
2179 | },{"./$":10,"./$.array-includes":2,"./$.def":6,"./$.replacer":13,"./$.string-at":16}],38:[function(require,module,exports){
2180 | // JavaScript 1.6 / Strawman array statics shim
2181 | var $ = require('./$')
2182 | , $def = require('./$.def')
2183 | , statics = {};
2184 | function setStatics(keys, length){
2185 | $.each.call($.a(keys), function(key){
2186 | if(key in [])statics[key] = $.ctx(Function.call, [][key], length);
2187 | });
2188 | }
2189 | setStatics('pop,reverse,shift,keys,values,entries', 1);
2190 | setStatics('indexOf,every,some,forEach,map,filter,find,findIndex,includes', 3);
2191 | setStatics('join,slice,concat,push,splice,unshift,sort,lastIndexOf,' +
2192 | 'reduce,reduceRight,copyWithin,fill,turn');
2193 | $def($def.S, 'Array', statics);
2194 | },{"./$":10,"./$.def":6}],39:[function(require,module,exports){
2195 | var $ = require('./$')
2196 | , Iterators = require('./$.iter').Iterators
2197 | , ITERATOR = require('./$.wks')('iterator')
2198 | , NodeList = $.g.NodeList;
2199 | if($.FW && NodeList && !(ITERATOR in NodeList.prototype)){
2200 | $.hide(NodeList.prototype, ITERATOR, Iterators.Array);
2201 | }
2202 | Iterators.NodeList = Iterators.Array;
2203 | },{"./$":10,"./$.iter":9,"./$.wks":19}],40:[function(require,module,exports){
2204 | var $def = require('./$.def')
2205 | , $task = require('./$.task');
2206 | $def($def.G + $def.B, {
2207 | setImmediate: $task.set,
2208 | clearImmediate: $task.clear
2209 | });
2210 | },{"./$.def":6,"./$.task":17}],41:[function(require,module,exports){
2211 | // ie9- setTimeout & setInterval additional parameters fix
2212 | var $ = require('./$')
2213 | , $def = require('./$.def')
2214 | , invoke = require('./$.invoke')
2215 | , partial = require('./$.partial')
2216 | , MSIE = !!$.g.navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
2217 | function wrap(set){
2218 | return MSIE ? function(fn, time /*, ...args */){
2219 | return set(invoke(partial, [].slice.call(arguments, 2), $.isFunction(fn) ? fn : Function(fn)), time);
2220 | } : set;
2221 | }
2222 | $def($def.G + $def.B + $def.F * MSIE, {
2223 | setTimeout: wrap(setTimeout),
2224 | setInterval: wrap(setInterval)
2225 | });
2226 | },{"./$":10,"./$.def":6,"./$.invoke":8,"./$.partial":12}]},{},[1]);
2227 |
2228 | // CommonJS export
2229 | if(typeof module != 'undefined' && module.exports)module.exports = __e;
2230 | // RequireJS export
2231 | else if(typeof define == 'function' && define.amd)define(function(){return __e});
2232 | // Export to global object
2233 | else __g.core = __e;
2234 | }();
2235 |
--------------------------------------------------------------------------------
/lib/runtime.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
7 | * additional grant of patent rights can be found in the PATENTS file in
8 | * the same directory.
9 | */
10 |
11 | !(function(global) {
12 | "use strict";
13 |
14 | var hasOwn = Object.prototype.hasOwnProperty;
15 | var undefined; // More compressible than void 0.
16 | var iteratorSymbol =
17 | typeof Symbol === "function" && Symbol.iterator || "@@iterator";
18 |
19 | var inModule = typeof module === "object";
20 | var runtime = global.regeneratorRuntime;
21 | if (runtime) {
22 | if (inModule) {
23 | // If regeneratorRuntime is defined globally and we're in a module,
24 | // make the exports object identical to regeneratorRuntime.
25 | module.exports = runtime;
26 | }
27 | // Don't bother evaluating the rest of this file if the runtime was
28 | // already defined globally.
29 | return;
30 | }
31 |
32 | // Define the runtime globally (as expected by generated code) as either
33 | // module.exports (if we're in a module) or a new, empty object.
34 | runtime = global.regeneratorRuntime = inModule ? module.exports : {};
35 |
36 | function wrap(innerFn, outerFn, self, tryLocsList) {
37 | // If outerFn provided, then outerFn.prototype instanceof Generator.
38 | var generator = Object.create((outerFn || Generator).prototype);
39 |
40 | generator._invoke = makeInvokeMethod(
41 | innerFn, self || null,
42 | new Context(tryLocsList || [])
43 | );
44 |
45 | return generator;
46 | }
47 | runtime.wrap = wrap;
48 |
49 | // Try/catch helper to minimize deoptimizations. Returns a completion
50 | // record like context.tryEntries[i].completion. This interface could
51 | // have been (and was previously) designed to take a closure to be
52 | // invoked without arguments, but in all the cases we care about we
53 | // already have an existing method we want to call, so there's no need
54 | // to create a new function object. We can even get away with assuming
55 | // the method takes exactly one argument, since that happens to be true
56 | // in every case, so we don't have to touch the arguments object. The
57 | // only additional allocation required is the completion record, which
58 | // has a stable shape and so hopefully should be cheap to allocate.
59 | function tryCatch(fn, obj, arg) {
60 | try {
61 | return { type: "normal", arg: fn.call(obj, arg) };
62 | } catch (err) {
63 | return { type: "throw", arg: err };
64 | }
65 | }
66 |
67 | var GenStateSuspendedStart = "suspendedStart";
68 | var GenStateSuspendedYield = "suspendedYield";
69 | var GenStateExecuting = "executing";
70 | var GenStateCompleted = "completed";
71 |
72 | // Returning this object from the innerFn has the same effect as
73 | // breaking out of the dispatch switch statement.
74 | var ContinueSentinel = {};
75 |
76 | // Dummy constructor functions that we use as the .constructor and
77 | // .constructor.prototype properties for functions that return Generator
78 | // objects. For full spec compliance, you may wish to configure your
79 | // minifier not to mangle the names of these two functions.
80 | function Generator() {}
81 | function GeneratorFunction() {}
82 | function GeneratorFunctionPrototype() {}
83 |
84 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
85 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
86 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
87 | GeneratorFunction.displayName = "GeneratorFunction";
88 |
89 | runtime.isGeneratorFunction = function(genFun) {
90 | var ctor = typeof genFun === "function" && genFun.constructor;
91 | return ctor
92 | ? ctor === GeneratorFunction ||
93 | // For the native GeneratorFunction constructor, the best we can
94 | // do is to check its .name property.
95 | (ctor.displayName || ctor.name) === "GeneratorFunction"
96 | : false;
97 | };
98 |
99 | runtime.mark = function(genFun) {
100 | genFun.__proto__ = GeneratorFunctionPrototype;
101 | genFun.prototype = Object.create(Gp);
102 | return genFun;
103 | };
104 |
105 | runtime.async = function(innerFn, outerFn, self, tryLocsList) {
106 | return new Promise(function(resolve, reject) {
107 | var generator = wrap(innerFn, outerFn, self, tryLocsList);
108 | var callNext = step.bind(generator, "next");
109 | var callThrow = step.bind(generator, "throw");
110 |
111 | function step(method, arg) {
112 | var record = tryCatch(generator[method], generator, arg);
113 | if (record.type === "throw") {
114 | reject(record.arg);
115 | return;
116 | }
117 |
118 | var info = record.arg;
119 | if (info.done) {
120 | resolve(info.value);
121 | } else {
122 | Promise.resolve(info.value).then(callNext, callThrow);
123 | }
124 | }
125 |
126 | callNext();
127 | });
128 | };
129 |
130 | function makeInvokeMethod(innerFn, self, context) {
131 | var state = GenStateSuspendedStart;
132 |
133 | return function invoke(method, arg) {
134 | if (state === GenStateExecuting) {
135 | throw new Error("Generator is already running");
136 | }
137 |
138 | if (state === GenStateCompleted) {
139 | // Be forgiving, per 25.3.3.3.3 of the spec:
140 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
141 | return doneResult();
142 | }
143 |
144 | while (true) {
145 | var delegate = context.delegate;
146 | if (delegate) {
147 | if (method === "return" ||
148 | (method === "throw" && delegate.iterator.throw === undefined)) {
149 | // A return or throw (when the delegate iterator has no throw
150 | // method) always terminates the yield* loop.
151 | context.delegate = null;
152 |
153 | // If the delegate iterator has a return method, give it a
154 | // chance to clean up.
155 | var returnMethod = delegate.iterator.return;
156 | if (returnMethod) {
157 | var record = tryCatch(returnMethod, delegate.iterator, arg);
158 | if (record.type === "throw") {
159 | // If the return method threw an exception, let that
160 | // exception prevail over the original return or throw.
161 | method = "throw";
162 | arg = record.arg;
163 | continue;
164 | }
165 | }
166 |
167 | if (method === "return") {
168 | // Continue with the outer return, now that the delegate
169 | // iterator has been terminated.
170 | continue;
171 | }
172 | }
173 |
174 | var record = tryCatch(
175 | delegate.iterator[method],
176 | delegate.iterator,
177 | arg
178 | );
179 |
180 | if (record.type === "throw") {
181 | context.delegate = null;
182 |
183 | // Like returning generator.throw(uncaught), but without the
184 | // overhead of an extra function call.
185 | method = "throw";
186 | arg = record.arg;
187 | continue;
188 | }
189 |
190 | // Delegate generator ran and handled its own exceptions so
191 | // regardless of what the method was, we continue as if it is
192 | // "next" with an undefined arg.
193 | method = "next";
194 | arg = undefined;
195 |
196 | var info = record.arg;
197 | if (info.done) {
198 | context[delegate.resultName] = info.value;
199 | context.next = delegate.nextLoc;
200 | } else {
201 | state = GenStateSuspendedYield;
202 | return info;
203 | }
204 |
205 | context.delegate = null;
206 | }
207 |
208 | if (method === "next") {
209 | if (state === GenStateSuspendedYield) {
210 | context.sent = arg;
211 | } else {
212 | delete context.sent;
213 | }
214 |
215 | } else if (method === "throw") {
216 | if (state === GenStateSuspendedStart) {
217 | state = GenStateCompleted;
218 | throw arg;
219 | }
220 |
221 | if (context.dispatchException(arg)) {
222 | // If the dispatched exception was caught by a catch block,
223 | // then let that catch block handle the exception normally.
224 | method = "next";
225 | arg = undefined;
226 | }
227 |
228 | } else if (method === "return") {
229 | context.abrupt("return", arg);
230 | }
231 |
232 | state = GenStateExecuting;
233 |
234 | var record = tryCatch(innerFn, self, context);
235 | if (record.type === "normal") {
236 | // If an exception is thrown from innerFn, we leave state ===
237 | // GenStateExecuting and loop back for another invocation.
238 | state = context.done
239 | ? GenStateCompleted
240 | : GenStateSuspendedYield;
241 |
242 | var info = {
243 | value: record.arg,
244 | done: context.done
245 | };
246 |
247 | if (record.arg === ContinueSentinel) {
248 | if (context.delegate && method === "next") {
249 | // Deliberately forget the last sent value so that we don't
250 | // accidentally pass it on to the delegate.
251 | arg = undefined;
252 | }
253 | } else {
254 | return info;
255 | }
256 |
257 | } else if (record.type === "throw") {
258 | state = GenStateCompleted;
259 | // Dispatch the exception by looping back around to the
260 | // context.dispatchException(arg) call above.
261 | method = "throw";
262 | arg = record.arg;
263 | }
264 | }
265 | };
266 | }
267 |
268 | function defineGeneratorMethod(method) {
269 | Gp[method] = function(arg) {
270 | return this._invoke(method, arg);
271 | };
272 | }
273 | defineGeneratorMethod("next");
274 | defineGeneratorMethod("throw");
275 | defineGeneratorMethod("return");
276 |
277 | Gp[iteratorSymbol] = function() {
278 | return this;
279 | };
280 |
281 | Gp.toString = function() {
282 | return "[object Generator]";
283 | };
284 |
285 | function pushTryEntry(locs) {
286 | var entry = { tryLoc: locs[0] };
287 |
288 | if (1 in locs) {
289 | entry.catchLoc = locs[1];
290 | }
291 |
292 | if (2 in locs) {
293 | entry.finallyLoc = locs[2];
294 | entry.afterLoc = locs[3];
295 | }
296 |
297 | this.tryEntries.push(entry);
298 | }
299 |
300 | function resetTryEntry(entry) {
301 | var record = entry.completion || {};
302 | record.type = "normal";
303 | delete record.arg;
304 | entry.completion = record;
305 | }
306 |
307 | function Context(tryLocsList) {
308 | // The root entry object (effectively a try statement without a catch
309 | // or a finally block) gives us a place to store values thrown from
310 | // locations where there is no enclosing try statement.
311 | this.tryEntries = [{ tryLoc: "root" }];
312 | tryLocsList.forEach(pushTryEntry, this);
313 | this.reset();
314 | }
315 |
316 | runtime.keys = function(object) {
317 | var keys = [];
318 | for (var key in object) {
319 | keys.push(key);
320 | }
321 | keys.reverse();
322 |
323 | // Rather than returning an object with a next method, we keep
324 | // things simple and return the next function itself.
325 | return function next() {
326 | while (keys.length) {
327 | var key = keys.pop();
328 | if (key in object) {
329 | next.value = key;
330 | next.done = false;
331 | return next;
332 | }
333 | }
334 |
335 | // To avoid creating an additional object, we just hang the .value
336 | // and .done properties off the next function object itself. This
337 | // also ensures that the minifier will not anonymize the function.
338 | next.done = true;
339 | return next;
340 | };
341 | };
342 |
343 | function values(iterable) {
344 | if (iterable) {
345 | var iteratorMethod = iterable[iteratorSymbol];
346 | if (iteratorMethod) {
347 | return iteratorMethod.call(iterable);
348 | }
349 |
350 | if (typeof iterable.next === "function") {
351 | return iterable;
352 | }
353 |
354 | if (!isNaN(iterable.length)) {
355 | var i = -1, next = function next() {
356 | while (++i < iterable.length) {
357 | if (hasOwn.call(iterable, i)) {
358 | next.value = iterable[i];
359 | next.done = false;
360 | return next;
361 | }
362 | }
363 |
364 | next.value = undefined;
365 | next.done = true;
366 |
367 | return next;
368 | };
369 |
370 | return next.next = next;
371 | }
372 | }
373 |
374 | // Return an iterator with no values.
375 | return { next: doneResult };
376 | }
377 | runtime.values = values;
378 |
379 | function doneResult() {
380 | return { value: undefined, done: true };
381 | }
382 |
383 | Context.prototype = {
384 | constructor: Context,
385 |
386 | reset: function() {
387 | this.prev = 0;
388 | this.next = 0;
389 | this.sent = undefined;
390 | this.done = false;
391 | this.delegate = null;
392 |
393 | this.tryEntries.forEach(resetTryEntry);
394 |
395 | // Pre-initialize at least 20 temporary variables to enable hidden
396 | // class optimizations for simple generators.
397 | for (var tempIndex = 0, tempName;
398 | hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20;
399 | ++tempIndex) {
400 | this[tempName] = null;
401 | }
402 | },
403 |
404 | stop: function() {
405 | this.done = true;
406 |
407 | var rootEntry = this.tryEntries[0];
408 | var rootRecord = rootEntry.completion;
409 | if (rootRecord.type === "throw") {
410 | throw rootRecord.arg;
411 | }
412 |
413 | return this.rval;
414 | },
415 |
416 | dispatchException: function(exception) {
417 | if (this.done) {
418 | throw exception;
419 | }
420 |
421 | var context = this;
422 | function handle(loc, caught) {
423 | record.type = "throw";
424 | record.arg = exception;
425 | context.next = loc;
426 | return !!caught;
427 | }
428 |
429 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
430 | var entry = this.tryEntries[i];
431 | var record = entry.completion;
432 |
433 | if (entry.tryLoc === "root") {
434 | // Exception thrown outside of any try block that could handle
435 | // it, so set the completion value of the entire function to
436 | // throw the exception.
437 | return handle("end");
438 | }
439 |
440 | if (entry.tryLoc <= this.prev) {
441 | var hasCatch = hasOwn.call(entry, "catchLoc");
442 | var hasFinally = hasOwn.call(entry, "finallyLoc");
443 |
444 | if (hasCatch && hasFinally) {
445 | if (this.prev < entry.catchLoc) {
446 | return handle(entry.catchLoc, true);
447 | } else if (this.prev < entry.finallyLoc) {
448 | return handle(entry.finallyLoc);
449 | }
450 |
451 | } else if (hasCatch) {
452 | if (this.prev < entry.catchLoc) {
453 | return handle(entry.catchLoc, true);
454 | }
455 |
456 | } else if (hasFinally) {
457 | if (this.prev < entry.finallyLoc) {
458 | return handle(entry.finallyLoc);
459 | }
460 |
461 | } else {
462 | throw new Error("try statement without catch or finally");
463 | }
464 | }
465 | }
466 | },
467 |
468 | abrupt: function(type, arg) {
469 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
470 | var entry = this.tryEntries[i];
471 | if (entry.tryLoc <= this.prev &&
472 | hasOwn.call(entry, "finallyLoc") &&
473 | this.prev < entry.finallyLoc) {
474 | var finallyEntry = entry;
475 | break;
476 | }
477 | }
478 |
479 | if (finallyEntry &&
480 | (type === "break" ||
481 | type === "continue") &&
482 | finallyEntry.tryLoc <= arg &&
483 | arg < finallyEntry.finallyLoc) {
484 | // Ignore the finally entry if control is not jumping to a
485 | // location outside the try/catch block.
486 | finallyEntry = null;
487 | }
488 |
489 | var record = finallyEntry ? finallyEntry.completion : {};
490 | record.type = type;
491 | record.arg = arg;
492 |
493 | if (finallyEntry) {
494 | this.next = finallyEntry.finallyLoc;
495 | } else {
496 | this.complete(record);
497 | }
498 |
499 | return ContinueSentinel;
500 | },
501 |
502 | complete: function(record, afterLoc) {
503 | if (record.type === "throw") {
504 | throw record.arg;
505 | }
506 |
507 | if (record.type === "break" ||
508 | record.type === "continue") {
509 | this.next = record.arg;
510 | } else if (record.type === "return") {
511 | this.rval = record.arg;
512 | this.next = "end";
513 | } else if (record.type === "normal" && afterLoc) {
514 | this.next = afterLoc;
515 | }
516 |
517 | return ContinueSentinel;
518 | },
519 |
520 | finish: function(finallyLoc) {
521 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
522 | var entry = this.tryEntries[i];
523 | if (entry.finallyLoc === finallyLoc) {
524 | return this.complete(entry.completion, entry.afterLoc);
525 | }
526 | }
527 | },
528 |
529 | "catch": function(tryLoc) {
530 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
531 | var entry = this.tryEntries[i];
532 | if (entry.tryLoc === tryLoc) {
533 | var record = entry.completion;
534 | if (record.type === "throw") {
535 | var thrown = record.arg;
536 | resetTryEntry(entry);
537 | }
538 | return thrown;
539 | }
540 | }
541 |
542 | // The context.catch method must only be called with a location
543 | // argument that corresponds to a known catch block.
544 | throw new Error("illegal catch attempt");
545 | },
546 |
547 | delegateYield: function(iterable, resultName, nextLoc) {
548 | this.delegate = {
549 | iterator: values(iterable),
550 | resultName: resultName,
551 | nextLoc: nextLoc
552 | };
553 |
554 | return ContinueSentinel;
555 | }
556 | };
557 | })(
558 | // Among the various tricks for obtaining a reference to the global
559 | // object, this seems to be the most reliable technique that does not
560 | // use indirect eval (which violates Content Security Policy).
561 | typeof global === "object" ? global :
562 | typeof window === "object" ? window :
563 | typeof self === "object" ? self : this
564 | );
565 |
--------------------------------------------------------------------------------
/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'pbastowski:angular-babel',
3 | summary: 'Write javascript ES6 in your Angular-Meteor app',
4 | version: '0.1.10',
5 | git: 'https://github.com/pbastowski/angular-meteor-babel.git'
6 | });
7 |
8 |
9 | Package.registerBuildPlugin({
10 | name: 'compile6to5',
11 | use: [],
12 | sources: [
13 | 'plugin/compile-6to5.js'
14 | ],
15 | npmDependencies: {
16 | 'babel-core': '5.8.23',
17 | 'ng-annotate': '1.0.2'
18 | }
19 | });
20 |
21 | Package.onUse(function (api) {
22 | api.versionsFrom('1.0.2.1');
23 |
24 | api.addFiles('lib/core-js-no-number.js');
25 | // runtime
26 | api.addFiles('lib/runtime.js');
27 |
28 | // watch for changes in the config file and rebuild
29 | api.add_files(['../../babel.json']);
30 | });
31 |
32 | Package.onTest(function (api) {
33 | api.use(['pbastowski:angular-babel', 'tinytest']);
34 | api.addFiles([
35 | 'tests/basic_test.es6.js'
36 | ], ['client', 'server']);
37 | });
38 |
--------------------------------------------------------------------------------
/plugin/compile-6to5.js:
--------------------------------------------------------------------------------
1 | var to5 = Npm.require('babel-core');
2 | var fs = Npm.require('fs');
3 | var path = Npm.require('path');
4 | var ngAnnotate = Npm.require('ng-annotate');
5 |
6 |
7 | Object.merge = function (destination, source) {
8 | for (var property in source)
9 | destination[property] = source[property];
10 | return destination;
11 | }
12 |
13 | var defaultConfig = {
14 | // print loaded config
15 | "debug": false,
16 | // print active file extensions
17 | "verbose": true,
18 | // babel managed extensions
19 | "extensions": ['es6.js', 'es6', 'jsx'],
20 | // experimental ES7 support
21 | "stage": 0,
22 | // module format to use
23 | "modules": 'common'
24 | }
25 |
26 | var handler = function (compileStep, isLiterate) {
27 | var source = compileStep.read().toString('utf8');
28 | //var outputFile = compileStep.inputPath + ".js";
29 | var outputFile = compileStep.inputPath;
30 | var to5output = "";
31 |
32 | try {
33 | to5output = to5.transform(source, {
34 | blacklist: ["useStrict"],
35 | sourceMap: true,
36 | stage: config.stage,
37 | filename: compileStep.pathForSourceMap,
38 | modules: config.modules
39 | });
40 | } catch (e) {
41 | console.log(e); // Show the nicely styled babel error
42 | return compileStep.error({
43 | message: 'Babel transform error',
44 | sourcePath: compileStep.inputPath,
45 | line: e.loc.line,
46 | column: e.loc.column
47 | });
48 | }
49 |
50 | var ret = ngAnnotate(to5output.code, {
51 | add: true
52 | });
53 |
54 | if (ret.errors) {
55 | throw new Error(ret.errors.join(': '));
56 | }
57 |
58 | compileStep.addJavaScript({
59 | path: outputFile,
60 | sourcePath: compileStep.inputPath,
61 | data: ret.src,
62 | sourceMap: JSON.stringify(to5output.map)
63 | });
64 | };
65 |
66 | // initialization once at `meteor` exec
67 | var appdir = process.env.PWD || process.cwd();
68 | var filename = path.join(appdir, 'babel.json');
69 | var userConfig = {};
70 |
71 | if (fs.existsSync(filename)) {
72 | userConfig = JSON.parse(fs.readFileSync(filename, {encoding: 'utf8'}));
73 | }
74 |
75 | var config = Object.merge(defaultConfig, userConfig);
76 |
77 | config.extensions.forEach(function (ext) {
78 | Plugin.registerSourceHandler(ext, handler);
79 | });
80 |
81 | if (config.verbose)
82 | console.log("Babel active on file extensions: " + config.extensions.join(', '));
83 |
84 | if (config.debug) {
85 | console.log("\nBabel config:");
86 | console.log(config);
87 | }
88 |
--------------------------------------------------------------------------------
/tests/basic_test.es6.js:
--------------------------------------------------------------------------------
1 | Tinytest.add('truth', function (test) {
2 | test.equal(true, true);
3 | });
4 |
5 | Tinytest.add('Classes', function (test) {
6 | class Person {
7 | constructor(name) {
8 | this.name = name;
9 | }
10 |
11 | getName () {
12 | return this.name;
13 | }
14 | }
15 | var pippo = new Person('grigio');
16 |
17 | test.equal(pippo.name , 'grigio');
18 | });
19 |
20 | Tinytest.add('Template strings', function (test) {
21 | var name = 'Luigi', surname = 'Maselli';
22 |
23 | test.equal( `Hi, ${name} ${surname}`, 'Hi, Luigi Maselli');
24 | });
25 |
26 |
27 |
28 | Tinytest.add('Destructuring', function (test) {
29 | let [head, , tail] = [1,2,3];
30 |
31 | test.equal( head, 1);
32 | test.equal( tail, 3);
33 | });
34 |
35 |
36 | Tinytest.add('Generators functions', function (test) {
37 | function* foo() {
38 | yield 1;
39 | yield 2;
40 | yield 3;
41 | yield 4;
42 | yield 5;
43 | return 6;
44 | }
45 |
46 | var out = [];
47 | for (var v of foo()) {
48 | out.push(v)
49 | }
50 |
51 | test.equal( out, [1,2,3,4,5]);
52 | });
53 |
54 | Tinytest.add('Sets', function (test) {
55 | var s = new Set();
56 | s.add("hello").add("goodbye").add("hello");
57 |
58 | test.equal( s.size, 2);
59 | test.equal( s.has("hello"), true);
60 | });
61 |
62 | Tinytest.add('ES7 - async await', function (test, done) {
63 | function sleep(ms){
64 | return new Promise(resolve => setTimeout(resolve, ms));
65 | }
66 |
67 | async function asyncValue(value){
68 | await sleep(500);
69 | return value;
70 | }
71 |
72 | Meteor.wrapAsync(function execute(args, onCompleted) {
73 | (async function(){
74 | var value = await asyncValue(42);
75 | test.equal( value, 42);
76 | // onCompleted();
77 | })();
78 | });
79 |
80 | });
81 |
82 | Tinytest.add('Meteor - check Number', function (test) {
83 | test.equal( check(666, Number ), undefined );
84 | });
85 |
86 | // blacklist: ["useStrict"]
87 | Tinytest.add('Meteor - global vars', function (test) {
88 | (function () {
89 | myVar = 'yes';
90 | })();
91 | test.equal( myVar , 'yes');
92 | });
93 |
94 |
95 |
--------------------------------------------------------------------------------
/update-bundled-libs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Build latest core-js without ES6 Number
3 | # https://github.com/grigio/meteor-babel/issues/5
4 |
5 | echo "--> Building latest 'core-js' .."
6 | sh -c "mkdir temp && cd temp && npm install core-js && \
7 | cd node_modules/core-js && npm install && \
8 | grunt build:es5,es6,es7,js,web --blacklist=es6.number.constructor --path=core-js-no-number"
9 |
10 | mv temp/node_modules/core-js/core-js-no-number.js lib/ && rm -Rf temp
11 |
12 | echo "--> Getting latest 'runtime' .."
13 | curl https://raw.githubusercontent.com/facebook/regenerator/master/runtime.js > lib/runtime.js
--------------------------------------------------------------------------------