empower.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  1. /**
  2. * Modules in this bundle
  3. * @license
  4. *
  5. * empower:
  6. * license: MIT (http://opensource.org/licenses/MIT)
  7. * author: Takuto Wada <takuto.wada@gmail.com>
  8. * contributors: James Talmage
  9. * homepage: https://github.com/power-assert-js/empower
  10. * version: 1.3.1
  11. *
  12. * call-signature:
  13. * license: MIT (http://opensource.org/licenses/MIT)
  14. * author: James Talmage <james@talmage.io>
  15. * homepage: https://github.com/jamestalmage/call-signature#readme
  16. * version: 0.0.2
  17. *
  18. * core-js:
  19. * license: MIT (http://opensource.org/licenses/MIT)
  20. * homepage: https://github.com/zloirock/core-js#readme
  21. * version: 2.5.7
  22. *
  23. * empower-core:
  24. * license: MIT (http://opensource.org/licenses/MIT)
  25. * author: Takuto Wada <takuto.wada@gmail.com>
  26. * contributors: James Talmage
  27. * homepage: https://github.com/twada/power-assert-runtime
  28. * version: 1.2.0
  29. *
  30. * This header is generated by licensify (https://github.com/twada/licensify)
  31. */
  32. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.empower = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw (a.code="MODULE_NOT_FOUND", a)}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
  33. /**
  34. * empower - Power Assert feature enhancer for assert function/object.
  35. *
  36. * https://github.com/power-assert-js/empower
  37. *
  38. * Copyright (c) 2013-2018 Takuto Wada
  39. * Licensed under the MIT license.
  40. * https://github.com/power-assert-js/empower/blob/master/MIT-LICENSE.txt
  41. */
  42. var empowerCore = _dereq_('empower-core');
  43. var defaultOptions = _dereq_('./lib/default-options');
  44. var capturable = _dereq_('./lib/capturable');
  45. var assign = _dereq_('core-js/library/fn/object/assign');
  46. var define = _dereq_('./lib/define-properties');
  47. /**
  48. * Enhance Power Assert feature to assert function/object.
  49. * @param assert target assert function or object to enhance
  50. * @param formatter power assert format function
  51. * @param options enhancement options
  52. * @return enhanced assert function/object
  53. */
  54. function empower (assert, formatter, options) {
  55. var config = assign(defaultOptions(), options);
  56. var eagerEvaluation = !(config.modifyMessageOnRethrow || config.saveContextOnRethrow);
  57. // see: https://github.com/power-assert-js/empower/pull/26
  58. var shouldRecreateAssertionError = (function isStackUnchanged () {
  59. if (typeof assert !== 'function') {
  60. return false;
  61. }
  62. if (typeof assert.AssertionError !== 'function') {
  63. return false;
  64. }
  65. var ae = new assert.AssertionError({
  66. actual: 123,
  67. expected: 456,
  68. operator: '==='
  69. });
  70. ae.message = '[REPLACED MESSAGE]';
  71. return !(/REPLACED MESSAGE/.test(ae.stack)) && /123 === 456/.test(ae.stack);
  72. })();
  73. var empowerCoreConfig = assign(config, {
  74. modifyMessageBeforeAssert: function (beforeAssertEvent) {
  75. var message = beforeAssertEvent.originalMessage;
  76. if (!eagerEvaluation) {
  77. return message;
  78. }
  79. return buildPowerAssertText(formatter, message, beforeAssertEvent.powerAssertContext);
  80. },
  81. onError: function onError (errorEvent) {
  82. var e = errorEvent.error;
  83. if (!/^AssertionError/.test(e.name)) {
  84. throw e;
  85. }
  86. if (!errorEvent.powerAssertContext) {
  87. throw e;
  88. }
  89. var poweredMessage;
  90. if (config.modifyMessageOnRethrow || config.saveContextOnRethrow) {
  91. poweredMessage = buildPowerAssertText(formatter, errorEvent.originalMessage, errorEvent.powerAssertContext);
  92. if (shouldRecreateAssertionError) {
  93. e = new assert.AssertionError({
  94. message: poweredMessage,
  95. actual: e.actual,
  96. expected: e.expected,
  97. operator: e.operator,
  98. stackStartFunction: e.stackStartFunction || onError
  99. });
  100. e.generatedMessage = false;
  101. }
  102. }
  103. if (config.modifyMessageOnRethrow && !shouldRecreateAssertionError) {
  104. e.message = poweredMessage;
  105. e.generatedMessage = false;
  106. }
  107. if (config.saveContextOnRethrow) {
  108. e.powerAssertContext = errorEvent.powerAssertContext;
  109. }
  110. throw e;
  111. }
  112. });
  113. var enhancedAssert = empowerCore(assert, empowerCoreConfig);
  114. define(enhancedAssert, capturable());
  115. return enhancedAssert;
  116. }
  117. function buildPowerAssertText (formatter, message, context) {
  118. // console.log(message);
  119. var powerAssertText = formatter(context);
  120. return message ? message + ' ' + powerAssertText : powerAssertText;
  121. };
  122. empower.defaultOptions = defaultOptions;
  123. module.exports = empower;
  124. },{"./lib/capturable":2,"./lib/default-options":3,"./lib/define-properties":4,"core-js/library/fn/object/assign":10,"empower-core":67}],2:[function(_dereq_,module,exports){
  125. 'use strict';
  126. module.exports = function capturable () {
  127. var events = [];
  128. function _capt (value, espath) {
  129. events.push({value: value, espath: espath});
  130. return value;
  131. }
  132. function _expr (value, args) {
  133. var captured = events;
  134. events = [];
  135. var source = {
  136. content: args.content,
  137. filepath: args.filepath,
  138. line: args.line
  139. };
  140. if (args.generator) {
  141. source.generator = true;
  142. }
  143. if (args.async) {
  144. source.async = true;
  145. }
  146. return {
  147. powerAssertContext: {
  148. value: value,
  149. events: captured
  150. },
  151. source: source
  152. };
  153. }
  154. return {
  155. _capt: _capt,
  156. _expr: _expr
  157. };
  158. };
  159. },{}],3:[function(_dereq_,module,exports){
  160. 'use strict';
  161. var empowerCore = _dereq_('empower-core');
  162. var assign = _dereq_('core-js/library/fn/object/assign');
  163. module.exports = function defaultOptions () {
  164. return assign(empowerCore.defaultOptions(), {
  165. modifyMessageOnRethrow: false,
  166. saveContextOnRethrow: false
  167. });
  168. };
  169. },{"core-js/library/fn/object/assign":10,"empower-core":67}],4:[function(_dereq_,module,exports){
  170. 'use strict';
  171. var defineProperty = _dereq_('core-js/library/fn/object/define-property');
  172. var forEach = _dereq_('core-js/library/fn/array/for-each');
  173. var keys = _dereq_('core-js/library/fn/object/keys');
  174. module.exports = function defineProperties (obj, map) {
  175. forEach(keys(map), function (name) {
  176. defineProperty(obj, name, {
  177. configurable: true,
  178. enumerable: false,
  179. value: map[name],
  180. writable: true
  181. });
  182. });
  183. };
  184. },{"core-js/library/fn/array/for-each":7,"core-js/library/fn/object/define-property":12,"core-js/library/fn/object/keys":13}],5:[function(_dereq_,module,exports){
  185. 'use strict';
  186. module.exports.parse = parse;
  187. module.exports.generate = generate;
  188. // TODO(jamestalmage): Allow full range of identifier characters instead of just ASCII
  189. //
  190. // This will likely require a build step
  191. //
  192. // SPEC: http://www.ecma-international.org/ecma-262/5.1/#sec-7.6
  193. //
  194. // TOOLING:
  195. // https://github.com/mathiasbynens/regenerate
  196. // https://www.npmjs.com/package/regjsgen
  197. var regex = /^\s*(?:([A-Za-z$_][A-Za-z0-9$_]*)\s*\.)?\s*([A-Za-z$_][A-Za-z0-9$_]*)\s*\(\s*((?:[A-Za-z$_][A-Za-z0-9$_]*)|(?:\[\s*[A-Za-z$_][A-Za-z0-9$_]*\s*]))?((?:\s*,\s*(?:(?:[A-Za-z$_][A-Za-z0-9$_]*)|(?:\[\s*[A-Za-z$_][A-Za-z0-9$_]*\s*])))+)?\s*\)\s*$/;
  198. function parse(str) {
  199. var match = regex.exec(str);
  200. if (!match) {
  201. return null;
  202. }
  203. var callee;
  204. if (match[1]) {
  205. callee = {
  206. type: 'MemberExpression',
  207. object: match[1],
  208. member: match[2]
  209. };
  210. } else {
  211. callee = {
  212. type: 'Identifier',
  213. name: match[2]
  214. };
  215. }
  216. var args = match[4] || '';
  217. args = args.split(',');
  218. if (match[3]) {
  219. args[0] = match[3];
  220. }
  221. var trimmed = [];
  222. args.forEach(function (str) {
  223. var optional = false;
  224. str = str.replace(/\s+/g, '');
  225. if (!str.length) {
  226. return;
  227. }
  228. if (str.charAt(0) === '[' && str.charAt(str.length - 1) === ']') {
  229. optional = true;
  230. str = str.substring(1, str.length - 1);
  231. }
  232. trimmed.push({
  233. name: str,
  234. optional: optional
  235. });
  236. });
  237. return {
  238. callee: callee,
  239. args: trimmed
  240. };
  241. }
  242. function generate(parsed) {
  243. var callee;
  244. if (parsed.callee.type === 'MemberExpression') {
  245. callee = [
  246. parsed.callee.object,
  247. '.',
  248. parsed.callee.member
  249. ];
  250. } else {
  251. callee = [parsed.callee.name];
  252. }
  253. return callee.concat([
  254. '(',
  255. parsed.args.map(function (arg) {
  256. return arg.optional ? '[' + arg.name + ']' : arg.name;
  257. }).join(', '),
  258. ')'
  259. ]).join('');
  260. }
  261. },{}],6:[function(_dereq_,module,exports){
  262. _dereq_('../../modules/es6.array.filter');
  263. module.exports = _dereq_('../../modules/_core').Array.filter;
  264. },{"../../modules/_core":21,"../../modules/es6.array.filter":59}],7:[function(_dereq_,module,exports){
  265. _dereq_('../../modules/es6.array.for-each');
  266. module.exports = _dereq_('../../modules/_core').Array.forEach;
  267. },{"../../modules/_core":21,"../../modules/es6.array.for-each":60}],8:[function(_dereq_,module,exports){
  268. _dereq_('../../modules/es6.array.map');
  269. module.exports = _dereq_('../../modules/_core').Array.map;
  270. },{"../../modules/_core":21,"../../modules/es6.array.map":61}],9:[function(_dereq_,module,exports){
  271. _dereq_('../../modules/es6.array.some');
  272. module.exports = _dereq_('../../modules/_core').Array.some;
  273. },{"../../modules/_core":21,"../../modules/es6.array.some":62}],10:[function(_dereq_,module,exports){
  274. _dereq_('../../modules/es6.object.assign');
  275. module.exports = _dereq_('../../modules/_core').Object.assign;
  276. },{"../../modules/_core":21,"../../modules/es6.object.assign":63}],11:[function(_dereq_,module,exports){
  277. _dereq_('../../modules/es6.object.create');
  278. var $Object = _dereq_('../../modules/_core').Object;
  279. module.exports = function create(P, D) {
  280. return $Object.create(P, D);
  281. };
  282. },{"../../modules/_core":21,"../../modules/es6.object.create":64}],12:[function(_dereq_,module,exports){
  283. _dereq_('../../modules/es6.object.define-property');
  284. var $Object = _dereq_('../../modules/_core').Object;
  285. module.exports = function defineProperty(it, key, desc) {
  286. return $Object.defineProperty(it, key, desc);
  287. };
  288. },{"../../modules/_core":21,"../../modules/es6.object.define-property":65}],13:[function(_dereq_,module,exports){
  289. _dereq_('../../modules/es6.object.keys');
  290. module.exports = _dereq_('../../modules/_core').Object.keys;
  291. },{"../../modules/_core":21,"../../modules/es6.object.keys":66}],14:[function(_dereq_,module,exports){
  292. module.exports = function (it) {
  293. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  294. return it;
  295. };
  296. },{}],15:[function(_dereq_,module,exports){
  297. var isObject = _dereq_('./_is-object');
  298. module.exports = function (it) {
  299. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  300. return it;
  301. };
  302. },{"./_is-object":36}],16:[function(_dereq_,module,exports){
  303. // false -> Array#indexOf
  304. // true -> Array#includes
  305. var toIObject = _dereq_('./_to-iobject');
  306. var toLength = _dereq_('./_to-length');
  307. var toAbsoluteIndex = _dereq_('./_to-absolute-index');
  308. module.exports = function (IS_INCLUDES) {
  309. return function ($this, el, fromIndex) {
  310. var O = toIObject($this);
  311. var length = toLength(O.length);
  312. var index = toAbsoluteIndex(fromIndex, length);
  313. var value;
  314. // Array#includes uses SameValueZero equality algorithm
  315. // eslint-disable-next-line no-self-compare
  316. if (IS_INCLUDES && el != el) while (length > index) {
  317. value = O[index++];
  318. // eslint-disable-next-line no-self-compare
  319. if (value != value) return true;
  320. // Array#indexOf ignores holes, Array#includes - not
  321. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  322. if (O[index] === el) return IS_INCLUDES || index || 0;
  323. } return !IS_INCLUDES && -1;
  324. };
  325. };
  326. },{"./_to-absolute-index":51,"./_to-iobject":53,"./_to-length":54}],17:[function(_dereq_,module,exports){
  327. // 0 -> Array#forEach
  328. // 1 -> Array#map
  329. // 2 -> Array#filter
  330. // 3 -> Array#some
  331. // 4 -> Array#every
  332. // 5 -> Array#find
  333. // 6 -> Array#findIndex
  334. var ctx = _dereq_('./_ctx');
  335. var IObject = _dereq_('./_iobject');
  336. var toObject = _dereq_('./_to-object');
  337. var toLength = _dereq_('./_to-length');
  338. var asc = _dereq_('./_array-species-create');
  339. module.exports = function (TYPE, $create) {
  340. var IS_MAP = TYPE == 1;
  341. var IS_FILTER = TYPE == 2;
  342. var IS_SOME = TYPE == 3;
  343. var IS_EVERY = TYPE == 4;
  344. var IS_FIND_INDEX = TYPE == 6;
  345. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  346. var create = $create || asc;
  347. return function ($this, callbackfn, that) {
  348. var O = toObject($this);
  349. var self = IObject(O);
  350. var f = ctx(callbackfn, that, 3);
  351. var length = toLength(self.length);
  352. var index = 0;
  353. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  354. var val, res;
  355. for (;length > index; index++) if (NO_HOLES || index in self) {
  356. val = self[index];
  357. res = f(val, index, O);
  358. if (TYPE) {
  359. if (IS_MAP) result[index] = res; // map
  360. else if (res) switch (TYPE) {
  361. case 3: return true; // some
  362. case 5: return val; // find
  363. case 6: return index; // findIndex
  364. case 2: result.push(val); // filter
  365. } else if (IS_EVERY) return false; // every
  366. }
  367. }
  368. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  369. };
  370. };
  371. },{"./_array-species-create":19,"./_ctx":22,"./_iobject":34,"./_to-length":54,"./_to-object":55}],18:[function(_dereq_,module,exports){
  372. var isObject = _dereq_('./_is-object');
  373. var isArray = _dereq_('./_is-array');
  374. var SPECIES = _dereq_('./_wks')('species');
  375. module.exports = function (original) {
  376. var C;
  377. if (isArray(original)) {
  378. C = original.constructor;
  379. // cross-realm fallback
  380. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  381. if (isObject(C)) {
  382. C = C[SPECIES];
  383. if (C === null) C = undefined;
  384. }
  385. } return C === undefined ? Array : C;
  386. };
  387. },{"./_is-array":35,"./_is-object":36,"./_wks":58}],19:[function(_dereq_,module,exports){
  388. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  389. var speciesConstructor = _dereq_('./_array-species-constructor');
  390. module.exports = function (original, length) {
  391. return new (speciesConstructor(original))(length);
  392. };
  393. },{"./_array-species-constructor":18}],20:[function(_dereq_,module,exports){
  394. var toString = {}.toString;
  395. module.exports = function (it) {
  396. return toString.call(it).slice(8, -1);
  397. };
  398. },{}],21:[function(_dereq_,module,exports){
  399. var core = module.exports = { version: '2.5.7' };
  400. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  401. },{}],22:[function(_dereq_,module,exports){
  402. // optional / simple context binding
  403. var aFunction = _dereq_('./_a-function');
  404. module.exports = function (fn, that, length) {
  405. aFunction(fn);
  406. if (that === undefined) return fn;
  407. switch (length) {
  408. case 1: return function (a) {
  409. return fn.call(that, a);
  410. };
  411. case 2: return function (a, b) {
  412. return fn.call(that, a, b);
  413. };
  414. case 3: return function (a, b, c) {
  415. return fn.call(that, a, b, c);
  416. };
  417. }
  418. return function (/* ...args */) {
  419. return fn.apply(that, arguments);
  420. };
  421. };
  422. },{"./_a-function":14}],23:[function(_dereq_,module,exports){
  423. // 7.2.1 RequireObjectCoercible(argument)
  424. module.exports = function (it) {
  425. if (it == undefined) throw TypeError("Can't call method on " + it);
  426. return it;
  427. };
  428. },{}],24:[function(_dereq_,module,exports){
  429. // Thank's IE8 for his funny defineProperty
  430. module.exports = !_dereq_('./_fails')(function () {
  431. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  432. });
  433. },{"./_fails":28}],25:[function(_dereq_,module,exports){
  434. var isObject = _dereq_('./_is-object');
  435. var document = _dereq_('./_global').document;
  436. // typeof document.createElement is 'object' in old IE
  437. var is = isObject(document) && isObject(document.createElement);
  438. module.exports = function (it) {
  439. return is ? document.createElement(it) : {};
  440. };
  441. },{"./_global":29,"./_is-object":36}],26:[function(_dereq_,module,exports){
  442. // IE 8- don't enum bug keys
  443. module.exports = (
  444. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  445. ).split(',');
  446. },{}],27:[function(_dereq_,module,exports){
  447. var global = _dereq_('./_global');
  448. var core = _dereq_('./_core');
  449. var ctx = _dereq_('./_ctx');
  450. var hide = _dereq_('./_hide');
  451. var has = _dereq_('./_has');
  452. var PROTOTYPE = 'prototype';
  453. var $export = function (type, name, source) {
  454. var IS_FORCED = type & $export.F;
  455. var IS_GLOBAL = type & $export.G;
  456. var IS_STATIC = type & $export.S;
  457. var IS_PROTO = type & $export.P;
  458. var IS_BIND = type & $export.B;
  459. var IS_WRAP = type & $export.W;
  460. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  461. var expProto = exports[PROTOTYPE];
  462. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
  463. var key, own, out;
  464. if (IS_GLOBAL) source = name;
  465. for (key in source) {
  466. // contains in native
  467. own = !IS_FORCED && target && target[key] !== undefined;
  468. if (own && has(exports, key)) continue;
  469. // export native or passed
  470. out = own ? target[key] : source[key];
  471. // prevent global pollution for namespaces
  472. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  473. // bind timers to global for call from export context
  474. : IS_BIND && own ? ctx(out, global)
  475. // wrap global constructors for prevent change them in library
  476. : IS_WRAP && target[key] == out ? (function (C) {
  477. var F = function (a, b, c) {
  478. if (this instanceof C) {
  479. switch (arguments.length) {
  480. case 0: return new C();
  481. case 1: return new C(a);
  482. case 2: return new C(a, b);
  483. } return new C(a, b, c);
  484. } return C.apply(this, arguments);
  485. };
  486. F[PROTOTYPE] = C[PROTOTYPE];
  487. return F;
  488. // make static versions for prototype methods
  489. })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  490. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  491. if (IS_PROTO) {
  492. (exports.virtual || (exports.virtual = {}))[key] = out;
  493. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  494. if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
  495. }
  496. }
  497. };
  498. // type bitmap
  499. $export.F = 1; // forced
  500. $export.G = 2; // global
  501. $export.S = 4; // static
  502. $export.P = 8; // proto
  503. $export.B = 16; // bind
  504. $export.W = 32; // wrap
  505. $export.U = 64; // safe
  506. $export.R = 128; // real proto method for `library`
  507. module.exports = $export;
  508. },{"./_core":21,"./_ctx":22,"./_global":29,"./_has":30,"./_hide":31}],28:[function(_dereq_,module,exports){
  509. module.exports = function (exec) {
  510. try {
  511. return !!exec();
  512. } catch (e) {
  513. return true;
  514. }
  515. };
  516. },{}],29:[function(_dereq_,module,exports){
  517. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  518. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  519. ? window : typeof self != 'undefined' && self.Math == Math ? self
  520. // eslint-disable-next-line no-new-func
  521. : Function('return this')();
  522. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  523. },{}],30:[function(_dereq_,module,exports){
  524. var hasOwnProperty = {}.hasOwnProperty;
  525. module.exports = function (it, key) {
  526. return hasOwnProperty.call(it, key);
  527. };
  528. },{}],31:[function(_dereq_,module,exports){
  529. var dP = _dereq_('./_object-dp');
  530. var createDesc = _dereq_('./_property-desc');
  531. module.exports = _dereq_('./_descriptors') ? function (object, key, value) {
  532. return dP.f(object, key, createDesc(1, value));
  533. } : function (object, key, value) {
  534. object[key] = value;
  535. return object;
  536. };
  537. },{"./_descriptors":24,"./_object-dp":40,"./_property-desc":47}],32:[function(_dereq_,module,exports){
  538. var document = _dereq_('./_global').document;
  539. module.exports = document && document.documentElement;
  540. },{"./_global":29}],33:[function(_dereq_,module,exports){
  541. module.exports = !_dereq_('./_descriptors') && !_dereq_('./_fails')(function () {
  542. return Object.defineProperty(_dereq_('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
  543. });
  544. },{"./_descriptors":24,"./_dom-create":25,"./_fails":28}],34:[function(_dereq_,module,exports){
  545. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  546. var cof = _dereq_('./_cof');
  547. // eslint-disable-next-line no-prototype-builtins
  548. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  549. return cof(it) == 'String' ? it.split('') : Object(it);
  550. };
  551. },{"./_cof":20}],35:[function(_dereq_,module,exports){
  552. // 7.2.2 IsArray(argument)
  553. var cof = _dereq_('./_cof');
  554. module.exports = Array.isArray || function isArray(arg) {
  555. return cof(arg) == 'Array';
  556. };
  557. },{"./_cof":20}],36:[function(_dereq_,module,exports){
  558. module.exports = function (it) {
  559. return typeof it === 'object' ? it !== null : typeof it === 'function';
  560. };
  561. },{}],37:[function(_dereq_,module,exports){
  562. module.exports = true;
  563. },{}],38:[function(_dereq_,module,exports){
  564. 'use strict';
  565. // 19.1.2.1 Object.assign(target, source, ...)
  566. var getKeys = _dereq_('./_object-keys');
  567. var gOPS = _dereq_('./_object-gops');
  568. var pIE = _dereq_('./_object-pie');
  569. var toObject = _dereq_('./_to-object');
  570. var IObject = _dereq_('./_iobject');
  571. var $assign = Object.assign;
  572. // should work with symbols and should have deterministic property order (V8 bug)
  573. module.exports = !$assign || _dereq_('./_fails')(function () {
  574. var A = {};
  575. var B = {};
  576. // eslint-disable-next-line no-undef
  577. var S = Symbol();
  578. var K = 'abcdefghijklmnopqrst';
  579. A[S] = 7;
  580. K.split('').forEach(function (k) { B[k] = k; });
  581. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  582. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  583. var T = toObject(target);
  584. var aLen = arguments.length;
  585. var index = 1;
  586. var getSymbols = gOPS.f;
  587. var isEnum = pIE.f;
  588. while (aLen > index) {
  589. var S = IObject(arguments[index++]);
  590. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  591. var length = keys.length;
  592. var j = 0;
  593. var key;
  594. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  595. } return T;
  596. } : $assign;
  597. },{"./_fails":28,"./_iobject":34,"./_object-gops":42,"./_object-keys":44,"./_object-pie":45,"./_to-object":55}],39:[function(_dereq_,module,exports){
  598. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  599. var anObject = _dereq_('./_an-object');
  600. var dPs = _dereq_('./_object-dps');
  601. var enumBugKeys = _dereq_('./_enum-bug-keys');
  602. var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
  603. var Empty = function () { /* empty */ };
  604. var PROTOTYPE = 'prototype';
  605. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  606. var createDict = function () {
  607. // Thrash, waste and sodomy: IE GC bug
  608. var iframe = _dereq_('./_dom-create')('iframe');
  609. var i = enumBugKeys.length;
  610. var lt = '<';
  611. var gt = '>';
  612. var iframeDocument;
  613. iframe.style.display = 'none';
  614. _dereq_('./_html').appendChild(iframe);
  615. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  616. // createDict = iframe.contentWindow.Object;
  617. // html.removeChild(iframe);
  618. iframeDocument = iframe.contentWindow.document;
  619. iframeDocument.open();
  620. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  621. iframeDocument.close();
  622. createDict = iframeDocument.F;
  623. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  624. return createDict();
  625. };
  626. module.exports = Object.create || function create(O, Properties) {
  627. var result;
  628. if (O !== null) {
  629. Empty[PROTOTYPE] = anObject(O);
  630. result = new Empty();
  631. Empty[PROTOTYPE] = null;
  632. // add "__proto__" for Object.getPrototypeOf polyfill
  633. result[IE_PROTO] = O;
  634. } else result = createDict();
  635. return Properties === undefined ? result : dPs(result, Properties);
  636. };
  637. },{"./_an-object":15,"./_dom-create":25,"./_enum-bug-keys":26,"./_html":32,"./_object-dps":41,"./_shared-key":48}],40:[function(_dereq_,module,exports){
  638. var anObject = _dereq_('./_an-object');
  639. var IE8_DOM_DEFINE = _dereq_('./_ie8-dom-define');
  640. var toPrimitive = _dereq_('./_to-primitive');
  641. var dP = Object.defineProperty;
  642. exports.f = _dereq_('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  643. anObject(O);
  644. P = toPrimitive(P, true);
  645. anObject(Attributes);
  646. if (IE8_DOM_DEFINE) try {
  647. return dP(O, P, Attributes);
  648. } catch (e) { /* empty */ }
  649. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  650. if ('value' in Attributes) O[P] = Attributes.value;
  651. return O;
  652. };
  653. },{"./_an-object":15,"./_descriptors":24,"./_ie8-dom-define":33,"./_to-primitive":56}],41:[function(_dereq_,module,exports){
  654. var dP = _dereq_('./_object-dp');
  655. var anObject = _dereq_('./_an-object');
  656. var getKeys = _dereq_('./_object-keys');
  657. module.exports = _dereq_('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
  658. anObject(O);
  659. var keys = getKeys(Properties);
  660. var length = keys.length;
  661. var i = 0;
  662. var P;
  663. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  664. return O;
  665. };
  666. },{"./_an-object":15,"./_descriptors":24,"./_object-dp":40,"./_object-keys":44}],42:[function(_dereq_,module,exports){
  667. exports.f = Object.getOwnPropertySymbols;
  668. },{}],43:[function(_dereq_,module,exports){
  669. var has = _dereq_('./_has');
  670. var toIObject = _dereq_('./_to-iobject');
  671. var arrayIndexOf = _dereq_('./_array-includes')(false);
  672. var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
  673. module.exports = function (object, names) {
  674. var O = toIObject(object);
  675. var i = 0;
  676. var result = [];
  677. var key;
  678. for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
  679. // Don't enum bug & hidden keys
  680. while (names.length > i) if (has(O, key = names[i++])) {
  681. ~arrayIndexOf(result, key) || result.push(key);
  682. }
  683. return result;
  684. };
  685. },{"./_array-includes":16,"./_has":30,"./_shared-key":48,"./_to-iobject":53}],44:[function(_dereq_,module,exports){
  686. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  687. var $keys = _dereq_('./_object-keys-internal');
  688. var enumBugKeys = _dereq_('./_enum-bug-keys');
  689. module.exports = Object.keys || function keys(O) {
  690. return $keys(O, enumBugKeys);
  691. };
  692. },{"./_enum-bug-keys":26,"./_object-keys-internal":43}],45:[function(_dereq_,module,exports){
  693. exports.f = {}.propertyIsEnumerable;
  694. },{}],46:[function(_dereq_,module,exports){
  695. // most Object methods by ES6 should accept primitives
  696. var $export = _dereq_('./_export');
  697. var core = _dereq_('./_core');
  698. var fails = _dereq_('./_fails');
  699. module.exports = function (KEY, exec) {
  700. var fn = (core.Object || {})[KEY] || Object[KEY];
  701. var exp = {};
  702. exp[KEY] = exec(fn);
  703. $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
  704. };
  705. },{"./_core":21,"./_export":27,"./_fails":28}],47:[function(_dereq_,module,exports){
  706. module.exports = function (bitmap, value) {
  707. return {
  708. enumerable: !(bitmap & 1),
  709. configurable: !(bitmap & 2),
  710. writable: !(bitmap & 4),
  711. value: value
  712. };
  713. };
  714. },{}],48:[function(_dereq_,module,exports){
  715. var shared = _dereq_('./_shared')('keys');
  716. var uid = _dereq_('./_uid');
  717. module.exports = function (key) {
  718. return shared[key] || (shared[key] = uid(key));
  719. };
  720. },{"./_shared":49,"./_uid":57}],49:[function(_dereq_,module,exports){
  721. var core = _dereq_('./_core');
  722. var global = _dereq_('./_global');
  723. var SHARED = '__core-js_shared__';
  724. var store = global[SHARED] || (global[SHARED] = {});
  725. (module.exports = function (key, value) {
  726. return store[key] || (store[key] = value !== undefined ? value : {});
  727. })('versions', []).push({
  728. version: core.version,
  729. mode: _dereq_('./_library') ? 'pure' : 'global',
  730. copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
  731. });
  732. },{"./_core":21,"./_global":29,"./_library":37}],50:[function(_dereq_,module,exports){
  733. 'use strict';
  734. var fails = _dereq_('./_fails');
  735. module.exports = function (method, arg) {
  736. return !!method && fails(function () {
  737. // eslint-disable-next-line no-useless-call
  738. arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);
  739. });
  740. };
  741. },{"./_fails":28}],51:[function(_dereq_,module,exports){
  742. var toInteger = _dereq_('./_to-integer');
  743. var max = Math.max;
  744. var min = Math.min;
  745. module.exports = function (index, length) {
  746. index = toInteger(index);
  747. return index < 0 ? max(index + length, 0) : min(index, length);
  748. };
  749. },{"./_to-integer":52}],52:[function(_dereq_,module,exports){
  750. // 7.1.4 ToInteger
  751. var ceil = Math.ceil;
  752. var floor = Math.floor;
  753. module.exports = function (it) {
  754. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  755. };
  756. },{}],53:[function(_dereq_,module,exports){
  757. // to indexed object, toObject with fallback for non-array-like ES3 strings
  758. var IObject = _dereq_('./_iobject');
  759. var defined = _dereq_('./_defined');
  760. module.exports = function (it) {
  761. return IObject(defined(it));
  762. };
  763. },{"./_defined":23,"./_iobject":34}],54:[function(_dereq_,module,exports){
  764. // 7.1.15 ToLength
  765. var toInteger = _dereq_('./_to-integer');
  766. var min = Math.min;
  767. module.exports = function (it) {
  768. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  769. };
  770. },{"./_to-integer":52}],55:[function(_dereq_,module,exports){
  771. // 7.1.13 ToObject(argument)
  772. var defined = _dereq_('./_defined');
  773. module.exports = function (it) {
  774. return Object(defined(it));
  775. };
  776. },{"./_defined":23}],56:[function(_dereq_,module,exports){
  777. // 7.1.1 ToPrimitive(input [, PreferredType])
  778. var isObject = _dereq_('./_is-object');
  779. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  780. // and the second argument - flag - preferred type is a string
  781. module.exports = function (it, S) {
  782. if (!isObject(it)) return it;
  783. var fn, val;
  784. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  785. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  786. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  787. throw TypeError("Can't convert object to primitive value");
  788. };
  789. },{"./_is-object":36}],57:[function(_dereq_,module,exports){
  790. var id = 0;
  791. var px = Math.random();
  792. module.exports = function (key) {
  793. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  794. };
  795. },{}],58:[function(_dereq_,module,exports){
  796. var store = _dereq_('./_shared')('wks');
  797. var uid = _dereq_('./_uid');
  798. var Symbol = _dereq_('./_global').Symbol;
  799. var USE_SYMBOL = typeof Symbol == 'function';
  800. var $exports = module.exports = function (name) {
  801. return store[name] || (store[name] =
  802. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  803. };
  804. $exports.store = store;
  805. },{"./_global":29,"./_shared":49,"./_uid":57}],59:[function(_dereq_,module,exports){
  806. 'use strict';
  807. var $export = _dereq_('./_export');
  808. var $filter = _dereq_('./_array-methods')(2);
  809. $export($export.P + $export.F * !_dereq_('./_strict-method')([].filter, true), 'Array', {
  810. // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
  811. filter: function filter(callbackfn /* , thisArg */) {
  812. return $filter(this, callbackfn, arguments[1]);
  813. }
  814. });
  815. },{"./_array-methods":17,"./_export":27,"./_strict-method":50}],60:[function(_dereq_,module,exports){
  816. 'use strict';
  817. var $export = _dereq_('./_export');
  818. var $forEach = _dereq_('./_array-methods')(0);
  819. var STRICT = _dereq_('./_strict-method')([].forEach, true);
  820. $export($export.P + $export.F * !STRICT, 'Array', {
  821. // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
  822. forEach: function forEach(callbackfn /* , thisArg */) {
  823. return $forEach(this, callbackfn, arguments[1]);
  824. }
  825. });
  826. },{"./_array-methods":17,"./_export":27,"./_strict-method":50}],61:[function(_dereq_,module,exports){
  827. 'use strict';
  828. var $export = _dereq_('./_export');
  829. var $map = _dereq_('./_array-methods')(1);
  830. $export($export.P + $export.F * !_dereq_('./_strict-method')([].map, true), 'Array', {
  831. // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
  832. map: function map(callbackfn /* , thisArg */) {
  833. return $map(this, callbackfn, arguments[1]);
  834. }
  835. });
  836. },{"./_array-methods":17,"./_export":27,"./_strict-method":50}],62:[function(_dereq_,module,exports){
  837. 'use strict';
  838. var $export = _dereq_('./_export');
  839. var $some = _dereq_('./_array-methods')(3);
  840. $export($export.P + $export.F * !_dereq_('./_strict-method')([].some, true), 'Array', {
  841. // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
  842. some: function some(callbackfn /* , thisArg */) {
  843. return $some(this, callbackfn, arguments[1]);
  844. }
  845. });
  846. },{"./_array-methods":17,"./_export":27,"./_strict-method":50}],63:[function(_dereq_,module,exports){
  847. // 19.1.3.1 Object.assign(target, source)
  848. var $export = _dereq_('./_export');
  849. $export($export.S + $export.F, 'Object', { assign: _dereq_('./_object-assign') });
  850. },{"./_export":27,"./_object-assign":38}],64:[function(_dereq_,module,exports){
  851. var $export = _dereq_('./_export');
  852. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  853. $export($export.S, 'Object', { create: _dereq_('./_object-create') });
  854. },{"./_export":27,"./_object-create":39}],65:[function(_dereq_,module,exports){
  855. var $export = _dereq_('./_export');
  856. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  857. $export($export.S + $export.F * !_dereq_('./_descriptors'), 'Object', { defineProperty: _dereq_('./_object-dp').f });
  858. },{"./_descriptors":24,"./_export":27,"./_object-dp":40}],66:[function(_dereq_,module,exports){
  859. // 19.1.2.14 Object.keys(O)
  860. var toObject = _dereq_('./_to-object');
  861. var $keys = _dereq_('./_object-keys');
  862. _dereq_('./_object-sap')('keys', function () {
  863. return function keys(it) {
  864. return $keys(toObject(it));
  865. };
  866. });
  867. },{"./_object-keys":44,"./_object-sap":46,"./_to-object":55}],67:[function(_dereq_,module,exports){
  868. /**
  869. * empower-core - Power Assert feature enhancer for assert function/object.
  870. *
  871. * https://github.com/twada/power-assert-runtime/packages/empower-core
  872. *
  873. * Copyright (c) 2013-2018 Takuto Wada
  874. * Licensed under the MIT license.
  875. * https://github.com/twada/power-assert-runtime/blob/master/LICENSE
  876. */
  877. var create = _dereq_('core-js/library/fn/object/create');
  878. var assign = _dereq_('core-js/library/fn/object/assign');
  879. var defaultOptions = _dereq_('./lib/default-options');
  880. var Decorator = _dereq_('./lib/decorator');
  881. var define = _dereq_('./lib/define-properties');
  882. var slice = Array.prototype.slice;
  883. /**
  884. * Enhance Power Assert feature to assert function/object.
  885. * @param assert target assert function or object to enhance
  886. * @param options enhancement options
  887. * @return enhanced assert function/object
  888. */
  889. function empowerCore (assert, options) {
  890. var typeOfAssert = (typeof assert);
  891. var enhancedAssert;
  892. if ((typeOfAssert !== 'object' && typeOfAssert !== 'function') || assert === null) {
  893. throw new TypeError('empower-core argument should be a function or object.');
  894. }
  895. if (isEmpowered(assert)) {
  896. return assert;
  897. }
  898. switch (typeOfAssert) {
  899. case 'function':
  900. enhancedAssert = empowerAssertFunction(assert, options);
  901. break;
  902. case 'object':
  903. enhancedAssert = empowerAssertObject(assert, options);
  904. break;
  905. default:
  906. throw new Error('Cannot be here');
  907. }
  908. define(enhancedAssert, { _empowered: true });
  909. return enhancedAssert;
  910. }
  911. function empowerAssertObject (assertObject, options) {
  912. var config = assign(defaultOptions(), options);
  913. var target = config.destructive ? assertObject : create(assertObject);
  914. var decorator = new Decorator(target, config);
  915. return assign(target, decorator.enhancement());
  916. }
  917. function empowerAssertFunction (assertFunction, options) {
  918. var config = assign(defaultOptions(), options);
  919. if (config.destructive) {
  920. throw new Error('cannot use destructive:true to function.');
  921. }
  922. var decorator = new Decorator(assertFunction, config);
  923. var enhancement = decorator.enhancement();
  924. var powerAssert;
  925. if (typeof enhancement === 'function') {
  926. powerAssert = function powerAssert () {
  927. return enhancement.apply(null, slice.apply(arguments));
  928. };
  929. } else {
  930. powerAssert = function powerAssert () {
  931. return assertFunction.apply(null, slice.apply(arguments));
  932. };
  933. }
  934. assign(powerAssert, assertFunction);
  935. return assign(powerAssert, enhancement);
  936. }
  937. function isEmpowered (assertObjectOrFunction) {
  938. return assertObjectOrFunction._empowered;
  939. }
  940. empowerCore.defaultOptions = defaultOptions;
  941. module.exports = empowerCore;
  942. },{"./lib/decorator":69,"./lib/default-options":70,"./lib/define-properties":71,"core-js/library/fn/object/assign":10,"core-js/library/fn/object/create":11}],68:[function(_dereq_,module,exports){
  943. 'use strict';
  944. var some = _dereq_('core-js/library/fn/array/some');
  945. var map = _dereq_('core-js/library/fn/array/map');
  946. function decorate (callSpec, decorator) {
  947. var numArgsToCapture = callSpec.numArgsToCapture;
  948. return function decoratedAssert () {
  949. var context, message, hasMessage = false;
  950. // see: https://github.com/twada/empower-core/pull/8#issue-127859465
  951. // see: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
  952. var args = new Array(arguments.length);
  953. for(var i = 0; i < args.length; ++i) {
  954. args[i] = arguments[i];
  955. }
  956. if (numArgsToCapture === (args.length - 1)) {
  957. message = args.pop();
  958. hasMessage = true;
  959. }
  960. var invocation = {
  961. thisObj: this,
  962. values: args,
  963. message: message,
  964. hasMessage: hasMessage
  965. };
  966. if (some(args, isCaptured)) {
  967. invocation.values = map(args.slice(0, numArgsToCapture), function (arg) {
  968. if (isNotCaptured(arg)) {
  969. return arg;
  970. }
  971. if (!context) {
  972. context = {
  973. source: arg.source,
  974. args: []
  975. };
  976. }
  977. context.args.push({
  978. value: arg.powerAssertContext.value,
  979. events: arg.powerAssertContext.events
  980. });
  981. return arg.powerAssertContext.value;
  982. });
  983. return decorator.concreteAssert(callSpec, invocation, context);
  984. } else {
  985. return decorator.concreteAssert(callSpec, invocation);
  986. }
  987. };
  988. }
  989. function isNotCaptured (value) {
  990. return !isCaptured(value);
  991. }
  992. function isCaptured (value) {
  993. return (typeof value === 'object') &&
  994. (value !== null) &&
  995. (typeof value.powerAssertContext !== 'undefined');
  996. }
  997. module.exports = decorate;
  998. },{"core-js/library/fn/array/map":8,"core-js/library/fn/array/some":9}],69:[function(_dereq_,module,exports){
  999. 'use strict';
  1000. var forEach = _dereq_('core-js/library/fn/array/for-each');
  1001. var filter = _dereq_('core-js/library/fn/array/filter');
  1002. var map = _dereq_('core-js/library/fn/array/map');
  1003. var signature = _dereq_('call-signature');
  1004. var decorate = _dereq_('./decorate');
  1005. var keys = _dereq_('core-js/library/fn/object/keys');
  1006. function Decorator (receiver, config) {
  1007. this.receiver = receiver;
  1008. this.config = config;
  1009. this.onError = config.onError;
  1010. this.onSuccess = config.onSuccess;
  1011. this.signatures = map(config.patterns, parse);
  1012. this.wrapOnlySignatures = map(config.wrapOnlyPatterns, parse);
  1013. }
  1014. Decorator.prototype.enhancement = function () {
  1015. var that = this;
  1016. var container = this.container();
  1017. var wrappedMethods = [];
  1018. function attach(matcherSpec, enhanced) {
  1019. var matcher = matcherSpec.parsed;
  1020. var methodName = detectMethodName(matcher.callee);
  1021. if (typeof that.receiver[methodName] !== 'function' || wrappedMethods.indexOf(methodName) !== -1) {
  1022. return;
  1023. }
  1024. var callSpec = {
  1025. thisObj: that.receiver,
  1026. func: that.receiver[methodName],
  1027. numArgsToCapture: numberOfArgumentsToCapture(matcherSpec),
  1028. matcherSpec: matcherSpec,
  1029. enhanced: enhanced
  1030. };
  1031. container[methodName] = callSpec.enhancedFunc = decorate(callSpec, that);
  1032. wrappedMethods.push(methodName);
  1033. }
  1034. forEach(filter(this.signatures, methodCall), function (matcher) {
  1035. attach(matcher, true);
  1036. });
  1037. forEach(filter(this.wrapOnlySignatures, methodCall), function (matcher) {
  1038. attach(matcher, false);
  1039. });
  1040. return container;
  1041. };
  1042. Decorator.prototype.container = function () {
  1043. var basement = {};
  1044. if (typeof this.receiver === 'function') {
  1045. var candidates = filter(this.signatures, functionCall);
  1046. var enhanced = true;
  1047. if (candidates.length === 0) {
  1048. enhanced = false;
  1049. candidates = filter(this.wrapOnlySignatures, functionCall);
  1050. }
  1051. if (candidates.length === 1) {
  1052. var callSpec = {
  1053. thisObj: null,
  1054. func: this.receiver,
  1055. numArgsToCapture: numberOfArgumentsToCapture(candidates[0]),
  1056. matcherSpec: candidates[0],
  1057. enhanced: enhanced
  1058. };
  1059. basement = callSpec.enhancedFunc = decorate(callSpec, this);
  1060. }
  1061. }
  1062. return basement;
  1063. };
  1064. Decorator.prototype.concreteAssert = function (callSpec, invocation, context) {
  1065. var func = callSpec.func;
  1066. var thisObj = this.config.bindReceiver ? callSpec.thisObj : invocation.thisObj;
  1067. var enhanced = callSpec.enhanced;
  1068. var args = invocation.values;
  1069. var message = invocation.message;
  1070. var matcherSpec = callSpec.matcherSpec;
  1071. if (context && typeof this.config.modifyMessageBeforeAssert === 'function') {
  1072. message = this.config.modifyMessageBeforeAssert({originalMessage: message, powerAssertContext: context});
  1073. }
  1074. args = args.concat(message);
  1075. var data = {
  1076. thisObj: invocation.thisObj,
  1077. assertionFunction: callSpec.enhancedFunc,
  1078. originalMessage: message,
  1079. defaultMessage: matcherSpec.defaultMessage,
  1080. matcherSpec: matcherSpec,
  1081. enhanced: enhanced,
  1082. args: args
  1083. };
  1084. if (context) {
  1085. data.powerAssertContext = context;
  1086. }
  1087. return this._callFunc(func, thisObj, args, data);
  1088. };
  1089. // see: https://github.com/twada/empower-core/pull/8#issuecomment-173480982
  1090. Decorator.prototype._callFunc = function (func, thisObj, args, data) {
  1091. var ret;
  1092. try {
  1093. ret = func.apply(thisObj, args);
  1094. } catch (e) {
  1095. data.assertionThrew = true;
  1096. data.error = e;
  1097. return this.onError.call(thisObj, data);
  1098. }
  1099. data.assertionThrew = false;
  1100. data.returnValue = ret;
  1101. return this.onSuccess.call(thisObj, data);
  1102. };
  1103. function numberOfArgumentsToCapture (matcherSpec) {
  1104. var matcher = matcherSpec.parsed;
  1105. var len = matcher.args.length;
  1106. var lastArg;
  1107. if (0 < len) {
  1108. lastArg = matcher.args[len - 1];
  1109. if (lastArg.name === 'message' && lastArg.optional) {
  1110. len -= 1;
  1111. }
  1112. }
  1113. return len;
  1114. }
  1115. function detectMethodName (callee) {
  1116. if (callee.type === 'MemberExpression') {
  1117. return callee.member;
  1118. }
  1119. return null;
  1120. }
  1121. function functionCall (matcherSpec) {
  1122. return matcherSpec.parsed.callee.type === 'Identifier';
  1123. }
  1124. function methodCall (matcherSpec) {
  1125. return matcherSpec.parsed.callee.type === 'MemberExpression';
  1126. }
  1127. function parse(matcherSpec) {
  1128. if (typeof matcherSpec === 'string') {
  1129. matcherSpec = {pattern: matcherSpec};
  1130. }
  1131. var ret = {};
  1132. forEach(keys(matcherSpec), function (key) {
  1133. ret[key] = matcherSpec[key];
  1134. });
  1135. ret.parsed = signature.parse(matcherSpec.pattern);
  1136. return ret;
  1137. }
  1138. module.exports = Decorator;
  1139. },{"./decorate":68,"call-signature":5,"core-js/library/fn/array/filter":6,"core-js/library/fn/array/for-each":7,"core-js/library/fn/array/map":8,"core-js/library/fn/object/keys":13}],70:[function(_dereq_,module,exports){
  1140. 'use strict';
  1141. module.exports = function defaultOptions () {
  1142. return {
  1143. destructive: false,
  1144. bindReceiver: true,
  1145. onError: onError,
  1146. onSuccess: onSuccess,
  1147. patterns: [
  1148. 'assert(value, [message])',
  1149. 'assert.ok(value, [message])',
  1150. 'assert.equal(actual, expected, [message])',
  1151. 'assert.notEqual(actual, expected, [message])',
  1152. 'assert.strictEqual(actual, expected, [message])',
  1153. 'assert.notStrictEqual(actual, expected, [message])',
  1154. 'assert.deepEqual(actual, expected, [message])',
  1155. 'assert.notDeepEqual(actual, expected, [message])',
  1156. 'assert.deepStrictEqual(actual, expected, [message])',
  1157. 'assert.notDeepStrictEqual(actual, expected, [message])'
  1158. ],
  1159. wrapOnlyPatterns: []
  1160. };
  1161. };
  1162. function onError (errorEvent) {
  1163. var e = errorEvent.error;
  1164. if (errorEvent.powerAssertContext && /^AssertionError/.test(e.name)) {
  1165. e.powerAssertContext = errorEvent.powerAssertContext;
  1166. }
  1167. throw e;
  1168. }
  1169. function onSuccess(successEvent) {
  1170. return successEvent.returnValue;
  1171. }
  1172. },{}],71:[function(_dereq_,module,exports){
  1173. arguments[4][4][0].apply(exports,arguments)
  1174. },{"core-js/library/fn/array/for-each":7,"core-js/library/fn/object/define-property":12,"core-js/library/fn/object/keys":13,"dup":4}]},{},[1])(1)
  1175. });