1 | (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.armature = f()}})(function(){var define,module,exports;return (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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 | "use strict";
|
3 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
4 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
5 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
6 | r = Reflect.decorate(decorators, target, key, desc);
|
7 | else
|
8 | for (var i = decorators.length - 1; i >= 0; i--)
|
9 | if (d = decorators[i])
|
10 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
11 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
12 | };
|
13 | var UUID_1 = require("./UUID");
|
14 | var Decorators_1 = require("./Decorators");
|
15 | var ComponentStore_1 = require("./ComponentStore");
|
16 | var assign = require("object-assign");
|
17 |
|
18 |
|
19 |
|
20 | var Component = (function () {
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 | function Component(data) {
|
27 | |
28 |
|
29 |
|
30 | this.$children = [];
|
31 | this.$data = data;
|
32 | this.$id = UUID_1.default.get();
|
33 | }
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | Component.$for = function (parent, label, data) {
|
44 | var identifier = this.$getIdentifier(label);
|
45 | var existing = parent.$children.find(function (v) { return v.$getIdentifier() === identifier; });
|
46 | if (existing) {
|
47 | return existing;
|
48 | }
|
49 | if (data === null) {
|
50 | throw new Error("Subcomponent was created with no data!");
|
51 | }
|
52 | var inst = new this(data);
|
53 | inst.$label = label;
|
54 | inst.$parent = parent;
|
55 | parent.$children.push(inst);
|
56 | return inst;
|
57 | };
|
58 | |
59 |
|
60 |
|
61 | Component.prototype.$serializeData = function () {
|
62 | return assign({}, this.$data);
|
63 | };
|
64 | |
65 |
|
66 |
|
67 | Component.$getTypeName = function () {
|
68 | var classString = this.$classNames.map(function (v) { return "." + v; }).join("");
|
69 | return this.$tagName + classString;
|
70 | };
|
71 | |
72 |
|
73 |
|
74 | Component.prototype.$deflate = function () {
|
75 | var thisClass = this.constructor;
|
76 | return {
|
77 | type: thisClass.$getTypeName(),
|
78 | data: this.$serializeData(),
|
79 | id: this.$id,
|
80 | label: this.$label,
|
81 | children: this.$children.map(function (v) { return v.$deflate(); })
|
82 | };
|
83 | };
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | Component.$inflate = function (deflated, inst) {
|
91 | if (!inst) {
|
92 | inst = new this(deflated.data);
|
93 | }
|
94 | inst.$id = deflated.id;
|
95 | inst.$label = deflated.label;
|
96 | if (deflated.children) {
|
97 | for (var _i = 0, _a = deflated.children; _i < _a.length; _i++) {
|
98 | var child = _a[_i];
|
99 | var thatClass = ComponentStore_1.default.get(child.type);
|
100 | var childInst = thatClass.$for(inst, child.label, child.data);
|
101 | thatClass.$inflate(child, childInst);
|
102 | }
|
103 | }
|
104 | return inst;
|
105 | };
|
106 | |
107 |
|
108 |
|
109 |
|
110 |
|
111 | Component.$getIdentifier = function (label) {
|
112 | return this.$getTypeName() + "__" + label;
|
113 | };
|
114 | |
115 |
|
116 |
|
117 | Component.prototype.$getIdentifier = function () {
|
118 | var thisClass = this.constructor;
|
119 | return thisClass.$getIdentifier(this.$label);
|
120 | };
|
121 | Component.prototype.toString = function () {
|
122 | return this.$getHTML();
|
123 | };
|
124 | |
125 |
|
126 |
|
127 | Component.prototype.$getHTML = function () {
|
128 | var thisClass = this.constructor;
|
129 | return "<" + thisClass.$tagName + "\n\t\t\tclass=\"" + thisClass.$classNames.join(" ") + "\"\n\t\t\tdata-armid=\"" + this.$id + "\"\n\t\t\t" + (this.$label ? "data-label=\"" + this.$label + "\"" : "") + "\n\t\t\t>" + this.$template(this) + "</" + thisClass.$tagName + ">";
|
130 | };
|
131 | |
132 |
|
133 |
|
134 | Component.prototype.$ensureElement = function () {
|
135 | if (!this.$element) {
|
136 | var thisClass = this.constructor;
|
137 | var el = document.createElement(thisClass.$tagName);
|
138 | (_a = el.classList).add.apply(_a, thisClass.$classNames);
|
139 | this.$attachTo(el);
|
140 | }
|
141 | var _a;
|
142 | };
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 | Component.prototype.$attachTo = function (element) {
|
149 | this.$element = element;
|
150 | element.setAttribute("data-armid", this.$id.toString());
|
151 | if (this.$label) {
|
152 | element.setAttribute("data-label", this.$label);
|
153 | }
|
154 | };
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 | Component.prototype.$locate = function (parent) {
|
161 | if (parent === void 0) {
|
162 | parent = document.body;
|
163 | }
|
164 | var thisClass = this.constructor;
|
165 | var el = parent.querySelector(thisClass.$tagName + "[data-armid=\"" + this.$id + "\"]");
|
166 | if (el) {
|
167 | this.$element = el;
|
168 | this.$children.forEach(function (child) {
|
169 | child.$locate(el);
|
170 | });
|
171 | return el;
|
172 | }
|
173 | };
|
174 | |
175 |
|
176 |
|
177 | Component.prototype.$render = function () {
|
178 | this.$element.innerHTML = this.$template(this);
|
179 | };
|
180 | |
181 |
|
182 |
|
183 |
|
184 | Component.prototype.$hydrate = function () {
|
185 | for (var _i = 0, _a = this.$children; _i < _a.length; _i++) {
|
186 | var child = _a[_i];
|
187 | if (child.$locate(this.$element)) {
|
188 | child.$hydrate();
|
189 | }
|
190 | }
|
191 | };
|
192 | |
193 |
|
194 |
|
195 | Component.prototype.$reify = function () {
|
196 | this.$ensureElement();
|
197 | this.$render();
|
198 | this.$hydrate();
|
199 | };
|
200 | |
201 |
|
202 |
|
203 | Component.$classNames = [];
|
204 | Component = __decorate([
|
205 | Decorators_1.TagName("arm-component"),
|
206 | Decorators_1.Template(function () { return ""; })
|
207 | ], Component);
|
208 | return Component;
|
209 | }());
|
210 | exports.Component = Component;
|
211 |
|
212 |
|
213 | },{"./ComponentStore":2,"./Decorators":3,"./UUID":5,"object-assign":42}],2:[function(require,module,exports){
|
214 | "use strict";
|
215 | var ComponentStore = {
|
216 | store: new Map(),
|
217 | register: function (componentType) {
|
218 | this.store.set(componentType.$getTypeName(), componentType);
|
219 | },
|
220 | get: function (typeName) {
|
221 | return this.store.get(typeName);
|
222 | }
|
223 | };
|
224 | Object.defineProperty(exports, "__esModule", { value: true });
|
225 | exports.default = ComponentStore;
|
226 |
|
227 |
|
228 | },{}],3:[function(require,module,exports){
|
229 | "use strict";
|
230 |
|
231 |
|
232 |
|
233 |
|
234 | function Template(template) {
|
235 | return function (target) {
|
236 | target.prototype.$template = template;
|
237 | };
|
238 | }
|
239 | exports.Template = Template;
|
240 |
|
241 |
|
242 |
|
243 |
|
244 | function TagName(name) {
|
245 | return function (target) {
|
246 | target.$tagName = name;
|
247 | };
|
248 | }
|
249 | exports.TagName = TagName;
|
250 |
|
251 |
|
252 |
|
253 |
|
254 | function ClassNames() {
|
255 | var names = [];
|
256 | for (var _i = 0; _i < arguments.length; _i++) {
|
257 | names[_i - 0] = arguments[_i];
|
258 | }
|
259 | return function (target) {
|
260 | (_a = target.$classNames).push.apply(_a, names);
|
261 | var _a;
|
262 | };
|
263 | }
|
264 | exports.ClassNames = ClassNames;
|
265 |
|
266 |
|
267 | },{}],4:[function(require,module,exports){
|
268 | "use strict";
|
269 | var ComponentStore_1 = require("./ComponentStore");
|
270 | function Properties(data) {
|
271 | return function (target) {
|
272 | target.prototype.$template = data.template;
|
273 | target.$tagName = data.tag;
|
274 | if (data.classes) {
|
275 | target.$classNames = target.$classNames.concat(data.classes);
|
276 | }
|
277 | ComponentStore_1.default.register(target);
|
278 | };
|
279 | }
|
280 | exports.Properties = Properties;
|
281 |
|
282 |
|
283 | },{"./ComponentStore":2}],5:[function(require,module,exports){
|
284 | "use strict";
|
285 | var randomBuffer = new Uint16Array(1);
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | function rand() {
|
291 | if (typeof crypto !== "undefined") {
|
292 | crypto.getRandomValues(randomBuffer);
|
293 | return randomBuffer[0] / Math.pow(2, 16);
|
294 | }
|
295 | else {
|
296 | return Math.random();
|
297 | }
|
298 | }
|
299 | var UUID = {
|
300 | |
301 |
|
302 |
|
303 | get: function () {
|
304 | var template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
|
305 | var value = template.replace(/[xy]/g, function (c) {
|
306 | var v = Math.floor(rand() * 16);
|
307 | if (c !== "x") {
|
308 | v = v & 0x3 | 0x8;
|
309 | }
|
310 | return v.toString(16);
|
311 | });
|
312 | return value;
|
313 | }
|
314 | };
|
315 | Object.defineProperty(exports, "__esModule", { value: true });
|
316 | exports.default = UUID;
|
317 |
|
318 |
|
319 | },{}],6:[function(require,module,exports){
|
320 | "use strict";
|
321 | function __export(m) {
|
322 | for (var p in m)
|
323 | if (!exports.hasOwnProperty(p))
|
324 | exports[p] = m[p];
|
325 | }
|
326 | __export(require("./Component"));
|
327 | var ComponentStore_1 = require("./ComponentStore");
|
328 | exports.ComponentStore = ComponentStore_1.default;
|
329 | var UUID_1 = require("./UUID");
|
330 | exports.UUID = UUID_1.default;
|
331 | __export(require("./Decorators"));
|
332 | __export(require("./Properties"));
|
333 |
|
334 |
|
335 | },{"./Component":1,"./ComponentStore":2,"./Decorators":3,"./Properties":4,"./UUID":5}],7:[function(require,module,exports){
|
336 | (function (process,__filename){
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | 'use strict';
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 | function amdefine(module, requireFn) {
|
358 | 'use strict';
|
359 | var defineCache = {},
|
360 | loaderCache = {},
|
361 | alreadyCalled = false,
|
362 | path = require('path'),
|
363 | makeRequire, stringRequire;
|
364 |
|
365 | |
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 | function trimDots(ary) {
|
375 | var i, part;
|
376 | for (i = 0; ary[i]; i+= 1) {
|
377 | part = ary[i];
|
378 | if (part === '.') {
|
379 | ary.splice(i, 1);
|
380 | i -= 1;
|
381 | } else if (part === '..') {
|
382 | if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 | break;
|
390 | } else if (i > 0) {
|
391 | ary.splice(i - 1, 2);
|
392 | i -= 2;
|
393 | }
|
394 | }
|
395 | }
|
396 | }
|
397 |
|
398 | function normalize(name, baseName) {
|
399 | var baseParts;
|
400 |
|
401 |
|
402 | if (name && name.charAt(0) === '.') {
|
403 |
|
404 |
|
405 |
|
406 | if (baseName) {
|
407 | baseParts = baseName.split('/');
|
408 | baseParts = baseParts.slice(0, baseParts.length - 1);
|
409 | baseParts = baseParts.concat(name.split('/'));
|
410 | trimDots(baseParts);
|
411 | name = baseParts.join('/');
|
412 | }
|
413 | }
|
414 |
|
415 | return name;
|
416 | }
|
417 |
|
418 | |
419 |
|
420 |
|
421 |
|
422 | function makeNormalize(relName) {
|
423 | return function (name) {
|
424 | return normalize(name, relName);
|
425 | };
|
426 | }
|
427 |
|
428 | function makeLoad(id) {
|
429 | function load(value) {
|
430 | loaderCache[id] = value;
|
431 | }
|
432 |
|
433 | load.fromText = function (id, text) {
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 | throw new Error('amdefine does not implement load.fromText');
|
440 | };
|
441 |
|
442 | return load;
|
443 | }
|
444 |
|
445 | makeRequire = function (systemRequire, exports, module, relId) {
|
446 | function amdRequire(deps, callback) {
|
447 | if (typeof deps === 'string') {
|
448 |
|
449 | return stringRequire(systemRequire, exports, module, deps, relId);
|
450 | } else {
|
451 |
|
452 |
|
453 |
|
454 | deps = deps.map(function (depName) {
|
455 | return stringRequire(systemRequire, exports, module, depName, relId);
|
456 | });
|
457 |
|
458 |
|
459 | if (callback) {
|
460 | process.nextTick(function () {
|
461 | callback.apply(null, deps);
|
462 | });
|
463 | }
|
464 | }
|
465 | }
|
466 |
|
467 | amdRequire.toUrl = function (filePath) {
|
468 | if (filePath.indexOf('.') === 0) {
|
469 | return normalize(filePath, path.dirname(module.filename));
|
470 | } else {
|
471 | return filePath;
|
472 | }
|
473 | };
|
474 |
|
475 | return amdRequire;
|
476 | };
|
477 |
|
478 |
|
479 | requireFn = requireFn || function req() {
|
480 | return module.require.apply(module, arguments);
|
481 | };
|
482 |
|
483 | function runFactory(id, deps, factory) {
|
484 | var r, e, m, result;
|
485 |
|
486 | if (id) {
|
487 | e = loaderCache[id] = {};
|
488 | m = {
|
489 | id: id,
|
490 | uri: __filename,
|
491 | exports: e
|
492 | };
|
493 | r = makeRequire(requireFn, e, m, id);
|
494 | } else {
|
495 |
|
496 | if (alreadyCalled) {
|
497 | throw new Error('amdefine with no module ID cannot be called more than once per file.');
|
498 | }
|
499 | alreadyCalled = true;
|
500 |
|
501 |
|
502 |
|
503 |
|
504 | e = module.exports;
|
505 | m = module;
|
506 | r = makeRequire(requireFn, e, m, module.id);
|
507 | }
|
508 |
|
509 |
|
510 |
|
511 | if (deps) {
|
512 | deps = deps.map(function (depName) {
|
513 | return r(depName);
|
514 | });
|
515 | }
|
516 |
|
517 |
|
518 | if (typeof factory === 'function') {
|
519 | result = factory.apply(m.exports, deps);
|
520 | } else {
|
521 | result = factory;
|
522 | }
|
523 |
|
524 | if (result !== undefined) {
|
525 | m.exports = result;
|
526 | if (id) {
|
527 | loaderCache[id] = m.exports;
|
528 | }
|
529 | }
|
530 | }
|
531 |
|
532 | stringRequire = function (systemRequire, exports, module, id, relId) {
|
533 |
|
534 | var index = id.indexOf('!'),
|
535 | originalId = id,
|
536 | prefix, plugin;
|
537 |
|
538 | if (index === -1) {
|
539 | id = normalize(id, relId);
|
540 |
|
541 |
|
542 |
|
543 | if (id === 'require') {
|
544 | return makeRequire(systemRequire, exports, module, relId);
|
545 | } else if (id === 'exports') {
|
546 | return exports;
|
547 | } else if (id === 'module') {
|
548 | return module;
|
549 | } else if (loaderCache.hasOwnProperty(id)) {
|
550 | return loaderCache[id];
|
551 | } else if (defineCache[id]) {
|
552 | runFactory.apply(null, defineCache[id]);
|
553 | return loaderCache[id];
|
554 | } else {
|
555 | if(systemRequire) {
|
556 | return systemRequire(originalId);
|
557 | } else {
|
558 | throw new Error('No module with ID: ' + id);
|
559 | }
|
560 | }
|
561 | } else {
|
562 |
|
563 | prefix = id.substring(0, index);
|
564 | id = id.substring(index + 1, id.length);
|
565 |
|
566 | plugin = stringRequire(systemRequire, exports, module, prefix, relId);
|
567 |
|
568 | if (plugin.normalize) {
|
569 | id = plugin.normalize(id, makeNormalize(relId));
|
570 | } else {
|
571 |
|
572 | id = normalize(id, relId);
|
573 | }
|
574 |
|
575 | if (loaderCache[id]) {
|
576 | return loaderCache[id];
|
577 | } else {
|
578 | plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
|
579 |
|
580 | return loaderCache[id];
|
581 | }
|
582 | }
|
583 | };
|
584 |
|
585 |
|
586 | function define(id, deps, factory) {
|
587 | if (Array.isArray(id)) {
|
588 | factory = deps;
|
589 | deps = id;
|
590 | id = undefined;
|
591 | } else if (typeof id !== 'string') {
|
592 | factory = id;
|
593 | id = deps = undefined;
|
594 | }
|
595 |
|
596 | if (deps && !Array.isArray(deps)) {
|
597 | factory = deps;
|
598 | deps = undefined;
|
599 | }
|
600 |
|
601 | if (!deps) {
|
602 | deps = ['require', 'exports', 'module'];
|
603 | }
|
604 |
|
605 |
|
606 |
|
607 |
|
608 | if (id) {
|
609 |
|
610 |
|
611 | defineCache[id] = [id, deps, factory];
|
612 | } else {
|
613 | runFactory(id, deps, factory);
|
614 | }
|
615 | }
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 | define.require = function (id) {
|
622 | if (loaderCache[id]) {
|
623 | return loaderCache[id];
|
624 | }
|
625 |
|
626 | if (defineCache[id]) {
|
627 | runFactory.apply(null, defineCache[id]);
|
628 | return loaderCache[id];
|
629 | }
|
630 | };
|
631 |
|
632 | define.amd = {};
|
633 |
|
634 | return define;
|
635 | }
|
636 |
|
637 | module.exports = amdefine;
|
638 |
|
639 | }).call(this,require('_process'),"/node_modules/amdefine/amdefine.js")
|
640 |
|
641 | },{"_process":67,"path":66}],8:[function(require,module,exports){
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 | function exclude() {
|
656 | var excludes = [].slice.call(arguments);
|
657 | function excludeProps(res, obj) {
|
658 | Object.keys(obj).forEach(function (key) {
|
659 | if (!~excludes.indexOf(key))
|
660 | res[key] = obj[key];
|
661 | });
|
662 | }
|
663 | return function extendExclude() {
|
664 | var args = [].slice.call(arguments), i = 0, res = {};
|
665 | for (; i < args.length; i++) {
|
666 | excludeProps(res, args[i]);
|
667 | }
|
668 | return res;
|
669 | };
|
670 | }
|
671 | ;
|
672 |
|
673 |
|
674 |
|
675 | module.exports = AssertionError;
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 | function AssertionError(message, _props, ssf) {
|
687 | var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON'), props = extend(_props || {});
|
688 |
|
689 | this.message = message || 'Unspecified AssertionError';
|
690 | this.showDiff = false;
|
691 |
|
692 | for (var key in props) {
|
693 | this[key] = props[key];
|
694 | }
|
695 |
|
696 | ssf = ssf || arguments.callee;
|
697 | if (ssf && Error.captureStackTrace) {
|
698 | Error.captureStackTrace(this, ssf);
|
699 | }
|
700 | else {
|
701 | this.stack = new Error().stack;
|
702 | }
|
703 | }
|
704 |
|
705 |
|
706 |
|
707 | AssertionError.prototype = Object.create(Error.prototype);
|
708 |
|
709 |
|
710 |
|
711 | AssertionError.prototype.name = 'AssertionError';
|
712 |
|
713 |
|
714 |
|
715 | AssertionError.prototype.constructor = AssertionError;
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 |
|
722 | AssertionError.prototype.toJSON = function (stack) {
|
723 | var extend = exclude('constructor', 'toJSON', 'stack'), props = extend({ name: this.name }, this);
|
724 |
|
725 | if (false !== stack && this.stack) {
|
726 | props.stack = this.stack;
|
727 | }
|
728 | return props;
|
729 | };
|
730 |
|
731 | },{}],9:[function(require,module,exports){
|
732 | module.exports = require('./lib/chai');
|
733 |
|
734 | },{"./lib/chai":10}],10:[function(require,module,exports){
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 | var used = [], exports = module.exports = {};
|
741 |
|
742 |
|
743 |
|
744 | exports.version = '3.5.0';
|
745 |
|
746 |
|
747 |
|
748 | exports.AssertionError = require('assertion-error');
|
749 |
|
750 |
|
751 |
|
752 | var util = require('./chai/utils');
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 | exports.use = function (fn) {
|
763 | if (!~used.indexOf(fn)) {
|
764 | fn(this, util);
|
765 | used.push(fn);
|
766 | }
|
767 | return this;
|
768 | };
|
769 |
|
770 |
|
771 |
|
772 | exports.util = util;
|
773 |
|
774 |
|
775 |
|
776 | var config = require('./chai/config');
|
777 | exports.config = config;
|
778 |
|
779 |
|
780 |
|
781 | var assertion = require('./chai/assertion');
|
782 | exports.use(assertion);
|
783 |
|
784 |
|
785 |
|
786 | var core = require('./chai/core/assertions');
|
787 | exports.use(core);
|
788 |
|
789 |
|
790 |
|
791 | var expect = require('./chai/interface/expect');
|
792 | exports.use(expect);
|
793 |
|
794 |
|
795 |
|
796 | var should = require('./chai/interface/should');
|
797 | exports.use(should);
|
798 |
|
799 |
|
800 |
|
801 | var assert = require('./chai/interface/assert');
|
802 | exports.use(assert);
|
803 |
|
804 | },{"./chai/assertion":11,"./chai/config":12,"./chai/core/assertions":13,"./chai/interface/assert":14,"./chai/interface/expect":15,"./chai/interface/should":16,"./chai/utils":30,"assertion-error":8}],11:[function(require,module,exports){
|
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 | var config = require('./config');
|
812 | module.exports = function (_chai, util) {
|
813 | |
814 |
|
815 |
|
816 | var AssertionError = _chai.AssertionError, flag = util.flag;
|
817 | |
818 |
|
819 |
|
820 | _chai.Assertion = Assertion;
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 | function Assertion(obj, msg, stack) {
|
829 | flag(this, 'ssfi', stack || arguments.callee);
|
830 | flag(this, 'object', obj);
|
831 | flag(this, 'message', msg);
|
832 | }
|
833 | Object.defineProperty(Assertion, 'includeStack', {
|
834 | get: function () {
|
835 | console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
836 | return config.includeStack;
|
837 | },
|
838 | set: function (value) {
|
839 | console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
840 | config.includeStack = value;
|
841 | }
|
842 | });
|
843 | Object.defineProperty(Assertion, 'showDiff', {
|
844 | get: function () {
|
845 | console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
846 | return config.showDiff;
|
847 | },
|
848 | set: function (value) {
|
849 | console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
850 | config.showDiff = value;
|
851 | }
|
852 | });
|
853 | Assertion.addProperty = function (name, fn) {
|
854 | util.addProperty(this.prototype, name, fn);
|
855 | };
|
856 | Assertion.addMethod = function (name, fn) {
|
857 | util.addMethod(this.prototype, name, fn);
|
858 | };
|
859 | Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
|
860 | util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
861 | };
|
862 | Assertion.overwriteProperty = function (name, fn) {
|
863 | util.overwriteProperty(this.prototype, name, fn);
|
864 | };
|
865 | Assertion.overwriteMethod = function (name, fn) {
|
866 | util.overwriteMethod(this.prototype, name, fn);
|
867 | };
|
868 | Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
|
869 | util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
870 | };
|
871 | |
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 | Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
|
886 | var ok = util.test(this, arguments);
|
887 | if (true !== showDiff)
|
888 | showDiff = false;
|
889 | if (true !== config.showDiff)
|
890 | showDiff = false;
|
891 | if (!ok) {
|
892 | var msg = util.getMessage(this, arguments), actual = util.getActual(this, arguments);
|
893 | throw new AssertionError(msg, {
|
894 | actual: actual,
|
895 | expected: expected,
|
896 | showDiff: showDiff
|
897 | }, (config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
898 | }
|
899 | };
|
900 | |
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 | Object.defineProperty(Assertion.prototype, '_obj', { get: function () {
|
908 | return flag(this, 'object');
|
909 | },
|
910 | set: function (val) {
|
911 | flag(this, 'object', val);
|
912 | }
|
913 | });
|
914 | };
|
915 |
|
916 | },{"./config":12}],12:[function(require,module,exports){
|
917 | module.exports = {
|
918 | |
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 | includeStack: false,
|
931 | |
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 | showDiff: true,
|
944 | |
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 | truncateThreshold: 40
|
964 | };
|
965 |
|
966 | },{}],13:[function(require,module,exports){
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | module.exports = function (chai, _) {
|
974 | var Assertion = chai.Assertion, toString = Object.prototype.toString, flag = _.flag;
|
975 | |
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 | ['to', 'be', 'been',
|
1004 | 'is', 'and', 'has', 'have',
|
1005 | 'with', 'that', 'which', 'at',
|
1006 | 'of', 'same'].forEach(function (chain) {
|
1007 | Assertion.addProperty(chain, function () {
|
1008 | return this;
|
1009 | });
|
1010 | });
|
1011 | |
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 | Assertion.addProperty('not', function () {
|
1026 | flag(this, 'negate', true);
|
1027 | });
|
1028 | |
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 | Assertion.addProperty('deep', function () {
|
1049 | flag(this, 'deep', true);
|
1050 | });
|
1051 | |
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 | Assertion.addProperty('any', function () {
|
1064 | flag(this, 'any', true);
|
1065 | flag(this, 'all', false);
|
1066 | });
|
1067 | |
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 | Assertion.addProperty('all', function () {
|
1080 | flag(this, 'all', true);
|
1081 | flag(this, 'any', false);
|
1082 | });
|
1083 | |
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 | function an(type, msg) {
|
1114 | if (msg)
|
1115 | flag(this, 'message', msg);
|
1116 | type = type.toLowerCase();
|
1117 | var obj = flag(this, 'object'), article = ~['a', 'e', 'i', 'o', 'u'].indexOf(type.charAt(0)) ? 'an ' : 'a ';
|
1118 | this.assert(type === _.type(obj), 'expected #{this} to be ' + article + type, 'expected #{this} not to be ' + article + type);
|
1119 | }
|
1120 | Assertion.addChainableMethod('an', an);
|
1121 | Assertion.addChainableMethod('a', an);
|
1122 | |
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 | function includeChainingBehavior() {
|
1144 | flag(this, 'contains', true);
|
1145 | }
|
1146 | function include(val, msg) {
|
1147 | _.expectTypes(this, ['array', 'object', 'string']);
|
1148 | if (msg)
|
1149 | flag(this, 'message', msg);
|
1150 | var obj = flag(this, 'object');
|
1151 | var expected = false;
|
1152 | if (_.type(obj) === 'array' && _.type(val) === 'object') {
|
1153 | for (var i in obj) {
|
1154 | if (_.eql(obj[i], val)) {
|
1155 | expected = true;
|
1156 | break;
|
1157 | }
|
1158 | }
|
1159 | }
|
1160 | else if (_.type(val) === 'object') {
|
1161 | if (!flag(this, 'negate')) {
|
1162 | for (var k in val)
|
1163 | new Assertion(obj).property(k, val[k]);
|
1164 | return;
|
1165 | }
|
1166 | var subset = {};
|
1167 | for (var k in val)
|
1168 | subset[k] = obj[k];
|
1169 | expected = _.eql(subset, val);
|
1170 | }
|
1171 | else {
|
1172 | expected = (obj != undefined) && ~obj.indexOf(val);
|
1173 | }
|
1174 | this.assert(expected, 'expected #{this} to include ' + _.inspect(val), 'expected #{this} to not include ' + _.inspect(val));
|
1175 | }
|
1176 | Assertion.addChainableMethod('include', include, includeChainingBehavior);
|
1177 | Assertion.addChainableMethod('contain', include, includeChainingBehavior);
|
1178 | Assertion.addChainableMethod('contains', include, includeChainingBehavior);
|
1179 | Assertion.addChainableMethod('includes', include, includeChainingBehavior);
|
1180 | |
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 | Assertion.addProperty('ok', function () {
|
1196 | this.assert(flag(this, 'object'), 'expected #{this} to be truthy', 'expected #{this} to be falsy');
|
1197 | });
|
1198 | |
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 | Assertion.addProperty('true', function () {
|
1211 | this.assert(true === flag(this, 'object'), 'expected #{this} to be true', 'expected #{this} to be false', this.negate ? false : true);
|
1212 | });
|
1213 | |
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 | Assertion.addProperty('false', function () {
|
1226 | this.assert(false === flag(this, 'object'), 'expected #{this} to be false', 'expected #{this} to be true', this.negate ? true : false);
|
1227 | });
|
1228 | |
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 | Assertion.addProperty('null', function () {
|
1241 | this.assert(null === flag(this, 'object'), 'expected #{this} to be null', 'expected #{this} not to be null');
|
1242 | });
|
1243 | |
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | Assertion.addProperty('undefined', function () {
|
1256 | this.assert(undefined === flag(this, 'object'), 'expected #{this} to be undefined', 'expected #{this} not to be undefined');
|
1257 | });
|
1258 | |
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 | Assertion.addProperty('NaN', function () {
|
1270 | this.assert(isNaN(flag(this, 'object')), 'expected #{this} to be NaN', 'expected #{this} not to be NaN');
|
1271 | });
|
1272 | |
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 | Assertion.addProperty('exist', function () {
|
1290 | this.assert(null != flag(this, 'object'), 'expected #{this} to exist', 'expected #{this} to not exist');
|
1291 | });
|
1292 | |
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 | Assertion.addProperty('empty', function () {
|
1308 | var obj = flag(this, 'object'), expected = obj;
|
1309 | if (Array.isArray(obj) || 'string' === typeof object) {
|
1310 | expected = obj.length;
|
1311 | }
|
1312 | else if (typeof obj === 'object') {
|
1313 | expected = Object.keys(obj).length;
|
1314 | }
|
1315 | this.assert(!expected, 'expected #{this} to be empty', 'expected #{this} not to be empty');
|
1316 | });
|
1317 | |
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 | function checkArguments() {
|
1332 | var obj = flag(this, 'object'), type = Object.prototype.toString.call(obj);
|
1333 | this.assert('[object Arguments]' === type, 'expected #{this} to be arguments but got ' + type, 'expected #{this} to not be arguments');
|
1334 | }
|
1335 | Assertion.addProperty('arguments', checkArguments);
|
1336 | Assertion.addProperty('Arguments', checkArguments);
|
1337 | |
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 | function assertEqual(val, msg) {
|
1360 | if (msg)
|
1361 | flag(this, 'message', msg);
|
1362 | var obj = flag(this, 'object');
|
1363 | if (flag(this, 'deep')) {
|
1364 | return this.eql(val);
|
1365 | }
|
1366 | else {
|
1367 | this.assert(val === obj, 'expected #{this} to equal #{exp}', 'expected #{this} to not equal #{exp}', val, this._obj, true);
|
1368 | }
|
1369 | }
|
1370 | Assertion.addMethod('equal', assertEqual);
|
1371 | Assertion.addMethod('equals', assertEqual);
|
1372 | Assertion.addMethod('eq', assertEqual);
|
1373 | |
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 | function assertEql(obj, msg) {
|
1389 | if (msg)
|
1390 | flag(this, 'message', msg);
|
1391 | this.assert(_.eql(obj, flag(this, 'object')), 'expected #{this} to deeply equal #{exp}', 'expected #{this} to not deeply equal #{exp}', obj, this._obj, true);
|
1392 | }
|
1393 | Assertion.addMethod('eql', assertEql);
|
1394 | Assertion.addMethod('eqls', assertEql);
|
1395 | |
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 | function assertAbove(n, msg) {
|
1419 | if (msg)
|
1420 | flag(this, 'message', msg);
|
1421 | var obj = flag(this, 'object');
|
1422 | if (flag(this, 'doLength')) {
|
1423 | new Assertion(obj, msg).to.have.property('length');
|
1424 | var len = obj.length;
|
1425 | this.assert(len > n, 'expected #{this} to have a length above #{exp} but got #{act}', 'expected #{this} to not have a length above #{exp}', n, len);
|
1426 | }
|
1427 | else {
|
1428 | this.assert(obj > n, 'expected #{this} to be above ' + n, 'expected #{this} to be at most ' + n);
|
1429 | }
|
1430 | }
|
1431 | Assertion.addMethod('above', assertAbove);
|
1432 | Assertion.addMethod('gt', assertAbove);
|
1433 | Assertion.addMethod('greaterThan', assertAbove);
|
1434 | |
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 | function assertLeast(n, msg) {
|
1457 | if (msg)
|
1458 | flag(this, 'message', msg);
|
1459 | var obj = flag(this, 'object');
|
1460 | if (flag(this, 'doLength')) {
|
1461 | new Assertion(obj, msg).to.have.property('length');
|
1462 | var len = obj.length;
|
1463 | this.assert(len >= n, 'expected #{this} to have a length at least #{exp} but got #{act}', 'expected #{this} to have a length below #{exp}', n, len);
|
1464 | }
|
1465 | else {
|
1466 | this.assert(obj >= n, 'expected #{this} to be at least ' + n, 'expected #{this} to be below ' + n);
|
1467 | }
|
1468 | }
|
1469 | Assertion.addMethod('least', assertLeast);
|
1470 | Assertion.addMethod('gte', assertLeast);
|
1471 | |
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 | function assertBelow(n, msg) {
|
1495 | if (msg)
|
1496 | flag(this, 'message', msg);
|
1497 | var obj = flag(this, 'object');
|
1498 | if (flag(this, 'doLength')) {
|
1499 | new Assertion(obj, msg).to.have.property('length');
|
1500 | var len = obj.length;
|
1501 | this.assert(len < n, 'expected #{this} to have a length below #{exp} but got #{act}', 'expected #{this} to not have a length below #{exp}', n, len);
|
1502 | }
|
1503 | else {
|
1504 | this.assert(obj < n, 'expected #{this} to be below ' + n, 'expected #{this} to be at least ' + n);
|
1505 | }
|
1506 | }
|
1507 | Assertion.addMethod('below', assertBelow);
|
1508 | Assertion.addMethod('lt', assertBelow);
|
1509 | Assertion.addMethod('lessThan', assertBelow);
|
1510 | |
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 | function assertMost(n, msg) {
|
1533 | if (msg)
|
1534 | flag(this, 'message', msg);
|
1535 | var obj = flag(this, 'object');
|
1536 | if (flag(this, 'doLength')) {
|
1537 | new Assertion(obj, msg).to.have.property('length');
|
1538 | var len = obj.length;
|
1539 | this.assert(len <= n, 'expected #{this} to have a length at most #{exp} but got #{act}', 'expected #{this} to have a length above #{exp}', n, len);
|
1540 | }
|
1541 | else {
|
1542 | this.assert(obj <= n, 'expected #{this} to be at most ' + n, 'expected #{this} to be above ' + n);
|
1543 | }
|
1544 | }
|
1545 | Assertion.addMethod('most', assertMost);
|
1546 | Assertion.addMethod('lte', assertMost);
|
1547 | |
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 | Assertion.addMethod('within', function (start, finish, msg) {
|
1570 | if (msg)
|
1571 | flag(this, 'message', msg);
|
1572 | var obj = flag(this, 'object'), range = start + '..' + finish;
|
1573 | if (flag(this, 'doLength')) {
|
1574 | new Assertion(obj, msg).to.have.property('length');
|
1575 | var len = obj.length;
|
1576 | this.assert(len >= start && len <= finish, 'expected #{this} to have a length within ' + range, 'expected #{this} to not have a length within ' + range);
|
1577 | }
|
1578 | else {
|
1579 | this.assert(obj >= start && obj <= finish, 'expected #{this} to be within ' + range, 'expected #{this} to not be within ' + range);
|
1580 | }
|
1581 | });
|
1582 | |
1583 |
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 | function assertInstanceOf(constructor, msg) {
|
1601 | if (msg)
|
1602 | flag(this, 'message', msg);
|
1603 | var name = _.getName(constructor);
|
1604 | this.assert(flag(this, 'object') instanceof constructor, 'expected #{this} to be an instance of ' + name, 'expected #{this} to not be an instance of ' + name);
|
1605 | }
|
1606 | ;
|
1607 | Assertion.addMethod('instanceof', assertInstanceOf);
|
1608 | Assertion.addMethod('instanceOf', assertInstanceOf);
|
1609 | |
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 | Assertion.addMethod('property', function (name, val, msg) {
|
1681 | if (msg)
|
1682 | flag(this, 'message', msg);
|
1683 | var isDeep = !!flag(this, 'deep'), descriptor = isDeep ? 'deep property ' : 'property ', negate = flag(this, 'negate'), obj = flag(this, 'object'), pathInfo = isDeep ? _.getPathInfo(name, obj) : null, hasProperty = isDeep
|
1684 | ? pathInfo.exists
|
1685 | : _.hasProperty(name, obj), value = isDeep
|
1686 | ? pathInfo.value
|
1687 | : obj[name];
|
1688 | if (negate && arguments.length > 1) {
|
1689 | if (undefined === value) {
|
1690 | msg = (msg != null) ? msg + ': ' : '';
|
1691 | throw new Error(msg + _.inspect(obj) + ' has no ' + descriptor + _.inspect(name));
|
1692 | }
|
1693 | }
|
1694 | else {
|
1695 | this.assert(hasProperty, 'expected #{this} to have a ' + descriptor + _.inspect(name), 'expected #{this} to not have ' + descriptor + _.inspect(name));
|
1696 | }
|
1697 | if (arguments.length > 1) {
|
1698 | this.assert(val === value, 'expected #{this} to have a ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}', 'expected #{this} to not have a ' + descriptor + _.inspect(name) + ' of #{act}', val, value);
|
1699 | }
|
1700 | flag(this, 'object', value);
|
1701 | });
|
1702 | |
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 | function assertOwnProperty(name, msg) {
|
1717 | if (msg)
|
1718 | flag(this, 'message', msg);
|
1719 | var obj = flag(this, 'object');
|
1720 | this.assert(obj.hasOwnProperty(name), 'expected #{this} to have own property ' + _.inspect(name), 'expected #{this} to not have own property ' + _.inspect(name));
|
1721 | }
|
1722 | Assertion.addMethod('ownProperty', assertOwnProperty);
|
1723 | Assertion.addMethod('haveOwnProperty', assertOwnProperty);
|
1724 | |
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 | function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
1744 | if (typeof descriptor === 'string') {
|
1745 | msg = descriptor;
|
1746 | descriptor = null;
|
1747 | }
|
1748 | if (msg)
|
1749 | flag(this, 'message', msg);
|
1750 | var obj = flag(this, 'object');
|
1751 | var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
1752 | if (actualDescriptor && descriptor) {
|
1753 | this.assert(_.eql(descriptor, actualDescriptor), 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor), 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor), descriptor, actualDescriptor, true);
|
1754 | }
|
1755 | else {
|
1756 | this.assert(actualDescriptor, 'expected #{this} to have an own property descriptor for ' + _.inspect(name), 'expected #{this} to not have an own property descriptor for ' + _.inspect(name));
|
1757 | }
|
1758 | flag(this, 'object', actualDescriptor);
|
1759 | }
|
1760 | Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
|
1761 | Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);
|
1762 | |
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 | |
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 | function assertLengthChain() {
|
1800 | flag(this, 'doLength', true);
|
1801 | }
|
1802 | function assertLength(n, msg) {
|
1803 | if (msg)
|
1804 | flag(this, 'message', msg);
|
1805 | var obj = flag(this, 'object');
|
1806 | new Assertion(obj, msg).to.have.property('length');
|
1807 | var len = obj.length;
|
1808 | this.assert(len == n, 'expected #{this} to have a length of #{exp} but got #{act}', 'expected #{this} to not have a length of #{act}', n, len);
|
1809 | }
|
1810 | Assertion.addChainableMethod('length', assertLength, assertLengthChain);
|
1811 | Assertion.addMethod('lengthOf', assertLength);
|
1812 | |
1813 |
|
1814 |
|
1815 |
|
1816 |
|
1817 |
|
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 | function assertMatch(re, msg) {
|
1827 | if (msg)
|
1828 | flag(this, 'message', msg);
|
1829 | var obj = flag(this, 'object');
|
1830 | this.assert(re.exec(obj), 'expected #{this} to match ' + re, 'expected #{this} not to match ' + re);
|
1831 | }
|
1832 | Assertion.addMethod('match', assertMatch);
|
1833 | Assertion.addMethod('matches', assertMatch);
|
1834 | |
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 |
|
1847 | Assertion.addMethod('string', function (str, msg) {
|
1848 | if (msg)
|
1849 | flag(this, 'message', msg);
|
1850 | var obj = flag(this, 'object');
|
1851 | new Assertion(obj, msg).is.a('string');
|
1852 | this.assert(~obj.indexOf(str), 'expected #{this} to contain ' + _.inspect(str), 'expected #{this} to not contain ' + _.inspect(str));
|
1853 | });
|
1854 | |
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 | function assertKeys(keys) {
|
1893 | var obj = flag(this, 'object'), str, ok = true, mixedArgsMsg = 'keys must be given single argument of Array|Object|String, or multiple String arguments';
|
1894 | switch (_.type(keys)) {
|
1895 | case "array":
|
1896 | if (arguments.length > 1)
|
1897 | throw (new Error(mixedArgsMsg));
|
1898 | break;
|
1899 | case "object":
|
1900 | if (arguments.length > 1)
|
1901 | throw (new Error(mixedArgsMsg));
|
1902 | keys = Object.keys(keys);
|
1903 | break;
|
1904 | default:
|
1905 | keys = Array.prototype.slice.call(arguments);
|
1906 | }
|
1907 | if (!keys.length)
|
1908 | throw new Error('keys required');
|
1909 | var actual = Object.keys(obj), expected = keys, len = keys.length, any = flag(this, 'any'), all = flag(this, 'all');
|
1910 | if (!any && !all) {
|
1911 | all = true;
|
1912 | }
|
1913 |
|
1914 | if (any) {
|
1915 | var intersection = expected.filter(function (key) {
|
1916 | return ~actual.indexOf(key);
|
1917 | });
|
1918 | ok = intersection.length > 0;
|
1919 | }
|
1920 |
|
1921 | if (all) {
|
1922 | ok = keys.every(function (key) {
|
1923 | return ~actual.indexOf(key);
|
1924 | });
|
1925 | if (!flag(this, 'negate') && !flag(this, 'contains')) {
|
1926 | ok = ok && keys.length == actual.length;
|
1927 | }
|
1928 | }
|
1929 |
|
1930 | if (len > 1) {
|
1931 | keys = keys.map(function (key) {
|
1932 | return _.inspect(key);
|
1933 | });
|
1934 | var last = keys.pop();
|
1935 | if (all) {
|
1936 | str = keys.join(', ') + ', and ' + last;
|
1937 | }
|
1938 | if (any) {
|
1939 | str = keys.join(', ') + ', or ' + last;
|
1940 | }
|
1941 | }
|
1942 | else {
|
1943 | str = _.inspect(keys[0]);
|
1944 | }
|
1945 |
|
1946 | str = (len > 1 ? 'keys ' : 'key ') + str;
|
1947 |
|
1948 | str = (flag(this, 'contains') ? 'contain ' : 'have ') + str;
|
1949 |
|
1950 | this.assert(ok, 'expected #{this} to ' + str, 'expected #{this} to not ' + str, expected.slice(0).sort(), actual.sort(), true);
|
1951 | }
|
1952 | Assertion.addMethod('keys', assertKeys);
|
1953 | Assertion.addMethod('key', assertKeys);
|
1954 | |
1955 |
|
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 |
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 |
|
1980 |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 | function assertThrows(constructor, errMsg, msg) {
|
1990 | if (msg)
|
1991 | flag(this, 'message', msg);
|
1992 | var obj = flag(this, 'object');
|
1993 | new Assertion(obj, msg).is.a('function');
|
1994 | var thrown = false, desiredError = null, name = null, thrownError = null;
|
1995 | if (arguments.length === 0) {
|
1996 | errMsg = null;
|
1997 | constructor = null;
|
1998 | }
|
1999 | else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
|
2000 | errMsg = constructor;
|
2001 | constructor = null;
|
2002 | }
|
2003 | else if (constructor && constructor instanceof Error) {
|
2004 | desiredError = constructor;
|
2005 | constructor = null;
|
2006 | errMsg = null;
|
2007 | }
|
2008 | else if (typeof constructor === 'function') {
|
2009 | name = constructor.prototype.name;
|
2010 | if (!name || (name === 'Error' && constructor !== Error)) {
|
2011 | name = constructor.name || (new constructor()).name;
|
2012 | }
|
2013 | }
|
2014 | else {
|
2015 | constructor = null;
|
2016 | }
|
2017 | try {
|
2018 | obj();
|
2019 | }
|
2020 | catch (err) {
|
2021 |
|
2022 | if (desiredError) {
|
2023 | this.assert(err === desiredError, 'expected #{this} to throw #{exp} but #{act} was thrown', 'expected #{this} to not throw #{exp}', (desiredError instanceof Error ? desiredError.toString() : desiredError), (err instanceof Error ? err.toString() : err));
|
2024 | flag(this, 'object', err);
|
2025 | return this;
|
2026 | }
|
2027 |
|
2028 | if (constructor) {
|
2029 | this.assert(err instanceof constructor, 'expected #{this} to throw #{exp} but #{act} was thrown', 'expected #{this} to not throw #{exp} but #{act} was thrown', name, (err instanceof Error ? err.toString() : err));
|
2030 | if (!errMsg) {
|
2031 | flag(this, 'object', err);
|
2032 | return this;
|
2033 | }
|
2034 | }
|
2035 |
|
2036 | var message = 'error' === _.type(err) && "message" in err
|
2037 | ? err.message
|
2038 | : '' + err;
|
2039 | if ((message != null) && errMsg && errMsg instanceof RegExp) {
|
2040 | this.assert(errMsg.exec(message), 'expected #{this} to throw error matching #{exp} but got #{act}', 'expected #{this} to throw error not matching #{exp}', errMsg, message);
|
2041 | flag(this, 'object', err);
|
2042 | return this;
|
2043 | }
|
2044 | else if ((message != null) && errMsg && 'string' === typeof errMsg) {
|
2045 | this.assert(~message.indexOf(errMsg), 'expected #{this} to throw error including #{exp} but got #{act}', 'expected #{this} to throw error not including #{act}', errMsg, message);
|
2046 | flag(this, 'object', err);
|
2047 | return this;
|
2048 | }
|
2049 | else {
|
2050 | thrown = true;
|
2051 | thrownError = err;
|
2052 | }
|
2053 | }
|
2054 | var actuallyGot = '', expectedThrown = name !== null
|
2055 | ? name
|
2056 | : desiredError
|
2057 | ? '#{exp}'
|
2058 | : 'an error';
|
2059 | if (thrown) {
|
2060 | actuallyGot = ' but #{act} was thrown';
|
2061 | }
|
2062 | this.assert(thrown === true, 'expected #{this} to throw ' + expectedThrown + actuallyGot, 'expected #{this} to not throw ' + expectedThrown + actuallyGot, (desiredError instanceof Error ? desiredError.toString() : desiredError), (thrownError instanceof Error ? thrownError.toString() : thrownError));
|
2063 | flag(this, 'object', thrownError);
|
2064 | }
|
2065 | ;
|
2066 | Assertion.addMethod('throw', assertThrows);
|
2067 | Assertion.addMethod('throws', assertThrows);
|
2068 | Assertion.addMethod('Throw', assertThrows);
|
2069 | |
2070 |
|
2071 |
|
2072 |
|
2073 |
|
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 | function respondTo(method, msg) {
|
2092 | if (msg)
|
2093 | flag(this, 'message', msg);
|
2094 | var obj = flag(this, 'object'), itself = flag(this, 'itself'), context = ('function' === _.type(obj) && !itself)
|
2095 | ? obj.prototype[method]
|
2096 | : obj[method];
|
2097 | this.assert('function' === typeof context, 'expected #{this} to respond to ' + _.inspect(method), 'expected #{this} to not respond to ' + _.inspect(method));
|
2098 | }
|
2099 | Assertion.addMethod('respondTo', respondTo);
|
2100 | Assertion.addMethod('respondsTo', respondTo);
|
2101 | |
2102 |
|
2103 |
|
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 | Assertion.addProperty('itself', function () {
|
2118 | flag(this, 'itself', true);
|
2119 | });
|
2120 | |
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 | function satisfy(matcher, msg) {
|
2135 | if (msg)
|
2136 | flag(this, 'message', msg);
|
2137 | var obj = flag(this, 'object');
|
2138 | var result = matcher(obj);
|
2139 | this.assert(result, 'expected #{this} to satisfy ' + _.objDisplay(matcher), 'expected #{this} to not satisfy' + _.objDisplay(matcher), this.negate ? false : true, result);
|
2140 | }
|
2141 | Assertion.addMethod('satisfy', satisfy);
|
2142 | Assertion.addMethod('satisfies', satisfy);
|
2143 | |
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 |
|
2157 |
|
2158 | function closeTo(expected, delta, msg) {
|
2159 | if (msg)
|
2160 | flag(this, 'message', msg);
|
2161 | var obj = flag(this, 'object');
|
2162 | new Assertion(obj, msg).is.a('number');
|
2163 | if (_.type(expected) !== 'number' || _.type(delta) !== 'number') {
|
2164 | throw new Error('the arguments to closeTo or approximately must be numbers');
|
2165 | }
|
2166 | this.assert(Math.abs(obj - expected) <= delta, 'expected #{this} to be close to ' + expected + ' +/- ' + delta, 'expected #{this} not to be close to ' + expected + ' +/- ' + delta);
|
2167 | }
|
2168 | Assertion.addMethod('closeTo', closeTo);
|
2169 | Assertion.addMethod('approximately', closeTo);
|
2170 | function isSubsetOf(subset, superset, cmp) {
|
2171 | return subset.every(function (elem) {
|
2172 | if (!cmp)
|
2173 | return superset.indexOf(elem) !== -1;
|
2174 | return superset.some(function (elem2) {
|
2175 | return cmp(elem, elem2);
|
2176 | });
|
2177 | });
|
2178 | }
|
2179 | |
2180 |
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 | Assertion.addMethod('members', function (subset, msg) {
|
2202 | if (msg)
|
2203 | flag(this, 'message', msg);
|
2204 | var obj = flag(this, 'object');
|
2205 | new Assertion(obj).to.be.an('array');
|
2206 | new Assertion(subset).to.be.an('array');
|
2207 | var cmp = flag(this, 'deep') ? _.eql : undefined;
|
2208 | if (flag(this, 'contains')) {
|
2209 | return this.assert(isSubsetOf(subset, obj, cmp), 'expected #{this} to be a superset of #{act}', 'expected #{this} to not be a superset of #{act}', obj, subset);
|
2210 | }
|
2211 | this.assert(isSubsetOf(obj, subset, cmp) && isSubsetOf(subset, obj, cmp), 'expected #{this} to have the same members as #{act}', 'expected #{this} to not have the same members as #{act}', obj, subset);
|
2212 | });
|
2213 | |
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 | function oneOf(list, msg) {
|
2235 | if (msg)
|
2236 | flag(this, 'message', msg);
|
2237 | var expected = flag(this, 'object');
|
2238 | new Assertion(list).to.be.an('array');
|
2239 | this.assert(list.indexOf(expected) > -1, 'expected #{this} to be one of #{exp}', 'expected #{this} to not be one of #{exp}', list, expected);
|
2240 | }
|
2241 | Assertion.addMethod('oneOf', oneOf);
|
2242 | |
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 |
|
2251 |
|
2252 |
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 | function assertChanges(object, prop, msg) {
|
2263 | if (msg)
|
2264 | flag(this, 'message', msg);
|
2265 | var fn = flag(this, 'object');
|
2266 | new Assertion(object, msg).to.have.property(prop);
|
2267 | new Assertion(fn).is.a('function');
|
2268 | var initial = object[prop];
|
2269 | fn();
|
2270 | this.assert(initial !== object[prop], 'expected .' + prop + ' to change', 'expected .' + prop + ' to not change');
|
2271 | }
|
2272 | Assertion.addChainableMethod('change', assertChanges);
|
2273 | Assertion.addChainableMethod('changes', assertChanges);
|
2274 | |
2275 |
|
2276 |
|
2277 |
|
2278 |
|
2279 |
|
2280 |
|
2281 |
|
2282 |
|
2283 |
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 |
|
2289 |
|
2290 |
|
2291 |
|
2292 | function assertIncreases(object, prop, msg) {
|
2293 | if (msg)
|
2294 | flag(this, 'message', msg);
|
2295 | var fn = flag(this, 'object');
|
2296 | new Assertion(object, msg).to.have.property(prop);
|
2297 | new Assertion(fn).is.a('function');
|
2298 | var initial = object[prop];
|
2299 | fn();
|
2300 | this.assert(object[prop] - initial > 0, 'expected .' + prop + ' to increase', 'expected .' + prop + ' to not increase');
|
2301 | }
|
2302 | Assertion.addChainableMethod('increase', assertIncreases);
|
2303 | Assertion.addChainableMethod('increases', assertIncreases);
|
2304 | |
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 |
|
2314 |
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 | function assertDecreases(object, prop, msg) {
|
2323 | if (msg)
|
2324 | flag(this, 'message', msg);
|
2325 | var fn = flag(this, 'object');
|
2326 | new Assertion(object, msg).to.have.property(prop);
|
2327 | new Assertion(fn).is.a('function');
|
2328 | var initial = object[prop];
|
2329 | fn();
|
2330 | this.assert(object[prop] - initial < 0, 'expected .' + prop + ' to decrease', 'expected .' + prop + ' to not decrease');
|
2331 | }
|
2332 | Assertion.addChainableMethod('decrease', assertDecreases);
|
2333 | Assertion.addChainableMethod('decreases', assertDecreases);
|
2334 | |
2335 |
|
2336 |
|
2337 |
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 | Assertion.addProperty('extensible', function () {
|
2354 | var obj = flag(this, 'object');
|
2355 |
|
2356 |
|
2357 |
|
2358 |
|
2359 | var isExtensible;
|
2360 | try {
|
2361 | isExtensible = Object.isExtensible(obj);
|
2362 | }
|
2363 | catch (err) {
|
2364 | if (err instanceof TypeError)
|
2365 | isExtensible = false;
|
2366 | else
|
2367 | throw err;
|
2368 | }
|
2369 | this.assert(isExtensible, 'expected #{this} to be extensible', 'expected #{this} to not be extensible');
|
2370 | });
|
2371 | |
2372 |
|
2373 |
|
2374 |
|
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 | Assertion.addProperty('sealed', function () {
|
2389 | var obj = flag(this, 'object');
|
2390 |
|
2391 |
|
2392 |
|
2393 |
|
2394 | var isSealed;
|
2395 | try {
|
2396 | isSealed = Object.isSealed(obj);
|
2397 | }
|
2398 | catch (err) {
|
2399 | if (err instanceof TypeError)
|
2400 | isSealed = true;
|
2401 | else
|
2402 | throw err;
|
2403 | }
|
2404 | this.assert(isSealed, 'expected #{this} to be sealed', 'expected #{this} to not be sealed');
|
2405 | });
|
2406 | |
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |
|
2415 |
|
2416 |
|
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 | Assertion.addProperty('frozen', function () {
|
2422 | var obj = flag(this, 'object');
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 | var isFrozen;
|
2428 | try {
|
2429 | isFrozen = Object.isFrozen(obj);
|
2430 | }
|
2431 | catch (err) {
|
2432 | if (err instanceof TypeError)
|
2433 | isFrozen = true;
|
2434 | else
|
2435 | throw err;
|
2436 | }
|
2437 | this.assert(isFrozen, 'expected #{this} to be frozen', 'expected #{this} to not be frozen');
|
2438 | });
|
2439 | };
|
2440 |
|
2441 | },{}],14:[function(require,module,exports){
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 | module.exports = function (chai, util) {
|
2448 | |
2449 |
|
2450 |
|
2451 | var Assertion = chai.Assertion, flag = util.flag;
|
2452 | |
2453 |
|
2454 |
|
2455 | |
2456 |
|
2457 |
|
2458 |
|
2459 |
|
2460 |
|
2461 |
|
2462 |
|
2463 |
|
2464 |
|
2465 |
|
2466 |
|
2467 |
|
2468 |
|
2469 | var assert = chai.assert = function (express, errmsg) {
|
2470 | var test = new Assertion(null, null, chai.assert);
|
2471 | test.assert(express, errmsg, '[ negation message unavailable ]');
|
2472 | };
|
2473 | |
2474 |
|
2475 |
|
2476 |
|
2477 |
|
2478 |
|
2479 |
|
2480 |
|
2481 |
|
2482 |
|
2483 |
|
2484 |
|
2485 |
|
2486 | assert.fail = function (actual, expected, message, operator) {
|
2487 | message = message || 'assert.fail()';
|
2488 | throw new chai.AssertionError(message, {
|
2489 | actual: actual,
|
2490 | expected: expected,
|
2491 | operator: operator
|
2492 | }, assert.fail);
|
2493 | };
|
2494 | |
2495 |
|
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 | assert.isOk = function (val, msg) {
|
2510 | new Assertion(val, msg).is.ok;
|
2511 | };
|
2512 | |
2513 |
|
2514 |
|
2515 |
|
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 |
|
2527 | assert.isNotOk = function (val, msg) {
|
2528 | new Assertion(val, msg).is.not.ok;
|
2529 | };
|
2530 | |
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 |
|
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 | assert.equal = function (act, exp, msg) {
|
2545 | var test = new Assertion(act, msg, assert.equal);
|
2546 | test.assert(exp == flag(test, 'object'), 'expected #{this} to equal #{exp}', 'expected #{this} to not equal #{act}', exp, act);
|
2547 | };
|
2548 | |
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 |
|
2556 |
|
2557 |
|
2558 |
|
2559 |
|
2560 |
|
2561 |
|
2562 | assert.notEqual = function (act, exp, msg) {
|
2563 | var test = new Assertion(act, msg, assert.notEqual);
|
2564 | test.assert(exp != flag(test, 'object'), 'expected #{this} to not equal #{exp}', 'expected #{this} to equal #{act}', exp, act);
|
2565 | };
|
2566 | |
2567 |
|
2568 |
|
2569 |
|
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 |
|
2579 |
|
2580 | assert.strictEqual = function (act, exp, msg) {
|
2581 | new Assertion(act, msg).to.equal(exp);
|
2582 | };
|
2583 | |
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 |
|
2591 |
|
2592 |
|
2593 |
|
2594 |
|
2595 |
|
2596 |
|
2597 | assert.notStrictEqual = function (act, exp, msg) {
|
2598 | new Assertion(act, msg).to.not.equal(exp);
|
2599 | };
|
2600 | |
2601 |
|
2602 |
|
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 |
|
2609 |
|
2610 |
|
2611 |
|
2612 |
|
2613 |
|
2614 | assert.deepEqual = function (act, exp, msg) {
|
2615 | new Assertion(act, msg).to.eql(exp);
|
2616 | };
|
2617 | |
2618 |
|
2619 |
|
2620 |
|
2621 |
|
2622 |
|
2623 |
|
2624 |
|
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 | assert.notDeepEqual = function (act, exp, msg) {
|
2632 | new Assertion(act, msg).to.not.eql(exp);
|
2633 | };
|
2634 | |
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 |
|
2646 |
|
2647 |
|
2648 | assert.isAbove = function (val, abv, msg) {
|
2649 | new Assertion(val, msg).to.be.above(abv);
|
2650 | };
|
2651 | |
2652 |
|
2653 |
|
2654 |
|
2655 |
|
2656 |
|
2657 |
|
2658 |
|
2659 |
|
2660 |
|
2661 |
|
2662 |
|
2663 |
|
2664 |
|
2665 |
|
2666 | assert.isAtLeast = function (val, atlst, msg) {
|
2667 | new Assertion(val, msg).to.be.least(atlst);
|
2668 | };
|
2669 | |
2670 |
|
2671 |
|
2672 |
|
2673 |
|
2674 |
|
2675 |
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 | assert.isBelow = function (val, blw, msg) {
|
2684 | new Assertion(val, msg).to.be.below(blw);
|
2685 | };
|
2686 | |
2687 |
|
2688 |
|
2689 |
|
2690 |
|
2691 |
|
2692 |
|
2693 |
|
2694 |
|
2695 |
|
2696 |
|
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 | assert.isAtMost = function (val, atmst, msg) {
|
2702 | new Assertion(val, msg).to.be.most(atmst);
|
2703 | };
|
2704 | |
2705 |
|
2706 |
|
2707 |
|
2708 |
|
2709 |
|
2710 |
|
2711 |
|
2712 |
|
2713 |
|
2714 |
|
2715 |
|
2716 |
|
2717 |
|
2718 | assert.isTrue = function (val, msg) {
|
2719 | new Assertion(val, msg).is['true'];
|
2720 | };
|
2721 | |
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 |
|
2729 |
|
2730 |
|
2731 |
|
2732 |
|
2733 |
|
2734 |
|
2735 | assert.isNotTrue = function (val, msg) {
|
2736 | new Assertion(val, msg).to.not.equal(true);
|
2737 | };
|
2738 | |
2739 |
|
2740 |
|
2741 |
|
2742 |
|
2743 |
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 | assert.isFalse = function (val, msg) {
|
2753 | new Assertion(val, msg).is['false'];
|
2754 | };
|
2755 | |
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 |
|
2764 |
|
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 | assert.isNotFalse = function (val, msg) {
|
2770 | new Assertion(val, msg).to.not.equal(false);
|
2771 | };
|
2772 | |
2773 |
|
2774 |
|
2775 |
|
2776 |
|
2777 |
|
2778 |
|
2779 |
|
2780 |
|
2781 |
|
2782 |
|
2783 |
|
2784 |
|
2785 | assert.isNull = function (val, msg) {
|
2786 | new Assertion(val, msg).to.equal(null);
|
2787 | };
|
2788 | |
2789 |
|
2790 |
|
2791 |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 | assert.isNotNull = function (val, msg) {
|
2803 | new Assertion(val, msg).to.not.equal(null);
|
2804 | };
|
2805 | |
2806 |
|
2807 |
|
2808 |
|
2809 |
|
2810 |
|
2811 |
|
2812 |
|
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 | assert.isNaN = function (val, msg) {
|
2818 | new Assertion(val, msg).to.be.NaN;
|
2819 | };
|
2820 | |
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 |
|
2832 | assert.isNotNaN = function (val, msg) {
|
2833 | new Assertion(val, msg).not.to.be.NaN;
|
2834 | };
|
2835 | |
2836 |
|
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 |
|
2845 |
|
2846 |
|
2847 |
|
2848 |
|
2849 | assert.isUndefined = function (val, msg) {
|
2850 | new Assertion(val, msg).to.equal(undefined);
|
2851 | };
|
2852 | |
2853 |
|
2854 |
|
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 | assert.isDefined = function (val, msg) {
|
2867 | new Assertion(val, msg).to.not.equal(undefined);
|
2868 | };
|
2869 | |
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 |
|
2883 | assert.isFunction = function (val, msg) {
|
2884 | new Assertion(val, msg).to.be.a('function');
|
2885 | };
|
2886 | |
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 |
|
2899 |
|
2900 | assert.isNotFunction = function (val, msg) {
|
2901 | new Assertion(val, msg).to.not.be.a('function');
|
2902 | };
|
2903 | |
2904 |
|
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 | assert.isObject = function (val, msg) {
|
2919 | new Assertion(val, msg).to.be.a('object');
|
2920 | };
|
2921 | |
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 |
|
2931 |
|
2932 |
|
2933 |
|
2934 |
|
2935 |
|
2936 | assert.isNotObject = function (val, msg) {
|
2937 | new Assertion(val, msg).to.not.be.a('object');
|
2938 | };
|
2939 | |
2940 |
|
2941 |
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 | assert.isArray = function (val, msg) {
|
2954 | new Assertion(val, msg).to.be.an('array');
|
2955 | };
|
2956 | |
2957 |
|
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 |
|
2967 |
|
2968 |
|
2969 |
|
2970 | assert.isNotArray = function (val, msg) {
|
2971 | new Assertion(val, msg).to.not.be.an('array');
|
2972 | };
|
2973 | |
2974 |
|
2975 |
|
2976 |
|
2977 |
|
2978 |
|
2979 |
|
2980 |
|
2981 |
|
2982 |
|
2983 |
|
2984 |
|
2985 |
|
2986 |
|
2987 | assert.isString = function (val, msg) {
|
2988 | new Assertion(val, msg).to.be.a('string');
|
2989 | };
|
2990 | |
2991 |
|
2992 |
|
2993 |
|
2994 |
|
2995 |
|
2996 |
|
2997 |
|
2998 |
|
2999 |
|
3000 |
|
3001 |
|
3002 |
|
3003 |
|
3004 | assert.isNotString = function (val, msg) {
|
3005 | new Assertion(val, msg).to.not.be.a('string');
|
3006 | };
|
3007 | |
3008 |
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 |
|
3016 |
|
3017 |
|
3018 |
|
3019 |
|
3020 |
|
3021 | assert.isNumber = function (val, msg) {
|
3022 | new Assertion(val, msg).to.be.a('number');
|
3023 | };
|
3024 | |
3025 |
|
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 |
|
3034 |
|
3035 |
|
3036 |
|
3037 |
|
3038 | assert.isNotNumber = function (val, msg) {
|
3039 | new Assertion(val, msg).to.not.be.a('number');
|
3040 | };
|
3041 | |
3042 |
|
3043 |
|
3044 |
|
3045 |
|
3046 |
|
3047 |
|
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 | assert.isBoolean = function (val, msg) {
|
3059 | new Assertion(val, msg).to.be.a('boolean');
|
3060 | };
|
3061 | |
3062 |
|
3063 |
|
3064 |
|
3065 |
|
3066 |
|
3067 |
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 | assert.isNotBoolean = function (val, msg) {
|
3079 | new Assertion(val, msg).to.not.be.a('boolean');
|
3080 | };
|
3081 | |
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 | assert.typeOf = function (val, type, msg) {
|
3102 | new Assertion(val, msg).to.be.a(type);
|
3103 | };
|
3104 | |
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 | assert.notTypeOf = function (val, type, msg) {
|
3120 | new Assertion(val, msg).to.not.be.a(type);
|
3121 | };
|
3122 | |
3123 |
|
3124 |
|
3125 |
|
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 |
|
3136 |
|
3137 |
|
3138 |
|
3139 | assert.instanceOf = function (val, type, msg) {
|
3140 | new Assertion(val, msg).to.be.instanceOf(type);
|
3141 | };
|
3142 | |
3143 |
|
3144 |
|
3145 |
|
3146 |
|
3147 |
|
3148 |
|
3149 |
|
3150 |
|
3151 |
|
3152 |
|
3153 |
|
3154 |
|
3155 |
|
3156 |
|
3157 |
|
3158 |
|
3159 | assert.notInstanceOf = function (val, type, msg) {
|
3160 | new Assertion(val, msg).to.not.be.instanceOf(type);
|
3161 | };
|
3162 | |
3163 |
|
3164 |
|
3165 |
|
3166 |
|
3167 |
|
3168 |
|
3169 |
|
3170 |
|
3171 |
|
3172 |
|
3173 |
|
3174 |
|
3175 |
|
3176 |
|
3177 |
|
3178 | assert.include = function (exp, inc, msg) {
|
3179 | new Assertion(exp, msg, assert.include).include(inc);
|
3180 | };
|
3181 | |
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
|
3191 |
|
3192 |
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 | assert.notInclude = function (exp, inc, msg) {
|
3198 | new Assertion(exp, msg, assert.notInclude).not.include(inc);
|
3199 | };
|
3200 | |
3201 |
|
3202 |
|
3203 |
|
3204 |
|
3205 |
|
3206 |
|
3207 |
|
3208 |
|
3209 |
|
3210 |
|
3211 |
|
3212 |
|
3213 |
|
3214 | assert.match = function (exp, re, msg) {
|
3215 | new Assertion(exp, msg).to.match(re);
|
3216 | };
|
3217 | |
3218 |
|
3219 |
|
3220 |
|
3221 |
|
3222 |
|
3223 |
|
3224 |
|
3225 |
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 |
|
3231 | assert.notMatch = function (exp, re, msg) {
|
3232 | new Assertion(exp, msg).to.not.match(re);
|
3233 | };
|
3234 | |
3235 |
|
3236 |
|
3237 |
|
3238 |
|
3239 |
|
3240 |
|
3241 |
|
3242 |
|
3243 |
|
3244 |
|
3245 |
|
3246 |
|
3247 |
|
3248 | assert.property = function (obj, prop, msg) {
|
3249 | new Assertion(obj, msg).to.have.property(prop);
|
3250 | };
|
3251 | |
3252 |
|
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 | assert.notProperty = function (obj, prop, msg) {
|
3266 | new Assertion(obj, msg).to.not.have.property(prop);
|
3267 | };
|
3268 | |
3269 |
|
3270 |
|
3271 |
|
3272 |
|
3273 |
|
3274 |
|
3275 |
|
3276 |
|
3277 |
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 | assert.deepProperty = function (obj, prop, msg) {
|
3284 | new Assertion(obj, msg).to.have.deep.property(prop);
|
3285 | };
|
3286 | |
3287 |
|
3288 |
|
3289 |
|
3290 |
|
3291 |
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 |
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 | assert.notDeepProperty = function (obj, prop, msg) {
|
3302 | new Assertion(obj, msg).to.not.have.deep.property(prop);
|
3303 | };
|
3304 | |
3305 |
|
3306 |
|
3307 |
|
3308 |
|
3309 |
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 |
|
3315 |
|
3316 |
|
3317 |
|
3318 |
|
3319 |
|
3320 | assert.propertyVal = function (obj, prop, val, msg) {
|
3321 | new Assertion(obj, msg).to.have.property(prop, val);
|
3322 | };
|
3323 | |
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 |
|
3332 |
|
3333 |
|
3334 |
|
3335 |
|
3336 |
|
3337 |
|
3338 |
|
3339 | assert.propertyNotVal = function (obj, prop, val, msg) {
|
3340 | new Assertion(obj, msg).to.not.have.property(prop, val);
|
3341 | };
|
3342 | |
3343 |
|
3344 |
|
3345 |
|
3346 |
|
3347 |
|
3348 |
|
3349 |
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 |
|
3359 | assert.deepPropertyVal = function (obj, prop, val, msg) {
|
3360 | new Assertion(obj, msg).to.have.deep.property(prop, val);
|
3361 | };
|
3362 | |
3363 |
|
3364 |
|
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 |
|
3375 |
|
3376 |
|
3377 |
|
3378 |
|
3379 | assert.deepPropertyNotVal = function (obj, prop, val, msg) {
|
3380 | new Assertion(obj, msg).to.not.have.deep.property(prop, val);
|
3381 | };
|
3382 | |
3383 |
|
3384 |
|
3385 |
|
3386 |
|
3387 |
|
3388 |
|
3389 |
|
3390 |
|
3391 |
|
3392 |
|
3393 |
|
3394 |
|
3395 |
|
3396 |
|
3397 | assert.lengthOf = function (exp, len, msg) {
|
3398 | new Assertion(exp, msg).to.have.length(len);
|
3399 | };
|
3400 | |
3401 |
|
3402 |
|
3403 |
|
3404 |
|
3405 |
|
3406 |
|
3407 |
|
3408 |
|
3409 |
|
3410 |
|
3411 |
|
3412 |
|
3413 |
|
3414 |
|
3415 |
|
3416 |
|
3417 |
|
3418 |
|
3419 |
|
3420 |
|
3421 |
|
3422 |
|
3423 |
|
3424 | assert.throws = function (fn, errt, errs, msg) {
|
3425 | if ('string' === typeof errt || errt instanceof RegExp) {
|
3426 | errs = errt;
|
3427 | errt = null;
|
3428 | }
|
3429 | var assertErr = new Assertion(fn, msg).to.throw(errt, errs);
|
3430 | return flag(assertErr, 'object');
|
3431 | };
|
3432 | |
3433 |
|
3434 |
|
3435 |
|
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 |
|
3443 |
|
3444 |
|
3445 |
|
3446 |
|
3447 |
|
3448 |
|
3449 |
|
3450 | assert.doesNotThrow = function (fn, type, msg) {
|
3451 | if ('string' === typeof type) {
|
3452 | msg = type;
|
3453 | type = null;
|
3454 | }
|
3455 | new Assertion(fn, msg).to.not.Throw(type);
|
3456 | };
|
3457 | |
3458 |
|
3459 |
|
3460 |
|
3461 |
|
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 |
|
3468 |
|
3469 |
|
3470 |
|
3471 |
|
3472 |
|
3473 | assert.operator = function (val, operator, val2, msg) {
|
3474 | var ok;
|
3475 | switch (operator) {
|
3476 | case '==':
|
3477 | ok = val == val2;
|
3478 | break;
|
3479 | case '===':
|
3480 | ok = val === val2;
|
3481 | break;
|
3482 | case '>':
|
3483 | ok = val > val2;
|
3484 | break;
|
3485 | case '>=':
|
3486 | ok = val >= val2;
|
3487 | break;
|
3488 | case '<':
|
3489 | ok = val < val2;
|
3490 | break;
|
3491 | case '<=':
|
3492 | ok = val <= val2;
|
3493 | break;
|
3494 | case '!=':
|
3495 | ok = val != val2;
|
3496 | break;
|
3497 | case '!==':
|
3498 | ok = val !== val2;
|
3499 | break;
|
3500 | default:
|
3501 | throw new Error('Invalid operator "' + operator + '"');
|
3502 | }
|
3503 | var test = new Assertion(ok, msg);
|
3504 | test.assert(true === flag(test, 'object'), 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2), 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2));
|
3505 | };
|
3506 | |
3507 |
|
3508 |
|
3509 |
|
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 |
|
3515 |
|
3516 |
|
3517 |
|
3518 |
|
3519 |
|
3520 |
|
3521 | assert.closeTo = function (act, exp, delta, msg) {
|
3522 | new Assertion(act, msg).to.be.closeTo(exp, delta);
|
3523 | };
|
3524 | |
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 |
|
3533 |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 | assert.approximately = function (act, exp, delta, msg) {
|
3540 | new Assertion(act, msg).to.be.approximately(exp, delta);
|
3541 | };
|
3542 | |
3543 |
|
3544 |
|
3545 |
|
3546 |
|
3547 |
|
3548 |
|
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 |
|
3556 |
|
3557 | assert.sameMembers = function (set1, set2, msg) {
|
3558 | new Assertion(set1, msg).to.have.same.members(set2);
|
3559 | };
|
3560 | |
3561 |
|
3562 |
|
3563 |
|
3564 |
|
3565 |
|
3566 |
|
3567 |
|
3568 |
|
3569 |
|
3570 |
|
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 | assert.sameDeepMembers = function (set1, set2, msg) {
|
3576 | new Assertion(set1, msg).to.have.same.deep.members(set2);
|
3577 | };
|
3578 | |
3579 |
|
3580 |
|
3581 |
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 |
|
3593 | assert.includeMembers = function (superset, subset, msg) {
|
3594 | new Assertion(superset, msg).to.include.members(subset);
|
3595 | };
|
3596 | |
3597 |
|
3598 |
|
3599 |
|
3600 |
|
3601 |
|
3602 |
|
3603 |
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 |
|
3609 |
|
3610 |
|
3611 |
|
3612 | assert.includeDeepMembers = function (superset, subset, msg) {
|
3613 | new Assertion(superset, msg).to.include.deep.members(subset);
|
3614 | };
|
3615 | |
3616 |
|
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 |
|
3626 |
|
3627 |
|
3628 |
|
3629 | assert.oneOf = function (inList, list, msg) {
|
3630 | new Assertion(inList, msg).to.be.oneOf(list);
|
3631 | };
|
3632 | |
3633 |
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 |
|
3639 |
|
3640 |
|
3641 |
|
3642 |
|
3643 |
|
3644 |
|
3645 |
|
3646 |
|
3647 |
|
3648 |
|
3649 | assert.changes = function (fn, obj, prop) {
|
3650 | new Assertion(fn).to.change(obj, prop);
|
3651 | };
|
3652 | |
3653 |
|
3654 |
|
3655 |
|
3656 |
|
3657 |
|
3658 |
|
3659 |
|
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 |
|
3668 |
|
3669 | assert.doesNotChange = function (fn, obj, prop) {
|
3670 | new Assertion(fn).to.not.change(obj, prop);
|
3671 | };
|
3672 | |
3673 |
|
3674 |
|
3675 |
|
3676 |
|
3677 |
|
3678 |
|
3679 |
|
3680 |
|
3681 |
|
3682 |
|
3683 |
|
3684 |
|
3685 |
|
3686 |
|
3687 |
|
3688 |
|
3689 | assert.increases = function (fn, obj, prop) {
|
3690 | new Assertion(fn).to.increase(obj, prop);
|
3691 | };
|
3692 | |
3693 |
|
3694 |
|
3695 |
|
3696 |
|
3697 |
|
3698 |
|
3699 |
|
3700 |
|
3701 |
|
3702 |
|
3703 |
|
3704 |
|
3705 |
|
3706 |
|
3707 |
|
3708 |
|
3709 | assert.doesNotIncrease = function (fn, obj, prop) {
|
3710 | new Assertion(fn).to.not.increase(obj, prop);
|
3711 | };
|
3712 | |
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 |
|
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 | assert.decreases = function (fn, obj, prop) {
|
3730 | new Assertion(fn).to.decrease(obj, prop);
|
3731 | };
|
3732 | |
3733 |
|
3734 |
|
3735 |
|
3736 |
|
3737 |
|
3738 |
|
3739 |
|
3740 |
|
3741 |
|
3742 |
|
3743 |
|
3744 |
|
3745 |
|
3746 |
|
3747 |
|
3748 |
|
3749 | assert.doesNotDecrease = function (fn, obj, prop) {
|
3750 | new Assertion(fn).to.not.decrease(obj, prop);
|
3751 | };
|
3752 | |
3753 |
|
3754 |
|
3755 |
|
3756 |
|
3757 |
|
3758 |
|
3759 |
|
3760 |
|
3761 |
|
3762 |
|
3763 |
|
3764 |
|
3765 |
|
3766 |
|
3767 | assert.ifError = function (val) {
|
3768 | if (val) {
|
3769 | throw (val);
|
3770 | }
|
3771 | };
|
3772 | |
3773 |
|
3774 |
|
3775 |
|
3776 |
|
3777 |
|
3778 |
|
3779 |
|
3780 |
|
3781 |
|
3782 |
|
3783 |
|
3784 |
|
3785 |
|
3786 | assert.isExtensible = function (obj, msg) {
|
3787 | new Assertion(obj, msg).to.be.extensible;
|
3788 | };
|
3789 | |
3790 |
|
3791 |
|
3792 |
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 |
|
3803 |
|
3804 |
|
3805 |
|
3806 |
|
3807 |
|
3808 |
|
3809 | assert.isNotExtensible = function (obj, msg) {
|
3810 | new Assertion(obj, msg).to.not.be.extensible;
|
3811 | };
|
3812 | |
3813 |
|
3814 |
|
3815 |
|
3816 |
|
3817 |
|
3818 |
|
3819 |
|
3820 |
|
3821 |
|
3822 |
|
3823 |
|
3824 |
|
3825 |
|
3826 |
|
3827 |
|
3828 |
|
3829 |
|
3830 |
|
3831 | assert.isSealed = function (obj, msg) {
|
3832 | new Assertion(obj, msg).to.be.sealed;
|
3833 | };
|
3834 | |
3835 |
|
3836 |
|
3837 |
|
3838 |
|
3839 |
|
3840 |
|
3841 |
|
3842 |
|
3843 |
|
3844 |
|
3845 |
|
3846 |
|
3847 |
|
3848 | assert.isNotSealed = function (obj, msg) {
|
3849 | new Assertion(obj, msg).to.not.be.sealed;
|
3850 | };
|
3851 | |
3852 |
|
3853 |
|
3854 |
|
3855 |
|
3856 |
|
3857 |
|
3858 |
|
3859 |
|
3860 |
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 | assert.isFrozen = function (obj, msg) {
|
3868 | new Assertion(obj, msg).to.be.frozen;
|
3869 | };
|
3870 | |
3871 |
|
3872 |
|
3873 |
|
3874 |
|
3875 |
|
3876 |
|
3877 |
|
3878 |
|
3879 |
|
3880 |
|
3881 |
|
3882 |
|
3883 |
|
3884 | assert.isNotFrozen = function (obj, msg) {
|
3885 | new Assertion(obj, msg).to.not.be.frozen;
|
3886 | };
|
3887 | |
3888 |
|
3889 |
|
3890 | (function alias(name, as) {
|
3891 | assert[as] = assert[name];
|
3892 | return alias;
|
3893 | })('isOk', 'ok')('isNotOk', 'notOk')('throws', 'throw')('throws', 'Throw')('isExtensible', 'extensible')('isNotExtensible', 'notExtensible')('isSealed', 'sealed')('isNotSealed', 'notSealed')('isFrozen', 'frozen')('isNotFrozen', 'notFrozen');
|
3894 | };
|
3895 |
|
3896 | },{}],15:[function(require,module,exports){
|
3897 |
|
3898 |
|
3899 |
|
3900 |
|
3901 |
|
3902 | module.exports = function (chai, util) {
|
3903 | chai.expect = function (val, message) {
|
3904 | return new chai.Assertion(val, message);
|
3905 | };
|
3906 | |
3907 |
|
3908 |
|
3909 |
|
3910 |
|
3911 |
|
3912 |
|
3913 |
|
3914 |
|
3915 |
|
3916 |
|
3917 |
|
3918 |
|
3919 | chai.expect.fail = function (actual, expected, message, operator) {
|
3920 | message = message || 'expect.fail()';
|
3921 | throw new chai.AssertionError(message, {
|
3922 | actual: actual,
|
3923 | expected: expected,
|
3924 | operator: operator
|
3925 | }, chai.expect.fail);
|
3926 | };
|
3927 | };
|
3928 |
|
3929 | },{}],16:[function(require,module,exports){
|
3930 |
|
3931 |
|
3932 |
|
3933 |
|
3934 |
|
3935 | module.exports = function (chai, util) {
|
3936 | var Assertion = chai.Assertion;
|
3937 | function loadShould() {
|
3938 |
|
3939 | function shouldGetter() {
|
3940 | if (this instanceof String || this instanceof Number || this instanceof Boolean) {
|
3941 | return new Assertion(this.valueOf(), null, shouldGetter);
|
3942 | }
|
3943 | return new Assertion(this, null, shouldGetter);
|
3944 | }
|
3945 | function shouldSetter(value) {
|
3946 |
|
3947 |
|
3948 |
|
3949 |
|
3950 |
|
3951 |
|
3952 | Object.defineProperty(this, 'should', {
|
3953 | value: value,
|
3954 | enumerable: true,
|
3955 | configurable: true,
|
3956 | writable: true
|
3957 | });
|
3958 | }
|
3959 |
|
3960 | Object.defineProperty(Object.prototype, 'should', {
|
3961 | set: shouldSetter,
|
3962 | get: shouldGetter,
|
3963 | configurable: true
|
3964 | });
|
3965 | var should = {};
|
3966 | |
3967 |
|
3968 |
|
3969 |
|
3970 |
|
3971 |
|
3972 |
|
3973 |
|
3974 |
|
3975 |
|
3976 |
|
3977 |
|
3978 |
|
3979 | should.fail = function (actual, expected, message, operator) {
|
3980 | message = message || 'should.fail()';
|
3981 | throw new chai.AssertionError(message, {
|
3982 | actual: actual,
|
3983 | expected: expected,
|
3984 | operator: operator
|
3985 | }, should.fail);
|
3986 | };
|
3987 | |
3988 |
|
3989 |
|
3990 |
|
3991 |
|
3992 |
|
3993 |
|
3994 |
|
3995 |
|
3996 |
|
3997 |
|
3998 |
|
3999 |
|
4000 |
|
4001 | should.equal = function (val1, val2, msg) {
|
4002 | new Assertion(val1, msg).to.equal(val2);
|
4003 | };
|
4004 | |
4005 |
|
4006 |
|
4007 |
|
4008 |
|
4009 |
|
4010 |
|
4011 |
|
4012 |
|
4013 |
|
4014 |
|
4015 |
|
4016 |
|
4017 |
|
4018 |
|
4019 |
|
4020 |
|
4021 |
|
4022 |
|
4023 |
|
4024 |
|
4025 |
|
4026 |
|
4027 | should.Throw = function (fn, errt, errs, msg) {
|
4028 | new Assertion(fn, msg).to.Throw(errt, errs);
|
4029 | };
|
4030 | |
4031 |
|
4032 |
|
4033 |
|
4034 |
|
4035 |
|
4036 |
|
4037 |
|
4038 |
|
4039 |
|
4040 |
|
4041 |
|
4042 |
|
4043 | should.exist = function (val, msg) {
|
4044 | new Assertion(val, msg).to.exist;
|
4045 | };
|
4046 |
|
4047 | should.not = {};
|
4048 | |
4049 |
|
4050 |
|
4051 |
|
4052 |
|
4053 |
|
4054 |
|
4055 |
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 |
|
4061 |
|
4062 | should.not.equal = function (val1, val2, msg) {
|
4063 | new Assertion(val1, msg).to.not.equal(val2);
|
4064 | };
|
4065 | |
4066 |
|
4067 |
|
4068 |
|
4069 |
|
4070 |
|
4071 |
|
4072 |
|
4073 |
|
4074 |
|
4075 |
|
4076 |
|
4077 |
|
4078 |
|
4079 |
|
4080 |
|
4081 |
|
4082 |
|
4083 |
|
4084 | should.not.Throw = function (fn, errt, errs, msg) {
|
4085 | new Assertion(fn, msg).to.not.Throw(errt, errs);
|
4086 | };
|
4087 | |
4088 |
|
4089 |
|
4090 |
|
4091 |
|
4092 |
|
4093 |
|
4094 |
|
4095 |
|
4096 |
|
4097 |
|
4098 |
|
4099 |
|
4100 | should.not.exist = function (val, msg) {
|
4101 | new Assertion(val, msg).to.not.exist;
|
4102 | };
|
4103 | should['throw'] = should['Throw'];
|
4104 | should.not['throw'] = should.not['Throw'];
|
4105 | return should;
|
4106 | }
|
4107 | ;
|
4108 | chai.should = loadShould;
|
4109 | chai.Should = loadShould;
|
4110 | };
|
4111 |
|
4112 | },{}],17:[function(require,module,exports){
|
4113 |
|
4114 |
|
4115 |
|
4116 |
|
4117 |
|
4118 |
|
4119 |
|
4120 |
|
4121 | var transferFlags = require('./transferFlags');
|
4122 | var flag = require('./flag');
|
4123 | var config = require('../config');
|
4124 |
|
4125 |
|
4126 |
|
4127 |
|
4128 | var hasProtoSupport = '__proto__' in Object;
|
4129 |
|
4130 |
|
4131 |
|
4132 | var excludeNames = /^(?:length|name|arguments|caller)$/;
|
4133 |
|
4134 | var call = Function.prototype.call, apply = Function.prototype.apply;
|
4135 |
|
4136 |
|
4137 |
|
4138 |
|
4139 |
|
4140 |
|
4141 |
|
4142 |
|
4143 |
|
4144 |
|
4145 |
|
4146 |
|
4147 |
|
4148 |
|
4149 |
|
4150 |
|
4151 |
|
4152 |
|
4153 |
|
4154 |
|
4155 |
|
4156 |
|
4157 |
|
4158 |
|
4159 |
|
4160 |
|
4161 |
|
4162 |
|
4163 | module.exports = function (ctx, name, method, chainingBehavior) {
|
4164 | if (typeof chainingBehavior !== 'function') {
|
4165 | chainingBehavior = function () { };
|
4166 | }
|
4167 | var chainableBehavior = {
|
4168 | method: method,
|
4169 | chainingBehavior: chainingBehavior
|
4170 | };
|
4171 |
|
4172 | if (!ctx.__methods) {
|
4173 | ctx.__methods = {};
|
4174 | }
|
4175 | ctx.__methods[name] = chainableBehavior;
|
4176 | Object.defineProperty(ctx, name, { get: function () {
|
4177 | chainableBehavior.chainingBehavior.call(this);
|
4178 | var assert = function assert() {
|
4179 | var old_ssfi = flag(this, 'ssfi');
|
4180 | if (old_ssfi && config.includeStack === false)
|
4181 | flag(this, 'ssfi', assert);
|
4182 | var result = chainableBehavior.method.apply(this, arguments);
|
4183 | return result === undefined ? this : result;
|
4184 | };
|
4185 |
|
4186 | if (hasProtoSupport) {
|
4187 |
|
4188 | var prototype = assert.__proto__ = Object.create(this);
|
4189 |
|
4190 | prototype.call = call;
|
4191 | prototype.apply = apply;
|
4192 | }
|
4193 | else {
|
4194 | var asserterNames = Object.getOwnPropertyNames(ctx);
|
4195 | asserterNames.forEach(function (asserterName) {
|
4196 | if (!excludeNames.test(asserterName)) {
|
4197 | var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
4198 | Object.defineProperty(assert, asserterName, pd);
|
4199 | }
|
4200 | });
|
4201 | }
|
4202 | transferFlags(this, assert);
|
4203 | return assert;
|
4204 | },
|
4205 | configurable: true
|
4206 | });
|
4207 | };
|
4208 |
|
4209 | },{"../config":12,"./flag":21,"./transferFlags":37}],18:[function(require,module,exports){
|
4210 |
|
4211 |
|
4212 |
|
4213 |
|
4214 |
|
4215 | var config = require('../config');
|
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 |
|
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 |
|
4237 |
|
4238 |
|
4239 |
|
4240 |
|
4241 | var flag = require('./flag');
|
4242 | module.exports = function (ctx, name, method) {
|
4243 | ctx[name] = function () {
|
4244 | var old_ssfi = flag(this, 'ssfi');
|
4245 | if (old_ssfi && config.includeStack === false)
|
4246 | flag(this, 'ssfi', ctx[name]);
|
4247 | var result = method.apply(this, arguments);
|
4248 | return result === undefined ? this : result;
|
4249 | };
|
4250 | };
|
4251 |
|
4252 | },{"../config":12,"./flag":21}],19:[function(require,module,exports){
|
4253 |
|
4254 |
|
4255 |
|
4256 |
|
4257 |
|
4258 | var config = require('../config');
|
4259 | var flag = require('./flag');
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 |
|
4269 |
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 |
|
4278 |
|
4279 |
|
4280 |
|
4281 |
|
4282 |
|
4283 |
|
4284 |
|
4285 | module.exports = function (ctx, name, getter) {
|
4286 | Object.defineProperty(ctx, name, { get: function addProperty() {
|
4287 | var old_ssfi = flag(this, 'ssfi');
|
4288 | if (old_ssfi && config.includeStack === false)
|
4289 | flag(this, 'ssfi', addProperty);
|
4290 | var result = getter.call(this);
|
4291 | return result === undefined ? this : result;
|
4292 | },
|
4293 | configurable: true
|
4294 | });
|
4295 | };
|
4296 |
|
4297 | },{"../config":12,"./flag":21}],20:[function(require,module,exports){
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 |
|
4311 |
|
4312 |
|
4313 |
|
4314 |
|
4315 |
|
4316 | var AssertionError = require('assertion-error');
|
4317 | var flag = require('./flag');
|
4318 | var type = require('type-detect');
|
4319 | module.exports = function (obj, types) {
|
4320 | var obj = flag(obj, 'object');
|
4321 | types = types.map(function (t) { return t.toLowerCase(); });
|
4322 | types.sort();
|
4323 |
|
4324 | var str = types.map(function (t, index) {
|
4325 | var art = ~['a', 'e', 'i', 'o', 'u'].indexOf(t.charAt(0)) ? 'an' : 'a';
|
4326 | var or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
|
4327 | return or + art + ' ' + t;
|
4328 | }).join(', ');
|
4329 | if (!types.some(function (expected) { return type(obj) === expected; })) {
|
4330 | throw new AssertionError('object tested must be ' + str + ', but ' + type(obj) + ' given');
|
4331 | }
|
4332 | };
|
4333 |
|
4334 | },{"./flag":21,"assertion-error":8,"type-detect":53}],21:[function(require,module,exports){
|
4335 |
|
4336 |
|
4337 |
|
4338 |
|
4339 |
|
4340 |
|
4341 |
|
4342 |
|
4343 |
|
4344 |
|
4345 |
|
4346 |
|
4347 |
|
4348 |
|
4349 |
|
4350 |
|
4351 |
|
4352 |
|
4353 |
|
4354 |
|
4355 |
|
4356 |
|
4357 |
|
4358 | module.exports = function (obj, key, value) {
|
4359 | var flags = obj.__flags || (obj.__flags = Object.create(null));
|
4360 | if (arguments.length === 3) {
|
4361 | flags[key] = value;
|
4362 | }
|
4363 | else {
|
4364 | return flags[key];
|
4365 | }
|
4366 | };
|
4367 |
|
4368 | },{}],22:[function(require,module,exports){
|
4369 |
|
4370 |
|
4371 |
|
4372 |
|
4373 |
|
4374 |
|
4375 |
|
4376 |
|
4377 |
|
4378 |
|
4379 |
|
4380 |
|
4381 |
|
4382 |
|
4383 |
|
4384 | module.exports = function (obj, args) {
|
4385 | return args.length > 4 ? args[4] : obj._obj;
|
4386 | };
|
4387 |
|
4388 | },{}],23:[function(require,module,exports){
|
4389 |
|
4390 |
|
4391 |
|
4392 |
|
4393 |
|
4394 |
|
4395 |
|
4396 |
|
4397 |
|
4398 |
|
4399 |
|
4400 |
|
4401 |
|
4402 |
|
4403 |
|
4404 |
|
4405 |
|
4406 | module.exports = function getEnumerableProperties(object) {
|
4407 | var result = [];
|
4408 | for (var name in object) {
|
4409 | result.push(name);
|
4410 | }
|
4411 | return result;
|
4412 | };
|
4413 |
|
4414 | },{}],24:[function(require,module,exports){
|
4415 |
|
4416 |
|
4417 |
|
4418 |
|
4419 |
|
4420 |
|
4421 |
|
4422 |
|
4423 | var flag = require('./flag'), getActual = require('./getActual'), inspect = require('./inspect'), objDisplay = require('./objDisplay');
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 |
|
4439 |
|
4440 |
|
4441 |
|
4442 | module.exports = function (obj, args) {
|
4443 | var negate = flag(obj, 'negate'), val = flag(obj, 'object'), expected = args[3], actual = getActual(obj, args), msg = negate ? args[2] : args[1], flagMsg = flag(obj, 'message');
|
4444 | if (typeof msg === "function")
|
4445 | msg = msg();
|
4446 | msg = msg || '';
|
4447 | msg = msg
|
4448 | .replace(/#\{this\}/g, function () { return objDisplay(val); })
|
4449 | .replace(/#\{act\}/g, function () { return objDisplay(actual); })
|
4450 | .replace(/#\{exp\}/g, function () { return objDisplay(expected); });
|
4451 | return flagMsg ? flagMsg + ': ' + msg : msg;
|
4452 | };
|
4453 |
|
4454 | },{"./flag":21,"./getActual":22,"./inspect":31,"./objDisplay":32}],25:[function(require,module,exports){
|
4455 |
|
4456 |
|
4457 |
|
4458 |
|
4459 |
|
4460 |
|
4461 |
|
4462 |
|
4463 |
|
4464 |
|
4465 |
|
4466 |
|
4467 |
|
4468 |
|
4469 | module.exports = function (func) {
|
4470 | if (func.name)
|
4471 | return func.name;
|
4472 | var match = /^\s?function ([^(]*)\(/.exec(func);
|
4473 | return match && match[1] ? match[1] : "";
|
4474 | };
|
4475 |
|
4476 | },{}],26:[function(require,module,exports){
|
4477 |
|
4478 |
|
4479 |
|
4480 |
|
4481 |
|
4482 | var hasProperty = require('./hasProperty');
|
4483 |
|
4484 |
|
4485 |
|
4486 |
|
4487 |
|
4488 |
|
4489 |
|
4490 |
|
4491 |
|
4492 |
|
4493 |
|
4494 |
|
4495 |
|
4496 |
|
4497 |
|
4498 |
|
4499 |
|
4500 |
|
4501 |
|
4502 |
|
4503 |
|
4504 | module.exports = function getPathInfo(path, obj) {
|
4505 | var parsed = parsePath(path), last = parsed[parsed.length - 1];
|
4506 | var info = {
|
4507 | parent: parsed.length > 1 ? _getPathValue(parsed, obj, parsed.length - 1) : obj,
|
4508 | name: last.p || last.i,
|
4509 | value: _getPathValue(parsed, obj)
|
4510 | };
|
4511 | info.exists = hasProperty(info.name, info.parent);
|
4512 | return info;
|
4513 | };
|
4514 |
|
4515 |
|
4516 |
|
4517 |
|
4518 |
|
4519 |
|
4520 |
|
4521 |
|
4522 |
|
4523 |
|
4524 |
|
4525 |
|
4526 |
|
4527 |
|
4528 |
|
4529 |
|
4530 |
|
4531 |
|
4532 | function parsePath(path) {
|
4533 | var str = path.replace(/([^\\])\[/g, '$1.['), parts = str.match(/(\\\.|[^.]+?)+/g);
|
4534 | return parts.map(function (value) {
|
4535 | var re = /^\[(\d+)\]$/, mArr = re.exec(value);
|
4536 | if (mArr)
|
4537 | return { i: parseFloat(mArr[1]) };
|
4538 | else
|
4539 | return { p: value.replace(/\\([.\[\]])/g, '$1') };
|
4540 | });
|
4541 | }
|
4542 |
|
4543 |
|
4544 |
|
4545 |
|
4546 |
|
4547 |
|
4548 |
|
4549 |
|
4550 |
|
4551 |
|
4552 |
|
4553 |
|
4554 |
|
4555 |
|
4556 | function _getPathValue(parsed, obj, index) {
|
4557 | var tmp = obj, res;
|
4558 | index = (index === undefined ? parsed.length : index);
|
4559 | for (var i = 0, l = index; i < l; i++) {
|
4560 | var part = parsed[i];
|
4561 | if (tmp) {
|
4562 | if ('undefined' !== typeof part.p)
|
4563 | tmp = tmp[part.p];
|
4564 | else if ('undefined' !== typeof part.i)
|
4565 | tmp = tmp[part.i];
|
4566 | if (i == (l - 1))
|
4567 | res = tmp;
|
4568 | }
|
4569 | else {
|
4570 | res = undefined;
|
4571 | }
|
4572 | }
|
4573 | return res;
|
4574 | }
|
4575 |
|
4576 | },{"./hasProperty":29}],27:[function(require,module,exports){
|
4577 |
|
4578 |
|
4579 |
|
4580 |
|
4581 |
|
4582 |
|
4583 | var getPathInfo = require('./getPathInfo');
|
4584 |
|
4585 |
|
4586 |
|
4587 |
|
4588 |
|
4589 |
|
4590 |
|
4591 |
|
4592 |
|
4593 |
|
4594 |
|
4595 |
|
4596 |
|
4597 |
|
4598 |
|
4599 |
|
4600 |
|
4601 |
|
4602 |
|
4603 |
|
4604 |
|
4605 |
|
4606 |
|
4607 |
|
4608 |
|
4609 |
|
4610 |
|
4611 |
|
4612 |
|
4613 |
|
4614 | module.exports = function (path, obj) {
|
4615 | var info = getPathInfo(path, obj);
|
4616 | return info.value;
|
4617 | };
|
4618 |
|
4619 | },{"./getPathInfo":26}],28:[function(require,module,exports){
|
4620 |
|
4621 |
|
4622 |
|
4623 |
|
4624 |
|
4625 |
|
4626 |
|
4627 |
|
4628 |
|
4629 |
|
4630 |
|
4631 |
|
4632 |
|
4633 |
|
4634 |
|
4635 |
|
4636 |
|
4637 | module.exports = function getProperties(object) {
|
4638 | var result = Object.getOwnPropertyNames(object);
|
4639 | function addProperty(property) {
|
4640 | if (result.indexOf(property) === -1) {
|
4641 | result.push(property);
|
4642 | }
|
4643 | }
|
4644 | var proto = Object.getPrototypeOf(object);
|
4645 | while (proto !== null) {
|
4646 | Object.getOwnPropertyNames(proto).forEach(addProperty);
|
4647 | proto = Object.getPrototypeOf(proto);
|
4648 | }
|
4649 | return result;
|
4650 | };
|
4651 |
|
4652 | },{}],29:[function(require,module,exports){
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 | var type = require('type-detect');
|
4659 |
|
4660 |
|
4661 |
|
4662 |
|
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 |
|
4670 |
|
4671 |
|
4672 |
|
4673 |
|
4674 |
|
4675 |
|
4676 |
|
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 |
|
4685 |
|
4686 |
|
4687 |
|
4688 |
|
4689 |
|
4690 |
|
4691 |
|
4692 |
|
4693 |
|
4694 |
|
4695 | var literals = {
|
4696 | 'number': Number,
|
4697 | 'string': String
|
4698 | };
|
4699 | module.exports = function hasProperty(name, obj) {
|
4700 | var ot = type(obj);
|
4701 |
|
4702 | if (ot === 'null' || ot === 'undefined')
|
4703 | return false;
|
4704 |
|
4705 |
|
4706 | if (literals[ot] && typeof obj !== 'object')
|
4707 | obj = new literals[ot](obj);
|
4708 | return name in obj;
|
4709 | };
|
4710 |
|
4711 | },{"type-detect":53}],30:[function(require,module,exports){
|
4712 |
|
4713 |
|
4714 |
|
4715 |
|
4716 |
|
4717 |
|
4718 |
|
4719 |
|
4720 | var exports = module.exports = {};
|
4721 |
|
4722 |
|
4723 |
|
4724 | exports.test = require('./test');
|
4725 |
|
4726 |
|
4727 |
|
4728 | exports.type = require('type-detect');
|
4729 |
|
4730 |
|
4731 |
|
4732 | exports.expectTypes = require('./expectTypes');
|
4733 |
|
4734 |
|
4735 |
|
4736 | exports.getMessage = require('./getMessage');
|
4737 |
|
4738 |
|
4739 |
|
4740 | exports.getActual = require('./getActual');
|
4741 |
|
4742 |
|
4743 |
|
4744 | exports.inspect = require('./inspect');
|
4745 |
|
4746 |
|
4747 |
|
4748 | exports.objDisplay = require('./objDisplay');
|
4749 |
|
4750 |
|
4751 |
|
4752 | exports.flag = require('./flag');
|
4753 |
|
4754 |
|
4755 |
|
4756 | exports.transferFlags = require('./transferFlags');
|
4757 |
|
4758 |
|
4759 |
|
4760 | exports.eql = require('deep-eql');
|
4761 |
|
4762 |
|
4763 |
|
4764 | exports.getPathValue = require('./getPathValue');
|
4765 |
|
4766 |
|
4767 |
|
4768 | exports.getPathInfo = require('./getPathInfo');
|
4769 |
|
4770 |
|
4771 |
|
4772 | exports.hasProperty = require('./hasProperty');
|
4773 |
|
4774 |
|
4775 |
|
4776 | exports.getName = require('./getName');
|
4777 |
|
4778 |
|
4779 |
|
4780 | exports.addProperty = require('./addProperty');
|
4781 |
|
4782 |
|
4783 |
|
4784 | exports.addMethod = require('./addMethod');
|
4785 |
|
4786 |
|
4787 |
|
4788 | exports.overwriteProperty = require('./overwriteProperty');
|
4789 |
|
4790 |
|
4791 |
|
4792 | exports.overwriteMethod = require('./overwriteMethod');
|
4793 |
|
4794 |
|
4795 |
|
4796 | exports.addChainableMethod = require('./addChainableMethod');
|
4797 |
|
4798 |
|
4799 |
|
4800 | exports.overwriteChainableMethod = require('./overwriteChainableMethod');
|
4801 |
|
4802 | },{"./addChainableMethod":17,"./addMethod":18,"./addProperty":19,"./expectTypes":20,"./flag":21,"./getActual":22,"./getMessage":24,"./getName":25,"./getPathInfo":26,"./getPathValue":27,"./hasProperty":29,"./inspect":31,"./objDisplay":32,"./overwriteChainableMethod":33,"./overwriteMethod":34,"./overwriteProperty":35,"./test":36,"./transferFlags":37,"deep-eql":38,"type-detect":53}],31:[function(require,module,exports){
|
4803 |
|
4804 |
|
4805 | var getName = require('./getName');
|
4806 | var getProperties = require('./getProperties');
|
4807 | var getEnumerableProperties = require('./getEnumerableProperties');
|
4808 | module.exports = inspect;
|
4809 |
|
4810 |
|
4811 |
|
4812 |
|
4813 |
|
4814 |
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 |
|
4822 | function inspect(obj, showHidden, depth, colors) {
|
4823 | var ctx = {
|
4824 | showHidden: showHidden,
|
4825 | seen: [],
|
4826 | stylize: function (str) { return str; }
|
4827 | };
|
4828 | return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
4829 | }
|
4830 |
|
4831 | var isDOMElement = function (object) {
|
4832 | if (typeof HTMLElement === 'object') {
|
4833 | return object instanceof HTMLElement;
|
4834 | }
|
4835 | else {
|
4836 | return object &&
|
4837 | typeof object === 'object' &&
|
4838 | object.nodeType === 1 &&
|
4839 | typeof object.nodeName === 'string';
|
4840 | }
|
4841 | };
|
4842 | function formatValue(ctx, value, recurseTimes) {
|
4843 |
|
4844 |
|
4845 | if (value && typeof value.inspect === 'function' &&
|
4846 |
|
4847 | value.inspect !== exports.inspect &&
|
4848 |
|
4849 | !(value.constructor && value.constructor.prototype === value)) {
|
4850 | var ret = value.inspect(recurseTimes);
|
4851 | if (typeof ret !== 'string') {
|
4852 | ret = formatValue(ctx, ret, recurseTimes);
|
4853 | }
|
4854 | return ret;
|
4855 | }
|
4856 |
|
4857 | var primitive = formatPrimitive(ctx, value);
|
4858 | if (primitive) {
|
4859 | return primitive;
|
4860 | }
|
4861 |
|
4862 | if (isDOMElement(value)) {
|
4863 | if ('outerHTML' in value) {
|
4864 | return value.outerHTML;
|
4865 | }
|
4866 | else {
|
4867 |
|
4868 | try {
|
4869 | if (document.xmlVersion) {
|
4870 | var xmlSerializer = new XMLSerializer();
|
4871 | return xmlSerializer.serializeToString(value);
|
4872 | }
|
4873 | else {
|
4874 |
|
4875 |
|
4876 |
|
4877 | var ns = "http://www.w3.org/1999/xhtml";
|
4878 | var container = document.createElementNS(ns, '_');
|
4879 | container.appendChild(value.cloneNode(false));
|
4880 | html = container.innerHTML
|
4881 | .replace('><', '>' + value.innerHTML + '<');
|
4882 | container.innerHTML = '';
|
4883 | return html;
|
4884 | }
|
4885 | }
|
4886 | catch (err) {
|
4887 | }
|
4888 | }
|
4889 | }
|
4890 |
|
4891 | var visibleKeys = getEnumerableProperties(value);
|
4892 | var keys = ctx.showHidden ? getProperties(value) : visibleKeys;
|
4893 |
|
4894 |
|
4895 |
|
4896 | if (keys.length === 0 || (isError(value) && ((keys.length === 1 && keys[0] === 'stack') ||
|
4897 | (keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack')))) {
|
4898 | if (typeof value === 'function') {
|
4899 | var name = getName(value);
|
4900 | var nameSuffix = name ? ': ' + name : '';
|
4901 | return ctx.stylize('[Function' + nameSuffix + ']', 'special');
|
4902 | }
|
4903 | if (isRegExp(value)) {
|
4904 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
4905 | }
|
4906 | if (isDate(value)) {
|
4907 | return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
|
4908 | }
|
4909 | if (isError(value)) {
|
4910 | return formatError(value);
|
4911 | }
|
4912 | }
|
4913 | var base = '', array = false, braces = ['{', '}'];
|
4914 |
|
4915 | if (isArray(value)) {
|
4916 | array = true;
|
4917 | braces = ['[', ']'];
|
4918 | }
|
4919 |
|
4920 | if (typeof value === 'function') {
|
4921 | var name = getName(value);
|
4922 | var nameSuffix = name ? ': ' + name : '';
|
4923 | base = ' [Function' + nameSuffix + ']';
|
4924 | }
|
4925 |
|
4926 | if (isRegExp(value)) {
|
4927 | base = ' ' + RegExp.prototype.toString.call(value);
|
4928 | }
|
4929 |
|
4930 | if (isDate(value)) {
|
4931 | base = ' ' + Date.prototype.toUTCString.call(value);
|
4932 | }
|
4933 |
|
4934 | if (isError(value)) {
|
4935 | return formatError(value);
|
4936 | }
|
4937 | if (keys.length === 0 && (!array || value.length == 0)) {
|
4938 | return braces[0] + base + braces[1];
|
4939 | }
|
4940 | if (recurseTimes < 0) {
|
4941 | if (isRegExp(value)) {
|
4942 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
4943 | }
|
4944 | else {
|
4945 | return ctx.stylize('[Object]', 'special');
|
4946 | }
|
4947 | }
|
4948 | ctx.seen.push(value);
|
4949 | var output;
|
4950 | if (array) {
|
4951 | output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
4952 | }
|
4953 | else {
|
4954 | output = keys.map(function (key) {
|
4955 | return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
4956 | });
|
4957 | }
|
4958 | ctx.seen.pop();
|
4959 | return reduceToSingleString(output, base, braces);
|
4960 | }
|
4961 | function formatPrimitive(ctx, value) {
|
4962 | switch (typeof value) {
|
4963 | case 'undefined':
|
4964 | return ctx.stylize('undefined', 'undefined');
|
4965 | case 'string':
|
4966 | var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
4967 | .replace(/'/g, "\\'")
|
4968 | .replace(/\\"/g, '"') + '\'';
|
4969 | return ctx.stylize(simple, 'string');
|
4970 | case 'number':
|
4971 | if (value === 0 && (1 / value) === -Infinity) {
|
4972 | return ctx.stylize('-0', 'number');
|
4973 | }
|
4974 | return ctx.stylize('' + value, 'number');
|
4975 | case 'boolean':
|
4976 | return ctx.stylize('' + value, 'boolean');
|
4977 | }
|
4978 |
|
4979 | if (value === null) {
|
4980 | return ctx.stylize('null', 'null');
|
4981 | }
|
4982 | }
|
4983 | function formatError(value) {
|
4984 | return '[' + Error.prototype.toString.call(value) + ']';
|
4985 | }
|
4986 | function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
4987 | var output = [];
|
4988 | for (var i = 0, l = value.length; i < l; ++i) {
|
4989 | if (Object.prototype.hasOwnProperty.call(value, String(i))) {
|
4990 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
|
4991 | }
|
4992 | else {
|
4993 | output.push('');
|
4994 | }
|
4995 | }
|
4996 | keys.forEach(function (key) {
|
4997 | if (!key.match(/^\d+$/)) {
|
4998 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
|
4999 | }
|
5000 | });
|
5001 | return output;
|
5002 | }
|
5003 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
5004 | var name, str;
|
5005 | if (value.__lookupGetter__) {
|
5006 | if (value.__lookupGetter__(key)) {
|
5007 | if (value.__lookupSetter__(key)) {
|
5008 | str = ctx.stylize('[Getter/Setter]', 'special');
|
5009 | }
|
5010 | else {
|
5011 | str = ctx.stylize('[Getter]', 'special');
|
5012 | }
|
5013 | }
|
5014 | else {
|
5015 | if (value.__lookupSetter__(key)) {
|
5016 | str = ctx.stylize('[Setter]', 'special');
|
5017 | }
|
5018 | }
|
5019 | }
|
5020 | if (visibleKeys.indexOf(key) < 0) {
|
5021 | name = '[' + key + ']';
|
5022 | }
|
5023 | if (!str) {
|
5024 | if (ctx.seen.indexOf(value[key]) < 0) {
|
5025 | if (recurseTimes === null) {
|
5026 | str = formatValue(ctx, value[key], null);
|
5027 | }
|
5028 | else {
|
5029 | str = formatValue(ctx, value[key], recurseTimes - 1);
|
5030 | }
|
5031 | if (str.indexOf('\n') > -1) {
|
5032 | if (array) {
|
5033 | str = str.split('\n').map(function (line) {
|
5034 | return ' ' + line;
|
5035 | }).join('\n').substr(2);
|
5036 | }
|
5037 | else {
|
5038 | str = '\n' + str.split('\n').map(function (line) {
|
5039 | return ' ' + line;
|
5040 | }).join('\n');
|
5041 | }
|
5042 | }
|
5043 | }
|
5044 | else {
|
5045 | str = ctx.stylize('[Circular]', 'special');
|
5046 | }
|
5047 | }
|
5048 | if (typeof name === 'undefined') {
|
5049 | if (array && key.match(/^\d+$/)) {
|
5050 | return str;
|
5051 | }
|
5052 | name = JSON.stringify('' + key);
|
5053 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
5054 | name = name.substr(1, name.length - 2);
|
5055 | name = ctx.stylize(name, 'name');
|
5056 | }
|
5057 | else {
|
5058 | name = name.replace(/'/g, "\\'")
|
5059 | .replace(/\\"/g, '"')
|
5060 | .replace(/(^"|"$)/g, "'");
|
5061 | name = ctx.stylize(name, 'string');
|
5062 | }
|
5063 | }
|
5064 | return name + ': ' + str;
|
5065 | }
|
5066 | function reduceToSingleString(output, base, braces) {
|
5067 | var numLinesEst = 0;
|
5068 | var length = output.reduce(function (prev, cur) {
|
5069 | numLinesEst++;
|
5070 | if (cur.indexOf('\n') >= 0)
|
5071 | numLinesEst++;
|
5072 | return prev + cur.length + 1;
|
5073 | }, 0);
|
5074 | if (length > 60) {
|
5075 | return braces[0] +
|
5076 | (base === '' ? '' : base + '\n ') +
|
5077 | ' ' +
|
5078 | output.join(',\n ') +
|
5079 | ' ' +
|
5080 | braces[1];
|
5081 | }
|
5082 | return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
5083 | }
|
5084 | function isArray(ar) {
|
5085 | return Array.isArray(ar) ||
|
5086 | (typeof ar === 'object' && objectToString(ar) === '[object Array]');
|
5087 | }
|
5088 | function isRegExp(re) {
|
5089 | return typeof re === 'object' && objectToString(re) === '[object RegExp]';
|
5090 | }
|
5091 | function isDate(d) {
|
5092 | return typeof d === 'object' && objectToString(d) === '[object Date]';
|
5093 | }
|
5094 | function isError(e) {
|
5095 | return typeof e === 'object' && objectToString(e) === '[object Error]';
|
5096 | }
|
5097 | function objectToString(o) {
|
5098 | return Object.prototype.toString.call(o);
|
5099 | }
|
5100 |
|
5101 | },{"./getEnumerableProperties":23,"./getName":25,"./getProperties":28}],32:[function(require,module,exports){
|
5102 |
|
5103 |
|
5104 |
|
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 |
|
5110 | var inspect = require('./inspect');
|
5111 | var config = require('../config');
|
5112 |
|
5113 |
|
5114 |
|
5115 |
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 |
|
5121 |
|
5122 |
|
5123 |
|
5124 | module.exports = function (obj) {
|
5125 | var str = inspect(obj), type = Object.prototype.toString.call(obj);
|
5126 | if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
5127 | if (type === '[object Function]') {
|
5128 | return !obj.name || obj.name === ''
|
5129 | ? '[Function]'
|
5130 | : '[Function: ' + obj.name + ']';
|
5131 | }
|
5132 | else if (type === '[object Array]') {
|
5133 | return '[ Array(' + obj.length + ') ]';
|
5134 | }
|
5135 | else if (type === '[object Object]') {
|
5136 | var keys = Object.keys(obj), kstr = keys.length > 2
|
5137 | ? keys.splice(0, 2).join(', ') + ', ...'
|
5138 | : keys.join(', ');
|
5139 | return '{ Object (' + kstr + ') }';
|
5140 | }
|
5141 | else {
|
5142 | return str;
|
5143 | }
|
5144 | }
|
5145 | else {
|
5146 | return str;
|
5147 | }
|
5148 | };
|
5149 |
|
5150 | },{"../config":12,"./inspect":31}],33:[function(require,module,exports){
|
5151 |
|
5152 |
|
5153 |
|
5154 |
|
5155 |
|
5156 |
|
5157 |
|
5158 |
|
5159 |
|
5160 |
|
5161 |
|
5162 |
|
5163 |
|
5164 |
|
5165 |
|
5166 |
|
5167 |
|
5168 |
|
5169 |
|
5170 |
|
5171 |
|
5172 |
|
5173 |
|
5174 |
|
5175 |
|
5176 |
|
5177 |
|
5178 |
|
5179 |
|
5180 |
|
5181 |
|
5182 |
|
5183 |
|
5184 |
|
5185 |
|
5186 |
|
5187 |
|
5188 | module.exports = function (ctx, name, method, chainingBehavior) {
|
5189 | var chainableBehavior = ctx.__methods[name];
|
5190 | var _chainingBehavior = chainableBehavior.chainingBehavior;
|
5191 | chainableBehavior.chainingBehavior = function () {
|
5192 | var result = chainingBehavior(_chainingBehavior).call(this);
|
5193 | return result === undefined ? this : result;
|
5194 | };
|
5195 | var _method = chainableBehavior.method;
|
5196 | chainableBehavior.method = function () {
|
5197 | var result = method(_method).apply(this, arguments);
|
5198 | return result === undefined ? this : result;
|
5199 | };
|
5200 | };
|
5201 |
|
5202 | },{}],34:[function(require,module,exports){
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 |
|
5209 |
|
5210 |
|
5211 |
|
5212 |
|
5213 |
|
5214 |
|
5215 |
|
5216 |
|
5217 |
|
5218 |
|
5219 |
|
5220 |
|
5221 |
|
5222 |
|
5223 |
|
5224 |
|
5225 |
|
5226 |
|
5227 |
|
5228 |
|
5229 |
|
5230 |
|
5231 |
|
5232 |
|
5233 |
|
5234 |
|
5235 |
|
5236 |
|
5237 |
|
5238 |
|
5239 |
|
5240 |
|
5241 | module.exports = function (ctx, name, method) {
|
5242 | var _method = ctx[name], _super = function () { return this; };
|
5243 | if (_method && 'function' === typeof _method)
|
5244 | _super = _method;
|
5245 | ctx[name] = function () {
|
5246 | var result = method(_super).apply(this, arguments);
|
5247 | return result === undefined ? this : result;
|
5248 | };
|
5249 | };
|
5250 |
|
5251 | },{}],35:[function(require,module,exports){
|
5252 |
|
5253 |
|
5254 |
|
5255 |
|
5256 |
|
5257 |
|
5258 |
|
5259 |
|
5260 |
|
5261 |
|
5262 |
|
5263 |
|
5264 |
|
5265 |
|
5266 |
|
5267 |
|
5268 |
|
5269 |
|
5270 |
|
5271 |
|
5272 |
|
5273 |
|
5274 |
|
5275 |
|
5276 |
|
5277 |
|
5278 |
|
5279 |
|
5280 |
|
5281 |
|
5282 |
|
5283 |
|
5284 |
|
5285 |
|
5286 |
|
5287 |
|
5288 |
|
5289 |
|
5290 | module.exports = function (ctx, name, getter) {
|
5291 | var _get = Object.getOwnPropertyDescriptor(ctx, name), _super = function () { };
|
5292 | if (_get && 'function' === typeof _get.get)
|
5293 | _super = _get.get;
|
5294 | Object.defineProperty(ctx, name, { get: function () {
|
5295 | var result = getter(_super).call(this);
|
5296 | return result === undefined ? this : result;
|
5297 | },
|
5298 | configurable: true
|
5299 | });
|
5300 | };
|
5301 |
|
5302 | },{}],36:[function(require,module,exports){
|
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 |
|
5310 |
|
5311 | var flag = require('./flag');
|
5312 |
|
5313 |
|
5314 |
|
5315 |
|
5316 |
|
5317 |
|
5318 |
|
5319 |
|
5320 |
|
5321 |
|
5322 | module.exports = function (obj, args) {
|
5323 | var negate = flag(obj, 'negate'), expr = args[0];
|
5324 | return negate ? !expr : expr;
|
5325 | };
|
5326 |
|
5327 | },{"./flag":21}],37:[function(require,module,exports){
|
5328 |
|
5329 |
|
5330 |
|
5331 |
|
5332 |
|
5333 |
|
5334 |
|
5335 |
|
5336 |
|
5337 |
|
5338 |
|
5339 |
|
5340 |
|
5341 |
|
5342 |
|
5343 |
|
5344 |
|
5345 |
|
5346 |
|
5347 |
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 |
|
5355 | module.exports = function (assertion, object, includeAll) {
|
5356 | var flags = assertion.__flags || (assertion.__flags = Object.create(null));
|
5357 | if (!object.__flags) {
|
5358 | object.__flags = Object.create(null);
|
5359 | }
|
5360 | includeAll = arguments.length === 3 ? includeAll : true;
|
5361 | for (var flag in flags) {
|
5362 | if (includeAll ||
|
5363 | (flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
|
5364 | object.__flags[flag] = flags[flag];
|
5365 | }
|
5366 | }
|
5367 | };
|
5368 |
|
5369 | },{}],38:[function(require,module,exports){
|
5370 | module.exports = require('./lib/eql');
|
5371 |
|
5372 | },{"./lib/eql":39}],39:[function(require,module,exports){
|
5373 |
|
5374 |
|
5375 |
|
5376 |
|
5377 |
|
5378 |
|
5379 |
|
5380 |
|
5381 | var type = require('type-detect');
|
5382 |
|
5383 |
|
5384 |
|
5385 | var Buffer;
|
5386 | try {
|
5387 | Buffer = require('buffer').Buffer;
|
5388 | }
|
5389 | catch (ex) {
|
5390 | Buffer = {};
|
5391 | Buffer.isBuffer = function () { return false; };
|
5392 | }
|
5393 |
|
5394 |
|
5395 |
|
5396 | module.exports = deepEqual;
|
5397 |
|
5398 |
|
5399 |
|
5400 |
|
5401 |
|
5402 |
|
5403 |
|
5404 |
|
5405 |
|
5406 | function deepEqual(a, b, m) {
|
5407 | if (sameValue(a, b)) {
|
5408 | return true;
|
5409 | }
|
5410 | else if ('date' === type(a)) {
|
5411 | return dateEqual(a, b);
|
5412 | }
|
5413 | else if ('regexp' === type(a)) {
|
5414 | return regexpEqual(a, b);
|
5415 | }
|
5416 | else if (Buffer.isBuffer(a)) {
|
5417 | return bufferEqual(a, b);
|
5418 | }
|
5419 | else if ('arguments' === type(a)) {
|
5420 | return argumentsEqual(a, b, m);
|
5421 | }
|
5422 | else if (!typeEqual(a, b)) {
|
5423 | return false;
|
5424 | }
|
5425 | else if (('object' !== type(a) && 'object' !== type(b))
|
5426 | && ('array' !== type(a) && 'array' !== type(b))) {
|
5427 | return sameValue(a, b);
|
5428 | }
|
5429 | else {
|
5430 | return objectEqual(a, b, m);
|
5431 | }
|
5432 | }
|
5433 |
|
5434 |
|
5435 |
|
5436 |
|
5437 |
|
5438 |
|
5439 |
|
5440 |
|
5441 | function sameValue(a, b) {
|
5442 | if (a === b)
|
5443 | return a !== 0 || 1 / a === 1 / b;
|
5444 | return a !== a && b !== b;
|
5445 | }
|
5446 |
|
5447 |
|
5448 |
|
5449 |
|
5450 |
|
5451 |
|
5452 |
|
5453 |
|
5454 |
|
5455 |
|
5456 | function typeEqual(a, b) {
|
5457 | return type(a) === type(b);
|
5458 | }
|
5459 |
|
5460 |
|
5461 |
|
5462 |
|
5463 |
|
5464 |
|
5465 |
|
5466 |
|
5467 | function dateEqual(a, b) {
|
5468 | if ('date' !== type(b))
|
5469 | return false;
|
5470 | return sameValue(a.getTime(), b.getTime());
|
5471 | }
|
5472 |
|
5473 |
|
5474 |
|
5475 |
|
5476 |
|
5477 |
|
5478 |
|
5479 |
|
5480 | function regexpEqual(a, b) {
|
5481 | if ('regexp' !== type(b))
|
5482 | return false;
|
5483 | return sameValue(a.toString(), b.toString());
|
5484 | }
|
5485 |
|
5486 |
|
5487 |
|
5488 |
|
5489 |
|
5490 |
|
5491 |
|
5492 |
|
5493 |
|
5494 |
|
5495 | function argumentsEqual(a, b, m) {
|
5496 | if ('arguments' !== type(b))
|
5497 | return false;
|
5498 | a = [].slice.call(a);
|
5499 | b = [].slice.call(b);
|
5500 | return deepEqual(a, b, m);
|
5501 | }
|
5502 |
|
5503 |
|
5504 |
|
5505 |
|
5506 |
|
5507 |
|
5508 | function enumerable(a) {
|
5509 | var res = [];
|
5510 | for (var key in a)
|
5511 | res.push(key);
|
5512 | return res;
|
5513 | }
|
5514 |
|
5515 |
|
5516 |
|
5517 |
|
5518 |
|
5519 |
|
5520 |
|
5521 |
|
5522 | function iterableEqual(a, b) {
|
5523 | if (a.length !== b.length)
|
5524 | return false;
|
5525 | var i = 0;
|
5526 | var match = true;
|
5527 | for (; i < a.length; i++) {
|
5528 | if (a[i] !== b[i]) {
|
5529 | match = false;
|
5530 | break;
|
5531 | }
|
5532 | }
|
5533 | return match;
|
5534 | }
|
5535 |
|
5536 |
|
5537 |
|
5538 |
|
5539 |
|
5540 |
|
5541 |
|
5542 |
|
5543 | function bufferEqual(a, b) {
|
5544 | if (!Buffer.isBuffer(b))
|
5545 | return false;
|
5546 | return iterableEqual(a, b);
|
5547 | }
|
5548 |
|
5549 |
|
5550 |
|
5551 |
|
5552 |
|
5553 |
|
5554 |
|
5555 | function isValue(a) {
|
5556 | return a !== null && a !== undefined;
|
5557 | }
|
5558 |
|
5559 |
|
5560 |
|
5561 |
|
5562 |
|
5563 |
|
5564 |
|
5565 |
|
5566 |
|
5567 |
|
5568 | function objectEqual(a, b, m) {
|
5569 | if (!isValue(a) || !isValue(b)) {
|
5570 | return false;
|
5571 | }
|
5572 | if (a.prototype !== b.prototype) {
|
5573 | return false;
|
5574 | }
|
5575 | var i;
|
5576 | if (m) {
|
5577 | for (i = 0; i < m.length; i++) {
|
5578 | if ((m[i][0] === a && m[i][1] === b)
|
5579 | || (m[i][0] === b && m[i][1] === a)) {
|
5580 | return true;
|
5581 | }
|
5582 | }
|
5583 | }
|
5584 | else {
|
5585 | m = [];
|
5586 | }
|
5587 | try {
|
5588 | var ka = enumerable(a);
|
5589 | var kb = enumerable(b);
|
5590 | }
|
5591 | catch (ex) {
|
5592 | return false;
|
5593 | }
|
5594 | ka.sort();
|
5595 | kb.sort();
|
5596 | if (!iterableEqual(ka, kb)) {
|
5597 | return false;
|
5598 | }
|
5599 | m.push([a, b]);
|
5600 | var key;
|
5601 | for (i = ka.length - 1; i >= 0; i--) {
|
5602 | key = ka[i];
|
5603 | if (!deepEqual(a[key], b[key], m)) {
|
5604 | return false;
|
5605 | }
|
5606 | }
|
5607 | return true;
|
5608 | }
|
5609 |
|
5610 | },{"buffer":63,"type-detect":40}],40:[function(require,module,exports){
|
5611 | module.exports = require('./lib/type');
|
5612 |
|
5613 | },{"./lib/type":41}],41:[function(require,module,exports){
|
5614 |
|
5615 |
|
5616 |
|
5617 |
|
5618 |
|
5619 |
|
5620 |
|
5621 |
|
5622 |
|
5623 |
|
5624 | var exports = module.exports = getType;
|
5625 |
|
5626 |
|
5627 |
|
5628 |
|
5629 |
|
5630 | var natives = {
|
5631 | '[object Array]': 'array'
|
5632 | , '[object RegExp]': 'regexp'
|
5633 | , '[object Function]': 'function'
|
5634 | , '[object Arguments]': 'arguments'
|
5635 | , '[object Date]': 'date'
|
5636 | };
|
5637 |
|
5638 |
|
5639 |
|
5640 |
|
5641 |
|
5642 |
|
5643 |
|
5644 |
|
5645 |
|
5646 |
|
5647 |
|
5648 |
|
5649 |
|
5650 | function getType (obj) {
|
5651 | var str = Object.prototype.toString.call(obj);
|
5652 | if (natives[str]) return natives[str];
|
5653 | if (obj === null) return 'null';
|
5654 | if (obj === undefined) return 'undefined';
|
5655 | if (obj === Object(obj)) return 'object';
|
5656 | return typeof obj;
|
5657 | }
|
5658 |
|
5659 | exports.Library = Library;
|
5660 |
|
5661 |
|
5662 |
|
5663 |
|
5664 |
|
5665 |
|
5666 |
|
5667 |
|
5668 |
|
5669 |
|
5670 |
|
5671 |
|
5672 | function Library () {
|
5673 | this.tests = {};
|
5674 | }
|
5675 |
|
5676 |
|
5677 |
|
5678 |
|
5679 |
|
5680 |
|
5681 |
|
5682 |
|
5683 |
|
5684 |
|
5685 |
|
5686 |
|
5687 |
|
5688 |
|
5689 |
|
5690 |
|
5691 | Library.prototype.of = getType;
|
5692 |
|
5693 |
|
5694 |
|
5695 |
|
5696 |
|
5697 |
|
5698 |
|
5699 |
|
5700 |
|
5701 |
|
5702 |
|
5703 |
|
5704 |
|
5705 |
|
5706 |
|
5707 |
|
5708 |
|
5709 |
|
5710 |
|
5711 |
|
5712 |
|
5713 |
|
5714 |
|
5715 |
|
5716 |
|
5717 |
|
5718 |
|
5719 |
|
5720 | Library.prototype.define = function (type, test) {
|
5721 | if (arguments.length === 1) return this.tests[type];
|
5722 | this.tests[type] = test;
|
5723 | return this;
|
5724 | };
|
5725 |
|
5726 |
|
5727 |
|
5728 |
|
5729 |
|
5730 |
|
5731 |
|
5732 |
|
5733 |
|
5734 |
|
5735 |
|
5736 |
|
5737 |
|
5738 |
|
5739 |
|
5740 |
|
5741 |
|
5742 |
|
5743 |
|
5744 | Library.prototype.test = function (obj, type) {
|
5745 | if (type === getType(obj)) return true;
|
5746 | var test = this.tests[type];
|
5747 |
|
5748 | if (test && 'regexp' === getType(test)) {
|
5749 | return test.test(obj);
|
5750 | } else if (test && 'function' === getType(test)) {
|
5751 | return test(obj);
|
5752 | } else {
|
5753 | throw new ReferenceError('Type test "' + type + '" not defined or invalid.');
|
5754 | }
|
5755 | };
|
5756 |
|
5757 | },{}],42:[function(require,module,exports){
|
5758 | 'use strict';
|
5759 |
|
5760 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
5761 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
5762 | function toObject(val) {
|
5763 | if (val === null || val === undefined) {
|
5764 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
5765 | }
|
5766 | return Object(val);
|
5767 | }
|
5768 | function shouldUseNative() {
|
5769 | try {
|
5770 | if (!Object.assign) {
|
5771 | return false;
|
5772 | }
|
5773 |
|
5774 |
|
5775 | var test1 = new String('abc');
|
5776 | test1[5] = 'de';
|
5777 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
5778 | return false;
|
5779 | }
|
5780 |
|
5781 | var test2 = {};
|
5782 | for (var i = 0; i < 10; i++) {
|
5783 | test2['_' + String.fromCharCode(i)] = i;
|
5784 | }
|
5785 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
5786 | return test2[n];
|
5787 | });
|
5788 | if (order2.join('') !== '0123456789') {
|
5789 | return false;
|
5790 | }
|
5791 |
|
5792 | var test3 = {};
|
5793 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
5794 | test3[letter] = letter;
|
5795 | });
|
5796 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
5797 | 'abcdefghijklmnopqrst') {
|
5798 | return false;
|
5799 | }
|
5800 | return true;
|
5801 | }
|
5802 | catch (e) {
|
5803 |
|
5804 | return false;
|
5805 | }
|
5806 | }
|
5807 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
5808 | var from;
|
5809 | var to = toObject(target);
|
5810 | var symbols;
|
5811 | for (var s = 1; s < arguments.length; s++) {
|
5812 | from = Object(arguments[s]);
|
5813 | for (var key in from) {
|
5814 | if (hasOwnProperty.call(from, key)) {
|
5815 | to[key] = from[key];
|
5816 | }
|
5817 | }
|
5818 | if (Object.getOwnPropertySymbols) {
|
5819 | symbols = Object.getOwnPropertySymbols(from);
|
5820 | for (var i = 0; i < symbols.length; i++) {
|
5821 | if (propIsEnumerable.call(from, symbols[i])) {
|
5822 | to[symbols[i]] = from[symbols[i]];
|
5823 | }
|
5824 | }
|
5825 | }
|
5826 | }
|
5827 | return to;
|
5828 | };
|
5829 |
|
5830 | },{}],43:[function(require,module,exports){
|
5831 |
|
5832 |
|
5833 |
|
5834 |
|
5835 |
|
5836 | exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
|
5837 | exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
|
5838 | exports.SourceNode = require('./source-map/source-node').SourceNode;
|
5839 |
|
5840 | },{"./source-map/source-map-consumer":48,"./source-map/source-map-generator":49,"./source-map/source-node":50}],44:[function(require,module,exports){
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 | if (typeof define !== 'function') {
|
5848 | var define = require('amdefine')(module, require);
|
5849 | }
|
5850 | define(function (require, exports, module) {
|
5851 |
|
5852 | var util = require('./util');
|
5853 |
|
5854 | |
5855 |
|
5856 |
|
5857 |
|
5858 |
|
5859 |
|
5860 | function ArraySet() {
|
5861 | this._array = [];
|
5862 | this._set = {};
|
5863 | }
|
5864 |
|
5865 | |
5866 |
|
5867 |
|
5868 | ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
5869 | var set = new ArraySet();
|
5870 | for (var i = 0, len = aArray.length; i < len; i++) {
|
5871 | set.add(aArray[i], aAllowDuplicates);
|
5872 | }
|
5873 | return set;
|
5874 | };
|
5875 |
|
5876 | /**
|
5877 | * Add the given string to this set.
|
5878 | *
|
5879 | * @param String aStr
|
5880 | */
|
5881 | ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
5882 | var isDuplicate = this.has(aStr);
|
5883 | var idx = this._array.length;
|
5884 | if (!isDuplicate || aAllowDuplicates) {
|
5885 | this._array.push(aStr);
|
5886 | }
|
5887 | if (!isDuplicate) {
|
5888 | this._set[util.toSetString(aStr)] = idx;
|
5889 | }
|
5890 | };
|
5891 |
|
5892 | |
5893 |
|
5894 |
|
5895 |
|
5896 |
|
5897 | ArraySet.prototype.has = function ArraySet_has(aStr) {
|
5898 | return Object.prototype.hasOwnProperty.call(this._set,
|
5899 | util.toSetString(aStr));
|
5900 | };
|
5901 |
|
5902 | |
5903 |
|
5904 |
|
5905 |
|
5906 |
|
5907 | ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
5908 | if (this.has(aStr)) {
|
5909 | return this._set[util.toSetString(aStr)];
|
5910 | }
|
5911 | throw new Error('"' + aStr + '" is not in the set.');
|
5912 | };
|
5913 |
|
5914 | |
5915 |
|
5916 |
|
5917 |
|
5918 |
|
5919 | ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
5920 | if (aIdx >= 0 && aIdx < this._array.length) {
|
5921 | return this._array[aIdx];
|
5922 | }
|
5923 | throw new Error('No element indexed by ' + aIdx);
|
5924 | };
|
5925 |
|
5926 | |
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 | ArraySet.prototype.toArray = function ArraySet_toArray() {
|
5932 | return this._array.slice();
|
5933 | };
|
5934 |
|
5935 | exports.ArraySet = ArraySet;
|
5936 |
|
5937 | });
|
5938 |
|
5939 | },{"./util":51,"amdefine":7}],45:[function(require,module,exports){
|
5940 |
|
5941 |
|
5942 |
|
5943 |
|
5944 |
|
5945 |
|
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 |
|
5951 |
|
5952 |
|
5953 |
|
5954 |
|
5955 |
|
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 |
|
5961 |
|
5962 |
|
5963 |
|
5964 |
|
5965 |
|
5966 |
|
5967 |
|
5968 |
|
5969 |
|
5970 |
|
5971 |
|
5972 |
|
5973 |
|
5974 |
|
5975 |
|
5976 | if (typeof define !== 'function') {
|
5977 | var define = require('amdefine')(module, require);
|
5978 | }
|
5979 | define(function (require, exports, module) {
|
5980 |
|
5981 | var base64 = require('./base64');
|
5982 |
|
5983 |
|
5984 |
|
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 |
|
5992 |
|
5993 |
|
5994 |
|
5995 | var VLQ_BASE_SHIFT = 5;
|
5996 |
|
5997 |
|
5998 | var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
5999 |
|
6000 |
|
6001 | var VLQ_BASE_MASK = VLQ_BASE - 1;
|
6002 |
|
6003 |
|
6004 | var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
6005 |
|
6006 | |
6007 |
|
6008 |
|
6009 |
|
6010 |
|
6011 |
|
6012 | function toVLQSigned(aValue) {
|
6013 | return aValue < 0
|
6014 | ? ((-aValue) << 1) + 1
|
6015 | : (aValue << 1) + 0;
|
6016 | }
|
6017 |
|
6018 | |
6019 |
|
6020 |
|
6021 |
|
6022 |
|
6023 |
|
6024 | function fromVLQSigned(aValue) {
|
6025 | var isNegative = (aValue & 1) === 1;
|
6026 | var shifted = aValue >> 1;
|
6027 | return isNegative
|
6028 | ? -shifted
|
6029 | : shifted;
|
6030 | }
|
6031 |
|
6032 | |
6033 |
|
6034 |
|
6035 | exports.encode = function base64VLQ_encode(aValue) {
|
6036 | var encoded = "";
|
6037 | var digit;
|
6038 |
|
6039 | var vlq = toVLQSigned(aValue);
|
6040 |
|
6041 | do {
|
6042 | digit = vlq & VLQ_BASE_MASK;
|
6043 | vlq >>>= VLQ_BASE_SHIFT;
|
6044 | if (vlq > 0) {
|
6045 |
|
6046 |
|
6047 | digit |= VLQ_CONTINUATION_BIT;
|
6048 | }
|
6049 | encoded += base64.encode(digit);
|
6050 | } while (vlq > 0);
|
6051 |
|
6052 | return encoded;
|
6053 | };
|
6054 |
|
6055 | |
6056 |
|
6057 |
|
6058 |
|
6059 | exports.decode = function base64VLQ_decode(aStr) {
|
6060 | var i = 0;
|
6061 | var strLen = aStr.length;
|
6062 | var result = 0;
|
6063 | var shift = 0;
|
6064 | var continuation, digit;
|
6065 |
|
6066 | do {
|
6067 | if (i >= strLen) {
|
6068 | throw new Error("Expected more digits in base 64 VLQ value.");
|
6069 | }
|
6070 | digit = base64.decode(aStr.charAt(i++));
|
6071 | continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
6072 | digit &= VLQ_BASE_MASK;
|
6073 | result = result + (digit << shift);
|
6074 | shift += VLQ_BASE_SHIFT;
|
6075 | } while (continuation);
|
6076 |
|
6077 | return {
|
6078 | value: fromVLQSigned(result),
|
6079 | rest: aStr.slice(i)
|
6080 | };
|
6081 | };
|
6082 |
|
6083 | });
|
6084 |
|
6085 | },{"./base64":46,"amdefine":7}],46:[function(require,module,exports){
|
6086 |
|
6087 |
|
6088 |
|
6089 |
|
6090 |
|
6091 |
|
6092 | if (typeof define !== 'function') {
|
6093 | var define = require('amdefine')(module, require);
|
6094 | }
|
6095 | define(function (require, exports, module) {
|
6096 |
|
6097 | var charToIntMap = {};
|
6098 | var intToCharMap = {};
|
6099 |
|
6100 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
6101 | .split('')
|
6102 | .forEach(function (ch, index) {
|
6103 | charToIntMap[ch] = index;
|
6104 | intToCharMap[index] = ch;
|
6105 | });
|
6106 |
|
6107 | |
6108 |
|
6109 |
|
6110 | exports.encode = function base64_encode(aNumber) {
|
6111 | if (aNumber in intToCharMap) {
|
6112 | return intToCharMap[aNumber];
|
6113 | }
|
6114 | throw new TypeError("Must be between 0 and 63: " + aNumber);
|
6115 | };
|
6116 |
|
6117 | |
6118 |
|
6119 |
|
6120 | exports.decode = function base64_decode(aChar) {
|
6121 | if (aChar in charToIntMap) {
|
6122 | return charToIntMap[aChar];
|
6123 | }
|
6124 | throw new TypeError("Not a valid base 64 digit: " + aChar);
|
6125 | };
|
6126 |
|
6127 | });
|
6128 |
|
6129 | },{"amdefine":7}],47:[function(require,module,exports){
|
6130 |
|
6131 |
|
6132 |
|
6133 |
|
6134 |
|
6135 |
|
6136 | if (typeof define !== 'function') {
|
6137 | var define = require('amdefine')(module, require);
|
6138 | }
|
6139 | define(function (require, exports, module) {
|
6140 |
|
6141 | |
6142 |
|
6143 |
|
6144 |
|
6145 |
|
6146 |
|
6147 |
|
6148 |
|
6149 |
|
6150 | function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
|
6151 |
|
6152 |
|
6153 |
|
6154 |
|
6155 |
|
6156 |
|
6157 |
|
6158 |
|
6159 |
|
6160 |
|
6161 | var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
6162 | var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
6163 | if (cmp === 0) {
|
6164 |
|
6165 | return aHaystack[mid];
|
6166 | }
|
6167 | else if (cmp > 0) {
|
6168 |
|
6169 | if (aHigh - mid > 1) {
|
6170 |
|
6171 | return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
|
6172 | }
|
6173 |
|
6174 |
|
6175 | return aHaystack[mid];
|
6176 | }
|
6177 | else {
|
6178 |
|
6179 | if (mid - aLow > 1) {
|
6180 |
|
6181 | return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
|
6182 | }
|
6183 |
|
6184 |
|
6185 | return aLow < 0
|
6186 | ? null
|
6187 | : aHaystack[aLow];
|
6188 | }
|
6189 | }
|
6190 |
|
6191 | |
6192 |
|
6193 |
|
6194 |
|
6195 |
|
6196 |
|
6197 |
|
6198 |
|
6199 |
|
6200 |
|
6201 |
|
6202 |
|
6203 |
|
6204 | exports.search = function search(aNeedle, aHaystack, aCompare) {
|
6205 | return aHaystack.length > 0
|
6206 | ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
|
6207 | : null;
|
6208 | };
|
6209 |
|
6210 | });
|
6211 |
|
6212 | },{"amdefine":7}],48:[function(require,module,exports){
|
6213 |
|
6214 |
|
6215 |
|
6216 |
|
6217 |
|
6218 |
|
6219 | if (typeof define !== 'function') {
|
6220 | var define = require('amdefine')(module, require);
|
6221 | }
|
6222 | define(function (require, exports, module) {
|
6223 |
|
6224 | var util = require('./util');
|
6225 | var binarySearch = require('./binary-search');
|
6226 | var ArraySet = require('./array-set').ArraySet;
|
6227 | var base64VLQ = require('./base64-vlq');
|
6228 |
|
6229 | |
6230 |
|
6231 |
|
6232 |
|
6233 |
|
6234 |
|
6235 |
|
6236 |
|
6237 |
|
6238 |
|
6239 |
|
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 |
|
6246 |
|
6247 |
|
6248 |
|
6249 |
|
6250 |
|
6251 |
|
6252 |
|
6253 |
|
6254 |
|
6255 |
|
6256 |
|
6257 |
|
6258 |
|
6259 | function SourceMapConsumer(aSourceMap) {
|
6260 | var sourceMap = aSourceMap;
|
6261 | if (typeof aSourceMap === 'string') {
|
6262 | sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
6263 | }
|
6264 |
|
6265 | var version = util.getArg(sourceMap, 'version');
|
6266 | var sources = util.getArg(sourceMap, 'sources');
|
6267 |
|
6268 |
|
6269 | var names = util.getArg(sourceMap, 'names', []);
|
6270 | var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
|
6271 | var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
|
6272 | var mappings = util.getArg(sourceMap, 'mappings');
|
6273 | var file = util.getArg(sourceMap, 'file', null);
|
6274 |
|
6275 |
|
6276 |
|
6277 | if (version != this._version) {
|
6278 | throw new Error('Unsupported version: ' + version);
|
6279 | }
|
6280 |
|
6281 |
|
6282 |
|
6283 |
|
6284 |
|
6285 | this._names = ArraySet.fromArray(names, true);
|
6286 | this._sources = ArraySet.fromArray(sources, true);
|
6287 |
|
6288 | this.sourceRoot = sourceRoot;
|
6289 | this.sourcesContent = sourcesContent;
|
6290 | this._mappings = mappings;
|
6291 | this.file = file;
|
6292 | }
|
6293 |
|
6294 | |
6295 |
|
6296 |
|
6297 |
|
6298 |
|
6299 |
|
6300 |
|
6301 | SourceMapConsumer.fromSourceMap =
|
6302 | function SourceMapConsumer_fromSourceMap(aSourceMap) {
|
6303 | var smc = Object.create(SourceMapConsumer.prototype);
|
6304 |
|
6305 | smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
|
6306 | smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
|
6307 | smc.sourceRoot = aSourceMap._sourceRoot;
|
6308 | smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
|
6309 | smc.sourceRoot);
|
6310 | smc.file = aSourceMap._file;
|
6311 |
|
6312 | smc.__generatedMappings = aSourceMap._mappings.slice()
|
6313 | .sort(util.compareByGeneratedPositions);
|
6314 | smc.__originalMappings = aSourceMap._mappings.slice()
|
6315 | .sort(util.compareByOriginalPositions);
|
6316 |
|
6317 | return smc;
|
6318 | };
|
6319 |
|
6320 | |
6321 |
|
6322 |
|
6323 | SourceMapConsumer.prototype._version = 3;
|
6324 |
|
6325 | |
6326 |
|
6327 |
|
6328 | Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
|
6329 | get: function () {
|
6330 | return this._sources.toArray().map(function (s) {
|
6331 | return this.sourceRoot ? util.join(this.sourceRoot, s) : s;
|
6332 | }, this);
|
6333 | }
|
6334 | });
|
6335 |
|
6336 |
|
6337 |
|
6338 |
|
6339 |
|
6340 |
|
6341 |
|
6342 |
|
6343 |
|
6344 |
|
6345 |
|
6346 |
|
6347 |
|
6348 |
|
6349 |
|
6350 |
|
6351 |
|
6352 |
|
6353 |
|
6354 |
|
6355 |
|
6356 |
|
6357 |
|
6358 |
|
6359 |
|
6360 |
|
6361 |
|
6362 |
|
6363 |
|
6364 |
|
6365 |
|
6366 | SourceMapConsumer.prototype.__generatedMappings = null;
|
6367 | Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
6368 | get: function () {
|
6369 | if (!this.__generatedMappings) {
|
6370 | this.__generatedMappings = [];
|
6371 | this.__originalMappings = [];
|
6372 | this._parseMappings(this._mappings, this.sourceRoot);
|
6373 | }
|
6374 |
|
6375 | return this.__generatedMappings;
|
6376 | }
|
6377 | });
|
6378 |
|
6379 | SourceMapConsumer.prototype.__originalMappings = null;
|
6380 | Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
|
6381 | get: function () {
|
6382 | if (!this.__originalMappings) {
|
6383 | this.__generatedMappings = [];
|
6384 | this.__originalMappings = [];
|
6385 | this._parseMappings(this._mappings, this.sourceRoot);
|
6386 | }
|
6387 |
|
6388 | return this.__originalMappings;
|
6389 | }
|
6390 | });
|
6391 |
|
6392 | |
6393 |
|
6394 |
|
6395 |
|
6396 |
|
6397 | SourceMapConsumer.prototype._parseMappings =
|
6398 | function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
6399 | var generatedLine = 1;
|
6400 | var previousGeneratedColumn = 0;
|
6401 | var previousOriginalLine = 0;
|
6402 | var previousOriginalColumn = 0;
|
6403 | var previousSource = 0;
|
6404 | var previousName = 0;
|
6405 | var mappingSeparator = /^[,;]/;
|
6406 | var str = aStr;
|
6407 | var mapping;
|
6408 | var temp;
|
6409 |
|
6410 | while (str.length > 0) {
|
6411 | if (str.charAt(0) === ';') {
|
6412 | generatedLine++;
|
6413 | str = str.slice(1);
|
6414 | previousGeneratedColumn = 0;
|
6415 | }
|
6416 | else if (str.charAt(0) === ',') {
|
6417 | str = str.slice(1);
|
6418 | }
|
6419 | else {
|
6420 | mapping = {};
|
6421 | mapping.generatedLine = generatedLine;
|
6422 |
|
6423 |
|
6424 | temp = base64VLQ.decode(str);
|
6425 | mapping.generatedColumn = previousGeneratedColumn + temp.value;
|
6426 | previousGeneratedColumn = mapping.generatedColumn;
|
6427 | str = temp.rest;
|
6428 |
|
6429 | if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
|
6430 |
|
6431 | temp = base64VLQ.decode(str);
|
6432 | mapping.source = this._sources.at(previousSource + temp.value);
|
6433 | previousSource += temp.value;
|
6434 | str = temp.rest;
|
6435 | if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
|
6436 | throw new Error('Found a source, but no line and column');
|
6437 | }
|
6438 |
|
6439 |
|
6440 | temp = base64VLQ.decode(str);
|
6441 | mapping.originalLine = previousOriginalLine + temp.value;
|
6442 | previousOriginalLine = mapping.originalLine;
|
6443 |
|
6444 | mapping.originalLine += 1;
|
6445 | str = temp.rest;
|
6446 | if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
|
6447 | throw new Error('Found a source and line, but no column');
|
6448 | }
|
6449 |
|
6450 |
|
6451 | temp = base64VLQ.decode(str);
|
6452 | mapping.originalColumn = previousOriginalColumn + temp.value;
|
6453 | previousOriginalColumn = mapping.originalColumn;
|
6454 | str = temp.rest;
|
6455 |
|
6456 | if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
|
6457 |
|
6458 | temp = base64VLQ.decode(str);
|
6459 | mapping.name = this._names.at(previousName + temp.value);
|
6460 | previousName += temp.value;
|
6461 | str = temp.rest;
|
6462 | }
|
6463 | }
|
6464 |
|
6465 | this.__generatedMappings.push(mapping);
|
6466 | if (typeof mapping.originalLine === 'number') {
|
6467 | this.__originalMappings.push(mapping);
|
6468 | }
|
6469 | }
|
6470 | }
|
6471 |
|
6472 | this.__generatedMappings.sort(util.compareByGeneratedPositions);
|
6473 | this.__originalMappings.sort(util.compareByOriginalPositions);
|
6474 | };
|
6475 |
|
6476 | |
6477 |
|
6478 |
|
6479 |
|
6480 | SourceMapConsumer.prototype._findMapping =
|
6481 | function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
|
6482 | aColumnName, aComparator) {
|
6483 |
|
6484 |
|
6485 |
|
6486 |
|
6487 |
|
6488 | if (aNeedle[aLineName] <= 0) {
|
6489 | throw new TypeError('Line must be greater than or equal to 1, got '
|
6490 | + aNeedle[aLineName]);
|
6491 | }
|
6492 | if (aNeedle[aColumnName] < 0) {
|
6493 | throw new TypeError('Column must be greater than or equal to 0, got '
|
6494 | + aNeedle[aColumnName]);
|
6495 | }
|
6496 |
|
6497 | return binarySearch.search(aNeedle, aMappings, aComparator);
|
6498 | };
|
6499 |
|
6500 | |
6501 |
|
6502 |
|
6503 |
|
6504 |
|
6505 |
|
6506 |
|
6507 |
|
6508 |
|
6509 |
|
6510 |
|
6511 |
|
6512 |
|
6513 |
|
6514 |
|
6515 | SourceMapConsumer.prototype.originalPositionFor =
|
6516 | function SourceMapConsumer_originalPositionFor(aArgs) {
|
6517 | var needle = {
|
6518 | generatedLine: util.getArg(aArgs, 'line'),
|
6519 | generatedColumn: util.getArg(aArgs, 'column')
|
6520 | };
|
6521 |
|
6522 | var mapping = this._findMapping(needle,
|
6523 | this._generatedMappings,
|
6524 | "generatedLine",
|
6525 | "generatedColumn",
|
6526 | util.compareByGeneratedPositions);
|
6527 |
|
6528 | if (mapping) {
|
6529 | var source = util.getArg(mapping, 'source', null);
|
6530 | if (source && this.sourceRoot) {
|
6531 | source = util.join(this.sourceRoot, source);
|
6532 | }
|
6533 | return {
|
6534 | source: source,
|
6535 | line: util.getArg(mapping, 'originalLine', null),
|
6536 | column: util.getArg(mapping, 'originalColumn', null),
|
6537 | name: util.getArg(mapping, 'name', null)
|
6538 | };
|
6539 | }
|
6540 |
|
6541 | return {
|
6542 | source: null,
|
6543 | line: null,
|
6544 | column: null,
|
6545 | name: null
|
6546 | };
|
6547 | };
|
6548 |
|
6549 | |
6550 |
|
6551 |
|
6552 |
|
6553 |
|
6554 | SourceMapConsumer.prototype.sourceContentFor =
|
6555 | function SourceMapConsumer_sourceContentFor(aSource) {
|
6556 | if (!this.sourcesContent) {
|
6557 | return null;
|
6558 | }
|
6559 |
|
6560 | if (this.sourceRoot) {
|
6561 | aSource = util.relative(this.sourceRoot, aSource);
|
6562 | }
|
6563 |
|
6564 | if (this._sources.has(aSource)) {
|
6565 | return this.sourcesContent[this._sources.indexOf(aSource)];
|
6566 | }
|
6567 |
|
6568 | var url;
|
6569 | if (this.sourceRoot
|
6570 | && (url = util.urlParse(this.sourceRoot))) {
|
6571 |
|
6572 |
|
6573 |
|
6574 |
|
6575 | var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
|
6576 | if (url.scheme == "file"
|
6577 | && this._sources.has(fileUriAbsPath)) {
|
6578 | return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
6579 | }
|
6580 |
|
6581 | if ((!url.path || url.path == "/")
|
6582 | && this._sources.has("/" + aSource)) {
|
6583 | return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
6584 | }
|
6585 | }
|
6586 |
|
6587 | throw new Error('"' + aSource + '" is not in the SourceMap.');
|
6588 | };
|
6589 |
|
6590 | |
6591 |
|
6592 |
|
6593 |
|
6594 |
|
6595 |
|
6596 |
|
6597 |
|
6598 |
|
6599 |
|
6600 |
|
6601 |
|
6602 |
|
6603 |
|
6604 | SourceMapConsumer.prototype.generatedPositionFor =
|
6605 | function SourceMapConsumer_generatedPositionFor(aArgs) {
|
6606 | var needle = {
|
6607 | source: util.getArg(aArgs, 'source'),
|
6608 | originalLine: util.getArg(aArgs, 'line'),
|
6609 | originalColumn: util.getArg(aArgs, 'column')
|
6610 | };
|
6611 |
|
6612 | if (this.sourceRoot) {
|
6613 | needle.source = util.relative(this.sourceRoot, needle.source);
|
6614 | }
|
6615 |
|
6616 | var mapping = this._findMapping(needle,
|
6617 | this._originalMappings,
|
6618 | "originalLine",
|
6619 | "originalColumn",
|
6620 | util.compareByOriginalPositions);
|
6621 |
|
6622 | if (mapping) {
|
6623 | return {
|
6624 | line: util.getArg(mapping, 'generatedLine', null),
|
6625 | column: util.getArg(mapping, 'generatedColumn', null)
|
6626 | };
|
6627 | }
|
6628 |
|
6629 | return {
|
6630 | line: null,
|
6631 | column: null
|
6632 | };
|
6633 | };
|
6634 |
|
6635 | SourceMapConsumer.GENERATED_ORDER = 1;
|
6636 | SourceMapConsumer.ORIGINAL_ORDER = 2;
|
6637 |
|
6638 | |
6639 |
|
6640 |
|
6641 |
|
6642 |
|
6643 |
|
6644 |
|
6645 |
|
6646 |
|
6647 |
|
6648 |
|
6649 |
|
6650 |
|
6651 |
|
6652 |
|
6653 |
|
6654 | SourceMapConsumer.prototype.eachMapping =
|
6655 | function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
|
6656 | var context = aContext || null;
|
6657 | var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
|
6658 |
|
6659 | var mappings;
|
6660 | switch (order) {
|
6661 | case SourceMapConsumer.GENERATED_ORDER:
|
6662 | mappings = this._generatedMappings;
|
6663 | break;
|
6664 | case SourceMapConsumer.ORIGINAL_ORDER:
|
6665 | mappings = this._originalMappings;
|
6666 | break;
|
6667 | default:
|
6668 | throw new Error("Unknown order of iteration.");
|
6669 | }
|
6670 |
|
6671 | var sourceRoot = this.sourceRoot;
|
6672 | mappings.map(function (mapping) {
|
6673 | var source = mapping.source;
|
6674 | if (source && sourceRoot) {
|
6675 | source = util.join(sourceRoot, source);
|
6676 | }
|
6677 | return {
|
6678 | source: source,
|
6679 | generatedLine: mapping.generatedLine,
|
6680 | generatedColumn: mapping.generatedColumn,
|
6681 | originalLine: mapping.originalLine,
|
6682 | originalColumn: mapping.originalColumn,
|
6683 | name: mapping.name
|
6684 | };
|
6685 | }).forEach(aCallback, context);
|
6686 | };
|
6687 |
|
6688 | exports.SourceMapConsumer = SourceMapConsumer;
|
6689 |
|
6690 | });
|
6691 |
|
6692 | },{"./array-set":44,"./base64-vlq":45,"./binary-search":47,"./util":51,"amdefine":7}],49:[function(require,module,exports){
|
6693 |
|
6694 |
|
6695 |
|
6696 |
|
6697 |
|
6698 |
|
6699 | if (typeof define !== 'function') {
|
6700 | var define = require('amdefine')(module, require);
|
6701 | }
|
6702 | define(function (require, exports, module) {
|
6703 |
|
6704 | var base64VLQ = require('./base64-vlq');
|
6705 | var util = require('./util');
|
6706 | var ArraySet = require('./array-set').ArraySet;
|
6707 |
|
6708 | |
6709 |
|
6710 |
|
6711 |
|
6712 |
|
6713 |
|
6714 |
|
6715 |
|
6716 | function SourceMapGenerator(aArgs) {
|
6717 | this._file = util.getArg(aArgs, 'file');
|
6718 | this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
6719 | this._sources = new ArraySet();
|
6720 | this._names = new ArraySet();
|
6721 | this._mappings = [];
|
6722 | this._sourcesContents = null;
|
6723 | }
|
6724 |
|
6725 | SourceMapGenerator.prototype._version = 3;
|
6726 |
|
6727 | |
6728 |
|
6729 |
|
6730 |
|
6731 |
|
6732 | SourceMapGenerator.fromSourceMap =
|
6733 | function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
6734 | var sourceRoot = aSourceMapConsumer.sourceRoot;
|
6735 | var generator = new SourceMapGenerator({
|
6736 | file: aSourceMapConsumer.file,
|
6737 | sourceRoot: sourceRoot
|
6738 | });
|
6739 | aSourceMapConsumer.eachMapping(function (mapping) {
|
6740 | var newMapping = {
|
6741 | generated: {
|
6742 | line: mapping.generatedLine,
|
6743 | column: mapping.generatedColumn
|
6744 | }
|
6745 | };
|
6746 |
|
6747 | if (mapping.source) {
|
6748 | newMapping.source = mapping.source;
|
6749 | if (sourceRoot) {
|
6750 | newMapping.source = util.relative(sourceRoot, newMapping.source);
|
6751 | }
|
6752 |
|
6753 | newMapping.original = {
|
6754 | line: mapping.originalLine,
|
6755 | column: mapping.originalColumn
|
6756 | };
|
6757 |
|
6758 | if (mapping.name) {
|
6759 | newMapping.name = mapping.name;
|
6760 | }
|
6761 | }
|
6762 |
|
6763 | generator.addMapping(newMapping);
|
6764 | });
|
6765 | aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
6766 | var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
6767 | if (content) {
|
6768 | generator.setSourceContent(sourceFile, content);
|
6769 | }
|
6770 | });
|
6771 | return generator;
|
6772 | };
|
6773 |
|
6774 | |
6775 |
|
6776 |
|
6777 |
|
6778 |
|
6779 |
|
6780 |
|
6781 |
|
6782 |
|
6783 |
|
6784 | SourceMapGenerator.prototype.addMapping =
|
6785 | function SourceMapGenerator_addMapping(aArgs) {
|
6786 | var generated = util.getArg(aArgs, 'generated');
|
6787 | var original = util.getArg(aArgs, 'original', null);
|
6788 | var source = util.getArg(aArgs, 'source', null);
|
6789 | var name = util.getArg(aArgs, 'name', null);
|
6790 |
|
6791 | this._validateMapping(generated, original, source, name);
|
6792 |
|
6793 | if (source && !this._sources.has(source)) {
|
6794 | this._sources.add(source);
|
6795 | }
|
6796 |
|
6797 | if (name && !this._names.has(name)) {
|
6798 | this._names.add(name);
|
6799 | }
|
6800 |
|
6801 | this._mappings.push({
|
6802 | generatedLine: generated.line,
|
6803 | generatedColumn: generated.column,
|
6804 | originalLine: original != null && original.line,
|
6805 | originalColumn: original != null && original.column,
|
6806 | source: source,
|
6807 | name: name
|
6808 | });
|
6809 | };
|
6810 |
|
6811 | |
6812 |
|
6813 |
|
6814 | SourceMapGenerator.prototype.setSourceContent =
|
6815 | function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
6816 | var source = aSourceFile;
|
6817 | if (this._sourceRoot) {
|
6818 | source = util.relative(this._sourceRoot, source);
|
6819 | }
|
6820 |
|
6821 | if (aSourceContent !== null) {
|
6822 |
|
6823 |
|
6824 | if (!this._sourcesContents) {
|
6825 | this._sourcesContents = {};
|
6826 | }
|
6827 | this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
6828 | } else {
|
6829 |
|
6830 |
|
6831 | delete this._sourcesContents[util.toSetString(source)];
|
6832 | if (Object.keys(this._sourcesContents).length === 0) {
|
6833 | this._sourcesContents = null;
|
6834 | }
|
6835 | }
|
6836 | };
|
6837 |
|
6838 | |
6839 |
|
6840 |
|
6841 |
|
6842 |
|
6843 |
|
6844 |
|
6845 |
|
6846 |
|
6847 |
|
6848 | SourceMapGenerator.prototype.applySourceMap =
|
6849 | function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile) {
|
6850 |
|
6851 | if (!aSourceFile) {
|
6852 | aSourceFile = aSourceMapConsumer.file;
|
6853 | }
|
6854 | var sourceRoot = this._sourceRoot;
|
6855 |
|
6856 | if (sourceRoot) {
|
6857 | aSourceFile = util.relative(sourceRoot, aSourceFile);
|
6858 | }
|
6859 |
|
6860 |
|
6861 | var newSources = new ArraySet();
|
6862 | var newNames = new ArraySet();
|
6863 |
|
6864 |
|
6865 | this._mappings.forEach(function (mapping) {
|
6866 | if (mapping.source === aSourceFile && mapping.originalLine) {
|
6867 |
|
6868 | var original = aSourceMapConsumer.originalPositionFor({
|
6869 | line: mapping.originalLine,
|
6870 | column: mapping.originalColumn
|
6871 | });
|
6872 | if (original.source !== null) {
|
6873 |
|
6874 | if (sourceRoot) {
|
6875 | mapping.source = util.relative(sourceRoot, original.source);
|
6876 | } else {
|
6877 | mapping.source = original.source;
|
6878 | }
|
6879 | mapping.originalLine = original.line;
|
6880 | mapping.originalColumn = original.column;
|
6881 | if (original.name !== null && mapping.name !== null) {
|
6882 |
|
6883 |
|
6884 | mapping.name = original.name;
|
6885 | }
|
6886 | }
|
6887 | }
|
6888 |
|
6889 | var source = mapping.source;
|
6890 | if (source && !newSources.has(source)) {
|
6891 | newSources.add(source);
|
6892 | }
|
6893 |
|
6894 | var name = mapping.name;
|
6895 | if (name && !newNames.has(name)) {
|
6896 | newNames.add(name);
|
6897 | }
|
6898 |
|
6899 | }, this);
|
6900 | this._sources = newSources;
|
6901 | this._names = newNames;
|
6902 |
|
6903 |
|
6904 | aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
6905 | var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
6906 | if (content) {
|
6907 | if (sourceRoot) {
|
6908 | sourceFile = util.relative(sourceRoot, sourceFile);
|
6909 | }
|
6910 | this.setSourceContent(sourceFile, content);
|
6911 | }
|
6912 | }, this);
|
6913 | };
|
6914 |
|
6915 | |
6916 |
|
6917 |
|
6918 |
|
6919 |
|
6920 |
|
6921 |
|
6922 |
|
6923 |
|
6924 |
|
6925 |
|
6926 | SourceMapGenerator.prototype._validateMapping =
|
6927 | function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
6928 | aName) {
|
6929 | if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
6930 | && aGenerated.line > 0 && aGenerated.column >= 0
|
6931 | && !aOriginal && !aSource && !aName) {
|
6932 |
|
6933 | return;
|
6934 | }
|
6935 | else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
6936 | && aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
6937 | && aGenerated.line > 0 && aGenerated.column >= 0
|
6938 | && aOriginal.line > 0 && aOriginal.column >= 0
|
6939 | && aSource) {
|
6940 |
|
6941 | return;
|
6942 | }
|
6943 | else {
|
6944 | throw new Error('Invalid mapping: ' + JSON.stringify({
|
6945 | generated: aGenerated,
|
6946 | source: aSource,
|
6947 | original: aOriginal,
|
6948 | name: aName
|
6949 | }));
|
6950 | }
|
6951 | };
|
6952 |
|
6953 | |
6954 |
|
6955 |
|
6956 |
|
6957 | SourceMapGenerator.prototype._serializeMappings =
|
6958 | function SourceMapGenerator_serializeMappings() {
|
6959 | var previousGeneratedColumn = 0;
|
6960 | var previousGeneratedLine = 1;
|
6961 | var previousOriginalColumn = 0;
|
6962 | var previousOriginalLine = 0;
|
6963 | var previousName = 0;
|
6964 | var previousSource = 0;
|
6965 | var result = '';
|
6966 | var mapping;
|
6967 |
|
6968 |
|
6969 |
|
6970 |
|
6971 |
|
6972 |
|
6973 | this._mappings.sort(util.compareByGeneratedPositions);
|
6974 |
|
6975 | for (var i = 0, len = this._mappings.length; i < len; i++) {
|
6976 | mapping = this._mappings[i];
|
6977 |
|
6978 | if (mapping.generatedLine !== previousGeneratedLine) {
|
6979 | previousGeneratedColumn = 0;
|
6980 | while (mapping.generatedLine !== previousGeneratedLine) {
|
6981 | result += ';';
|
6982 | previousGeneratedLine++;
|
6983 | }
|
6984 | }
|
6985 | else {
|
6986 | if (i > 0) {
|
6987 | if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) {
|
6988 | continue;
|
6989 | }
|
6990 | result += ',';
|
6991 | }
|
6992 | }
|
6993 |
|
6994 | result += base64VLQ.encode(mapping.generatedColumn
|
6995 | - previousGeneratedColumn);
|
6996 | previousGeneratedColumn = mapping.generatedColumn;
|
6997 |
|
6998 | if (mapping.source) {
|
6999 | result += base64VLQ.encode(this._sources.indexOf(mapping.source)
|
7000 | - previousSource);
|
7001 | previousSource = this._sources.indexOf(mapping.source);
|
7002 |
|
7003 |
|
7004 | result += base64VLQ.encode(mapping.originalLine - 1
|
7005 | - previousOriginalLine);
|
7006 | previousOriginalLine = mapping.originalLine - 1;
|
7007 |
|
7008 | result += base64VLQ.encode(mapping.originalColumn
|
7009 | - previousOriginalColumn);
|
7010 | previousOriginalColumn = mapping.originalColumn;
|
7011 |
|
7012 | if (mapping.name) {
|
7013 | result += base64VLQ.encode(this._names.indexOf(mapping.name)
|
7014 | - previousName);
|
7015 | previousName = this._names.indexOf(mapping.name);
|
7016 | }
|
7017 | }
|
7018 | }
|
7019 |
|
7020 | return result;
|
7021 | };
|
7022 |
|
7023 | SourceMapGenerator.prototype._generateSourcesContent =
|
7024 | function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
7025 | return aSources.map(function (source) {
|
7026 | if (!this._sourcesContents) {
|
7027 | return null;
|
7028 | }
|
7029 | if (aSourceRoot) {
|
7030 | source = util.relative(aSourceRoot, source);
|
7031 | }
|
7032 | var key = util.toSetString(source);
|
7033 | return Object.prototype.hasOwnProperty.call(this._sourcesContents,
|
7034 | key)
|
7035 | ? this._sourcesContents[key]
|
7036 | : null;
|
7037 | }, this);
|
7038 | };
|
7039 |
|
7040 | |
7041 |
|
7042 |
|
7043 | SourceMapGenerator.prototype.toJSON =
|
7044 | function SourceMapGenerator_toJSON() {
|
7045 | var map = {
|
7046 | version: this._version,
|
7047 | file: this._file,
|
7048 | sources: this._sources.toArray(),
|
7049 | names: this._names.toArray(),
|
7050 | mappings: this._serializeMappings()
|
7051 | };
|
7052 | if (this._sourceRoot) {
|
7053 | map.sourceRoot = this._sourceRoot;
|
7054 | }
|
7055 | if (this._sourcesContents) {
|
7056 | map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
7057 | }
|
7058 |
|
7059 | return map;
|
7060 | };
|
7061 |
|
7062 | |
7063 |
|
7064 |
|
7065 | SourceMapGenerator.prototype.toString =
|
7066 | function SourceMapGenerator_toString() {
|
7067 | return JSON.stringify(this);
|
7068 | };
|
7069 |
|
7070 | exports.SourceMapGenerator = SourceMapGenerator;
|
7071 |
|
7072 | });
|
7073 |
|
7074 | },{"./array-set":44,"./base64-vlq":45,"./util":51,"amdefine":7}],50:[function(require,module,exports){
|
7075 |
|
7076 |
|
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 | if (typeof define !== 'function') {
|
7082 | var define = require('amdefine')(module, require);
|
7083 | }
|
7084 | define(function (require, exports, module) {
|
7085 |
|
7086 | var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
|
7087 | var util = require('./util');
|
7088 |
|
7089 | |
7090 |
|
7091 |
|
7092 |
|
7093 |
|
7094 |
|
7095 |
|
7096 |
|
7097 |
|
7098 |
|
7099 |
|
7100 |
|
7101 | function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
7102 | this.children = [];
|
7103 | this.sourceContents = {};
|
7104 | this.line = aLine === undefined ? null : aLine;
|
7105 | this.column = aColumn === undefined ? null : aColumn;
|
7106 | this.source = aSource === undefined ? null : aSource;
|
7107 | this.name = aName === undefined ? null : aName;
|
7108 | if (aChunks != null) this.add(aChunks);
|
7109 | }
|
7110 |
|
7111 | |
7112 |
|
7113 |
|
7114 |
|
7115 |
|
7116 |
|
7117 | SourceNode.fromStringWithSourceMap =
|
7118 | function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) {
|
7119 |
|
7120 |
|
7121 | var node = new SourceNode();
|
7122 |
|
7123 |
|
7124 |
|
7125 | var remainingLines = aGeneratedCode.split('\n');
|
7126 |
|
7127 |
|
7128 | var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
7129 |
|
7130 |
|
7131 |
|
7132 |
|
7133 | var lastMapping = null;
|
7134 |
|
7135 | aSourceMapConsumer.eachMapping(function (mapping) {
|
7136 | if (lastMapping === null) {
|
7137 |
|
7138 |
|
7139 |
|
7140 | while (lastGeneratedLine < mapping.generatedLine) {
|
7141 | node.add(remainingLines.shift() + "\n");
|
7142 | lastGeneratedLine++;
|
7143 | }
|
7144 | if (lastGeneratedColumn < mapping.generatedColumn) {
|
7145 | var nextLine = remainingLines[0];
|
7146 | node.add(nextLine.substr(0, mapping.generatedColumn));
|
7147 | remainingLines[0] = nextLine.substr(mapping.generatedColumn);
|
7148 | lastGeneratedColumn = mapping.generatedColumn;
|
7149 | }
|
7150 | } else {
|
7151 |
|
7152 |
|
7153 | if (lastGeneratedLine < mapping.generatedLine) {
|
7154 | var code = "";
|
7155 |
|
7156 | do {
|
7157 | code += remainingLines.shift() + "\n";
|
7158 | lastGeneratedLine++;
|
7159 | lastGeneratedColumn = 0;
|
7160 | } while (lastGeneratedLine < mapping.generatedLine);
|
7161 |
|
7162 |
|
7163 | if (lastGeneratedColumn < mapping.generatedColumn) {
|
7164 | var nextLine = remainingLines[0];
|
7165 | code += nextLine.substr(0, mapping.generatedColumn);
|
7166 | remainingLines[0] = nextLine.substr(mapping.generatedColumn);
|
7167 | lastGeneratedColumn = mapping.generatedColumn;
|
7168 | }
|
7169 |
|
7170 | addMappingWithCode(lastMapping, code);
|
7171 | } else {
|
7172 |
|
7173 |
|
7174 |
|
7175 | var nextLine = remainingLines[0];
|
7176 | var code = nextLine.substr(0, mapping.generatedColumn -
|
7177 | lastGeneratedColumn);
|
7178 | remainingLines[0] = nextLine.substr(mapping.generatedColumn -
|
7179 | lastGeneratedColumn);
|
7180 | lastGeneratedColumn = mapping.generatedColumn;
|
7181 | addMappingWithCode(lastMapping, code);
|
7182 | }
|
7183 | }
|
7184 | lastMapping = mapping;
|
7185 | }, this);
|
7186 |
|
7187 |
|
7188 |
|
7189 | addMappingWithCode(lastMapping, remainingLines.join("\n"));
|
7190 |
|
7191 |
|
7192 | aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
7193 | var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
7194 | if (content) {
|
7195 | node.setSourceContent(sourceFile, content);
|
7196 | }
|
7197 | });
|
7198 |
|
7199 | return node;
|
7200 |
|
7201 | function addMappingWithCode(mapping, code) {
|
7202 | if (mapping === null || mapping.source === undefined) {
|
7203 | node.add(code);
|
7204 | } else {
|
7205 | node.add(new SourceNode(mapping.originalLine,
|
7206 | mapping.originalColumn,
|
7207 | mapping.source,
|
7208 | code,
|
7209 | mapping.name));
|
7210 | }
|
7211 | }
|
7212 | };
|
7213 |
|
7214 | |
7215 |
|
7216 |
|
7217 |
|
7218 |
|
7219 |
|
7220 | SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
7221 | if (Array.isArray(aChunk)) {
|
7222 | aChunk.forEach(function (chunk) {
|
7223 | this.add(chunk);
|
7224 | }, this);
|
7225 | }
|
7226 | else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
|
7227 | if (aChunk) {
|
7228 | this.children.push(aChunk);
|
7229 | }
|
7230 | }
|
7231 | else {
|
7232 | throw new TypeError(
|
7233 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
7234 | );
|
7235 | }
|
7236 | return this;
|
7237 | };
|
7238 |
|
7239 | |
7240 |
|
7241 |
|
7242 |
|
7243 |
|
7244 |
|
7245 | SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
7246 | if (Array.isArray(aChunk)) {
|
7247 | for (var i = aChunk.length-1; i >= 0; i--) {
|
7248 | this.prepend(aChunk[i]);
|
7249 | }
|
7250 | }
|
7251 | else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
|
7252 | this.children.unshift(aChunk);
|
7253 | }
|
7254 | else {
|
7255 | throw new TypeError(
|
7256 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
7257 | );
|
7258 | }
|
7259 | return this;
|
7260 | };
|
7261 |
|
7262 | |
7263 |
|
7264 |
|
7265 |
|
7266 |
|
7267 |
|
7268 |
|
7269 | SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
7270 | var chunk;
|
7271 | for (var i = 0, len = this.children.length; i < len; i++) {
|
7272 | chunk = this.children[i];
|
7273 | if (chunk instanceof SourceNode) {
|
7274 | chunk.walk(aFn);
|
7275 | }
|
7276 | else {
|
7277 | if (chunk !== '') {
|
7278 | aFn(chunk, { source: this.source,
|
7279 | line: this.line,
|
7280 | column: this.column,
|
7281 | name: this.name });
|
7282 | }
|
7283 | }
|
7284 | }
|
7285 | };
|
7286 |
|
7287 | |
7288 |
|
7289 |
|
7290 |
|
7291 |
|
7292 |
|
7293 | SourceNode.prototype.join = function SourceNode_join(aSep) {
|
7294 | var newChildren;
|
7295 | var i;
|
7296 | var len = this.children.length;
|
7297 | if (len > 0) {
|
7298 | newChildren = [];
|
7299 | for (i = 0; i < len-1; i++) {
|
7300 | newChildren.push(this.children[i]);
|
7301 | newChildren.push(aSep);
|
7302 | }
|
7303 | newChildren.push(this.children[i]);
|
7304 | this.children = newChildren;
|
7305 | }
|
7306 | return this;
|
7307 | };
|
7308 |
|
7309 | |
7310 |
|
7311 |
|
7312 |
|
7313 |
|
7314 |
|
7315 |
|
7316 | SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
7317 | var lastChild = this.children[this.children.length - 1];
|
7318 | if (lastChild instanceof SourceNode) {
|
7319 | lastChild.replaceRight(aPattern, aReplacement);
|
7320 | }
|
7321 | else if (typeof lastChild === 'string') {
|
7322 | this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
7323 | }
|
7324 | else {
|
7325 | this.children.push(''.replace(aPattern, aReplacement));
|
7326 | }
|
7327 | return this;
|
7328 | };
|
7329 |
|
7330 | |
7331 |
|
7332 |
|
7333 |
|
7334 |
|
7335 |
|
7336 |
|
7337 | SourceNode.prototype.setSourceContent =
|
7338 | function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
7339 | this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
7340 | };
|
7341 |
|
7342 | |
7343 |
|
7344 |
|
7345 |
|
7346 |
|
7347 |
|
7348 | SourceNode.prototype.walkSourceContents =
|
7349 | function SourceNode_walkSourceContents(aFn) {
|
7350 | for (var i = 0, len = this.children.length; i < len; i++) {
|
7351 | if (this.children[i] instanceof SourceNode) {
|
7352 | this.children[i].walkSourceContents(aFn);
|
7353 | }
|
7354 | }
|
7355 |
|
7356 | var sources = Object.keys(this.sourceContents);
|
7357 | for (var i = 0, len = sources.length; i < len; i++) {
|
7358 | aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
7359 | }
|
7360 | };
|
7361 |
|
7362 | |
7363 |
|
7364 |
|
7365 |
|
7366 | SourceNode.prototype.toString = function SourceNode_toString() {
|
7367 | var str = "";
|
7368 | this.walk(function (chunk) {
|
7369 | str += chunk;
|
7370 | });
|
7371 | return str;
|
7372 | };
|
7373 |
|
7374 | |
7375 |
|
7376 |
|
7377 |
|
7378 | SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
7379 | var generated = {
|
7380 | code: "",
|
7381 | line: 1,
|
7382 | column: 0
|
7383 | };
|
7384 | var map = new SourceMapGenerator(aArgs);
|
7385 | var sourceMappingActive = false;
|
7386 | var lastOriginalSource = null;
|
7387 | var lastOriginalLine = null;
|
7388 | var lastOriginalColumn = null;
|
7389 | var lastOriginalName = null;
|
7390 | this.walk(function (chunk, original) {
|
7391 | generated.code += chunk;
|
7392 | if (original.source !== null
|
7393 | && original.line !== null
|
7394 | && original.column !== null) {
|
7395 | if(lastOriginalSource !== original.source
|
7396 | || lastOriginalLine !== original.line
|
7397 | || lastOriginalColumn !== original.column
|
7398 | || lastOriginalName !== original.name) {
|
7399 | map.addMapping({
|
7400 | source: original.source,
|
7401 | original: {
|
7402 | line: original.line,
|
7403 | column: original.column
|
7404 | },
|
7405 | generated: {
|
7406 | line: generated.line,
|
7407 | column: generated.column
|
7408 | },
|
7409 | name: original.name
|
7410 | });
|
7411 | }
|
7412 | lastOriginalSource = original.source;
|
7413 | lastOriginalLine = original.line;
|
7414 | lastOriginalColumn = original.column;
|
7415 | lastOriginalName = original.name;
|
7416 | sourceMappingActive = true;
|
7417 | } else if (sourceMappingActive) {
|
7418 | map.addMapping({
|
7419 | generated: {
|
7420 | line: generated.line,
|
7421 | column: generated.column
|
7422 | }
|
7423 | });
|
7424 | lastOriginalSource = null;
|
7425 | sourceMappingActive = false;
|
7426 | }
|
7427 | chunk.split('').forEach(function (ch) {
|
7428 | if (ch === '\n') {
|
7429 | generated.line++;
|
7430 | generated.column = 0;
|
7431 | } else {
|
7432 | generated.column++;
|
7433 | }
|
7434 | });
|
7435 | });
|
7436 | this.walkSourceContents(function (sourceFile, sourceContent) {
|
7437 | map.setSourceContent(sourceFile, sourceContent);
|
7438 | });
|
7439 |
|
7440 | return { code: generated.code, map: map };
|
7441 | };
|
7442 |
|
7443 | exports.SourceNode = SourceNode;
|
7444 |
|
7445 | });
|
7446 |
|
7447 | },{"./source-map-generator":49,"./util":51,"amdefine":7}],51:[function(require,module,exports){
|
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 |
|
7453 |
|
7454 | if (typeof define !== 'function') {
|
7455 | var define = require('amdefine')(module, require);
|
7456 | }
|
7457 | define(function (require, exports, module) {
|
7458 |
|
7459 | |
7460 |
|
7461 |
|
7462 |
|
7463 |
|
7464 |
|
7465 |
|
7466 |
|
7467 |
|
7468 |
|
7469 | function getArg(aArgs, aName, aDefaultValue) {
|
7470 | if (aName in aArgs) {
|
7471 | return aArgs[aName];
|
7472 | } else if (arguments.length === 3) {
|
7473 | return aDefaultValue;
|
7474 | } else {
|
7475 | throw new Error('"' + aName + '" is a required argument.');
|
7476 | }
|
7477 | }
|
7478 | exports.getArg = getArg;
|
7479 |
|
7480 | var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/;
|
7481 | var dataUrlRegexp = /^data:.+\,.+/;
|
7482 |
|
7483 | function urlParse(aUrl) {
|
7484 | var match = aUrl.match(urlRegexp);
|
7485 | if (!match) {
|
7486 | return null;
|
7487 | }
|
7488 | return {
|
7489 | scheme: match[1],
|
7490 | auth: match[3],
|
7491 | host: match[4],
|
7492 | port: match[6],
|
7493 | path: match[7]
|
7494 | };
|
7495 | }
|
7496 | exports.urlParse = urlParse;
|
7497 |
|
7498 | function urlGenerate(aParsedUrl) {
|
7499 | var url = aParsedUrl.scheme + "://";
|
7500 | if (aParsedUrl.auth) {
|
7501 | url += aParsedUrl.auth + "@"
|
7502 | }
|
7503 | if (aParsedUrl.host) {
|
7504 | url += aParsedUrl.host;
|
7505 | }
|
7506 | if (aParsedUrl.port) {
|
7507 | url += ":" + aParsedUrl.port
|
7508 | }
|
7509 | if (aParsedUrl.path) {
|
7510 | url += aParsedUrl.path;
|
7511 | }
|
7512 | return url;
|
7513 | }
|
7514 | exports.urlGenerate = urlGenerate;
|
7515 |
|
7516 | function join(aRoot, aPath) {
|
7517 | var url;
|
7518 |
|
7519 | if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) {
|
7520 | return aPath;
|
7521 | }
|
7522 |
|
7523 | if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) {
|
7524 | url.path = aPath;
|
7525 | return urlGenerate(url);
|
7526 | }
|
7527 |
|
7528 | return aRoot.replace(/\/$/, '') + '/' + aPath;
|
7529 | }
|
7530 | exports.join = join;
|
7531 |
|
7532 | |
7533 |
|
7534 |
|
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 |
|
7541 | function toSetString(aStr) {
|
7542 | return '$' + aStr;
|
7543 | }
|
7544 | exports.toSetString = toSetString;
|
7545 |
|
7546 | function fromSetString(aStr) {
|
7547 | return aStr.substr(1);
|
7548 | }
|
7549 | exports.fromSetString = fromSetString;
|
7550 |
|
7551 | function relative(aRoot, aPath) {
|
7552 | aRoot = aRoot.replace(/\/$/, '');
|
7553 |
|
7554 | var url = urlParse(aRoot);
|
7555 | if (aPath.charAt(0) == "/" && url && url.path == "/") {
|
7556 | return aPath.slice(1);
|
7557 | }
|
7558 |
|
7559 | return aPath.indexOf(aRoot + '/') === 0
|
7560 | ? aPath.substr(aRoot.length + 1)
|
7561 | : aPath;
|
7562 | }
|
7563 | exports.relative = relative;
|
7564 |
|
7565 | function strcmp(aStr1, aStr2) {
|
7566 | var s1 = aStr1 || "";
|
7567 | var s2 = aStr2 || "";
|
7568 | return (s1 > s2) - (s1 < s2);
|
7569 | }
|
7570 |
|
7571 | |
7572 |
|
7573 |
|
7574 |
|
7575 |
|
7576 |
|
7577 |
|
7578 |
|
7579 | function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
7580 | var cmp;
|
7581 |
|
7582 | cmp = strcmp(mappingA.source, mappingB.source);
|
7583 | if (cmp) {
|
7584 | return cmp;
|
7585 | }
|
7586 |
|
7587 | cmp = mappingA.originalLine - mappingB.originalLine;
|
7588 | if (cmp) {
|
7589 | return cmp;
|
7590 | }
|
7591 |
|
7592 | cmp = mappingA.originalColumn - mappingB.originalColumn;
|
7593 | if (cmp || onlyCompareOriginal) {
|
7594 | return cmp;
|
7595 | }
|
7596 |
|
7597 | cmp = strcmp(mappingA.name, mappingB.name);
|
7598 | if (cmp) {
|
7599 | return cmp;
|
7600 | }
|
7601 |
|
7602 | cmp = mappingA.generatedLine - mappingB.generatedLine;
|
7603 | if (cmp) {
|
7604 | return cmp;
|
7605 | }
|
7606 |
|
7607 | return mappingA.generatedColumn - mappingB.generatedColumn;
|
7608 | };
|
7609 | exports.compareByOriginalPositions = compareByOriginalPositions;
|
7610 |
|
7611 | |
7612 |
|
7613 |
|
7614 |
|
7615 |
|
7616 |
|
7617 |
|
7618 |
|
7619 |
|
7620 | function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
|
7621 | var cmp;
|
7622 |
|
7623 | cmp = mappingA.generatedLine - mappingB.generatedLine;
|
7624 | if (cmp) {
|
7625 | return cmp;
|
7626 | }
|
7627 |
|
7628 | cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
7629 | if (cmp || onlyCompareGenerated) {
|
7630 | return cmp;
|
7631 | }
|
7632 |
|
7633 | cmp = strcmp(mappingA.source, mappingB.source);
|
7634 | if (cmp) {
|
7635 | return cmp;
|
7636 | }
|
7637 |
|
7638 | cmp = mappingA.originalLine - mappingB.originalLine;
|
7639 | if (cmp) {
|
7640 | return cmp;
|
7641 | }
|
7642 |
|
7643 | cmp = mappingA.originalColumn - mappingB.originalColumn;
|
7644 | if (cmp) {
|
7645 | return cmp;
|
7646 | }
|
7647 |
|
7648 | return strcmp(mappingA.name, mappingB.name);
|
7649 | };
|
7650 | exports.compareByGeneratedPositions = compareByGeneratedPositions;
|
7651 |
|
7652 | });
|
7653 |
|
7654 | },{"amdefine":7}],52:[function(require,module,exports){
|
7655 | (function (process,Buffer){
|
7656 | var SourceMapConsumer = require('source-map').SourceMapConsumer;
|
7657 | var path = require('path');
|
7658 | var fs = require('fs');
|
7659 |
|
7660 | var errorFormatterInstalled = false;
|
7661 | var uncaughtShimInstalled = false;
|
7662 |
|
7663 | var emptyCacheBetweenOperations = false;
|
7664 |
|
7665 | var environment = "auto";
|
7666 |
|
7667 | var fileContentsCache = {};
|
7668 |
|
7669 | var sourceMapCache = {};
|
7670 |
|
7671 | var reSourceMap = /^data:application\/json[^,]+base64,/;
|
7672 |
|
7673 | var retrieveFileHandlers = [];
|
7674 | var retrieveMapHandlers = [];
|
7675 | function isInBrowser() {
|
7676 | if (environment === "browser")
|
7677 | return true;
|
7678 | if (environment === "node")
|
7679 | return false;
|
7680 | return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function'));
|
7681 | }
|
7682 | function hasGlobalProcessEventEmitter() {
|
7683 | return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
|
7684 | }
|
7685 | function handlerExec(list) {
|
7686 | return function (arg) {
|
7687 | for (var i = 0; i < list.length; i++) {
|
7688 | var ret = list[i](arg);
|
7689 | if (ret) {
|
7690 | return ret;
|
7691 | }
|
7692 | }
|
7693 | return null;
|
7694 | };
|
7695 | }
|
7696 | var retrieveFile = handlerExec(retrieveFileHandlers);
|
7697 | retrieveFileHandlers.push(function (path) {
|
7698 |
|
7699 | path = path.trim();
|
7700 | if (path in fileContentsCache) {
|
7701 | return fileContentsCache[path];
|
7702 | }
|
7703 | try {
|
7704 |
|
7705 | if (isInBrowser()) {
|
7706 | var xhr = new XMLHttpRequest();
|
7707 | xhr.open('GET', path, false);
|
7708 | xhr.send(null);
|
7709 | var contents = null;
|
7710 | if (xhr.readyState === 4 && xhr.status === 200) {
|
7711 | contents = xhr.responseText;
|
7712 | }
|
7713 | }
|
7714 | else {
|
7715 | var contents = fs.readFileSync(path, 'utf8');
|
7716 | }
|
7717 | }
|
7718 | catch (e) {
|
7719 | var contents = null;
|
7720 | }
|
7721 | return fileContentsCache[path] = contents;
|
7722 | });
|
7723 |
|
7724 |
|
7725 | function supportRelativeURL(file, url) {
|
7726 | if (!file)
|
7727 | return url;
|
7728 | var dir = path.dirname(file);
|
7729 | var match = /^\w+:\/\/[^\/]*/.exec(dir);
|
7730 | var protocol = match ? match[0] : '';
|
7731 | return protocol + path.resolve(dir.slice(protocol.length), url);
|
7732 | }
|
7733 | function retrieveSourceMapURL(source) {
|
7734 | var fileData;
|
7735 | if (isInBrowser()) {
|
7736 | var xhr = new XMLHttpRequest();
|
7737 | xhr.open('GET', source, false);
|
7738 | xhr.send(null);
|
7739 | fileData = xhr.readyState === 4 ? xhr.responseText : null;
|
7740 |
|
7741 | var sourceMapHeader = xhr.getResponseHeader("SourceMap") ||
|
7742 | xhr.getResponseHeader("X-SourceMap");
|
7743 | if (sourceMapHeader) {
|
7744 | return sourceMapHeader;
|
7745 | }
|
7746 | }
|
7747 |
|
7748 | fileData = retrieveFile(source);
|
7749 |
|
7750 | var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/mg;
|
7751 |
|
7752 |
|
7753 | var lastMatch, match;
|
7754 | while (match = re.exec(fileData))
|
7755 | lastMatch = match;
|
7756 | if (!lastMatch)
|
7757 | return null;
|
7758 | return lastMatch[1];
|
7759 | }
|
7760 | ;
|
7761 |
|
7762 |
|
7763 |
|
7764 |
|
7765 |
|
7766 | var retrieveSourceMap = handlerExec(retrieveMapHandlers);
|
7767 | retrieveMapHandlers.push(function (source) {
|
7768 | var sourceMappingURL = retrieveSourceMapURL(source);
|
7769 | if (!sourceMappingURL)
|
7770 | return null;
|
7771 |
|
7772 | var sourceMapData;
|
7773 | if (reSourceMap.test(sourceMappingURL)) {
|
7774 |
|
7775 | var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1);
|
7776 | sourceMapData = new Buffer(rawData, "base64").toString();
|
7777 | sourceMappingURL = null;
|
7778 | }
|
7779 | else {
|
7780 |
|
7781 | sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
|
7782 | sourceMapData = retrieveFile(sourceMappingURL);
|
7783 | }
|
7784 | if (!sourceMapData) {
|
7785 | return null;
|
7786 | }
|
7787 | return {
|
7788 | url: sourceMappingURL,
|
7789 | map: sourceMapData
|
7790 | };
|
7791 | });
|
7792 | function mapSourcePosition(position) {
|
7793 | var sourceMap = sourceMapCache[position.source];
|
7794 | if (!sourceMap) {
|
7795 |
|
7796 | var urlAndMap = retrieveSourceMap(position.source);
|
7797 | if (urlAndMap) {
|
7798 | sourceMap = sourceMapCache[position.source] = {
|
7799 | url: urlAndMap.url,
|
7800 | map: new SourceMapConsumer(urlAndMap.map)
|
7801 | };
|
7802 |
|
7803 |
|
7804 | if (sourceMap.map.sourcesContent) {
|
7805 | sourceMap.map.sources.forEach(function (source, i) {
|
7806 | var contents = sourceMap.map.sourcesContent[i];
|
7807 | if (contents) {
|
7808 | var url = supportRelativeURL(sourceMap.url, source);
|
7809 | fileContentsCache[url] = contents;
|
7810 | }
|
7811 | });
|
7812 | }
|
7813 | }
|
7814 | else {
|
7815 | sourceMap = sourceMapCache[position.source] = {
|
7816 | url: null,
|
7817 | map: null
|
7818 | };
|
7819 | }
|
7820 | }
|
7821 |
|
7822 | if (sourceMap && sourceMap.map) {
|
7823 | var originalPosition = sourceMap.map.originalPositionFor(position);
|
7824 |
|
7825 |
|
7826 |
|
7827 |
|
7828 |
|
7829 | if (originalPosition.source !== null) {
|
7830 | originalPosition.source = supportRelativeURL(sourceMap.url, originalPosition.source);
|
7831 | return originalPosition;
|
7832 | }
|
7833 | }
|
7834 | return position;
|
7835 | }
|
7836 |
|
7837 |
|
7838 | function mapEvalOrigin(origin) {
|
7839 |
|
7840 | var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
|
7841 | if (match) {
|
7842 | var position = mapSourcePosition({
|
7843 | source: match[2],
|
7844 | line: match[3],
|
7845 | column: match[4] - 1
|
7846 | });
|
7847 | return 'eval at ' + match[1] + ' (' + position.source + ':' +
|
7848 | position.line + ':' + (position.column + 1) + ')';
|
7849 | }
|
7850 |
|
7851 | match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
|
7852 | if (match) {
|
7853 | return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')';
|
7854 | }
|
7855 |
|
7856 | return origin;
|
7857 | }
|
7858 |
|
7859 |
|
7860 |
|
7861 |
|
7862 |
|
7863 |
|
7864 | function CallSiteToString() {
|
7865 | var fileName;
|
7866 | var fileLocation = "";
|
7867 | if (this.isNative()) {
|
7868 | fileLocation = "native";
|
7869 | }
|
7870 | else {
|
7871 | fileName = this.getScriptNameOrSourceURL();
|
7872 | if (!fileName && this.isEval()) {
|
7873 | fileLocation = this.getEvalOrigin();
|
7874 | fileLocation += ", ";
|
7875 | }
|
7876 | if (fileName) {
|
7877 | fileLocation += fileName;
|
7878 | }
|
7879 | else {
|
7880 |
|
7881 |
|
7882 |
|
7883 | fileLocation += "<anonymous>";
|
7884 | }
|
7885 | var lineNumber = this.getLineNumber();
|
7886 | if (lineNumber != null) {
|
7887 | fileLocation += ":" + lineNumber;
|
7888 | var columnNumber = this.getColumnNumber();
|
7889 | if (columnNumber) {
|
7890 | fileLocation += ":" + columnNumber;
|
7891 | }
|
7892 | }
|
7893 | }
|
7894 | var line = "";
|
7895 | var functionName = this.getFunctionName();
|
7896 | var addSuffix = true;
|
7897 | var isConstructor = this.isConstructor();
|
7898 | var isMethodCall = !(this.isToplevel() || isConstructor);
|
7899 | if (isMethodCall) {
|
7900 | var typeName = this.getTypeName();
|
7901 | var methodName = this.getMethodName();
|
7902 | if (functionName) {
|
7903 | if (typeName && functionName.indexOf(typeName) != 0) {
|
7904 | line += typeName + ".";
|
7905 | }
|
7906 | line += functionName;
|
7907 | if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) {
|
7908 | line += " [as " + methodName + "]";
|
7909 | }
|
7910 | }
|
7911 | else {
|
7912 | line += typeName + "." + (methodName || "<anonymous>");
|
7913 | }
|
7914 | }
|
7915 | else if (isConstructor) {
|
7916 | line += "new " + (functionName || "<anonymous>");
|
7917 | }
|
7918 | else if (functionName) {
|
7919 | line += functionName;
|
7920 | }
|
7921 | else {
|
7922 | line += fileLocation;
|
7923 | addSuffix = false;
|
7924 | }
|
7925 | if (addSuffix) {
|
7926 | line += " (" + fileLocation + ")";
|
7927 | }
|
7928 | return line;
|
7929 | }
|
7930 | function cloneCallSite(frame) {
|
7931 | var object = {};
|
7932 | Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function (name) {
|
7933 | object[name] = /^(?:is|get)/.test(name) ? function () { return frame[name].call(frame); } : frame[name];
|
7934 | });
|
7935 | object.toString = CallSiteToString;
|
7936 | return object;
|
7937 | }
|
7938 | function wrapCallSite(frame) {
|
7939 |
|
7940 |
|
7941 |
|
7942 | var source = frame.getFileName() || frame.getScriptNameOrSourceURL();
|
7943 | if (source) {
|
7944 | var line = frame.getLineNumber();
|
7945 | var column = frame.getColumnNumber() - 1;
|
7946 |
|
7947 |
|
7948 | if (line === 1 && !isInBrowser() && !frame.isEval()) {
|
7949 | column -= 62;
|
7950 | }
|
7951 | var position = mapSourcePosition({
|
7952 | source: source,
|
7953 | line: line,
|
7954 | column: column
|
7955 | });
|
7956 | frame = cloneCallSite(frame);
|
7957 | frame.getFileName = function () { return position.source; };
|
7958 | frame.getLineNumber = function () { return position.line; };
|
7959 | frame.getColumnNumber = function () { return position.column + 1; };
|
7960 | frame.getScriptNameOrSourceURL = function () { return position.source; };
|
7961 | return frame;
|
7962 | }
|
7963 |
|
7964 | var origin = frame.isEval() && frame.getEvalOrigin();
|
7965 | if (origin) {
|
7966 | origin = mapEvalOrigin(origin);
|
7967 | frame = cloneCallSite(frame);
|
7968 | frame.getEvalOrigin = function () { return origin; };
|
7969 | return frame;
|
7970 | }
|
7971 |
|
7972 | return frame;
|
7973 | }
|
7974 |
|
7975 |
|
7976 | function prepareStackTrace(error, stack) {
|
7977 | if (emptyCacheBetweenOperations) {
|
7978 | fileContentsCache = {};
|
7979 | sourceMapCache = {};
|
7980 | }
|
7981 | return error + stack.map(function (frame) {
|
7982 | return '\n at ' + wrapCallSite(frame);
|
7983 | }).join('');
|
7984 | }
|
7985 |
|
7986 | function getErrorSource(error) {
|
7987 | var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
|
7988 | if (match) {
|
7989 | var source = match[1];
|
7990 | var line = +match[2];
|
7991 | var column = +match[3];
|
7992 |
|
7993 | var contents = fileContentsCache[source];
|
7994 |
|
7995 | if (!contents && fs.existsSync(source)) {
|
7996 | contents = fs.readFileSync(source, 'utf8');
|
7997 | }
|
7998 |
|
7999 | if (contents) {
|
8000 | var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1];
|
8001 | if (code) {
|
8002 | return source + ':' + line + '\n' + code + '\n' +
|
8003 | new Array(column).join(' ') + '^';
|
8004 | }
|
8005 | }
|
8006 | }
|
8007 | return null;
|
8008 | }
|
8009 | function printErrorAndExit(error) {
|
8010 | var source = getErrorSource(error);
|
8011 | if (source) {
|
8012 | console.error();
|
8013 | console.error(source);
|
8014 | }
|
8015 | console.error(error.stack);
|
8016 | process.exit(1);
|
8017 | }
|
8018 | function shimEmitUncaughtException() {
|
8019 | var origEmit = process.emit;
|
8020 | process.emit = function (type) {
|
8021 | if (type === 'uncaughtException') {
|
8022 | var hasStack = (arguments[1] && arguments[1].stack);
|
8023 | var hasListeners = (this.listeners(type).length > 0);
|
8024 | if (hasStack && !hasListeners) {
|
8025 | return printErrorAndExit(arguments[1]);
|
8026 | }
|
8027 | }
|
8028 | return origEmit.apply(this, arguments);
|
8029 | };
|
8030 | }
|
8031 | exports.wrapCallSite = wrapCallSite;
|
8032 | exports.getErrorSource = getErrorSource;
|
8033 | exports.mapSourcePosition = mapSourcePosition;
|
8034 | exports.retrieveSourceMap = retrieveSourceMap;
|
8035 | exports.install = function (options) {
|
8036 | options = options || {};
|
8037 | if (options.environment) {
|
8038 | environment = options.environment;
|
8039 | if (["node", "browser", "auto"].indexOf(environment) === -1) {
|
8040 | throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}");
|
8041 | }
|
8042 | }
|
8043 |
|
8044 |
|
8045 | if (options.retrieveFile) {
|
8046 | if (options.overrideRetrieveFile) {
|
8047 | retrieveFileHandlers.length = 0;
|
8048 | }
|
8049 | retrieveFileHandlers.unshift(options.retrieveFile);
|
8050 | }
|
8051 |
|
8052 |
|
8053 | if (options.retrieveSourceMap) {
|
8054 | if (options.overrideRetrieveSourceMap) {
|
8055 | retrieveMapHandlers.length = 0;
|
8056 | }
|
8057 | retrieveMapHandlers.unshift(options.retrieveSourceMap);
|
8058 | }
|
8059 |
|
8060 | if (!emptyCacheBetweenOperations) {
|
8061 | emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ?
|
8062 | options.emptyCacheBetweenOperations : false;
|
8063 | }
|
8064 |
|
8065 | if (!errorFormatterInstalled) {
|
8066 | errorFormatterInstalled = true;
|
8067 | Error.prepareStackTrace = prepareStackTrace;
|
8068 | }
|
8069 | if (!uncaughtShimInstalled) {
|
8070 | var installHandler = 'handleUncaughtExceptions' in options ?
|
8071 | options.handleUncaughtExceptions : true;
|
8072 |
|
8073 |
|
8074 |
|
8075 |
|
8076 |
|
8077 |
|
8078 |
|
8079 | if (installHandler && hasGlobalProcessEventEmitter()) {
|
8080 | uncaughtShimInstalled = true;
|
8081 | shimEmitUncaughtException();
|
8082 | }
|
8083 | }
|
8084 | };
|
8085 |
|
8086 | }).call(this,require('_process'),require("buffer").Buffer)
|
8087 |
|
8088 | },{"_process":67,"buffer":63,"fs":62,"path":66,"source-map":43}],53:[function(require,module,exports){
|
8089 | module.exports = require('./lib/type');
|
8090 |
|
8091 | },{"./lib/type":54}],54:[function(require,module,exports){
|
8092 |
|
8093 |
|
8094 |
|
8095 |
|
8096 |
|
8097 |
|
8098 |
|
8099 |
|
8100 | var exports = module.exports = getType;
|
8101 |
|
8102 |
|
8103 |
|
8104 |
|
8105 |
|
8106 |
|
8107 |
|
8108 |
|
8109 |
|
8110 |
|
8111 |
|
8112 | var objectTypeRegexp = /^\[object (.*)\]$/;
|
8113 | function getType(obj) {
|
8114 | var type = Object.prototype.toString.call(obj).match(objectTypeRegexp)[1].toLowerCase();
|
8115 |
|
8116 | if (typeof Promise === 'function' && obj instanceof Promise)
|
8117 | return 'promise';
|
8118 |
|
8119 | if (obj === null)
|
8120 | return 'null';
|
8121 |
|
8122 | if (obj === undefined)
|
8123 | return 'undefined';
|
8124 | return type;
|
8125 | }
|
8126 | exports.Library = Library;
|
8127 |
|
8128 |
|
8129 |
|
8130 |
|
8131 |
|
8132 |
|
8133 |
|
8134 |
|
8135 |
|
8136 |
|
8137 | function Library() {
|
8138 | if (!(this instanceof Library))
|
8139 | return new Library();
|
8140 | this.tests = {};
|
8141 | }
|
8142 |
|
8143 |
|
8144 |
|
8145 |
|
8146 |
|
8147 |
|
8148 |
|
8149 |
|
8150 |
|
8151 |
|
8152 |
|
8153 |
|
8154 |
|
8155 |
|
8156 | Library.prototype.of = getType;
|
8157 |
|
8158 |
|
8159 |
|
8160 |
|
8161 |
|
8162 |
|
8163 |
|
8164 |
|
8165 |
|
8166 |
|
8167 |
|
8168 |
|
8169 |
|
8170 |
|
8171 |
|
8172 |
|
8173 |
|
8174 |
|
8175 |
|
8176 |
|
8177 |
|
8178 |
|
8179 |
|
8180 |
|
8181 |
|
8182 |
|
8183 | Library.prototype.define = function (type, test) {
|
8184 | if (arguments.length === 1)
|
8185 | return this.tests[type];
|
8186 | this.tests[type] = test;
|
8187 | return this;
|
8188 | };
|
8189 |
|
8190 |
|
8191 |
|
8192 |
|
8193 |
|
8194 |
|
8195 |
|
8196 |
|
8197 |
|
8198 |
|
8199 |
|
8200 |
|
8201 |
|
8202 |
|
8203 |
|
8204 |
|
8205 |
|
8206 | Library.prototype.test = function (obj, type) {
|
8207 | if (type === getType(obj))
|
8208 | return true;
|
8209 | var test = this.tests[type];
|
8210 | if (test && 'regexp' === getType(test)) {
|
8211 | return test.test(obj);
|
8212 | }
|
8213 | else if (test && 'function' === getType(test)) {
|
8214 | return test(obj);
|
8215 | }
|
8216 | else {
|
8217 | throw new ReferenceError('Type test "' + type + '" not defined or invalid.');
|
8218 | }
|
8219 | };
|
8220 |
|
8221 | },{}],55:[function(require,module,exports){
|
8222 |
|
8223 | },{}],56:[function(require,module,exports){
|
8224 | (function (global){
|
8225 | "use strict";
|
8226 | var _1 = require("../");
|
8227 | var chai_1 = require("chai");
|
8228 | var isBrowser = !!global.document;
|
8229 | describe("The default component", function () {
|
8230 | it("should be instantiable", function () {
|
8231 | var inst = new _1.Component({});
|
8232 | });
|
8233 | it("should store the given data", function () {
|
8234 | var inst = new _1.Component({ x: 5 });
|
8235 | chai_1.expect(inst.$data.x).to.equal(5);
|
8236 | });
|
8237 | it("should produce HTML when asked", function () {
|
8238 | var inst = new _1.Component({});
|
8239 | var body = inst.toString();
|
8240 | chai_1.expect(body).to.contain(_1.Component.$tagName);
|
8241 | });
|
8242 | it("should properly serialize data", function () {
|
8243 | var inst = new _1.Component({ x: 5 });
|
8244 | var serialized = inst.$serializeData();
|
8245 | chai_1.expect(serialized.x).to.equal(inst.$data.x);
|
8246 | chai_1.expect(serialized).to.not.equal(inst.$data);
|
8247 | });
|
8248 | it("should be deflatable", function () {
|
8249 | var inst = new _1.Component({ x: 5 });
|
8250 | var deflated = inst.$deflate();
|
8251 | chai_1.expect(deflated.data.x).to.equal(5);
|
8252 | });
|
8253 | it("should be inflatable", function () {
|
8254 | var inst = new _1.Component({ x: 5 });
|
8255 | var deflated = inst.$deflate();
|
8256 | var reinst = _1.Component.$inflate(deflated);
|
8257 | chai_1.expect(reinst.$data.x).to.equal(5);
|
8258 | });
|
8259 | it("should expose a consistent identifier", function () {
|
8260 | var inst = new _1.Component({});
|
8261 | chai_1.expect(inst.$getIdentifier()).to.equal(_1.Component.$getIdentifier(inst.$label));
|
8262 | });
|
8263 | it("should properly nest", function () {
|
8264 | var parent = new _1.Component({});
|
8265 | var child = _1.Component.$for(parent, "", {});
|
8266 | chai_1.expect(parent.$children).to.contain(child);
|
8267 | });
|
8268 | if (isBrowser) {
|
8269 | it("should have an element after being ensured", function () {
|
8270 | var inst = new _1.Component({});
|
8271 | inst.$ensureElement();
|
8272 | chai_1.expect(inst.$element).to.be.instanceof(Element);
|
8273 | });
|
8274 | it("should created an element when reified", function () {
|
8275 | var inst = new _1.Component({});
|
8276 | inst.$reify();
|
8277 | chai_1.expect(inst.$element).to.be.instanceof(Element);
|
8278 | });
|
8279 | it("should attach to existing elements", function () {
|
8280 | var inst = new _1.Component({});
|
8281 | var el = document.createElement("arm-component");
|
8282 | inst.$attachTo(el);
|
8283 | chai_1.expect(inst.$element).to.equal(el);
|
8284 | });
|
8285 | }
|
8286 | });
|
8287 |
|
8288 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
8289 |
|
8290 | },{"../":6,"chai":9}],57:[function(require,module,exports){
|
8291 | "use strict";
|
8292 | require("source-map-support").install();
|
8293 | require("./default-component");
|
8294 | require("./simple-component");
|
8295 | require("./nesting-component");
|
8296 |
|
8297 | },{"./default-component":56,"./nesting-component":58,"./simple-component":59,"source-map-support":52}],58:[function(require,module,exports){
|
8298 | (function (global){
|
8299 | "use strict";
|
8300 | var __extends = (this && this.__extends) || function (d, b) {
|
8301 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
8302 | function __() { this.constructor = d; }
|
8303 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8304 | };
|
8305 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
8306 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
8307 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
8308 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
8309 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
8310 | };
|
8311 | var _1 = require("../");
|
8312 | var chai_1 = require("chai");
|
8313 | var isBrowser = !!global.document;
|
8314 | describe("A nesting component", function () {
|
8315 | var template = function (component) { return ("\n\t\tThis is a child: " + Child.$for(component, "", null) + "\n\t"); };
|
8316 | var Parent = (function (_super) {
|
8317 | __extends(Parent, _super);
|
8318 | function Parent(data) {
|
8319 | _super.call(this, data);
|
8320 | Child.$for(this, "", {});
|
8321 | }
|
8322 | Parent = __decorate([
|
8323 | _1.TagName("parent-component"),
|
8324 | _1.Template(template)
|
8325 | ], Parent);
|
8326 | return Parent;
|
8327 | }(_1.Component));
|
8328 | var Child = (function (_super) {
|
8329 | __extends(Child, _super);
|
8330 | function Child() {
|
8331 | _super.apply(this, arguments);
|
8332 | }
|
8333 | Child = __decorate([
|
8334 | _1.TagName("child-component")
|
8335 | ], Child);
|
8336 | return Child;
|
8337 | }(_1.Component));
|
8338 | it("should recall children correctly", function () {
|
8339 | var parent = new Parent({});
|
8340 | var child = Child.$for(parent, "", null);
|
8341 | chai_1.expect(parent.$children[0]).to.equal(child);
|
8342 | });
|
8343 | if (isBrowser) {
|
8344 | it("should reify without creating a new child component", function () {
|
8345 | var parent = new Parent({});
|
8346 | parent.$reify();
|
8347 | chai_1.expect(parent.$children).to.have.length(1);
|
8348 | });
|
8349 | it("should be able to locate itself in the parent", function () {
|
8350 | var parent = new Parent({});
|
8351 | parent.$reify();
|
8352 | var child = Child.$for(parent, "", null);
|
8353 | chai_1.expect(child.$element).to.be.instanceof(Element);
|
8354 | });
|
8355 | }
|
8356 | });
|
8357 |
|
8358 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
8359 |
|
8360 | },{"../":6,"chai":9}],59:[function(require,module,exports){
|
8361 | (function (global){
|
8362 | "use strict";
|
8363 | var __extends = (this && this.__extends) || function (d, b) {
|
8364 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
8365 | function __() { this.constructor = d; }
|
8366 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8367 | };
|
8368 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
8369 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
8370 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
8371 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
8372 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
8373 | };
|
8374 | var _1 = require("../");
|
8375 | var chai_1 = require("chai");
|
8376 | var isBrowser = !!global.document;
|
8377 | describe("A simple component", function () {
|
8378 | var template = function (component) { return ("\n\t\tWe have this: " + component.$data.x + "\n\t"); };
|
8379 | var Simple = (function (_super) {
|
8380 | __extends(Simple, _super);
|
8381 | function Simple(params) {
|
8382 | _super.call(this, params);
|
8383 | }
|
8384 | Simple = __decorate([
|
8385 | _1.TagName("simple-component"),
|
8386 | _1.Template(template)
|
8387 | ], Simple);
|
8388 | return Simple;
|
8389 | }(_1.Component));
|
8390 | if (isBrowser) {
|
8391 | it("should render with the correct markup", function () {
|
8392 | var inst = new Simple({ x: 5 });
|
8393 | inst.$reify();
|
8394 | chai_1.expect(inst.$element.innerHTML).to.equal(inst.$template(inst));
|
8395 | });
|
8396 | }
|
8397 | });
|
8398 |
|
8399 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
8400 |
|
8401 | },{"../":6,"chai":9}],60:[function(require,module,exports){
|
8402 | arguments[4][55][0].apply(exports,arguments)
|
8403 | },{"dup":55}],61:[function(require,module,exports){
|
8404 | 'use strict'
|
8405 |
|
8406 | exports.toByteArray = toByteArray
|
8407 | exports.fromByteArray = fromByteArray
|
8408 |
|
8409 | var lookup = []
|
8410 | var revLookup = []
|
8411 | var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
8412 |
|
8413 | function init () {
|
8414 | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
8415 | for (var i = 0, len = code.length; i < len; ++i) {
|
8416 | lookup[i] = code[i]
|
8417 | revLookup[code.charCodeAt(i)] = i
|
8418 | }
|
8419 |
|
8420 | revLookup['-'.charCodeAt(0)] = 62
|
8421 | revLookup['_'.charCodeAt(0)] = 63
|
8422 | }
|
8423 |
|
8424 | init()
|
8425 |
|
8426 | function toByteArray (b64) {
|
8427 | var i, j, l, tmp, placeHolders, arr
|
8428 | var len = b64.length
|
8429 |
|
8430 | if (len % 4 > 0) {
|
8431 | throw new Error('Invalid string. Length must be a multiple of 4')
|
8432 | }
|
8433 |
|
8434 |
|
8435 |
|
8436 |
|
8437 |
|
8438 |
|
8439 | placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
|
8440 |
|
8441 |
|
8442 | arr = new Arr(len * 3 / 4 - placeHolders)
|
8443 |
|
8444 |
|
8445 | l = placeHolders > 0 ? len - 4 : len
|
8446 |
|
8447 | var L = 0
|
8448 |
|
8449 | for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
8450 | tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
|
8451 | arr[L++] = (tmp >> 16) & 0xFF
|
8452 | arr[L++] = (tmp >> 8) & 0xFF
|
8453 | arr[L++] = tmp & 0xFF
|
8454 | }
|
8455 |
|
8456 | if (placeHolders === 2) {
|
8457 | tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
|
8458 | arr[L++] = tmp & 0xFF
|
8459 | } else if (placeHolders === 1) {
|
8460 | tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
|
8461 | arr[L++] = (tmp >> 8) & 0xFF
|
8462 | arr[L++] = tmp & 0xFF
|
8463 | }
|
8464 |
|
8465 | return arr
|
8466 | }
|
8467 |
|
8468 | function tripletToBase64 (num) {
|
8469 | return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
|
8470 | }
|
8471 |
|
8472 | function encodeChunk (uint8, start, end) {
|
8473 | var tmp
|
8474 | var output = []
|
8475 | for (var i = start; i < end; i += 3) {
|
8476 | tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
8477 | output.push(tripletToBase64(tmp))
|
8478 | }
|
8479 | return output.join('')
|
8480 | }
|
8481 |
|
8482 | function fromByteArray (uint8) {
|
8483 | var tmp
|
8484 | var len = uint8.length
|
8485 | var extraBytes = len % 3
|
8486 | var output = ''
|
8487 | var parts = []
|
8488 | var maxChunkLength = 16383
|
8489 |
|
8490 |
|
8491 | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
8492 | parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
|
8493 | }
|
8494 |
|
8495 |
|
8496 | if (extraBytes === 1) {
|
8497 | tmp = uint8[len - 1]
|
8498 | output += lookup[tmp >> 2]
|
8499 | output += lookup[(tmp << 4) & 0x3F]
|
8500 | output += '=='
|
8501 | } else if (extraBytes === 2) {
|
8502 | tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
|
8503 | output += lookup[tmp >> 10]
|
8504 | output += lookup[(tmp >> 4) & 0x3F]
|
8505 | output += lookup[(tmp << 2) & 0x3F]
|
8506 | output += '='
|
8507 | }
|
8508 |
|
8509 | parts.push(output)
|
8510 |
|
8511 | return parts.join('')
|
8512 | }
|
8513 |
|
8514 | },{}],62:[function(require,module,exports){
|
8515 | arguments[4][55][0].apply(exports,arguments)
|
8516 | },{"dup":55}],63:[function(require,module,exports){
|
8517 | (function (global){
|
8518 |
|
8519 |
|
8520 |
|
8521 |
|
8522 |
|
8523 |
|
8524 |
|
8525 |
|
8526 | 'use strict'
|
8527 |
|
8528 | var base64 = require('base64-js')
|
8529 | var ieee754 = require('ieee754')
|
8530 | var isArray = require('isarray')
|
8531 |
|
8532 | exports.Buffer = Buffer
|
8533 | exports.SlowBuffer = SlowBuffer
|
8534 | exports.INSPECT_MAX_BYTES = 50
|
8535 |
|
8536 |
|
8537 |
|
8538 |
|
8539 |
|
8540 |
|
8541 |
|
8542 |
|
8543 |
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 |
|
8549 |
|
8550 |
|
8551 |
|
8552 |
|
8553 |
|
8554 |
|
8555 |
|
8556 |
|
8557 |
|
8558 |
|
8559 |
|
8560 | Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
8561 | ? global.TYPED_ARRAY_SUPPORT
|
8562 | : typedArraySupport()
|
8563 |
|
8564 |
|
8565 |
|
8566 |
|
8567 | exports.kMaxLength = kMaxLength()
|
8568 |
|
8569 | function typedArraySupport () {
|
8570 | try {
|
8571 | var arr = new Uint8Array(1)
|
8572 | arr.foo = function () { return 42 }
|
8573 | return arr.foo() === 42 &&
|
8574 | typeof arr.subarray === 'function' &&
|
8575 | arr.subarray(1, 1).byteLength === 0
|
8576 | } catch (e) {
|
8577 | return false
|
8578 | }
|
8579 | }
|
8580 |
|
8581 | function kMaxLength () {
|
8582 | return Buffer.TYPED_ARRAY_SUPPORT
|
8583 | ? 0x7fffffff
|
8584 | : 0x3fffffff
|
8585 | }
|
8586 |
|
8587 | function createBuffer (that, length) {
|
8588 | if (kMaxLength() < length) {
|
8589 | throw new RangeError('Invalid typed array length')
|
8590 | }
|
8591 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
8592 |
|
8593 | that = new Uint8Array(length)
|
8594 | that.__proto__ = Buffer.prototype
|
8595 | } else {
|
8596 |
|
8597 | if (that === null) {
|
8598 | that = new Buffer(length)
|
8599 | }
|
8600 | that.length = length
|
8601 | }
|
8602 |
|
8603 | return that
|
8604 | }
|
8605 |
|
8606 |
|
8607 |
|
8608 |
|
8609 |
|
8610 |
|
8611 |
|
8612 |
|
8613 |
|
8614 |
|
8615 |
|
8616 | function Buffer (arg, encodingOrOffset, length) {
|
8617 | if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
8618 | return new Buffer(arg, encodingOrOffset, length)
|
8619 | }
|
8620 |
|
8621 |
|
8622 | if (typeof arg === 'number') {
|
8623 | if (typeof encodingOrOffset === 'string') {
|
8624 | throw new Error(
|
8625 | 'If encoding is specified then the first argument must be a string'
|
8626 | )
|
8627 | }
|
8628 | return allocUnsafe(this, arg)
|
8629 | }
|
8630 | return from(this, arg, encodingOrOffset, length)
|
8631 | }
|
8632 |
|
8633 | Buffer.poolSize = 8192
|
8634 |
|
8635 |
|
8636 | Buffer._augment = function (arr) {
|
8637 | arr.__proto__ = Buffer.prototype
|
8638 | return arr
|
8639 | }
|
8640 |
|
8641 | function from (that, value, encodingOrOffset, length) {
|
8642 | if (typeof value === 'number') {
|
8643 | throw new TypeError('"value" argument must not be a number')
|
8644 | }
|
8645 |
|
8646 | if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
|
8647 | return fromArrayBuffer(that, value, encodingOrOffset, length)
|
8648 | }
|
8649 |
|
8650 | if (typeof value === 'string') {
|
8651 | return fromString(that, value, encodingOrOffset)
|
8652 | }
|
8653 |
|
8654 | return fromObject(that, value)
|
8655 | }
|
8656 |
|
8657 |
|
8658 |
|
8659 |
|
8660 |
|
8661 |
|
8662 |
|
8663 |
|
8664 |
|
8665 | Buffer.from = function (value, encodingOrOffset, length) {
|
8666 | return from(null, value, encodingOrOffset, length)
|
8667 | }
|
8668 |
|
8669 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
8670 | Buffer.prototype.__proto__ = Uint8Array.prototype
|
8671 | Buffer.__proto__ = Uint8Array
|
8672 | if (typeof Symbol !== 'undefined' && Symbol.species &&
|
8673 | Buffer[Symbol.species] === Buffer) {
|
8674 |
|
8675 | Object.defineProperty(Buffer, Symbol.species, {
|
8676 | value: null,
|
8677 | configurable: true
|
8678 | })
|
8679 | }
|
8680 | }
|
8681 |
|
8682 | function assertSize (size) {
|
8683 | if (typeof size !== 'number') {
|
8684 | throw new TypeError('"size" argument must be a number')
|
8685 | }
|
8686 | }
|
8687 |
|
8688 | function alloc (that, size, fill, encoding) {
|
8689 | assertSize(size)
|
8690 | if (size <= 0) {
|
8691 | return createBuffer(that, size)
|
8692 | }
|
8693 | if (fill !== undefined) {
|
8694 |
|
8695 |
|
8696 |
|
8697 | return typeof encoding === 'string'
|
8698 | ? createBuffer(that, size).fill(fill, encoding)
|
8699 | : createBuffer(that, size).fill(fill)
|
8700 | }
|
8701 | return createBuffer(that, size)
|
8702 | }
|
8703 |
|
8704 |
|
8705 |
|
8706 |
|
8707 |
|
8708 | Buffer.alloc = function (size, fill, encoding) {
|
8709 | return alloc(null, size, fill, encoding)
|
8710 | }
|
8711 |
|
8712 | function allocUnsafe (that, size) {
|
8713 | assertSize(size)
|
8714 | that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
|
8715 | if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
8716 | for (var i = 0; i < size; i++) {
|
8717 | that[i] = 0
|
8718 | }
|
8719 | }
|
8720 | return that
|
8721 | }
|
8722 |
|
8723 |
|
8724 |
|
8725 |
|
8726 | Buffer.allocUnsafe = function (size) {
|
8727 | return allocUnsafe(null, size)
|
8728 | }
|
8729 |
|
8730 |
|
8731 |
|
8732 | Buffer.allocUnsafeSlow = function (size) {
|
8733 | return allocUnsafe(null, size)
|
8734 | }
|
8735 |
|
8736 | function fromString (that, string, encoding) {
|
8737 | if (typeof encoding !== 'string' || encoding === '') {
|
8738 | encoding = 'utf8'
|
8739 | }
|
8740 |
|
8741 | if (!Buffer.isEncoding(encoding)) {
|
8742 | throw new TypeError('"encoding" must be a valid string encoding')
|
8743 | }
|
8744 |
|
8745 | var length = byteLength(string, encoding) | 0
|
8746 | that = createBuffer(that, length)
|
8747 |
|
8748 | that.write(string, encoding)
|
8749 | return that
|
8750 | }
|
8751 |
|
8752 | function fromArrayLike (that, array) {
|
8753 | var length = checked(array.length) | 0
|
8754 | that = createBuffer(that, length)
|
8755 | for (var i = 0; i < length; i += 1) {
|
8756 | that[i] = array[i] & 255
|
8757 | }
|
8758 | return that
|
8759 | }
|
8760 |
|
8761 | function fromArrayBuffer (that, array, byteOffset, length) {
|
8762 | array.byteLength
|
8763 |
|
8764 | if (byteOffset < 0 || array.byteLength < byteOffset) {
|
8765 | throw new RangeError('\'offset\' is out of bounds')
|
8766 | }
|
8767 |
|
8768 | if (array.byteLength < byteOffset + (length || 0)) {
|
8769 | throw new RangeError('\'length\' is out of bounds')
|
8770 | }
|
8771 |
|
8772 | if (length === undefined) {
|
8773 | array = new Uint8Array(array, byteOffset)
|
8774 | } else {
|
8775 | array = new Uint8Array(array, byteOffset, length)
|
8776 | }
|
8777 |
|
8778 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
8779 |
|
8780 | that = array
|
8781 | that.__proto__ = Buffer.prototype
|
8782 | } else {
|
8783 |
|
8784 | that = fromArrayLike(that, array)
|
8785 | }
|
8786 | return that
|
8787 | }
|
8788 |
|
8789 | function fromObject (that, obj) {
|
8790 | if (Buffer.isBuffer(obj)) {
|
8791 | var len = checked(obj.length) | 0
|
8792 | that = createBuffer(that, len)
|
8793 |
|
8794 | if (that.length === 0) {
|
8795 | return that
|
8796 | }
|
8797 |
|
8798 | obj.copy(that, 0, 0, len)
|
8799 | return that
|
8800 | }
|
8801 |
|
8802 | if (obj) {
|
8803 | if ((typeof ArrayBuffer !== 'undefined' &&
|
8804 | obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
|
8805 | if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
8806 | return createBuffer(that, 0)
|
8807 | }
|
8808 | return fromArrayLike(that, obj)
|
8809 | }
|
8810 |
|
8811 | if (obj.type === 'Buffer' && isArray(obj.data)) {
|
8812 | return fromArrayLike(that, obj.data)
|
8813 | }
|
8814 | }
|
8815 |
|
8816 | throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
8817 | }
|
8818 |
|
8819 | function checked (length) {
|
8820 |
|
8821 |
|
8822 | if (length >= kMaxLength()) {
|
8823 | throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
8824 | 'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
8825 | }
|
8826 | return length | 0
|
8827 | }
|
8828 |
|
8829 | function SlowBuffer (length) {
|
8830 | if (+length != length) {
|
8831 | length = 0
|
8832 | }
|
8833 | return Buffer.alloc(+length)
|
8834 | }
|
8835 |
|
8836 | Buffer.isBuffer = function isBuffer (b) {
|
8837 | return !!(b != null && b._isBuffer)
|
8838 | }
|
8839 |
|
8840 | Buffer.compare = function compare (a, b) {
|
8841 | if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
8842 | throw new TypeError('Arguments must be Buffers')
|
8843 | }
|
8844 |
|
8845 | if (a === b) return 0
|
8846 |
|
8847 | var x = a.length
|
8848 | var y = b.length
|
8849 |
|
8850 | for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
8851 | if (a[i] !== b[i]) {
|
8852 | x = a[i]
|
8853 | y = b[i]
|
8854 | break
|
8855 | }
|
8856 | }
|
8857 |
|
8858 | if (x < y) return -1
|
8859 | if (y < x) return 1
|
8860 | return 0
|
8861 | }
|
8862 |
|
8863 | Buffer.isEncoding = function isEncoding (encoding) {
|
8864 | switch (String(encoding).toLowerCase()) {
|
8865 | case 'hex':
|
8866 | case 'utf8':
|
8867 | case 'utf-8':
|
8868 | case 'ascii':
|
8869 | case 'binary':
|
8870 | case 'base64':
|
8871 | case 'raw':
|
8872 | case 'ucs2':
|
8873 | case 'ucs-2':
|
8874 | case 'utf16le':
|
8875 | case 'utf-16le':
|
8876 | return true
|
8877 | default:
|
8878 | return false
|
8879 | }
|
8880 | }
|
8881 |
|
8882 | Buffer.concat = function concat (list, length) {
|
8883 | if (!isArray(list)) {
|
8884 | throw new TypeError('"list" argument must be an Array of Buffers')
|
8885 | }
|
8886 |
|
8887 | if (list.length === 0) {
|
8888 | return Buffer.alloc(0)
|
8889 | }
|
8890 |
|
8891 | var i
|
8892 | if (length === undefined) {
|
8893 | length = 0
|
8894 | for (i = 0; i < list.length; i++) {
|
8895 | length += list[i].length
|
8896 | }
|
8897 | }
|
8898 |
|
8899 | var buffer = Buffer.allocUnsafe(length)
|
8900 | var pos = 0
|
8901 | for (i = 0; i < list.length; i++) {
|
8902 | var buf = list[i]
|
8903 | if (!Buffer.isBuffer(buf)) {
|
8904 | throw new TypeError('"list" argument must be an Array of Buffers')
|
8905 | }
|
8906 | buf.copy(buffer, pos)
|
8907 | pos += buf.length
|
8908 | }
|
8909 | return buffer
|
8910 | }
|
8911 |
|
8912 | function byteLength (string, encoding) {
|
8913 | if (Buffer.isBuffer(string)) {
|
8914 | return string.length
|
8915 | }
|
8916 | if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
|
8917 | (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
8918 | return string.byteLength
|
8919 | }
|
8920 | if (typeof string !== 'string') {
|
8921 | string = '' + string
|
8922 | }
|
8923 |
|
8924 | var len = string.length
|
8925 | if (len === 0) return 0
|
8926 |
|
8927 |
|
8928 | var loweredCase = false
|
8929 | for (;;) {
|
8930 | switch (encoding) {
|
8931 | case 'ascii':
|
8932 | case 'binary':
|
8933 |
|
8934 | case 'raw':
|
8935 | case 'raws':
|
8936 | return len
|
8937 | case 'utf8':
|
8938 | case 'utf-8':
|
8939 | case undefined:
|
8940 | return utf8ToBytes(string).length
|
8941 | case 'ucs2':
|
8942 | case 'ucs-2':
|
8943 | case 'utf16le':
|
8944 | case 'utf-16le':
|
8945 | return len * 2
|
8946 | case 'hex':
|
8947 | return len >>> 1
|
8948 | case 'base64':
|
8949 | return base64ToBytes(string).length
|
8950 | default:
|
8951 | if (loweredCase) return utf8ToBytes(string).length
|
8952 | encoding = ('' + encoding).toLowerCase()
|
8953 | loweredCase = true
|
8954 | }
|
8955 | }
|
8956 | }
|
8957 | Buffer.byteLength = byteLength
|
8958 |
|
8959 | function slowToString (encoding, start, end) {
|
8960 | var loweredCase = false
|
8961 |
|
8962 |
|
8963 |
|
8964 |
|
8965 |
|
8966 |
|
8967 |
|
8968 |
|
8969 | if (start === undefined || start < 0) {
|
8970 | start = 0
|
8971 | }
|
8972 |
|
8973 |
|
8974 | if (start > this.length) {
|
8975 | return ''
|
8976 | }
|
8977 |
|
8978 | if (end === undefined || end > this.length) {
|
8979 | end = this.length
|
8980 | }
|
8981 |
|
8982 | if (end <= 0) {
|
8983 | return ''
|
8984 | }
|
8985 |
|
8986 |
|
8987 | end >>>= 0
|
8988 | start >>>= 0
|
8989 |
|
8990 | if (end <= start) {
|
8991 | return ''
|
8992 | }
|
8993 |
|
8994 | if (!encoding) encoding = 'utf8'
|
8995 |
|
8996 | while (true) {
|
8997 | switch (encoding) {
|
8998 | case 'hex':
|
8999 | return hexSlice(this, start, end)
|
9000 |
|
9001 | case 'utf8':
|
9002 | case 'utf-8':
|
9003 | return utf8Slice(this, start, end)
|
9004 |
|
9005 | case 'ascii':
|
9006 | return asciiSlice(this, start, end)
|
9007 |
|
9008 | case 'binary':
|
9009 | return binarySlice(this, start, end)
|
9010 |
|
9011 | case 'base64':
|
9012 | return base64Slice(this, start, end)
|
9013 |
|
9014 | case 'ucs2':
|
9015 | case 'ucs-2':
|
9016 | case 'utf16le':
|
9017 | case 'utf-16le':
|
9018 | return utf16leSlice(this, start, end)
|
9019 |
|
9020 | default:
|
9021 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
9022 | encoding = (encoding + '').toLowerCase()
|
9023 | loweredCase = true
|
9024 | }
|
9025 | }
|
9026 | }
|
9027 |
|
9028 |
|
9029 |
|
9030 | Buffer.prototype._isBuffer = true
|
9031 |
|
9032 | function swap (b, n, m) {
|
9033 | var i = b[n]
|
9034 | b[n] = b[m]
|
9035 | b[m] = i
|
9036 | }
|
9037 |
|
9038 | Buffer.prototype.swap16 = function swap16 () {
|
9039 | var len = this.length
|
9040 | if (len % 2 !== 0) {
|
9041 | throw new RangeError('Buffer size must be a multiple of 16-bits')
|
9042 | }
|
9043 | for (var i = 0; i < len; i += 2) {
|
9044 | swap(this, i, i + 1)
|
9045 | }
|
9046 | return this
|
9047 | }
|
9048 |
|
9049 | Buffer.prototype.swap32 = function swap32 () {
|
9050 | var len = this.length
|
9051 | if (len % 4 !== 0) {
|
9052 | throw new RangeError('Buffer size must be a multiple of 32-bits')
|
9053 | }
|
9054 | for (var i = 0; i < len; i += 4) {
|
9055 | swap(this, i, i + 3)
|
9056 | swap(this, i + 1, i + 2)
|
9057 | }
|
9058 | return this
|
9059 | }
|
9060 |
|
9061 | Buffer.prototype.toString = function toString () {
|
9062 | var length = this.length | 0
|
9063 | if (length === 0) return ''
|
9064 | if (arguments.length === 0) return utf8Slice(this, 0, length)
|
9065 | return slowToString.apply(this, arguments)
|
9066 | }
|
9067 |
|
9068 | Buffer.prototype.equals = function equals (b) {
|
9069 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
9070 | if (this === b) return true
|
9071 | return Buffer.compare(this, b) === 0
|
9072 | }
|
9073 |
|
9074 | Buffer.prototype.inspect = function inspect () {
|
9075 | var str = ''
|
9076 | var max = exports.INSPECT_MAX_BYTES
|
9077 | if (this.length > 0) {
|
9078 | str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
9079 | if (this.length > max) str += ' ... '
|
9080 | }
|
9081 | return '<Buffer ' + str + '>'
|
9082 | }
|
9083 |
|
9084 | Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
9085 | if (!Buffer.isBuffer(target)) {
|
9086 | throw new TypeError('Argument must be a Buffer')
|
9087 | }
|
9088 |
|
9089 | if (start === undefined) {
|
9090 | start = 0
|
9091 | }
|
9092 | if (end === undefined) {
|
9093 | end = target ? target.length : 0
|
9094 | }
|
9095 | if (thisStart === undefined) {
|
9096 | thisStart = 0
|
9097 | }
|
9098 | if (thisEnd === undefined) {
|
9099 | thisEnd = this.length
|
9100 | }
|
9101 |
|
9102 | if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
9103 | throw new RangeError('out of range index')
|
9104 | }
|
9105 |
|
9106 | if (thisStart >= thisEnd && start >= end) {
|
9107 | return 0
|
9108 | }
|
9109 | if (thisStart >= thisEnd) {
|
9110 | return -1
|
9111 | }
|
9112 | if (start >= end) {
|
9113 | return 1
|
9114 | }
|
9115 |
|
9116 | start >>>= 0
|
9117 | end >>>= 0
|
9118 | thisStart >>>= 0
|
9119 | thisEnd >>>= 0
|
9120 |
|
9121 | if (this === target) return 0
|
9122 |
|
9123 | var x = thisEnd - thisStart
|
9124 | var y = end - start
|
9125 | var len = Math.min(x, y)
|
9126 |
|
9127 | var thisCopy = this.slice(thisStart, thisEnd)
|
9128 | var targetCopy = target.slice(start, end)
|
9129 |
|
9130 | for (var i = 0; i < len; ++i) {
|
9131 | if (thisCopy[i] !== targetCopy[i]) {
|
9132 | x = thisCopy[i]
|
9133 | y = targetCopy[i]
|
9134 | break
|
9135 | }
|
9136 | }
|
9137 |
|
9138 | if (x < y) return -1
|
9139 | if (y < x) return 1
|
9140 | return 0
|
9141 | }
|
9142 |
|
9143 | function arrayIndexOf (arr, val, byteOffset, encoding) {
|
9144 | var indexSize = 1
|
9145 | var arrLength = arr.length
|
9146 | var valLength = val.length
|
9147 |
|
9148 | if (encoding !== undefined) {
|
9149 | encoding = String(encoding).toLowerCase()
|
9150 | if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
9151 | encoding === 'utf16le' || encoding === 'utf-16le') {
|
9152 | if (arr.length < 2 || val.length < 2) {
|
9153 | return -1
|
9154 | }
|
9155 | indexSize = 2
|
9156 | arrLength /= 2
|
9157 | valLength /= 2
|
9158 | byteOffset /= 2
|
9159 | }
|
9160 | }
|
9161 |
|
9162 | function read (buf, i) {
|
9163 | if (indexSize === 1) {
|
9164 | return buf[i]
|
9165 | } else {
|
9166 | return buf.readUInt16BE(i * indexSize)
|
9167 | }
|
9168 | }
|
9169 |
|
9170 | var foundIndex = -1
|
9171 | for (var i = 0; byteOffset + i < arrLength; i++) {
|
9172 | if (read(arr, byteOffset + i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
9173 | if (foundIndex === -1) foundIndex = i
|
9174 | if (i - foundIndex + 1 === valLength) return (byteOffset + foundIndex) * indexSize
|
9175 | } else {
|
9176 | if (foundIndex !== -1) i -= i - foundIndex
|
9177 | foundIndex = -1
|
9178 | }
|
9179 | }
|
9180 | return -1
|
9181 | }
|
9182 |
|
9183 | Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
9184 | if (typeof byteOffset === 'string') {
|
9185 | encoding = byteOffset
|
9186 | byteOffset = 0
|
9187 | } else if (byteOffset > 0x7fffffff) {
|
9188 | byteOffset = 0x7fffffff
|
9189 | } else if (byteOffset < -0x80000000) {
|
9190 | byteOffset = -0x80000000
|
9191 | }
|
9192 | byteOffset >>= 0
|
9193 |
|
9194 | if (this.length === 0) return -1
|
9195 | if (byteOffset >= this.length) return -1
|
9196 |
|
9197 |
|
9198 | if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
|
9199 |
|
9200 | if (typeof val === 'string') {
|
9201 | val = Buffer.from(val, encoding)
|
9202 | }
|
9203 |
|
9204 | if (Buffer.isBuffer(val)) {
|
9205 |
|
9206 | if (val.length === 0) {
|
9207 | return -1
|
9208 | }
|
9209 | return arrayIndexOf(this, val, byteOffset, encoding)
|
9210 | }
|
9211 | if (typeof val === 'number') {
|
9212 | if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
9213 | return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
|
9214 | }
|
9215 | return arrayIndexOf(this, [ val ], byteOffset, encoding)
|
9216 | }
|
9217 |
|
9218 | throw new TypeError('val must be string, number or Buffer')
|
9219 | }
|
9220 |
|
9221 | Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
9222 | return this.indexOf(val, byteOffset, encoding) !== -1
|
9223 | }
|
9224 |
|
9225 | function hexWrite (buf, string, offset, length) {
|
9226 | offset = Number(offset) || 0
|
9227 | var remaining = buf.length - offset
|
9228 | if (!length) {
|
9229 | length = remaining
|
9230 | } else {
|
9231 | length = Number(length)
|
9232 | if (length > remaining) {
|
9233 | length = remaining
|
9234 | }
|
9235 | }
|
9236 |
|
9237 |
|
9238 | var strLen = string.length
|
9239 | if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
9240 |
|
9241 | if (length > strLen / 2) {
|
9242 | length = strLen / 2
|
9243 | }
|
9244 | for (var i = 0; i < length; i++) {
|
9245 | var parsed = parseInt(string.substr(i * 2, 2), 16)
|
9246 | if (isNaN(parsed)) return i
|
9247 | buf[offset + i] = parsed
|
9248 | }
|
9249 | return i
|
9250 | }
|
9251 |
|
9252 | function utf8Write (buf, string, offset, length) {
|
9253 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
9254 | }
|
9255 |
|
9256 | function asciiWrite (buf, string, offset, length) {
|
9257 | return blitBuffer(asciiToBytes(string), buf, offset, length)
|
9258 | }
|
9259 |
|
9260 | function binaryWrite (buf, string, offset, length) {
|
9261 | return asciiWrite(buf, string, offset, length)
|
9262 | }
|
9263 |
|
9264 | function base64Write (buf, string, offset, length) {
|
9265 | return blitBuffer(base64ToBytes(string), buf, offset, length)
|
9266 | }
|
9267 |
|
9268 | function ucs2Write (buf, string, offset, length) {
|
9269 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
9270 | }
|
9271 |
|
9272 | Buffer.prototype.write = function write (string, offset, length, encoding) {
|
9273 |
|
9274 | if (offset === undefined) {
|
9275 | encoding = 'utf8'
|
9276 | length = this.length
|
9277 | offset = 0
|
9278 |
|
9279 | } else if (length === undefined && typeof offset === 'string') {
|
9280 | encoding = offset
|
9281 | length = this.length
|
9282 | offset = 0
|
9283 |
|
9284 | } else if (isFinite(offset)) {
|
9285 | offset = offset | 0
|
9286 | if (isFinite(length)) {
|
9287 | length = length | 0
|
9288 | if (encoding === undefined) encoding = 'utf8'
|
9289 | } else {
|
9290 | encoding = length
|
9291 | length = undefined
|
9292 | }
|
9293 |
|
9294 | } else {
|
9295 | throw new Error(
|
9296 | 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
9297 | )
|
9298 | }
|
9299 |
|
9300 | var remaining = this.length - offset
|
9301 | if (length === undefined || length > remaining) length = remaining
|
9302 |
|
9303 | if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
9304 | throw new RangeError('Attempt to write outside buffer bounds')
|
9305 | }
|
9306 |
|
9307 | if (!encoding) encoding = 'utf8'
|
9308 |
|
9309 | var loweredCase = false
|
9310 | for (;;) {
|
9311 | switch (encoding) {
|
9312 | case 'hex':
|
9313 | return hexWrite(this, string, offset, length)
|
9314 |
|
9315 | case 'utf8':
|
9316 | case 'utf-8':
|
9317 | return utf8Write(this, string, offset, length)
|
9318 |
|
9319 | case 'ascii':
|
9320 | return asciiWrite(this, string, offset, length)
|
9321 |
|
9322 | case 'binary':
|
9323 | return binaryWrite(this, string, offset, length)
|
9324 |
|
9325 | case 'base64':
|
9326 |
|
9327 | return base64Write(this, string, offset, length)
|
9328 |
|
9329 | case 'ucs2':
|
9330 | case 'ucs-2':
|
9331 | case 'utf16le':
|
9332 | case 'utf-16le':
|
9333 | return ucs2Write(this, string, offset, length)
|
9334 |
|
9335 | default:
|
9336 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
9337 | encoding = ('' + encoding).toLowerCase()
|
9338 | loweredCase = true
|
9339 | }
|
9340 | }
|
9341 | }
|
9342 |
|
9343 | Buffer.prototype.toJSON = function toJSON () {
|
9344 | return {
|
9345 | type: 'Buffer',
|
9346 | data: Array.prototype.slice.call(this._arr || this, 0)
|
9347 | }
|
9348 | }
|
9349 |
|
9350 | function base64Slice (buf, start, end) {
|
9351 | if (start === 0 && end === buf.length) {
|
9352 | return base64.fromByteArray(buf)
|
9353 | } else {
|
9354 | return base64.fromByteArray(buf.slice(start, end))
|
9355 | }
|
9356 | }
|
9357 |
|
9358 | function utf8Slice (buf, start, end) {
|
9359 | end = Math.min(buf.length, end)
|
9360 | var res = []
|
9361 |
|
9362 | var i = start
|
9363 | while (i < end) {
|
9364 | var firstByte = buf[i]
|
9365 | var codePoint = null
|
9366 | var bytesPerSequence = (firstByte > 0xEF) ? 4
|
9367 | : (firstByte > 0xDF) ? 3
|
9368 | : (firstByte > 0xBF) ? 2
|
9369 | : 1
|
9370 |
|
9371 | if (i + bytesPerSequence <= end) {
|
9372 | var secondByte, thirdByte, fourthByte, tempCodePoint
|
9373 |
|
9374 | switch (bytesPerSequence) {
|
9375 | case 1:
|
9376 | if (firstByte < 0x80) {
|
9377 | codePoint = firstByte
|
9378 | }
|
9379 | break
|
9380 | case 2:
|
9381 | secondByte = buf[i + 1]
|
9382 | if ((secondByte & 0xC0) === 0x80) {
|
9383 | tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
9384 | if (tempCodePoint > 0x7F) {
|
9385 | codePoint = tempCodePoint
|
9386 | }
|
9387 | }
|
9388 | break
|
9389 | case 3:
|
9390 | secondByte = buf[i + 1]
|
9391 | thirdByte = buf[i + 2]
|
9392 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
9393 | tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
9394 | if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
9395 | codePoint = tempCodePoint
|
9396 | }
|
9397 | }
|
9398 | break
|
9399 | case 4:
|
9400 | secondByte = buf[i + 1]
|
9401 | thirdByte = buf[i + 2]
|
9402 | fourthByte = buf[i + 3]
|
9403 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
9404 | tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
9405 | if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
9406 | codePoint = tempCodePoint
|
9407 | }
|
9408 | }
|
9409 | }
|
9410 | }
|
9411 |
|
9412 | if (codePoint === null) {
|
9413 |
|
9414 |
|
9415 | codePoint = 0xFFFD
|
9416 | bytesPerSequence = 1
|
9417 | } else if (codePoint > 0xFFFF) {
|
9418 |
|
9419 | codePoint -= 0x10000
|
9420 | res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
9421 | codePoint = 0xDC00 | codePoint & 0x3FF
|
9422 | }
|
9423 |
|
9424 | res.push(codePoint)
|
9425 | i += bytesPerSequence
|
9426 | }
|
9427 |
|
9428 | return decodeCodePointsArray(res)
|
9429 | }
|
9430 |
|
9431 |
|
9432 |
|
9433 |
|
9434 | var MAX_ARGUMENTS_LENGTH = 0x1000
|
9435 |
|
9436 | function decodeCodePointsArray (codePoints) {
|
9437 | var len = codePoints.length
|
9438 | if (len <= MAX_ARGUMENTS_LENGTH) {
|
9439 | return String.fromCharCode.apply(String, codePoints)
|
9440 | }
|
9441 |
|
9442 |
|
9443 | var res = ''
|
9444 | var i = 0
|
9445 | while (i < len) {
|
9446 | res += String.fromCharCode.apply(
|
9447 | String,
|
9448 | codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
9449 | )
|
9450 | }
|
9451 | return res
|
9452 | }
|
9453 |
|
9454 | function asciiSlice (buf, start, end) {
|
9455 | var ret = ''
|
9456 | end = Math.min(buf.length, end)
|
9457 |
|
9458 | for (var i = start; i < end; i++) {
|
9459 | ret += String.fromCharCode(buf[i] & 0x7F)
|
9460 | }
|
9461 | return ret
|
9462 | }
|
9463 |
|
9464 | function binarySlice (buf, start, end) {
|
9465 | var ret = ''
|
9466 | end = Math.min(buf.length, end)
|
9467 |
|
9468 | for (var i = start; i < end; i++) {
|
9469 | ret += String.fromCharCode(buf[i])
|
9470 | }
|
9471 | return ret
|
9472 | }
|
9473 |
|
9474 | function hexSlice (buf, start, end) {
|
9475 | var len = buf.length
|
9476 |
|
9477 | if (!start || start < 0) start = 0
|
9478 | if (!end || end < 0 || end > len) end = len
|
9479 |
|
9480 | var out = ''
|
9481 | for (var i = start; i < end; i++) {
|
9482 | out += toHex(buf[i])
|
9483 | }
|
9484 | return out
|
9485 | }
|
9486 |
|
9487 | function utf16leSlice (buf, start, end) {
|
9488 | var bytes = buf.slice(start, end)
|
9489 | var res = ''
|
9490 | for (var i = 0; i < bytes.length; i += 2) {
|
9491 | res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
9492 | }
|
9493 | return res
|
9494 | }
|
9495 |
|
9496 | Buffer.prototype.slice = function slice (start, end) {
|
9497 | var len = this.length
|
9498 | start = ~~start
|
9499 | end = end === undefined ? len : ~~end
|
9500 |
|
9501 | if (start < 0) {
|
9502 | start += len
|
9503 | if (start < 0) start = 0
|
9504 | } else if (start > len) {
|
9505 | start = len
|
9506 | }
|
9507 |
|
9508 | if (end < 0) {
|
9509 | end += len
|
9510 | if (end < 0) end = 0
|
9511 | } else if (end > len) {
|
9512 | end = len
|
9513 | }
|
9514 |
|
9515 | if (end < start) end = start
|
9516 |
|
9517 | var newBuf
|
9518 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9519 | newBuf = this.subarray(start, end)
|
9520 | newBuf.__proto__ = Buffer.prototype
|
9521 | } else {
|
9522 | var sliceLen = end - start
|
9523 | newBuf = new Buffer(sliceLen, undefined)
|
9524 | for (var i = 0; i < sliceLen; i++) {
|
9525 | newBuf[i] = this[i + start]
|
9526 | }
|
9527 | }
|
9528 |
|
9529 | return newBuf
|
9530 | }
|
9531 |
|
9532 |
|
9533 |
|
9534 |
|
9535 | function checkOffset (offset, ext, length) {
|
9536 | if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
9537 | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
9538 | }
|
9539 |
|
9540 | Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
9541 | offset = offset | 0
|
9542 | byteLength = byteLength | 0
|
9543 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
9544 |
|
9545 | var val = this[offset]
|
9546 | var mul = 1
|
9547 | var i = 0
|
9548 | while (++i < byteLength && (mul *= 0x100)) {
|
9549 | val += this[offset + i] * mul
|
9550 | }
|
9551 |
|
9552 | return val
|
9553 | }
|
9554 |
|
9555 | Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
9556 | offset = offset | 0
|
9557 | byteLength = byteLength | 0
|
9558 | if (!noAssert) {
|
9559 | checkOffset(offset, byteLength, this.length)
|
9560 | }
|
9561 |
|
9562 | var val = this[offset + --byteLength]
|
9563 | var mul = 1
|
9564 | while (byteLength > 0 && (mul *= 0x100)) {
|
9565 | val += this[offset + --byteLength] * mul
|
9566 | }
|
9567 |
|
9568 | return val
|
9569 | }
|
9570 |
|
9571 | Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
9572 | if (!noAssert) checkOffset(offset, 1, this.length)
|
9573 | return this[offset]
|
9574 | }
|
9575 |
|
9576 | Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
9577 | if (!noAssert) checkOffset(offset, 2, this.length)
|
9578 | return this[offset] | (this[offset + 1] << 8)
|
9579 | }
|
9580 |
|
9581 | Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
9582 | if (!noAssert) checkOffset(offset, 2, this.length)
|
9583 | return (this[offset] << 8) | this[offset + 1]
|
9584 | }
|
9585 |
|
9586 | Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
9587 | if (!noAssert) checkOffset(offset, 4, this.length)
|
9588 |
|
9589 | return ((this[offset]) |
|
9590 | (this[offset + 1] << 8) |
|
9591 | (this[offset + 2] << 16)) +
|
9592 | (this[offset + 3] * 0x1000000)
|
9593 | }
|
9594 |
|
9595 | Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
9596 | if (!noAssert) checkOffset(offset, 4, this.length)
|
9597 |
|
9598 | return (this[offset] * 0x1000000) +
|
9599 | ((this[offset + 1] << 16) |
|
9600 | (this[offset + 2] << 8) |
|
9601 | this[offset + 3])
|
9602 | }
|
9603 |
|
9604 | Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
9605 | offset = offset | 0
|
9606 | byteLength = byteLength | 0
|
9607 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
9608 |
|
9609 | var val = this[offset]
|
9610 | var mul = 1
|
9611 | var i = 0
|
9612 | while (++i < byteLength && (mul *= 0x100)) {
|
9613 | val += this[offset + i] * mul
|
9614 | }
|
9615 | mul *= 0x80
|
9616 |
|
9617 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
9618 |
|
9619 | return val
|
9620 | }
|
9621 |
|
9622 | Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
9623 | offset = offset | 0
|
9624 | byteLength = byteLength | 0
|
9625 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
9626 |
|
9627 | var i = byteLength
|
9628 | var mul = 1
|
9629 | var val = this[offset + --i]
|
9630 | while (i > 0 && (mul *= 0x100)) {
|
9631 | val += this[offset + --i] * mul
|
9632 | }
|
9633 | mul *= 0x80
|
9634 |
|
9635 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
9636 |
|
9637 | return val
|
9638 | }
|
9639 |
|
9640 | Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
9641 | if (!noAssert) checkOffset(offset, 1, this.length)
|
9642 | if (!(this[offset] & 0x80)) return (this[offset])
|
9643 | return ((0xff - this[offset] + 1) * -1)
|
9644 | }
|
9645 |
|
9646 | Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
9647 | if (!noAssert) checkOffset(offset, 2, this.length)
|
9648 | var val = this[offset] | (this[offset + 1] << 8)
|
9649 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
9650 | }
|
9651 |
|
9652 | Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
9653 | if (!noAssert) checkOffset(offset, 2, this.length)
|
9654 | var val = this[offset + 1] | (this[offset] << 8)
|
9655 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
9656 | }
|
9657 |
|
9658 | Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
9659 | if (!noAssert) checkOffset(offset, 4, this.length)
|
9660 |
|
9661 | return (this[offset]) |
|
9662 | (this[offset + 1] << 8) |
|
9663 | (this[offset + 2] << 16) |
|
9664 | (this[offset + 3] << 24)
|
9665 | }
|
9666 |
|
9667 | Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
9668 | if (!noAssert) checkOffset(offset, 4, this.length)
|
9669 |
|
9670 | return (this[offset] << 24) |
|
9671 | (this[offset + 1] << 16) |
|
9672 | (this[offset + 2] << 8) |
|
9673 | (this[offset + 3])
|
9674 | }
|
9675 |
|
9676 | Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
9677 | if (!noAssert) checkOffset(offset, 4, this.length)
|
9678 | return ieee754.read(this, offset, true, 23, 4)
|
9679 | }
|
9680 |
|
9681 | Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
9682 | if (!noAssert) checkOffset(offset, 4, this.length)
|
9683 | return ieee754.read(this, offset, false, 23, 4)
|
9684 | }
|
9685 |
|
9686 | Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
9687 | if (!noAssert) checkOffset(offset, 8, this.length)
|
9688 | return ieee754.read(this, offset, true, 52, 8)
|
9689 | }
|
9690 |
|
9691 | Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
9692 | if (!noAssert) checkOffset(offset, 8, this.length)
|
9693 | return ieee754.read(this, offset, false, 52, 8)
|
9694 | }
|
9695 |
|
9696 | function checkInt (buf, value, offset, ext, max, min) {
|
9697 | if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
9698 | if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
9699 | if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
9700 | }
|
9701 |
|
9702 | Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
9703 | value = +value
|
9704 | offset = offset | 0
|
9705 | byteLength = byteLength | 0
|
9706 | if (!noAssert) {
|
9707 | var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
9708 | checkInt(this, value, offset, byteLength, maxBytes, 0)
|
9709 | }
|
9710 |
|
9711 | var mul = 1
|
9712 | var i = 0
|
9713 | this[offset] = value & 0xFF
|
9714 | while (++i < byteLength && (mul *= 0x100)) {
|
9715 | this[offset + i] = (value / mul) & 0xFF
|
9716 | }
|
9717 |
|
9718 | return offset + byteLength
|
9719 | }
|
9720 |
|
9721 | Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
9722 | value = +value
|
9723 | offset = offset | 0
|
9724 | byteLength = byteLength | 0
|
9725 | if (!noAssert) {
|
9726 | var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
9727 | checkInt(this, value, offset, byteLength, maxBytes, 0)
|
9728 | }
|
9729 |
|
9730 | var i = byteLength - 1
|
9731 | var mul = 1
|
9732 | this[offset + i] = value & 0xFF
|
9733 | while (--i >= 0 && (mul *= 0x100)) {
|
9734 | this[offset + i] = (value / mul) & 0xFF
|
9735 | }
|
9736 |
|
9737 | return offset + byteLength
|
9738 | }
|
9739 |
|
9740 | Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
9741 | value = +value
|
9742 | offset = offset | 0
|
9743 | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
9744 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
9745 | this[offset] = (value & 0xff)
|
9746 | return offset + 1
|
9747 | }
|
9748 |
|
9749 | function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
9750 | if (value < 0) value = 0xffff + value + 1
|
9751 | for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
|
9752 | buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
9753 | (littleEndian ? i : 1 - i) * 8
|
9754 | }
|
9755 | }
|
9756 |
|
9757 | Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
9758 | value = +value
|
9759 | offset = offset | 0
|
9760 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
9761 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9762 | this[offset] = (value & 0xff)
|
9763 | this[offset + 1] = (value >>> 8)
|
9764 | } else {
|
9765 | objectWriteUInt16(this, value, offset, true)
|
9766 | }
|
9767 | return offset + 2
|
9768 | }
|
9769 |
|
9770 | Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
9771 | value = +value
|
9772 | offset = offset | 0
|
9773 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
9774 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9775 | this[offset] = (value >>> 8)
|
9776 | this[offset + 1] = (value & 0xff)
|
9777 | } else {
|
9778 | objectWriteUInt16(this, value, offset, false)
|
9779 | }
|
9780 | return offset + 2
|
9781 | }
|
9782 |
|
9783 | function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
9784 | if (value < 0) value = 0xffffffff + value + 1
|
9785 | for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
|
9786 | buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
9787 | }
|
9788 | }
|
9789 |
|
9790 | Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
9791 | value = +value
|
9792 | offset = offset | 0
|
9793 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
9794 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9795 | this[offset + 3] = (value >>> 24)
|
9796 | this[offset + 2] = (value >>> 16)
|
9797 | this[offset + 1] = (value >>> 8)
|
9798 | this[offset] = (value & 0xff)
|
9799 | } else {
|
9800 | objectWriteUInt32(this, value, offset, true)
|
9801 | }
|
9802 | return offset + 4
|
9803 | }
|
9804 |
|
9805 | Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
9806 | value = +value
|
9807 | offset = offset | 0
|
9808 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
9809 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9810 | this[offset] = (value >>> 24)
|
9811 | this[offset + 1] = (value >>> 16)
|
9812 | this[offset + 2] = (value >>> 8)
|
9813 | this[offset + 3] = (value & 0xff)
|
9814 | } else {
|
9815 | objectWriteUInt32(this, value, offset, false)
|
9816 | }
|
9817 | return offset + 4
|
9818 | }
|
9819 |
|
9820 | Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
9821 | value = +value
|
9822 | offset = offset | 0
|
9823 | if (!noAssert) {
|
9824 | var limit = Math.pow(2, 8 * byteLength - 1)
|
9825 |
|
9826 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
9827 | }
|
9828 |
|
9829 | var i = 0
|
9830 | var mul = 1
|
9831 | var sub = 0
|
9832 | this[offset] = value & 0xFF
|
9833 | while (++i < byteLength && (mul *= 0x100)) {
|
9834 | if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
9835 | sub = 1
|
9836 | }
|
9837 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
9838 | }
|
9839 |
|
9840 | return offset + byteLength
|
9841 | }
|
9842 |
|
9843 | Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
9844 | value = +value
|
9845 | offset = offset | 0
|
9846 | if (!noAssert) {
|
9847 | var limit = Math.pow(2, 8 * byteLength - 1)
|
9848 |
|
9849 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
9850 | }
|
9851 |
|
9852 | var i = byteLength - 1
|
9853 | var mul = 1
|
9854 | var sub = 0
|
9855 | this[offset + i] = value & 0xFF
|
9856 | while (--i >= 0 && (mul *= 0x100)) {
|
9857 | if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
9858 | sub = 1
|
9859 | }
|
9860 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
9861 | }
|
9862 |
|
9863 | return offset + byteLength
|
9864 | }
|
9865 |
|
9866 | Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
9867 | value = +value
|
9868 | offset = offset | 0
|
9869 | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
9870 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
9871 | if (value < 0) value = 0xff + value + 1
|
9872 | this[offset] = (value & 0xff)
|
9873 | return offset + 1
|
9874 | }
|
9875 |
|
9876 | Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
9877 | value = +value
|
9878 | offset = offset | 0
|
9879 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
9880 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9881 | this[offset] = (value & 0xff)
|
9882 | this[offset + 1] = (value >>> 8)
|
9883 | } else {
|
9884 | objectWriteUInt16(this, value, offset, true)
|
9885 | }
|
9886 | return offset + 2
|
9887 | }
|
9888 |
|
9889 | Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
9890 | value = +value
|
9891 | offset = offset | 0
|
9892 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
9893 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9894 | this[offset] = (value >>> 8)
|
9895 | this[offset + 1] = (value & 0xff)
|
9896 | } else {
|
9897 | objectWriteUInt16(this, value, offset, false)
|
9898 | }
|
9899 | return offset + 2
|
9900 | }
|
9901 |
|
9902 | Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
9903 | value = +value
|
9904 | offset = offset | 0
|
9905 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
9906 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9907 | this[offset] = (value & 0xff)
|
9908 | this[offset + 1] = (value >>> 8)
|
9909 | this[offset + 2] = (value >>> 16)
|
9910 | this[offset + 3] = (value >>> 24)
|
9911 | } else {
|
9912 | objectWriteUInt32(this, value, offset, true)
|
9913 | }
|
9914 | return offset + 4
|
9915 | }
|
9916 |
|
9917 | Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
9918 | value = +value
|
9919 | offset = offset | 0
|
9920 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
9921 | if (value < 0) value = 0xffffffff + value + 1
|
9922 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
9923 | this[offset] = (value >>> 24)
|
9924 | this[offset + 1] = (value >>> 16)
|
9925 | this[offset + 2] = (value >>> 8)
|
9926 | this[offset + 3] = (value & 0xff)
|
9927 | } else {
|
9928 | objectWriteUInt32(this, value, offset, false)
|
9929 | }
|
9930 | return offset + 4
|
9931 | }
|
9932 |
|
9933 | function checkIEEE754 (buf, value, offset, ext, max, min) {
|
9934 | if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
9935 | if (offset < 0) throw new RangeError('Index out of range')
|
9936 | }
|
9937 |
|
9938 | function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
9939 | if (!noAssert) {
|
9940 | checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
9941 | }
|
9942 | ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
9943 | return offset + 4
|
9944 | }
|
9945 |
|
9946 | Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
9947 | return writeFloat(this, value, offset, true, noAssert)
|
9948 | }
|
9949 |
|
9950 | Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
9951 | return writeFloat(this, value, offset, false, noAssert)
|
9952 | }
|
9953 |
|
9954 | function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
9955 | if (!noAssert) {
|
9956 | checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
9957 | }
|
9958 | ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
9959 | return offset + 8
|
9960 | }
|
9961 |
|
9962 | Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
9963 | return writeDouble(this, value, offset, true, noAssert)
|
9964 | }
|
9965 |
|
9966 | Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
9967 | return writeDouble(this, value, offset, false, noAssert)
|
9968 | }
|
9969 |
|
9970 |
|
9971 | Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
9972 | if (!start) start = 0
|
9973 | if (!end && end !== 0) end = this.length
|
9974 | if (targetStart >= target.length) targetStart = target.length
|
9975 | if (!targetStart) targetStart = 0
|
9976 | if (end > 0 && end < start) end = start
|
9977 |
|
9978 |
|
9979 | if (end === start) return 0
|
9980 | if (target.length === 0 || this.length === 0) return 0
|
9981 |
|
9982 |
|
9983 | if (targetStart < 0) {
|
9984 | throw new RangeError('targetStart out of bounds')
|
9985 | }
|
9986 | if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
9987 | if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
9988 |
|
9989 |
|
9990 | if (end > this.length) end = this.length
|
9991 | if (target.length - targetStart < end - start) {
|
9992 | end = target.length - targetStart + start
|
9993 | }
|
9994 |
|
9995 | var len = end - start
|
9996 | var i
|
9997 |
|
9998 | if (this === target && start < targetStart && targetStart < end) {
|
9999 |
|
10000 | for (i = len - 1; i >= 0; i--) {
|
10001 | target[i + targetStart] = this[i + start]
|
10002 | }
|
10003 | } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
10004 |
|
10005 | for (i = 0; i < len; i++) {
|
10006 | target[i + targetStart] = this[i + start]
|
10007 | }
|
10008 | } else {
|
10009 | Uint8Array.prototype.set.call(
|
10010 | target,
|
10011 | this.subarray(start, start + len),
|
10012 | targetStart
|
10013 | )
|
10014 | }
|
10015 |
|
10016 | return len
|
10017 | }
|
10018 |
|
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 | Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
10024 |
|
10025 | if (typeof val === 'string') {
|
10026 | if (typeof start === 'string') {
|
10027 | encoding = start
|
10028 | start = 0
|
10029 | end = this.length
|
10030 | } else if (typeof end === 'string') {
|
10031 | encoding = end
|
10032 | end = this.length
|
10033 | }
|
10034 | if (val.length === 1) {
|
10035 | var code = val.charCodeAt(0)
|
10036 | if (code < 256) {
|
10037 | val = code
|
10038 | }
|
10039 | }
|
10040 | if (encoding !== undefined && typeof encoding !== 'string') {
|
10041 | throw new TypeError('encoding must be a string')
|
10042 | }
|
10043 | if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
10044 | throw new TypeError('Unknown encoding: ' + encoding)
|
10045 | }
|
10046 | } else if (typeof val === 'number') {
|
10047 | val = val & 255
|
10048 | }
|
10049 |
|
10050 |
|
10051 | if (start < 0 || this.length < start || this.length < end) {
|
10052 | throw new RangeError('Out of range index')
|
10053 | }
|
10054 |
|
10055 | if (end <= start) {
|
10056 | return this
|
10057 | }
|
10058 |
|
10059 | start = start >>> 0
|
10060 | end = end === undefined ? this.length : end >>> 0
|
10061 |
|
10062 | if (!val) val = 0
|
10063 |
|
10064 | var i
|
10065 | if (typeof val === 'number') {
|
10066 | for (i = start; i < end; i++) {
|
10067 | this[i] = val
|
10068 | }
|
10069 | } else {
|
10070 | var bytes = Buffer.isBuffer(val)
|
10071 | ? val
|
10072 | : utf8ToBytes(new Buffer(val, encoding).toString())
|
10073 | var len = bytes.length
|
10074 | for (i = 0; i < end - start; i++) {
|
10075 | this[i + start] = bytes[i % len]
|
10076 | }
|
10077 | }
|
10078 |
|
10079 | return this
|
10080 | }
|
10081 |
|
10082 |
|
10083 |
|
10084 |
|
10085 | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
10086 |
|
10087 | function base64clean (str) {
|
10088 |
|
10089 | str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
10090 |
|
10091 | if (str.length < 2) return ''
|
10092 |
|
10093 | while (str.length % 4 !== 0) {
|
10094 | str = str + '='
|
10095 | }
|
10096 | return str
|
10097 | }
|
10098 |
|
10099 | function stringtrim (str) {
|
10100 | if (str.trim) return str.trim()
|
10101 | return str.replace(/^\s+|\s+$/g, '')
|
10102 | }
|
10103 |
|
10104 | function toHex (n) {
|
10105 | if (n < 16) return '0' + n.toString(16)
|
10106 | return n.toString(16)
|
10107 | }
|
10108 |
|
10109 | function utf8ToBytes (string, units) {
|
10110 | units = units || Infinity
|
10111 | var codePoint
|
10112 | var length = string.length
|
10113 | var leadSurrogate = null
|
10114 | var bytes = []
|
10115 |
|
10116 | for (var i = 0; i < length; i++) {
|
10117 | codePoint = string.charCodeAt(i)
|
10118 |
|
10119 |
|
10120 | if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
10121 |
|
10122 | if (!leadSurrogate) {
|
10123 |
|
10124 | if (codePoint > 0xDBFF) {
|
10125 |
|
10126 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
10127 | continue
|
10128 | } else if (i + 1 === length) {
|
10129 |
|
10130 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
10131 | continue
|
10132 | }
|
10133 |
|
10134 |
|
10135 | leadSurrogate = codePoint
|
10136 |
|
10137 | continue
|
10138 | }
|
10139 |
|
10140 |
|
10141 | if (codePoint < 0xDC00) {
|
10142 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
10143 | leadSurrogate = codePoint
|
10144 | continue
|
10145 | }
|
10146 |
|
10147 |
|
10148 | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
10149 | } else if (leadSurrogate) {
|
10150 |
|
10151 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
10152 | }
|
10153 |
|
10154 | leadSurrogate = null
|
10155 |
|
10156 |
|
10157 | if (codePoint < 0x80) {
|
10158 | if ((units -= 1) < 0) break
|
10159 | bytes.push(codePoint)
|
10160 | } else if (codePoint < 0x800) {
|
10161 | if ((units -= 2) < 0) break
|
10162 | bytes.push(
|
10163 | codePoint >> 0x6 | 0xC0,
|
10164 | codePoint & 0x3F | 0x80
|
10165 | )
|
10166 | } else if (codePoint < 0x10000) {
|
10167 | if ((units -= 3) < 0) break
|
10168 | bytes.push(
|
10169 | codePoint >> 0xC | 0xE0,
|
10170 | codePoint >> 0x6 & 0x3F | 0x80,
|
10171 | codePoint & 0x3F | 0x80
|
10172 | )
|
10173 | } else if (codePoint < 0x110000) {
|
10174 | if ((units -= 4) < 0) break
|
10175 | bytes.push(
|
10176 | codePoint >> 0x12 | 0xF0,
|
10177 | codePoint >> 0xC & 0x3F | 0x80,
|
10178 | codePoint >> 0x6 & 0x3F | 0x80,
|
10179 | codePoint & 0x3F | 0x80
|
10180 | )
|
10181 | } else {
|
10182 | throw new Error('Invalid code point')
|
10183 | }
|
10184 | }
|
10185 |
|
10186 | return bytes
|
10187 | }
|
10188 |
|
10189 | function asciiToBytes (str) {
|
10190 | var byteArray = []
|
10191 | for (var i = 0; i < str.length; i++) {
|
10192 |
|
10193 | byteArray.push(str.charCodeAt(i) & 0xFF)
|
10194 | }
|
10195 | return byteArray
|
10196 | }
|
10197 |
|
10198 | function utf16leToBytes (str, units) {
|
10199 | var c, hi, lo
|
10200 | var byteArray = []
|
10201 | for (var i = 0; i < str.length; i++) {
|
10202 | if ((units -= 2) < 0) break
|
10203 |
|
10204 | c = str.charCodeAt(i)
|
10205 | hi = c >> 8
|
10206 | lo = c % 256
|
10207 | byteArray.push(lo)
|
10208 | byteArray.push(hi)
|
10209 | }
|
10210 |
|
10211 | return byteArray
|
10212 | }
|
10213 |
|
10214 | function base64ToBytes (str) {
|
10215 | return base64.toByteArray(base64clean(str))
|
10216 | }
|
10217 |
|
10218 | function blitBuffer (src, dst, offset, length) {
|
10219 | for (var i = 0; i < length; i++) {
|
10220 | if ((i + offset >= dst.length) || (i >= src.length)) break
|
10221 | dst[i + offset] = src[i]
|
10222 | }
|
10223 | return i
|
10224 | }
|
10225 |
|
10226 | function isnan (val) {
|
10227 | return val !== val
|
10228 | }
|
10229 |
|
10230 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
10231 |
|
10232 | },{"base64-js":61,"ieee754":64,"isarray":65}],64:[function(require,module,exports){
|
10233 | exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
10234 | var e, m
|
10235 | var eLen = nBytes * 8 - mLen - 1
|
10236 | var eMax = (1 << eLen) - 1
|
10237 | var eBias = eMax >> 1
|
10238 | var nBits = -7
|
10239 | var i = isLE ? (nBytes - 1) : 0
|
10240 | var d = isLE ? -1 : 1
|
10241 | var s = buffer[offset + i]
|
10242 |
|
10243 | i += d
|
10244 |
|
10245 | e = s & ((1 << (-nBits)) - 1)
|
10246 | s >>= (-nBits)
|
10247 | nBits += eLen
|
10248 | for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
10249 |
|
10250 | m = e & ((1 << (-nBits)) - 1)
|
10251 | e >>= (-nBits)
|
10252 | nBits += mLen
|
10253 | for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
10254 |
|
10255 | if (e === 0) {
|
10256 | e = 1 - eBias
|
10257 | } else if (e === eMax) {
|
10258 | return m ? NaN : ((s ? -1 : 1) * Infinity)
|
10259 | } else {
|
10260 | m = m + Math.pow(2, mLen)
|
10261 | e = e - eBias
|
10262 | }
|
10263 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
10264 | }
|
10265 |
|
10266 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
10267 | var e, m, c
|
10268 | var eLen = nBytes * 8 - mLen - 1
|
10269 | var eMax = (1 << eLen) - 1
|
10270 | var eBias = eMax >> 1
|
10271 | var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
10272 | var i = isLE ? 0 : (nBytes - 1)
|
10273 | var d = isLE ? 1 : -1
|
10274 | var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
10275 |
|
10276 | value = Math.abs(value)
|
10277 |
|
10278 | if (isNaN(value) || value === Infinity) {
|
10279 | m = isNaN(value) ? 1 : 0
|
10280 | e = eMax
|
10281 | } else {
|
10282 | e = Math.floor(Math.log(value) / Math.LN2)
|
10283 | if (value * (c = Math.pow(2, -e)) < 1) {
|
10284 | e--
|
10285 | c *= 2
|
10286 | }
|
10287 | if (e + eBias >= 1) {
|
10288 | value += rt / c
|
10289 | } else {
|
10290 | value += rt * Math.pow(2, 1 - eBias)
|
10291 | }
|
10292 | if (value * c >= 2) {
|
10293 | e++
|
10294 | c /= 2
|
10295 | }
|
10296 |
|
10297 | if (e + eBias >= eMax) {
|
10298 | m = 0
|
10299 | e = eMax
|
10300 | } else if (e + eBias >= 1) {
|
10301 | m = (value * c - 1) * Math.pow(2, mLen)
|
10302 | e = e + eBias
|
10303 | } else {
|
10304 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
10305 | e = 0
|
10306 | }
|
10307 | }
|
10308 |
|
10309 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
10310 |
|
10311 | e = (e << mLen) | m
|
10312 | eLen += mLen
|
10313 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
10314 |
|
10315 | buffer[offset + i - d] |= s * 128
|
10316 | }
|
10317 |
|
10318 | },{}],65:[function(require,module,exports){
|
10319 | var toString = {}.toString;
|
10320 |
|
10321 | module.exports = Array.isArray || function (arr) {
|
10322 | return toString.call(arr) == '[object Array]';
|
10323 | };
|
10324 |
|
10325 | },{}],66:[function(require,module,exports){
|
10326 | (function (process){
|
10327 |
|
10328 |
|
10329 |
|
10330 |
|
10331 |
|
10332 |
|
10333 |
|
10334 |
|
10335 |
|
10336 |
|
10337 |
|
10338 |
|
10339 |
|
10340 |
|
10341 |
|
10342 |
|
10343 |
|
10344 |
|
10345 |
|
10346 |
|
10347 |
|
10348 |
|
10349 |
|
10350 |
|
10351 |
|
10352 | function normalizeArray(parts, allowAboveRoot) {
|
10353 |
|
10354 | var up = 0;
|
10355 | for (var i = parts.length - 1; i >= 0; i--) {
|
10356 | var last = parts[i];
|
10357 | if (last === '.') {
|
10358 | parts.splice(i, 1);
|
10359 | } else if (last === '..') {
|
10360 | parts.splice(i, 1);
|
10361 | up++;
|
10362 | } else if (up) {
|
10363 | parts.splice(i, 1);
|
10364 | up--;
|
10365 | }
|
10366 | }
|
10367 |
|
10368 |
|
10369 | if (allowAboveRoot) {
|
10370 | for (; up--; up) {
|
10371 | parts.unshift('..');
|
10372 | }
|
10373 | }
|
10374 |
|
10375 | return parts;
|
10376 | }
|
10377 |
|
10378 |
|
10379 |
|
10380 | var splitPathRe =
|
10381 | /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
10382 | var splitPath = function(filename) {
|
10383 | return splitPathRe.exec(filename).slice(1);
|
10384 | };
|
10385 |
|
10386 |
|
10387 |
|
10388 | exports.resolve = function() {
|
10389 | var resolvedPath = '',
|
10390 | resolvedAbsolute = false;
|
10391 |
|
10392 | for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
10393 | var path = (i >= 0) ? arguments[i] : process.cwd();
|
10394 |
|
10395 |
|
10396 | if (typeof path !== 'string') {
|
10397 | throw new TypeError('Arguments to path.resolve must be strings');
|
10398 | } else if (!path) {
|
10399 | continue;
|
10400 | }
|
10401 |
|
10402 | resolvedPath = path + '/' + resolvedPath;
|
10403 | resolvedAbsolute = path.charAt(0) === '/';
|
10404 | }
|
10405 |
|
10406 |
|
10407 |
|
10408 |
|
10409 |
|
10410 | resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
10411 | return !!p;
|
10412 | }), !resolvedAbsolute).join('/');
|
10413 |
|
10414 | return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
10415 | };
|
10416 |
|
10417 |
|
10418 |
|
10419 | exports.normalize = function(path) {
|
10420 | var isAbsolute = exports.isAbsolute(path),
|
10421 | trailingSlash = substr(path, -1) === '/';
|
10422 |
|
10423 |
|
10424 | path = normalizeArray(filter(path.split('/'), function(p) {
|
10425 | return !!p;
|
10426 | }), !isAbsolute).join('/');
|
10427 |
|
10428 | if (!path && !isAbsolute) {
|
10429 | path = '.';
|
10430 | }
|
10431 | if (path && trailingSlash) {
|
10432 | path += '/';
|
10433 | }
|
10434 |
|
10435 | return (isAbsolute ? '/' : '') + path;
|
10436 | };
|
10437 |
|
10438 |
|
10439 | exports.isAbsolute = function(path) {
|
10440 | return path.charAt(0) === '/';
|
10441 | };
|
10442 |
|
10443 |
|
10444 | exports.join = function() {
|
10445 | var paths = Array.prototype.slice.call(arguments, 0);
|
10446 | return exports.normalize(filter(paths, function(p, index) {
|
10447 | if (typeof p !== 'string') {
|
10448 | throw new TypeError('Arguments to path.join must be strings');
|
10449 | }
|
10450 | return p;
|
10451 | }).join('/'));
|
10452 | };
|
10453 |
|
10454 |
|
10455 |
|
10456 |
|
10457 | exports.relative = function(from, to) {
|
10458 | from = exports.resolve(from).substr(1);
|
10459 | to = exports.resolve(to).substr(1);
|
10460 |
|
10461 | function trim(arr) {
|
10462 | var start = 0;
|
10463 | for (; start < arr.length; start++) {
|
10464 | if (arr[start] !== '') break;
|
10465 | }
|
10466 |
|
10467 | var end = arr.length - 1;
|
10468 | for (; end >= 0; end--) {
|
10469 | if (arr[end] !== '') break;
|
10470 | }
|
10471 |
|
10472 | if (start > end) return [];
|
10473 | return arr.slice(start, end - start + 1);
|
10474 | }
|
10475 |
|
10476 | var fromParts = trim(from.split('/'));
|
10477 | var toParts = trim(to.split('/'));
|
10478 |
|
10479 | var length = Math.min(fromParts.length, toParts.length);
|
10480 | var samePartsLength = length;
|
10481 | for (var i = 0; i < length; i++) {
|
10482 | if (fromParts[i] !== toParts[i]) {
|
10483 | samePartsLength = i;
|
10484 | break;
|
10485 | }
|
10486 | }
|
10487 |
|
10488 | var outputParts = [];
|
10489 | for (var i = samePartsLength; i < fromParts.length; i++) {
|
10490 | outputParts.push('..');
|
10491 | }
|
10492 |
|
10493 | outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
10494 |
|
10495 | return outputParts.join('/');
|
10496 | };
|
10497 |
|
10498 | exports.sep = '/';
|
10499 | exports.delimiter = ':';
|
10500 |
|
10501 | exports.dirname = function(path) {
|
10502 | var result = splitPath(path),
|
10503 | root = result[0],
|
10504 | dir = result[1];
|
10505 |
|
10506 | if (!root && !dir) {
|
10507 |
|
10508 | return '.';
|
10509 | }
|
10510 |
|
10511 | if (dir) {
|
10512 |
|
10513 | dir = dir.substr(0, dir.length - 1);
|
10514 | }
|
10515 |
|
10516 | return root + dir;
|
10517 | };
|
10518 |
|
10519 |
|
10520 | exports.basename = function(path, ext) {
|
10521 | var f = splitPath(path)[2];
|
10522 |
|
10523 | if (ext && f.substr(-1 * ext.length) === ext) {
|
10524 | f = f.substr(0, f.length - ext.length);
|
10525 | }
|
10526 | return f;
|
10527 | };
|
10528 |
|
10529 |
|
10530 | exports.extname = function(path) {
|
10531 | return splitPath(path)[3];
|
10532 | };
|
10533 |
|
10534 | function filter (xs, f) {
|
10535 | if (xs.filter) return xs.filter(f);
|
10536 | var res = [];
|
10537 | for (var i = 0; i < xs.length; i++) {
|
10538 | if (f(xs[i], i, xs)) res.push(xs[i]);
|
10539 | }
|
10540 | return res;
|
10541 | }
|
10542 |
|
10543 |
|
10544 | var substr = 'ab'.substr(-1) === 'b'
|
10545 | ? function (str, start, len) { return str.substr(start, len) }
|
10546 | : function (str, start, len) {
|
10547 | if (start < 0) start = str.length + start;
|
10548 | return str.substr(start, len);
|
10549 | }
|
10550 | ;
|
10551 |
|
10552 | }).call(this,require('_process'))
|
10553 |
|
10554 | },{"_process":67}],67:[function(require,module,exports){
|
10555 |
|
10556 |
|
10557 | var process = module.exports = {};
|
10558 | var queue = [];
|
10559 | var draining = false;
|
10560 | var currentQueue;
|
10561 | var queueIndex = -1;
|
10562 |
|
10563 | function cleanUpNextTick() {
|
10564 | if (!draining || !currentQueue) {
|
10565 | return;
|
10566 | }
|
10567 | draining = false;
|
10568 | if (currentQueue.length) {
|
10569 | queue = currentQueue.concat(queue);
|
10570 | } else {
|
10571 | queueIndex = -1;
|
10572 | }
|
10573 | if (queue.length) {
|
10574 | drainQueue();
|
10575 | }
|
10576 | }
|
10577 |
|
10578 | function drainQueue() {
|
10579 | if (draining) {
|
10580 | return;
|
10581 | }
|
10582 | var timeout = setTimeout(cleanUpNextTick);
|
10583 | draining = true;
|
10584 |
|
10585 | var len = queue.length;
|
10586 | while(len) {
|
10587 | currentQueue = queue;
|
10588 | queue = [];
|
10589 | while (++queueIndex < len) {
|
10590 | if (currentQueue) {
|
10591 | currentQueue[queueIndex].run();
|
10592 | }
|
10593 | }
|
10594 | queueIndex = -1;
|
10595 | len = queue.length;
|
10596 | }
|
10597 | currentQueue = null;
|
10598 | draining = false;
|
10599 | clearTimeout(timeout);
|
10600 | }
|
10601 |
|
10602 | process.nextTick = function (fun) {
|
10603 | var args = new Array(arguments.length - 1);
|
10604 | if (arguments.length > 1) {
|
10605 | for (var i = 1; i < arguments.length; i++) {
|
10606 | args[i - 1] = arguments[i];
|
10607 | }
|
10608 | }
|
10609 | queue.push(new Item(fun, args));
|
10610 | if (queue.length === 1 && !draining) {
|
10611 | setTimeout(drainQueue, 0);
|
10612 | }
|
10613 | };
|
10614 |
|
10615 |
|
10616 | function Item(fun, array) {
|
10617 | this.fun = fun;
|
10618 | this.array = array;
|
10619 | }
|
10620 | Item.prototype.run = function () {
|
10621 | this.fun.apply(null, this.array);
|
10622 | };
|
10623 | process.title = 'browser';
|
10624 | process.browser = true;
|
10625 | process.env = {};
|
10626 | process.argv = [];
|
10627 | process.version = '';
|
10628 | process.versions = {};
|
10629 |
|
10630 | function noop() {}
|
10631 |
|
10632 | process.on = noop;
|
10633 | process.addListener = noop;
|
10634 | process.once = noop;
|
10635 | process.off = noop;
|
10636 | process.removeListener = noop;
|
10637 | process.removeAllListeners = noop;
|
10638 | process.emit = noop;
|
10639 |
|
10640 | process.binding = function (name) {
|
10641 | throw new Error('process.binding is not supported');
|
10642 | };
|
10643 |
|
10644 | process.cwd = function () { return '/' };
|
10645 | process.chdir = function (dir) {
|
10646 | throw new Error('process.chdir is not supported');
|
10647 | };
|
10648 | process.umask = function() { return 0; };
|
10649 |
|
10650 | },{}]},{},[57,55,60])(60)
|
10651 | });
|
10652 |
|
10653 |
|
10654 |
|