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.GitHub = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
2 | 'use strict';
|
3 |
|
4 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
5 |
|
6 | var _Requestable2 = require('./Requestable');
|
7 |
|
8 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11 |
|
12 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
13 |
|
14 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
15 |
|
16 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | var Gist = function (_Requestable) {
|
27 | _inherits(Gist, _Requestable);
|
28 |
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | function Gist(id, auth, apiBase) {
|
36 | _classCallCheck(this, Gist);
|
37 |
|
38 | var _this = _possibleConstructorReturn(this, (Gist.__proto__ || Object.getPrototypeOf(Gist)).call(this, auth, apiBase));
|
39 |
|
40 | _this.__id = id;
|
41 | return _this;
|
42 | }
|
43 |
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | _createClass(Gist, [{
|
53 | key: 'read',
|
54 | value: function read(cb) {
|
55 | return this._request('GET', '/gists/' + this.__id, null, cb);
|
56 | }
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | }, {
|
67 | key: 'create',
|
68 | value: function create(gist, cb) {
|
69 | var _this2 = this;
|
70 |
|
71 | return this._request('POST', '/gists', gist, cb).then(function (response) {
|
72 | _this2.__id = response.data.id;
|
73 | return response;
|
74 | });
|
75 | }
|
76 |
|
77 | |
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | }, {
|
85 | key: 'delete',
|
86 | value: function _delete(cb) {
|
87 | return this._request('DELETE', '/gists/' + this.__id, null, cb);
|
88 | }
|
89 |
|
90 | |
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | }, {
|
98 | key: 'fork',
|
99 | value: function fork(cb) {
|
100 | return this._request('POST', '/gists/' + this.__id + '/forks', null, cb);
|
101 | }
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | }, {
|
112 | key: 'update',
|
113 | value: function update(gist, cb) {
|
114 | return this._request('PATCH', '/gists/' + this.__id, gist, cb);
|
115 | }
|
116 |
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 | }, {
|
125 | key: 'star',
|
126 | value: function star(cb) {
|
127 | return this._request('PUT', '/gists/' + this.__id + '/star', null, cb);
|
128 | }
|
129 |
|
130 | |
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | }, {
|
138 | key: 'unstar',
|
139 | value: function unstar(cb) {
|
140 | return this._request('DELETE', '/gists/' + this.__id + '/star', null, cb);
|
141 | }
|
142 |
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | }, {
|
151 | key: 'isStarred',
|
152 | value: function isStarred(cb) {
|
153 | return this._request204or404('/gists/' + this.__id + '/star', null, cb);
|
154 | }
|
155 |
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | }, {
|
164 | key: 'listCommits',
|
165 | value: function listCommits(cb) {
|
166 | return this._requestAllPages('/gists/' + this.__id + '/commits', null, cb);
|
167 | }
|
168 |
|
169 | |
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | }, {
|
178 | key: 'getRevision',
|
179 | value: function getRevision(revision, cb) {
|
180 | return this._request('GET', '/gists/' + this.__id + '/' + revision, null, cb);
|
181 | }
|
182 |
|
183 | |
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | }, {
|
191 | key: 'listComments',
|
192 | value: function listComments(cb) {
|
193 | return this._requestAllPages('/gists/' + this.__id + '/comments', null, cb);
|
194 | }
|
195 |
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 | }, {
|
205 | key: 'getComment',
|
206 | value: function getComment(comment, cb) {
|
207 | return this._request('GET', '/gists/' + this.__id + '/comments/' + comment, null, cb);
|
208 | }
|
209 |
|
210 | |
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 | }, {
|
219 | key: 'createComment',
|
220 | value: function createComment(comment, cb) {
|
221 | return this._request('POST', '/gists/' + this.__id + '/comments', { body: comment }, cb);
|
222 | }
|
223 |
|
224 | |
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 | }, {
|
234 | key: 'editComment',
|
235 | value: function editComment(comment, body, cb) {
|
236 | return this._request('PATCH', '/gists/' + this.__id + '/comments/' + comment, { body: body }, cb);
|
237 | }
|
238 |
|
239 | |
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 | }, {
|
248 | key: 'deleteComment',
|
249 | value: function deleteComment(comment, cb) {
|
250 | return this._request('DELETE', '/gists/' + this.__id + '/comments/' + comment, null, cb);
|
251 | }
|
252 | }]);
|
253 |
|
254 | return Gist;
|
255 | }(_Requestable3.default);
|
256 |
|
257 | module.exports = Gist;
|
258 |
|
259 | },{"./Requestable":9}],2:[function(require,module,exports){
|
260 | 'use strict';
|
261 |
|
262 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | var _Gist = require('./Gist');
|
271 |
|
272 | var _Gist2 = _interopRequireDefault(_Gist);
|
273 |
|
274 | var _User = require('./User');
|
275 |
|
276 | var _User2 = _interopRequireDefault(_User);
|
277 |
|
278 | var _Issue = require('./Issue');
|
279 |
|
280 | var _Issue2 = _interopRequireDefault(_Issue);
|
281 |
|
282 | var _Search = require('./Search');
|
283 |
|
284 | var _Search2 = _interopRequireDefault(_Search);
|
285 |
|
286 | var _RateLimit = require('./RateLimit');
|
287 |
|
288 | var _RateLimit2 = _interopRequireDefault(_RateLimit);
|
289 |
|
290 | var _Repository = require('./Repository');
|
291 |
|
292 | var _Repository2 = _interopRequireDefault(_Repository);
|
293 |
|
294 | var _Organization = require('./Organization');
|
295 |
|
296 | var _Organization2 = _interopRequireDefault(_Organization);
|
297 |
|
298 | var _Team = require('./Team');
|
299 |
|
300 | var _Team2 = _interopRequireDefault(_Team);
|
301 |
|
302 | var _Markdown = require('./Markdown');
|
303 |
|
304 | var _Markdown2 = _interopRequireDefault(_Markdown);
|
305 |
|
306 | var _Project = require('./Project');
|
307 |
|
308 | var _Project2 = _interopRequireDefault(_Project);
|
309 |
|
310 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
311 |
|
312 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
313 |
|
314 |
|
315 |
|
316 |
|
317 | var GitHub = function () {
|
318 | |
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | function GitHub(auth) {
|
325 | var apiBase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'https://api.github.com';
|
326 |
|
327 | _classCallCheck(this, GitHub);
|
328 |
|
329 | this.__apiBase = apiBase;
|
330 | this.__auth = auth || {};
|
331 | }
|
332 |
|
333 | |
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 | _createClass(GitHub, [{
|
341 | key: 'getGist',
|
342 | value: function getGist(id) {
|
343 | return new _Gist2.default(id, this.__auth, this.__apiBase);
|
344 | }
|
345 |
|
346 | |
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 | }, {
|
354 | key: 'getUser',
|
355 | value: function getUser(user) {
|
356 | return new _User2.default(user, this.__auth, this.__apiBase);
|
357 | }
|
358 |
|
359 | |
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 | }, {
|
366 | key: 'getOrganization',
|
367 | value: function getOrganization(organization) {
|
368 | return new _Organization2.default(organization, this.__auth, this.__apiBase);
|
369 | }
|
370 |
|
371 | |
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 | }, {
|
378 | key: 'getTeam',
|
379 | value: function getTeam(teamId) {
|
380 | return new _Team2.default(teamId, this.__auth, this.__apiBase);
|
381 | }
|
382 |
|
383 | |
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 | }, {
|
391 | key: 'getRepo',
|
392 | value: function getRepo(user, repo) {
|
393 | return new _Repository2.default(this._getFullName(user, repo), this.__auth, this.__apiBase);
|
394 | }
|
395 |
|
396 | |
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 | }, {
|
404 | key: 'getIssues',
|
405 | value: function getIssues(user, repo) {
|
406 | return new _Issue2.default(this._getFullName(user, repo), this.__auth, this.__apiBase);
|
407 | }
|
408 |
|
409 | |
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 | }, {
|
416 | key: 'search',
|
417 | value: function search(query) {
|
418 | return new _Search2.default(query, this.__auth, this.__apiBase);
|
419 | }
|
420 |
|
421 | |
422 |
|
423 |
|
424 |
|
425 |
|
426 | }, {
|
427 | key: 'getRateLimit',
|
428 | value: function getRateLimit() {
|
429 | return new _RateLimit2.default(this.__auth, this.__apiBase);
|
430 | }
|
431 |
|
432 | |
433 |
|
434 |
|
435 |
|
436 |
|
437 | }, {
|
438 | key: 'getMarkdown',
|
439 | value: function getMarkdown() {
|
440 | return new _Markdown2.default(this.__auth, this.__apiBase);
|
441 | }
|
442 |
|
443 | |
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 | }, {
|
450 | key: 'getProject',
|
451 | value: function getProject(id) {
|
452 | return new _Project2.default(id, this.__auth, this.__apiBase);
|
453 | }
|
454 |
|
455 | |
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 | }, {
|
463 | key: '_getFullName',
|
464 | value: function _getFullName(user, repo) {
|
465 | var fullname = user;
|
466 |
|
467 | if (repo) {
|
468 | fullname = user + '/' + repo;
|
469 | }
|
470 |
|
471 | return fullname;
|
472 | }
|
473 | }]);
|
474 |
|
475 | return GitHub;
|
476 | }();
|
477 |
|
478 | module.exports = GitHub;
|
479 |
|
480 | },{"./Gist":1,"./Issue":3,"./Markdown":4,"./Organization":5,"./Project":6,"./RateLimit":7,"./Repository":8,"./Search":10,"./Team":11,"./User":12}],3:[function(require,module,exports){
|
481 | 'use strict';
|
482 |
|
483 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
484 |
|
485 | var _Requestable2 = require('./Requestable');
|
486 |
|
487 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
488 |
|
489 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
490 |
|
491 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
492 |
|
493 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
494 |
|
495 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 | var Issue = function (_Requestable) {
|
506 | _inherits(Issue, _Requestable);
|
507 |
|
508 | |
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 | function Issue(repository, auth, apiBase) {
|
515 | _classCallCheck(this, Issue);
|
516 |
|
517 | var _this = _possibleConstructorReturn(this, (Issue.__proto__ || Object.getPrototypeOf(Issue)).call(this, auth, apiBase));
|
518 |
|
519 | _this.__repository = repository;
|
520 | return _this;
|
521 | }
|
522 |
|
523 | |
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 | _createClass(Issue, [{
|
533 | key: 'createIssue',
|
534 | value: function createIssue(issueData, cb) {
|
535 | return this._request('POST', '/repos/' + this.__repository + '/issues', issueData, cb);
|
536 | }
|
537 |
|
538 | |
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | }, {
|
547 | key: 'listIssues',
|
548 | value: function listIssues(options, cb) {
|
549 | return this._requestAllPages('/repos/' + this.__repository + '/issues', options, cb);
|
550 | }
|
551 |
|
552 | |
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 | }, {
|
561 | key: 'listIssueEvents',
|
562 | value: function listIssueEvents(issue, cb) {
|
563 | return this._request('GET', '/repos/' + this.__repository + '/issues/' + issue + '/events', null, cb);
|
564 | }
|
565 |
|
566 | |
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | }, {
|
575 | key: 'listIssueComments',
|
576 | value: function listIssueComments(issue, cb) {
|
577 | return this._request('GET', '/repos/' + this.__repository + '/issues/' + issue + '/comments', null, cb);
|
578 | }
|
579 |
|
580 | |
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 | }, {
|
589 | key: 'getIssueComment',
|
590 | value: function getIssueComment(id, cb) {
|
591 | return this._request('GET', '/repos/' + this.__repository + '/issues/comments/' + id, null, cb);
|
592 | }
|
593 |
|
594 | |
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 | }, {
|
604 | key: 'createIssueComment',
|
605 | value: function createIssueComment(issue, comment, cb) {
|
606 | return this._request('POST', '/repos/' + this.__repository + '/issues/' + issue + '/comments', { body: comment }, cb);
|
607 | }
|
608 |
|
609 | |
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 | }, {
|
619 | key: 'editIssueComment',
|
620 | value: function editIssueComment(id, comment, cb) {
|
621 | return this._request('PATCH', '/repos/' + this.__repository + '/issues/comments/' + id, { body: comment }, cb);
|
622 | }
|
623 |
|
624 | |
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 | }, {
|
633 | key: 'deleteIssueComment',
|
634 | value: function deleteIssueComment(id, cb) {
|
635 | return this._request('DELETE', '/repos/' + this.__repository + '/issues/comments/' + id, null, cb);
|
636 | }
|
637 |
|
638 | |
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 | }, {
|
648 | key: 'editIssue',
|
649 | value: function editIssue(issue, issueData, cb) {
|
650 | return this._request('PATCH', '/repos/' + this.__repository + '/issues/' + issue, issueData, cb);
|
651 | }
|
652 |
|
653 | |
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 | }, {
|
662 | key: 'getIssue',
|
663 | value: function getIssue(issue, cb) {
|
664 | return this._request('GET', '/repos/' + this.__repository + '/issues/' + issue, null, cb);
|
665 | }
|
666 |
|
667 | |
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 | }, {
|
676 | key: 'listMilestones',
|
677 | value: function listMilestones(options, cb) {
|
678 | return this._request('GET', '/repos/' + this.__repository + '/milestones', options, cb);
|
679 | }
|
680 |
|
681 | |
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 | }, {
|
690 | key: 'getMilestone',
|
691 | value: function getMilestone(milestone, cb) {
|
692 | return this._request('GET', '/repos/' + this.__repository + '/milestones/' + milestone, null, cb);
|
693 | }
|
694 |
|
695 | |
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 | }, {
|
704 | key: 'createMilestone',
|
705 | value: function createMilestone(milestoneData, cb) {
|
706 | return this._request('POST', '/repos/' + this.__repository + '/milestones', milestoneData, cb);
|
707 | }
|
708 |
|
709 | |
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 | }, {
|
719 | key: 'editMilestone',
|
720 | value: function editMilestone(milestone, milestoneData, cb) {
|
721 | return this._request('PATCH', '/repos/' + this.__repository + '/milestones/' + milestone, milestoneData, cb);
|
722 | }
|
723 |
|
724 | |
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 | }, {
|
733 | key: 'deleteMilestone',
|
734 | value: function deleteMilestone(milestone, cb) {
|
735 | return this._request('DELETE', '/repos/' + this.__repository + '/milestones/' + milestone, null, cb);
|
736 | }
|
737 |
|
738 | |
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 | }, {
|
747 | key: 'createLabel',
|
748 | value: function createLabel(labelData, cb) {
|
749 | return this._request('POST', '/repos/' + this.__repository + '/labels', labelData, cb);
|
750 | }
|
751 |
|
752 | |
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 | }, {
|
761 | key: 'listLabels',
|
762 | value: function listLabels(options, cb) {
|
763 | return this._request('GET', '/repos/' + this.__repository + '/labels', options, cb);
|
764 | }
|
765 |
|
766 | |
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 | }, {
|
775 | key: 'getLabel',
|
776 | value: function getLabel(label, cb) {
|
777 | return this._request('GET', '/repos/' + this.__repository + '/labels/' + label, null, cb);
|
778 | }
|
779 |
|
780 | |
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 | }, {
|
790 | key: 'editLabel',
|
791 | value: function editLabel(label, labelData, cb) {
|
792 | return this._request('PATCH', '/repos/' + this.__repository + '/labels/' + label, labelData, cb);
|
793 | }
|
794 |
|
795 | |
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 | }, {
|
804 | key: 'deleteLabel',
|
805 | value: function deleteLabel(label, cb) {
|
806 | return this._request('DELETE', '/repos/' + this.__repository + '/labels/' + label, null, cb);
|
807 | }
|
808 | }]);
|
809 |
|
810 | return Issue;
|
811 | }(_Requestable3.default);
|
812 |
|
813 | module.exports = Issue;
|
814 |
|
815 | },{"./Requestable":9}],4:[function(require,module,exports){
|
816 | 'use strict';
|
817 |
|
818 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
819 |
|
820 | var _Requestable2 = require('./Requestable');
|
821 |
|
822 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
823 |
|
824 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
825 |
|
826 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
827 |
|
828 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
829 |
|
830 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
831 |
|
832 |
|
833 |
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 | var Markdown = function (_Requestable) {
|
841 | _inherits(Markdown, _Requestable);
|
842 |
|
843 | |
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 | function Markdown(auth, apiBase) {
|
850 | _classCallCheck(this, Markdown);
|
851 |
|
852 | return _possibleConstructorReturn(this, (Markdown.__proto__ || Object.getPrototypeOf(Markdown)).call(this, auth, apiBase));
|
853 | }
|
854 |
|
855 | |
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 | _createClass(Markdown, [{
|
868 | key: 'render',
|
869 | value: function render(options, cb) {
|
870 | return this._request('POST', '/markdown', options, cb, true);
|
871 | }
|
872 | }]);
|
873 |
|
874 | return Markdown;
|
875 | }(_Requestable3.default);
|
876 |
|
877 | module.exports = Markdown;
|
878 |
|
879 | },{"./Requestable":9}],5:[function(require,module,exports){
|
880 | 'use strict';
|
881 |
|
882 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
883 |
|
884 | var _Requestable2 = require('./Requestable');
|
885 |
|
886 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
887 |
|
888 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
889 |
|
890 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
891 |
|
892 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
893 |
|
894 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 | var Organization = function (_Requestable) {
|
905 | _inherits(Organization, _Requestable);
|
906 |
|
907 | |
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 | function Organization(organization, auth, apiBase) {
|
914 | _classCallCheck(this, Organization);
|
915 |
|
916 | var _this = _possibleConstructorReturn(this, (Organization.__proto__ || Object.getPrototypeOf(Organization)).call(this, auth, apiBase));
|
917 |
|
918 | _this.__name = organization;
|
919 | return _this;
|
920 | }
|
921 |
|
922 | |
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 | _createClass(Organization, [{
|
932 | key: 'createRepo',
|
933 | value: function createRepo(options, cb) {
|
934 | return this._request('POST', '/orgs/' + this.__name + '/repos', options, cb);
|
935 | }
|
936 |
|
937 | |
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 | }, {
|
945 | key: 'getRepos',
|
946 | value: function getRepos(cb) {
|
947 | var requestOptions = this._getOptionsWithDefaults({ direction: 'desc' });
|
948 |
|
949 | return this._requestAllPages('/orgs/' + this.__name + '/repos', requestOptions, cb);
|
950 | }
|
951 |
|
952 | |
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 | }, {
|
960 | key: 'isMember',
|
961 | value: function isMember(username, cb) {
|
962 | return this._request204or404('/orgs/' + this.__name + '/members/' + username, null, cb);
|
963 | }
|
964 |
|
965 | |
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | }, {
|
976 | key: 'listMembers',
|
977 | value: function listMembers(options, cb) {
|
978 | return this._request('GET', '/orgs/' + this.__name + '/members', options, cb);
|
979 | }
|
980 |
|
981 | |
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 | }, {
|
989 | key: 'getTeams',
|
990 | value: function getTeams(cb) {
|
991 | return this._requestAllPages('/orgs/' + this.__name + '/teams', undefined, cb);
|
992 | }
|
993 |
|
994 | |
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 | }, {
|
1008 | key: 'createTeam',
|
1009 | value: function createTeam(options, cb) {
|
1010 | return this._request('POST', '/orgs/' + this.__name + '/teams', options, cb);
|
1011 | }
|
1012 |
|
1013 | |
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 | }, {
|
1021 | key: 'listProjects',
|
1022 | value: function listProjects(cb) {
|
1023 | return this._requestAllPages('/orgs/' + this.__name + '/projects', { AcceptHeader: 'inertia-preview' }, cb);
|
1024 | }
|
1025 |
|
1026 | |
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 | }, {
|
1035 | key: 'createProject',
|
1036 | value: function createProject(options, cb) {
|
1037 | options = options || {};
|
1038 | options.AcceptHeader = 'inertia-preview';
|
1039 | return this._request('POST', '/orgs/' + this.__name + '/projects', options, cb);
|
1040 | }
|
1041 | }]);
|
1042 |
|
1043 | return Organization;
|
1044 | }(_Requestable3.default);
|
1045 |
|
1046 | module.exports = Organization;
|
1047 |
|
1048 | },{"./Requestable":9}],6:[function(require,module,exports){
|
1049 | 'use strict';
|
1050 |
|
1051 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
1052 |
|
1053 | var _Requestable2 = require('./Requestable');
|
1054 |
|
1055 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
1056 |
|
1057 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1058 |
|
1059 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
1060 |
|
1061 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1062 |
|
1063 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
1064 |
|
1065 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 | var Project = function (_Requestable) {
|
1076 | _inherits(Project, _Requestable);
|
1077 |
|
1078 | |
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 | function Project(id, auth, apiBase) {
|
1085 | _classCallCheck(this, Project);
|
1086 |
|
1087 | var _this = _possibleConstructorReturn(this, (Project.__proto__ || Object.getPrototypeOf(Project)).call(this, auth, apiBase, 'inertia-preview'));
|
1088 |
|
1089 | _this.__id = id;
|
1090 | return _this;
|
1091 | }
|
1092 |
|
1093 | |
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 | _createClass(Project, [{
|
1102 | key: 'getProject',
|
1103 | value: function getProject(cb) {
|
1104 | return this._request('GET', '/projects/' + this.__id, null, cb);
|
1105 | }
|
1106 |
|
1107 | |
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 | }, {
|
1116 | key: 'updateProject',
|
1117 | value: function updateProject(options, cb) {
|
1118 | return this._request('PATCH', '/projects/' + this.__id, options, cb);
|
1119 | }
|
1120 |
|
1121 | |
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 | }, {
|
1129 | key: 'deleteProject',
|
1130 | value: function deleteProject(cb) {
|
1131 | return this._request('DELETE', '/projects/' + this.__id, null, cb);
|
1132 | }
|
1133 |
|
1134 | |
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 | }, {
|
1142 | key: 'listProjectColumns',
|
1143 | value: function listProjectColumns(cb) {
|
1144 | return this._requestAllPages('/projects/' + this.__id + '/columns', null, cb);
|
1145 | }
|
1146 |
|
1147 | |
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 | }, {
|
1156 | key: 'getProjectColumn',
|
1157 | value: function getProjectColumn(colId, cb) {
|
1158 | return this._request('GET', '/projects/columns/' + colId, null, cb);
|
1159 | }
|
1160 |
|
1161 | |
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 | }, {
|
1170 | key: 'createProjectColumn',
|
1171 | value: function createProjectColumn(options, cb) {
|
1172 | return this._request('POST', '/projects/' + this.__id + '/columns', options, cb);
|
1173 | }
|
1174 |
|
1175 | |
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 | }, {
|
1185 | key: 'updateProjectColumn',
|
1186 | value: function updateProjectColumn(colId, options, cb) {
|
1187 | return this._request('PATCH', '/projects/columns/' + colId, options, cb);
|
1188 | }
|
1189 |
|
1190 | |
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 | }, {
|
1199 | key: 'deleteProjectColumn',
|
1200 | value: function deleteProjectColumn(colId, cb) {
|
1201 | return this._request('DELETE', '/projects/columns/' + colId, null, cb);
|
1202 | }
|
1203 |
|
1204 | |
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 | }, {
|
1215 | key: 'moveProjectColumn',
|
1216 | value: function moveProjectColumn(colId, position, cb) {
|
1217 | return this._request('POST', '/projects/columns/' + colId + '/moves', { position: position }, cb);
|
1218 | }
|
1219 |
|
1220 | |
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 | }, {
|
1228 | key: 'listProjectCards',
|
1229 | value: function listProjectCards(cb) {
|
1230 | var _this2 = this;
|
1231 |
|
1232 | return this.listProjectColumns().then(function (_ref) {
|
1233 | var data = _ref.data;
|
1234 |
|
1235 | return Promise.all(data.map(function (column) {
|
1236 | return _this2._requestAllPages('/projects/columns/' + column.id + '/cards', null);
|
1237 | }));
|
1238 | }).then(function (cardsInColumns) {
|
1239 | var cards = cardsInColumns.reduce(function (prev, _ref2) {
|
1240 | var data = _ref2.data;
|
1241 |
|
1242 | prev.push.apply(prev, _toConsumableArray(data));
|
1243 | return prev;
|
1244 | }, []);
|
1245 | if (cb) {
|
1246 | cb(null, cards);
|
1247 | }
|
1248 | return cards;
|
1249 | }).catch(function (err) {
|
1250 | if (cb) {
|
1251 | cb(err);
|
1252 | return;
|
1253 | }
|
1254 | throw err;
|
1255 | });
|
1256 | }
|
1257 |
|
1258 | |
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 | }, {
|
1267 | key: 'listColumnCards',
|
1268 | value: function listColumnCards(colId, cb) {
|
1269 | return this._requestAllPages('/projects/columns/' + colId + '/cards', null, cb);
|
1270 | }
|
1271 |
|
1272 | |
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 | }, {
|
1281 | key: 'getProjectCard',
|
1282 | value: function getProjectCard(cardId, cb) {
|
1283 | return this._request('GET', '/projects/columns/cards/' + cardId, null, cb);
|
1284 | }
|
1285 |
|
1286 | |
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 |
|
1294 |
|
1295 | }, {
|
1296 | key: 'createProjectCard',
|
1297 | value: function createProjectCard(colId, options, cb) {
|
1298 | return this._request('POST', '/projects/columns/' + colId + '/cards', options, cb);
|
1299 | }
|
1300 |
|
1301 | |
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 | }, {
|
1311 | key: 'updateProjectCard',
|
1312 | value: function updateProjectCard(cardId, options, cb) {
|
1313 | return this._request('PATCH', '/projects/columns/cards/' + cardId, options, cb);
|
1314 | }
|
1315 |
|
1316 | |
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 | }, {
|
1325 | key: 'deleteProjectCard',
|
1326 | value: function deleteProjectCard(cardId, cb) {
|
1327 | return this._request('DELETE', '/projects/columns/cards/' + cardId, null, cb);
|
1328 | }
|
1329 |
|
1330 | |
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 | }, {
|
1342 | key: 'moveProjectCard',
|
1343 | value: function moveProjectCard(cardId, position, colId, cb) {
|
1344 | return this._request('POST', '/projects/columns/cards/' + cardId + '/moves', { position: position, column_id: colId },
|
1345 | cb);
|
1346 | }
|
1347 | }]);
|
1348 |
|
1349 | return Project;
|
1350 | }(_Requestable3.default);
|
1351 |
|
1352 | module.exports = Project;
|
1353 |
|
1354 | },{"./Requestable":9}],7:[function(require,module,exports){
|
1355 | 'use strict';
|
1356 |
|
1357 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
1358 |
|
1359 | var _Requestable2 = require('./Requestable');
|
1360 |
|
1361 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
1362 |
|
1363 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1364 |
|
1365 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1366 |
|
1367 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
1368 |
|
1369 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 | var RateLimit = function (_Requestable) {
|
1380 | _inherits(RateLimit, _Requestable);
|
1381 |
|
1382 | |
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 | function RateLimit(auth, apiBase) {
|
1389 | _classCallCheck(this, RateLimit);
|
1390 |
|
1391 | return _possibleConstructorReturn(this, (RateLimit.__proto__ || Object.getPrototypeOf(RateLimit)).call(this, auth, apiBase));
|
1392 | }
|
1393 |
|
1394 | |
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 | _createClass(RateLimit, [{
|
1403 | key: 'getRateLimit',
|
1404 | value: function getRateLimit(cb) {
|
1405 | return this._request('GET', '/rate_limit', null, cb);
|
1406 | }
|
1407 | }]);
|
1408 |
|
1409 | return RateLimit;
|
1410 | }(_Requestable3.default);
|
1411 |
|
1412 | module.exports = RateLimit;
|
1413 |
|
1414 | },{"./Requestable":9}],8:[function(require,module,exports){
|
1415 | (function (Buffer){(function (){
|
1416 | 'use strict';
|
1417 |
|
1418 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
1419 |
|
1420 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
1421 |
|
1422 | var _Requestable2 = require('./Requestable');
|
1423 |
|
1424 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
1425 |
|
1426 | var _utf = require('utf8');
|
1427 |
|
1428 | var _utf2 = _interopRequireDefault(_utf);
|
1429 |
|
1430 | var _jsBase = require('js-base64');
|
1431 |
|
1432 | var _debug = require('debug');
|
1433 |
|
1434 | var _debug2 = _interopRequireDefault(_debug);
|
1435 |
|
1436 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1437 |
|
1438 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1439 |
|
1440 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
1441 |
|
1442 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 | var log = (0, _debug2.default)('github:repository');
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 | var Repository = function (_Requestable) {
|
1456 | _inherits(Repository, _Requestable);
|
1457 |
|
1458 | |
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 | function Repository(fullname, auth, apiBase) {
|
1465 | _classCallCheck(this, Repository);
|
1466 |
|
1467 | var _this = _possibleConstructorReturn(this, (Repository.__proto__ || Object.getPrototypeOf(Repository)).call(this, auth, apiBase));
|
1468 |
|
1469 | _this.__fullname = fullname;
|
1470 | _this.__currentTree = {
|
1471 | branch: null,
|
1472 | sha: null
|
1473 | };
|
1474 | return _this;
|
1475 | }
|
1476 |
|
1477 | |
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 | _createClass(Repository, [{
|
1487 | key: 'getRef',
|
1488 | value: function getRef(ref, cb) {
|
1489 | return this._request('GET', '/repos/' + this.__fullname + '/git/refs/' + ref, null, cb);
|
1490 | }
|
1491 |
|
1492 | |
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 | }, {
|
1501 | key: 'createRef',
|
1502 | value: function createRef(options, cb) {
|
1503 | return this._request('POST', '/repos/' + this.__fullname + '/git/refs', options, cb);
|
1504 | }
|
1505 |
|
1506 | |
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 | }, {
|
1515 | key: 'deleteRef',
|
1516 | value: function deleteRef(ref, cb) {
|
1517 | return this._request('DELETE', '/repos/' + this.__fullname + '/git/refs/' + ref, null, cb);
|
1518 | }
|
1519 |
|
1520 | |
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 |
|
1526 |
|
1527 | }, {
|
1528 | key: 'deleteRepo',
|
1529 | value: function deleteRepo(cb) {
|
1530 | return this._request('DELETE', '/repos/' + this.__fullname, null, cb);
|
1531 | }
|
1532 |
|
1533 | |
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 | }, {
|
1541 | key: 'listTags',
|
1542 | value: function listTags(cb) {
|
1543 | return this._request('GET', '/repos/' + this.__fullname + '/tags', null, cb);
|
1544 | }
|
1545 |
|
1546 | |
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 | }, {
|
1555 | key: 'listPullRequests',
|
1556 | value: function listPullRequests(options, cb) {
|
1557 | options = options || {};
|
1558 | return this._request('GET', '/repos/' + this.__fullname + '/pulls', options, cb);
|
1559 | }
|
1560 |
|
1561 | |
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 | }, {
|
1570 | key: 'getPullRequest',
|
1571 | value: function getPullRequest(number, cb) {
|
1572 | return this._request('GET', '/repos/' + this.__fullname + '/pulls/' + number, null, cb);
|
1573 | }
|
1574 |
|
1575 | |
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 | }, {
|
1584 | key: 'listPullRequestFiles',
|
1585 | value: function listPullRequestFiles(number, cb) {
|
1586 | return this._request('GET', '/repos/' + this.__fullname + '/pulls/' + number + '/files', null, cb);
|
1587 | }
|
1588 |
|
1589 | |
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 | }, {
|
1599 | key: 'compareBranches',
|
1600 | value: function compareBranches(base, head, cb) {
|
1601 | return this._request('GET', '/repos/' + this.__fullname + '/compare/' + base + '...' + head, null, cb);
|
1602 | }
|
1603 |
|
1604 | |
1605 |
|
1606 |
|
1607 |
|
1608 |
|
1609 |
|
1610 |
|
1611 | }, {
|
1612 | key: 'listBranches',
|
1613 | value: function listBranches(cb) {
|
1614 | return this._request('GET', '/repos/' + this.__fullname + '/branches', null, cb);
|
1615 | }
|
1616 |
|
1617 | |
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 | }, {
|
1626 | key: 'getBlob',
|
1627 | value: function getBlob(sha, cb) {
|
1628 | return this._request('GET', '/repos/' + this.__fullname + '/git/blobs/' + sha, null, cb, 'raw');
|
1629 | }
|
1630 |
|
1631 | |
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 | }, {
|
1640 | key: 'getBranch',
|
1641 | value: function getBranch(branch, cb) {
|
1642 | return this._request('GET', '/repos/' + this.__fullname + '/branches/' + branch, null, cb);
|
1643 | }
|
1644 |
|
1645 | |
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 |
|
1653 | }, {
|
1654 | key: 'getCommit',
|
1655 | value: function getCommit(sha, cb) {
|
1656 | return this._request('GET', '/repos/' + this.__fullname + '/git/commits/' + sha, null, cb);
|
1657 | }
|
1658 |
|
1659 | |
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 | }, {
|
1673 | key: 'listCommits',
|
1674 | value: function listCommits(options, cb) {
|
1675 | options = options || {};
|
1676 | if (typeof options === 'function') {
|
1677 | cb = options;
|
1678 | options = {};
|
1679 | }
|
1680 | options.since = this._dateToISO(options.since);
|
1681 | options.until = this._dateToISO(options.until);
|
1682 |
|
1683 | return this._request('GET', '/repos/' + this.__fullname + '/commits', options, cb);
|
1684 | }
|
1685 |
|
1686 | |
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 | }, {
|
1696 | key: 'listCommitsOnPR',
|
1697 | value: function listCommitsOnPR(number, options, cb) {
|
1698 | options = options || {};
|
1699 | if (typeof options === 'function') {
|
1700 | cb = options;
|
1701 | options = {};
|
1702 | }
|
1703 | return this._request('GET', '/repos/' + this.__fullname + '/pulls/' + number + '/commits', options, cb);
|
1704 | }
|
1705 |
|
1706 | |
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 | }, {
|
1715 | key: 'getSingleCommit',
|
1716 | value: function getSingleCommit(ref, cb) {
|
1717 | ref = ref || '';
|
1718 | return this._request('GET', '/repos/' + this.__fullname + '/commits/' + ref, null, cb);
|
1719 | }
|
1720 |
|
1721 | |
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 |
|
1730 | }, {
|
1731 | key: 'getSha',
|
1732 | value: function getSha(branch, path, cb) {
|
1733 | branch = branch ? '?ref=' + branch : '';
|
1734 | return this._request('GET', '/repos/' + this.__fullname + '/contents/' + path + branch, null, cb);
|
1735 | }
|
1736 |
|
1737 | |
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 | }, {
|
1746 | key: 'listStatuses',
|
1747 | value: function listStatuses(sha, cb) {
|
1748 | return this._request('GET', '/repos/' + this.__fullname + '/commits/' + sha + '/statuses', null, cb);
|
1749 | }
|
1750 |
|
1751 | |
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 | }, {
|
1760 | key: 'getCombinedStatus',
|
1761 | value: function getCombinedStatus(sha, cb) {
|
1762 | return this._request('GET', '/repos/' + this.__fullname + '/commits/' + sha + '/status', null, cb);
|
1763 | }
|
1764 |
|
1765 | |
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 | }, {
|
1774 | key: 'getTree',
|
1775 | value: function getTree(treeSHA, cb) {
|
1776 | return this._request('GET', '/repos/' + this.__fullname + '/git/trees/' + treeSHA, null, cb);
|
1777 | }
|
1778 |
|
1779 | |
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 | }, {
|
1788 | key: 'createBlob',
|
1789 | value: function createBlob(content, cb) {
|
1790 | var postBody = this._getContentObject(content);
|
1791 |
|
1792 | log('sending content', postBody);
|
1793 | return this._request('POST', '/repos/' + this.__fullname + '/git/blobs', postBody, cb);
|
1794 | }
|
1795 |
|
1796 | |
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 | }, {
|
1803 | key: '_getContentObject',
|
1804 | value: function _getContentObject(content) {
|
1805 | if (typeof content === 'string') {
|
1806 | log('contet is a string');
|
1807 | return {
|
1808 | content: _utf2.default.encode(content),
|
1809 | encoding: 'utf-8'
|
1810 | };
|
1811 | } else if (typeof Buffer !== 'undefined' && content instanceof Buffer) {
|
1812 | log('We appear to be in Node');
|
1813 | return {
|
1814 | content: content.toString('base64'),
|
1815 | encoding: 'base64'
|
1816 | };
|
1817 | } else if (typeof Blob !== 'undefined' && content instanceof Blob) {
|
1818 | log('We appear to be in the browser');
|
1819 | return {
|
1820 | content: _jsBase.Base64.encode(content),
|
1821 | encoding: 'base64'
|
1822 | };
|
1823 | } else {
|
1824 |
|
1825 | log('Not sure what this content is: ' + (typeof content === 'undefined' ? 'undefined' : _typeof(content)) + ', ' + JSON.stringify(content));
|
1826 | throw new Error('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web)');
|
1827 | }
|
1828 | }
|
1829 |
|
1830 | |
1831 |
|
1832 |
|
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 | }, {
|
1842 | key: 'updateTree',
|
1843 | value: function updateTree(baseTreeSHA, path, blobSHA, cb) {
|
1844 | var newTree = {
|
1845 | base_tree: baseTreeSHA,
|
1846 | tree: [{
|
1847 | path: path,
|
1848 | sha: blobSHA,
|
1849 | mode: '100644',
|
1850 | type: 'blob'
|
1851 | }]
|
1852 | };
|
1853 |
|
1854 | return this._request('POST', '/repos/' + this.__fullname + '/git/trees', newTree, cb);
|
1855 | }
|
1856 |
|
1857 | |
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 | }, {
|
1867 | key: 'createTree',
|
1868 | value: function createTree(tree, baseSHA, cb) {
|
1869 | return this._request('POST', '/repos/' + this.__fullname + '/git/trees', {
|
1870 | tree: tree,
|
1871 | base_tree: baseSHA
|
1872 | }, cb);
|
1873 | }
|
1874 |
|
1875 | |
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 | }, {
|
1889 | key: 'commit',
|
1890 | value: function commit(parent, tree, message, options, cb) {
|
1891 | var _this2 = this;
|
1892 |
|
1893 | if (typeof options === 'function') {
|
1894 | cb = options;
|
1895 | options = {};
|
1896 | }
|
1897 |
|
1898 | var data = {
|
1899 | message: message,
|
1900 | tree: tree,
|
1901 | parents: [parent]
|
1902 | };
|
1903 |
|
1904 | data = Object.assign({}, options, data);
|
1905 |
|
1906 | return this._request('POST', '/repos/' + this.__fullname + '/git/commits', data, cb).then(function (response) {
|
1907 | _this2.__currentTree.sha = response.data.sha;
|
1908 | return response;
|
1909 | });
|
1910 | }
|
1911 |
|
1912 | |
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 |
|
1922 | }, {
|
1923 | key: 'updateHead',
|
1924 | value: function updateHead(ref, commitSHA, force, cb) {
|
1925 | return this._request('PATCH', '/repos/' + this.__fullname + '/git/refs/' + ref, {
|
1926 | sha: commitSHA,
|
1927 | force: force
|
1928 | }, cb);
|
1929 | }
|
1930 |
|
1931 | |
1932 |
|
1933 |
|
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 | }, {
|
1945 | key: 'updateStatus',
|
1946 | value: function updateStatus(commitSHA, options, cb) {
|
1947 | return this._request('POST', '/repos/' + this.__fullname + '/statuses/' + commitSHA, options, cb);
|
1948 | }
|
1949 |
|
1950 | |
1951 |
|
1952 |
|
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 |
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 | }, {
|
1967 | key: 'updateRepository',
|
1968 | value: function updateRepository(options, cb) {
|
1969 | return this._request('PATCH', '/repos/' + this.__fullname, options, cb);
|
1970 | }
|
1971 |
|
1972 | |
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 | }, {
|
1980 | key: 'getDetails',
|
1981 | value: function getDetails(cb) {
|
1982 | return this._request('GET', '/repos/' + this.__fullname, null, cb);
|
1983 | }
|
1984 |
|
1985 | |
1986 |
|
1987 |
|
1988 |
|
1989 |
|
1990 |
|
1991 |
|
1992 | }, {
|
1993 | key: 'getContributors',
|
1994 | value: function getContributors(cb) {
|
1995 | return this._request('GET', '/repos/' + this.__fullname + '/contributors', null, cb);
|
1996 | }
|
1997 |
|
1998 | |
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 | }, {
|
2006 | key: 'getContributorStats',
|
2007 | value: function getContributorStats(cb) {
|
2008 | return this._request('GET', '/repos/' + this.__fullname + '/stats/contributors', null, cb);
|
2009 | }
|
2010 |
|
2011 | |
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 | }, {
|
2020 | key: 'getCollaborators',
|
2021 | value: function getCollaborators(cb) {
|
2022 | return this._request('GET', '/repos/' + this.__fullname + '/collaborators', null, cb);
|
2023 | }
|
2024 |
|
2025 | |
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 | }, {
|
2034 | key: 'isCollaborator',
|
2035 | value: function isCollaborator(username, cb) {
|
2036 | return this._request('GET', '/repos/' + this.__fullname + '/collaborators/' + username, null, cb);
|
2037 | }
|
2038 |
|
2039 | |
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 | }, {
|
2050 | key: 'getContents',
|
2051 | value: function getContents(ref, path, raw, cb) {
|
2052 | path = path ? '' + encodeURI(path) : '';
|
2053 | return this._request('GET', '/repos/' + this.__fullname + '/contents/' + path, {
|
2054 | ref: ref
|
2055 | }, cb, raw);
|
2056 | }
|
2057 |
|
2058 | |
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 |
|
2067 | }, {
|
2068 | key: 'getReadme',
|
2069 | value: function getReadme(ref, raw, cb) {
|
2070 | return this._request('GET', '/repos/' + this.__fullname + '/readme', {
|
2071 | ref: ref
|
2072 | }, cb, raw);
|
2073 | }
|
2074 |
|
2075 | |
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 | }, {
|
2083 | key: 'fork',
|
2084 | value: function fork(cb) {
|
2085 | return this._request('POST', '/repos/' + this.__fullname + '/forks', null, cb);
|
2086 | }
|
2087 |
|
2088 | |
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 | }, {
|
2098 | key: 'forkToOrg',
|
2099 | value: function forkToOrg(org, cb) {
|
2100 | return this._request('POST', '/repos/' + this.__fullname + '/forks?organization=' + org, null, cb);
|
2101 | }
|
2102 |
|
2103 | |
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 |
|
2109 |
|
2110 | }, {
|
2111 | key: 'listForks',
|
2112 | value: function listForks(cb) {
|
2113 | return this._request('GET', '/repos/' + this.__fullname + '/forks', null, cb);
|
2114 | }
|
2115 |
|
2116 | |
2117 |
|
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 | }, {
|
2125 | key: 'createBranch',
|
2126 | value: function createBranch(oldBranch, newBranch, cb) {
|
2127 | var _this3 = this;
|
2128 |
|
2129 | if (typeof newBranch === 'function') {
|
2130 | cb = newBranch;
|
2131 | newBranch = oldBranch;
|
2132 | oldBranch = 'master';
|
2133 | }
|
2134 |
|
2135 | return this.getRef('heads/' + oldBranch).then(function (response) {
|
2136 | var sha = response.data.object.sha;
|
2137 | return _this3.createRef({
|
2138 | sha: sha,
|
2139 | ref: 'refs/heads/' + newBranch
|
2140 | }, cb);
|
2141 | });
|
2142 | }
|
2143 |
|
2144 | |
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 | }, {
|
2153 | key: 'createPullRequest',
|
2154 | value: function createPullRequest(options, cb) {
|
2155 | return this._request('POST', '/repos/' + this.__fullname + '/pulls', options, cb);
|
2156 | }
|
2157 |
|
2158 | |
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 |
|
2166 |
|
2167 | }, {
|
2168 | key: 'updatePullRequest',
|
2169 | value: function updatePullRequest(number, options, cb) {
|
2170 | return this._request('PATCH', '/repos/' + this.__fullname + '/pulls/' + number, options, cb);
|
2171 | }
|
2172 |
|
2173 | |
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 |
|
2179 |
|
2180 | }, {
|
2181 | key: 'listHooks',
|
2182 | value: function listHooks(cb) {
|
2183 | return this._request('GET', '/repos/' + this.__fullname + '/hooks', null, cb);
|
2184 | }
|
2185 |
|
2186 | |
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 | }, {
|
2195 | key: 'getHook',
|
2196 | value: function getHook(id, cb) {
|
2197 | return this._request('GET', '/repos/' + this.__fullname + '/hooks/' + id, null, cb);
|
2198 | }
|
2199 |
|
2200 | |
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 |
|
2206 |
|
2207 |
|
2208 | }, {
|
2209 | key: 'createHook',
|
2210 | value: function createHook(options, cb) {
|
2211 | return this._request('POST', '/repos/' + this.__fullname + '/hooks', options, cb);
|
2212 | }
|
2213 |
|
2214 | |
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 | }, {
|
2224 | key: 'updateHook',
|
2225 | value: function updateHook(id, options, cb) {
|
2226 | return this._request('PATCH', '/repos/' + this.__fullname + '/hooks/' + id, options, cb);
|
2227 | }
|
2228 |
|
2229 | |
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 | }, {
|
2238 | key: 'deleteHook',
|
2239 | value: function deleteHook(id, cb) {
|
2240 | return this._request('DELETE', '/repos/' + this.__fullname + '/hooks/' + id, null, cb);
|
2241 | }
|
2242 |
|
2243 | |
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 | }, {
|
2251 | key: 'listKeys',
|
2252 | value: function listKeys(cb) {
|
2253 | return this._request('GET', '/repos/' + this.__fullname + '/keys', null, cb);
|
2254 | }
|
2255 |
|
2256 | |
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 |
|
2264 | }, {
|
2265 | key: 'getKey',
|
2266 | value: function getKey(id, cb) {
|
2267 | return this._request('GET', '/repos/' + this.__fullname + '/keys/' + id, null, cb);
|
2268 | }
|
2269 |
|
2270 | |
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 | }, {
|
2279 | key: 'createKey',
|
2280 | value: function createKey(options, cb) {
|
2281 | return this._request('POST', '/repos/' + this.__fullname + '/keys', options, cb);
|
2282 | }
|
2283 |
|
2284 | |
2285 |
|
2286 |
|
2287 |
|
2288 |
|
2289 |
|
2290 |
|
2291 |
|
2292 | }, {
|
2293 | key: 'deleteKey',
|
2294 | value: function deleteKey(id, cb) {
|
2295 | return this._request('DELETE', '/repos/' + this.__fullname + '/keys/' + id, null, cb);
|
2296 | }
|
2297 |
|
2298 | |
2299 |
|
2300 |
|
2301 |
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 |
|
2307 | }, {
|
2308 | key: 'deleteFile',
|
2309 | value: function deleteFile(branch, path, cb) {
|
2310 | var _this4 = this;
|
2311 |
|
2312 | return this.getSha(branch, path).then(function (response) {
|
2313 | var deleteCommit = {
|
2314 | message: 'Delete the file at \'' + path + '\'',
|
2315 | sha: response.data.sha,
|
2316 | branch: branch
|
2317 | };
|
2318 | return _this4._request('DELETE', '/repos/' + _this4.__fullname + '/contents/' + path, deleteCommit, cb);
|
2319 | });
|
2320 | }
|
2321 |
|
2322 | |
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 | }, {
|
2332 | key: 'move',
|
2333 | value: function move(branch, oldPath, newPath, cb) {
|
2334 | var _this5 = this;
|
2335 |
|
2336 | var oldSha = void 0;
|
2337 | return this.getRef('heads/' + branch).then(function (_ref) {
|
2338 | var object = _ref.data.object;
|
2339 | return _this5.getTree(object.sha + '?recursive=true');
|
2340 | }).then(function (_ref2) {
|
2341 | var _ref2$data = _ref2.data,
|
2342 | tree = _ref2$data.tree,
|
2343 | sha = _ref2$data.sha;
|
2344 |
|
2345 | oldSha = sha;
|
2346 | var newTree = tree.map(function (ref) {
|
2347 | if (ref.path === oldPath) {
|
2348 | ref.path = newPath;
|
2349 | }
|
2350 | if (ref.type === 'tree') {
|
2351 | delete ref.sha;
|
2352 | }
|
2353 | return ref;
|
2354 | });
|
2355 | return _this5.createTree(newTree);
|
2356 | }).then(function (_ref3) {
|
2357 | var tree = _ref3.data;
|
2358 | return _this5.commit(oldSha, tree.sha, 'Renamed \'' + oldPath + '\' to \'' + newPath + '\'');
|
2359 | }).then(function (_ref4) {
|
2360 | var commit = _ref4.data;
|
2361 | return _this5.updateHead('heads/' + branch, commit.sha, true, cb);
|
2362 | });
|
2363 | }
|
2364 |
|
2365 | |
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 |
|
2371 |
|
2372 |
|
2373 |
|
2374 |
|
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 | }, {
|
2381 | key: 'writeFile',
|
2382 | value: function writeFile(branch, path, content, message, options, cb) {
|
2383 | var _this6 = this;
|
2384 |
|
2385 | options = options || {};
|
2386 | if (typeof options === 'function') {
|
2387 | cb = options;
|
2388 | options = {};
|
2389 | }
|
2390 | var filePath = path ? encodeURI(path) : '';
|
2391 | var shouldEncode = options.encode !== false;
|
2392 | var commit = {
|
2393 | branch: branch,
|
2394 | message: message,
|
2395 | author: options.author,
|
2396 | committer: options.committer,
|
2397 | content: shouldEncode ? _jsBase.Base64.encode(content) : content
|
2398 | };
|
2399 |
|
2400 | return this.getSha(branch, filePath).then(function (response) {
|
2401 | commit.sha = response.data.sha;
|
2402 | return _this6._request('PUT', '/repos/' + _this6.__fullname + '/contents/' + filePath, commit, cb);
|
2403 | }, function () {
|
2404 | return _this6._request('PUT', '/repos/' + _this6.__fullname + '/contents/' + filePath, commit, cb);
|
2405 | });
|
2406 | }
|
2407 |
|
2408 | |
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |
|
2415 |
|
2416 | }, {
|
2417 | key: 'isStarred',
|
2418 | value: function isStarred(cb) {
|
2419 | return this._request204or404('/user/starred/' + this.__fullname, null, cb);
|
2420 | }
|
2421 |
|
2422 | |
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 |
|
2428 |
|
2429 | }, {
|
2430 | key: 'star',
|
2431 | value: function star(cb) {
|
2432 | return this._request('PUT', '/user/starred/' + this.__fullname, null, cb);
|
2433 | }
|
2434 |
|
2435 | |
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 | }, {
|
2443 | key: 'unstar',
|
2444 | value: function unstar(cb) {
|
2445 | return this._request('DELETE', '/user/starred/' + this.__fullname, null, cb);
|
2446 | }
|
2447 |
|
2448 | |
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 |
|
2454 |
|
2455 |
|
2456 | }, {
|
2457 | key: 'createRelease',
|
2458 | value: function createRelease(options, cb) {
|
2459 | return this._request('POST', '/repos/' + this.__fullname + '/releases', options, cb);
|
2460 | }
|
2461 |
|
2462 | |
2463 |
|
2464 |
|
2465 |
|
2466 |
|
2467 |
|
2468 |
|
2469 |
|
2470 |
|
2471 | }, {
|
2472 | key: 'updateRelease',
|
2473 | value: function updateRelease(id, options, cb) {
|
2474 | return this._request('PATCH', '/repos/' + this.__fullname + '/releases/' + id, options, cb);
|
2475 | }
|
2476 |
|
2477 | |
2478 |
|
2479 |
|
2480 |
|
2481 |
|
2482 |
|
2483 |
|
2484 | }, {
|
2485 | key: 'listReleases',
|
2486 | value: function listReleases(cb) {
|
2487 | return this._request('GET', '/repos/' + this.__fullname + '/releases', null, cb);
|
2488 | }
|
2489 |
|
2490 | |
2491 |
|
2492 |
|
2493 |
|
2494 |
|
2495 |
|
2496 |
|
2497 |
|
2498 | }, {
|
2499 | key: 'getRelease',
|
2500 | value: function getRelease(id, cb) {
|
2501 | return this._request('GET', '/repos/' + this.__fullname + '/releases/' + id, null, cb);
|
2502 | }
|
2503 |
|
2504 | |
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 |
|
2510 |
|
2511 |
|
2512 | }, {
|
2513 | key: 'deleteRelease',
|
2514 | value: function deleteRelease(id, cb) {
|
2515 | return this._request('DELETE', '/repos/' + this.__fullname + '/releases/' + id, null, cb);
|
2516 | }
|
2517 |
|
2518 | |
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 |
|
2527 | }, {
|
2528 | key: 'mergePullRequest',
|
2529 | value: function mergePullRequest(number, options, cb) {
|
2530 | return this._request('PUT', '/repos/' + this.__fullname + '/pulls/' + number + '/merge', options, cb);
|
2531 | }
|
2532 |
|
2533 | |
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 |
|
2539 |
|
2540 | }, {
|
2541 | key: 'listProjects',
|
2542 | value: function listProjects(cb) {
|
2543 | return this._requestAllPages('/repos/' + this.__fullname + '/projects', { AcceptHeader: 'inertia-preview' }, cb);
|
2544 | }
|
2545 |
|
2546 | |
2547 |
|
2548 |
|
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 | }, {
|
2555 | key: 'createProject',
|
2556 | value: function createProject(options, cb) {
|
2557 | options = options || {};
|
2558 | options.AcceptHeader = 'inertia-preview';
|
2559 | return this._request('POST', '/repos/' + this.__fullname + '/projects', options, cb);
|
2560 | }
|
2561 | }]);
|
2562 |
|
2563 | return Repository;
|
2564 | }(_Requestable3.default);
|
2565 |
|
2566 | module.exports = Repository;
|
2567 |
|
2568 | }).call(this)}).call(this,require("buffer").Buffer)
|
2569 |
|
2570 | },{"./Requestable":9,"buffer":41,"debug":42,"js-base64":46,"utf8":49}],9:[function(require,module,exports){
|
2571 | 'use strict';
|
2572 |
|
2573 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
2574 |
|
2575 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
2576 |
|
2577 | var _axios = require('axios');
|
2578 |
|
2579 | var _axios2 = _interopRequireDefault(_axios);
|
2580 |
|
2581 | var _debug = require('debug');
|
2582 |
|
2583 | var _debug2 = _interopRequireDefault(_debug);
|
2584 |
|
2585 | var _jsBase = require('js-base64');
|
2586 |
|
2587 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2588 |
|
2589 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
2590 |
|
2591 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2592 |
|
2593 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
2594 |
|
2595 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
2596 |
|
2597 |
|
2598 |
|
2599 |
|
2600 |
|
2601 |
|
2602 | var log = (0, _debug2.default)('github:request');
|
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 | var ResponseError = function (_Error) {
|
2609 | _inherits(ResponseError, _Error);
|
2610 |
|
2611 | |
2612 |
|
2613 |
|
2614 |
|
2615 |
|
2616 |
|
2617 | function ResponseError(message, path, response) {
|
2618 | _classCallCheck(this, ResponseError);
|
2619 |
|
2620 | var _this = _possibleConstructorReturn(this, (ResponseError.__proto__ || Object.getPrototypeOf(ResponseError)).call(this, message));
|
2621 |
|
2622 | _this.path = path;
|
2623 | _this.request = response.config;
|
2624 | _this.response = (response || {}).response || response;
|
2625 | _this.status = response.status;
|
2626 | return _this;
|
2627 | }
|
2628 |
|
2629 | return ResponseError;
|
2630 | }(Error);
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 |
|
2636 |
|
2637 | var Requestable = function () {
|
2638 | |
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 | |
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 |
|
2651 |
|
2652 | function Requestable(auth, apiBase, AcceptHeader) {
|
2653 | _classCallCheck(this, Requestable);
|
2654 |
|
2655 | this.__apiBase = apiBase || 'https://api.github.com';
|
2656 | this.__auth = {
|
2657 | token: auth.token,
|
2658 | username: auth.username,
|
2659 | password: auth.password
|
2660 | };
|
2661 | this.__AcceptHeader = AcceptHeader || 'v3';
|
2662 |
|
2663 | if (auth.token) {
|
2664 | this.__authorizationHeader = 'token ' + auth.token;
|
2665 | } else if (auth.username && auth.password) {
|
2666 | this.__authorizationHeader = 'Basic ' + _jsBase.Base64.encode(auth.username + ':' + auth.password);
|
2667 | }
|
2668 | }
|
2669 |
|
2670 | |
2671 |
|
2672 |
|
2673 |
|
2674 |
|
2675 |
|
2676 |
|
2677 |
|
2678 | _createClass(Requestable, [{
|
2679 | key: '__getURL',
|
2680 | value: function __getURL(path) {
|
2681 | var url = path;
|
2682 |
|
2683 | if (path.indexOf('//') === -1) {
|
2684 | url = this.__apiBase + path;
|
2685 | }
|
2686 |
|
2687 | var newCacheBuster = 'timestamp=' + new Date().getTime();
|
2688 | return url.replace(/(timestamp=\d+)/, newCacheBuster);
|
2689 | }
|
2690 |
|
2691 | |
2692 |
|
2693 |
|
2694 |
|
2695 |
|
2696 |
|
2697 |
|
2698 |
|
2699 | }, {
|
2700 | key: '__getRequestHeaders',
|
2701 | value: function __getRequestHeaders(raw, AcceptHeader) {
|
2702 | var headers = {
|
2703 | 'Content-Type': 'application/json;charset=UTF-8',
|
2704 | 'Accept': 'application/vnd.github.' + (AcceptHeader || this.__AcceptHeader)
|
2705 | };
|
2706 |
|
2707 | if (raw) {
|
2708 | headers.Accept += '.raw';
|
2709 | }
|
2710 | headers.Accept += '+json';
|
2711 |
|
2712 | if (this.__authorizationHeader) {
|
2713 | headers.Authorization = this.__authorizationHeader;
|
2714 | }
|
2715 |
|
2716 | return headers;
|
2717 | }
|
2718 |
|
2719 | |
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 | }, {
|
2727 | key: '_getOptionsWithDefaults',
|
2728 | value: function _getOptionsWithDefaults() {
|
2729 | var requestOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2730 |
|
2731 | if (!(requestOptions.visibility || requestOptions.affiliation)) {
|
2732 | requestOptions.type = requestOptions.type || 'all';
|
2733 | }
|
2734 | requestOptions.sort = requestOptions.sort || 'updated';
|
2735 | requestOptions.per_page = requestOptions.per_page || '100';
|
2736 |
|
2737 | return requestOptions;
|
2738 | }
|
2739 |
|
2740 | |
2741 |
|
2742 |
|
2743 |
|
2744 |
|
2745 |
|
2746 | }, {
|
2747 | key: '_dateToISO',
|
2748 | value: function _dateToISO(date) {
|
2749 | if (date && date instanceof Date) {
|
2750 | date = date.toISOString();
|
2751 | }
|
2752 |
|
2753 | return date;
|
2754 | }
|
2755 |
|
2756 | |
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 | |
2764 |
|
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 |
|
2770 |
|
2771 |
|
2772 |
|
2773 |
|
2774 |
|
2775 | }, {
|
2776 | key: '_request',
|
2777 | value: function _request(method, path, data, cb, raw) {
|
2778 | var url = this.__getURL(path);
|
2779 |
|
2780 | var AcceptHeader = (data || {}).AcceptHeader;
|
2781 | if (AcceptHeader) {
|
2782 | delete data.AcceptHeader;
|
2783 | }
|
2784 | var headers = this.__getRequestHeaders(raw, AcceptHeader);
|
2785 |
|
2786 | var queryParams = {};
|
2787 |
|
2788 | var shouldUseDataAsParams = data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && methodHasNoBody(method);
|
2789 | if (shouldUseDataAsParams) {
|
2790 | queryParams = data;
|
2791 | data = undefined;
|
2792 | }
|
2793 |
|
2794 | var config = {
|
2795 | url: url,
|
2796 | method: method,
|
2797 | headers: headers,
|
2798 | params: queryParams,
|
2799 | data: data,
|
2800 | responseType: raw ? 'text' : 'json'
|
2801 | };
|
2802 |
|
2803 | log(config.method + ' to ' + config.url);
|
2804 | var requestPromise = (0, _axios2.default)(config).catch(callbackErrorOrThrow(cb, path));
|
2805 |
|
2806 | if (cb) {
|
2807 | requestPromise.then(function (response) {
|
2808 | if (response.data && Object.keys(response.data).length > 0) {
|
2809 |
|
2810 | cb(null, response.data, response);
|
2811 | } else if (config.method !== 'GET' && Object.keys(response.data).length < 1) {
|
2812 |
|
2813 | cb(null, response.status < 300, response);
|
2814 | } else {
|
2815 | cb(null, response.data, response);
|
2816 | }
|
2817 | });
|
2818 | }
|
2819 |
|
2820 | return requestPromise;
|
2821 | }
|
2822 |
|
2823 | |
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 |
|
2832 | }, {
|
2833 | key: '_request204or404',
|
2834 | value: function _request204or404(path, data, cb) {
|
2835 | var method = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'GET';
|
2836 |
|
2837 | return this._request(method, path, data).then(function success(response) {
|
2838 | if (cb) {
|
2839 | cb(null, true, response);
|
2840 | }
|
2841 | return true;
|
2842 | }, function failure(response) {
|
2843 | if (response.response.status === 404) {
|
2844 | if (cb) {
|
2845 | cb(null, false, response);
|
2846 | }
|
2847 | return false;
|
2848 | }
|
2849 |
|
2850 | if (cb) {
|
2851 | cb(response);
|
2852 | }
|
2853 | throw response;
|
2854 | });
|
2855 | }
|
2856 |
|
2857 | |
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 | }, {
|
2869 | key: '_requestAllPages',
|
2870 | value: function _requestAllPages(path, options, cb, results) {
|
2871 | var _this2 = this;
|
2872 |
|
2873 | results = results || [];
|
2874 |
|
2875 | return this._request('GET', path, options).then(function (response) {
|
2876 | var _results;
|
2877 |
|
2878 | var thisGroup = void 0;
|
2879 | if (response.data instanceof Array) {
|
2880 | thisGroup = response.data;
|
2881 | } else if (response.data.items instanceof Array) {
|
2882 | thisGroup = response.data.items;
|
2883 | } else {
|
2884 | var message = 'cannot figure out how to append ' + response.data + ' to the result set';
|
2885 | throw new ResponseError(message, path, response);
|
2886 | }
|
2887 | (_results = results).push.apply(_results, _toConsumableArray(thisGroup));
|
2888 |
|
2889 | var nextUrl = getNextPage(response.headers.link);
|
2890 | if (nextUrl) {
|
2891 | if (!options) {
|
2892 | options = {};
|
2893 | }
|
2894 | options.page = parseInt(nextUrl.match(/([&\?]page=[0-9]*)/g).shift().split('=').pop());
|
2895 | if (!(options && typeof options.page !== 'number')) {
|
2896 | log('getting next page: ' + nextUrl);
|
2897 | return _this2._requestAllPages(nextUrl, options, cb, results);
|
2898 | }
|
2899 | }
|
2900 |
|
2901 | if (cb) {
|
2902 | cb(null, results, response);
|
2903 | }
|
2904 |
|
2905 | response.data = results;
|
2906 | return response;
|
2907 | }).catch(callbackErrorOrThrow(cb, path));
|
2908 | }
|
2909 | }]);
|
2910 |
|
2911 | return Requestable;
|
2912 | }();
|
2913 |
|
2914 | module.exports = Requestable;
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 | var METHODS_WITH_NO_BODY = ['GET', 'HEAD', 'DELETE'];
|
2920 | function methodHasNoBody(method) {
|
2921 | return METHODS_WITH_NO_BODY.indexOf(method) !== -1;
|
2922 | }
|
2923 |
|
2924 | function getNextPage() {
|
2925 | var linksHeader = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
2926 |
|
2927 | var links = linksHeader.split(/\s*,\s*/);
|
2928 | return links.reduce(function (nextUrl, link) {
|
2929 | if (link.search(/rel="next"/) !== -1) {
|
2930 | return (link.match(/<(.*)>/) || [])[1];
|
2931 | }
|
2932 |
|
2933 | return nextUrl;
|
2934 | }, undefined);
|
2935 | }
|
2936 |
|
2937 | function callbackErrorOrThrow(cb, path) {
|
2938 | return function handler(object) {
|
2939 | var error = void 0;
|
2940 | if (object.hasOwnProperty('config')) {
|
2941 | var _object$response = object.response,
|
2942 | status = _object$response.status,
|
2943 | statusText = _object$response.statusText,
|
2944 | _object$config = object.config,
|
2945 | method = _object$config.method,
|
2946 | url = _object$config.url;
|
2947 |
|
2948 | var message = status + ' error making request ' + method + ' ' + url + ': "' + statusText + '"';
|
2949 | error = new ResponseError(message, path, object);
|
2950 | log(message + ' ' + JSON.stringify(object.data));
|
2951 | } else {
|
2952 | error = object;
|
2953 | }
|
2954 | if (cb) {
|
2955 | log('going to error callback');
|
2956 | cb(error);
|
2957 | } else {
|
2958 | log('throwing error');
|
2959 | throw error;
|
2960 | }
|
2961 | };
|
2962 | }
|
2963 |
|
2964 | },{"axios":13,"debug":42,"js-base64":46}],10:[function(require,module,exports){
|
2965 | 'use strict';
|
2966 |
|
2967 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
2968 |
|
2969 | var _Requestable2 = require('./Requestable');
|
2970 |
|
2971 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
2972 |
|
2973 | var _debug = require('debug');
|
2974 |
|
2975 | var _debug2 = _interopRequireDefault(_debug);
|
2976 |
|
2977 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2978 |
|
2979 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2980 |
|
2981 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
2982 |
|
2983 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
2984 |
|
2985 |
|
2986 |
|
2987 |
|
2988 |
|
2989 |
|
2990 | var log = (0, _debug2.default)('github:search');
|
2991 |
|
2992 |
|
2993 |
|
2994 |
|
2995 |
|
2996 | var Search = function (_Requestable) {
|
2997 | _inherits(Search, _Requestable);
|
2998 |
|
2999 | |
3000 |
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 | function Search(defaults, auth, apiBase) {
|
3006 | _classCallCheck(this, Search);
|
3007 |
|
3008 | var _this = _possibleConstructorReturn(this, (Search.__proto__ || Object.getPrototypeOf(Search)).call(this, auth, apiBase));
|
3009 |
|
3010 | _this.__defaults = _this._getOptionsWithDefaults(defaults);
|
3011 | return _this;
|
3012 | }
|
3013 |
|
3014 | |
3015 |
|
3016 |
|
3017 |
|
3018 |
|
3019 |
|
3020 |
|
3021 |
|
3022 |
|
3023 | |
3024 |
|
3025 |
|
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 | _createClass(Search, [{
|
3034 | key: '_search',
|
3035 | value: function _search(path) {
|
3036 | var _this2 = this;
|
3037 |
|
3038 | var withOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
3039 | var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
3040 |
|
3041 | var requestOptions = {};
|
3042 | Object.keys(this.__defaults).forEach(function (prop) {
|
3043 | requestOptions[prop] = _this2.__defaults[prop];
|
3044 | });
|
3045 | Object.keys(withOptions).forEach(function (prop) {
|
3046 | requestOptions[prop] = withOptions[prop];
|
3047 | });
|
3048 |
|
3049 | log('searching ' + path + ' with options:', requestOptions);
|
3050 | return this._requestAllPages('/search/' + path, requestOptions, cb);
|
3051 | }
|
3052 |
|
3053 | |
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 |
|
3059 |
|
3060 |
|
3061 | }, {
|
3062 | key: 'forRepositories',
|
3063 | value: function forRepositories(options, cb) {
|
3064 | return this._search('repositories', options, cb);
|
3065 | }
|
3066 |
|
3067 | |
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 | }, {
|
3076 | key: 'forCode',
|
3077 | value: function forCode(options, cb) {
|
3078 | return this._search('code', options, cb);
|
3079 | }
|
3080 |
|
3081 | |
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 | }, {
|
3090 | key: 'forIssues',
|
3091 | value: function forIssues(options, cb) {
|
3092 | return this._search('issues', options, cb);
|
3093 | }
|
3094 |
|
3095 | |
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 | }, {
|
3104 | key: 'forUsers',
|
3105 | value: function forUsers(options, cb) {
|
3106 | return this._search('users', options, cb);
|
3107 | }
|
3108 | }]);
|
3109 |
|
3110 | return Search;
|
3111 | }(_Requestable3.default);
|
3112 |
|
3113 | module.exports = Search;
|
3114 |
|
3115 | },{"./Requestable":9,"debug":42}],11:[function(require,module,exports){
|
3116 | 'use strict';
|
3117 |
|
3118 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
3119 |
|
3120 | var _Requestable2 = require('./Requestable');
|
3121 |
|
3122 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
3123 |
|
3124 | var _debug = require('debug');
|
3125 |
|
3126 | var _debug2 = _interopRequireDefault(_debug);
|
3127 |
|
3128 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
3129 |
|
3130 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3131 |
|
3132 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
3133 |
|
3134 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
3135 |
|
3136 |
|
3137 |
|
3138 |
|
3139 |
|
3140 |
|
3141 | var log = (0, _debug2.default)('github:team');
|
3142 |
|
3143 |
|
3144 |
|
3145 |
|
3146 |
|
3147 | var Team = function (_Requestable) {
|
3148 | _inherits(Team, _Requestable);
|
3149 |
|
3150 | |
3151 |
|
3152 |
|
3153 |
|
3154 |
|
3155 |
|
3156 | function Team(teamId, auth, apiBase) {
|
3157 | _classCallCheck(this, Team);
|
3158 |
|
3159 | var _this = _possibleConstructorReturn(this, (Team.__proto__ || Object.getPrototypeOf(Team)).call(this, auth, apiBase));
|
3160 |
|
3161 | _this.__teamId = teamId;
|
3162 | return _this;
|
3163 | }
|
3164 |
|
3165 | |
3166 |
|
3167 |
|
3168 |
|
3169 |
|
3170 |
|
3171 |
|
3172 |
|
3173 | _createClass(Team, [{
|
3174 | key: 'getTeam',
|
3175 | value: function getTeam(cb) {
|
3176 | log('Fetching Team ' + this.__teamId);
|
3177 | return this._request('Get', '/teams/' + this.__teamId, undefined, cb);
|
3178 | }
|
3179 |
|
3180 | |
3181 |
|
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 | }, {
|
3188 | key: 'listRepos',
|
3189 | value: function listRepos(cb) {
|
3190 | log('Fetching repositories for Team ' + this.__teamId);
|
3191 | return this._requestAllPages('/teams/' + this.__teamId + '/repos', undefined, cb);
|
3192 | }
|
3193 |
|
3194 | |
3195 |
|
3196 |
|
3197 |
|
3198 |
|
3199 |
|
3200 |
|
3201 |
|
3202 |
|
3203 |
|
3204 |
|
3205 |
|
3206 |
|
3207 | }, {
|
3208 | key: 'editTeam',
|
3209 | value: function editTeam(options, cb) {
|
3210 | log('Editing Team ' + this.__teamId);
|
3211 | return this._request('PATCH', '/teams/' + this.__teamId, options, cb);
|
3212 | }
|
3213 |
|
3214 | |
3215 |
|
3216 |
|
3217 |
|
3218 |
|
3219 |
|
3220 |
|
3221 |
|
3222 |
|
3223 | }, {
|
3224 | key: 'listMembers',
|
3225 | value: function listMembers(options, cb) {
|
3226 | log('Getting members of Team ' + this.__teamId);
|
3227 | return this._requestAllPages('/teams/' + this.__teamId + '/members', options, cb);
|
3228 | }
|
3229 |
|
3230 | |
3231 |
|
3232 |
|
3233 |
|
3234 |
|
3235 |
|
3236 |
|
3237 |
|
3238 | }, {
|
3239 | key: 'getMembership',
|
3240 | value: function getMembership(username, cb) {
|
3241 | log('Getting membership of user ' + username + ' in Team ' + this.__teamId);
|
3242 | return this._request('GET', '/teams/' + this.__teamId + '/memberships/' + username, undefined, cb);
|
3243 | }
|
3244 |
|
3245 | |
3246 |
|
3247 |
|
3248 |
|
3249 |
|
3250 |
|
3251 |
|
3252 |
|
3253 |
|
3254 |
|
3255 |
|
3256 | }, {
|
3257 | key: 'addMembership',
|
3258 | value: function addMembership(username, options, cb) {
|
3259 | log('Adding user ' + username + ' to Team ' + this.__teamId);
|
3260 | return this._request('PUT', '/teams/' + this.__teamId + '/memberships/' + username, options, cb);
|
3261 | }
|
3262 |
|
3263 | |
3264 |
|
3265 |
|
3266 |
|
3267 |
|
3268 |
|
3269 |
|
3270 |
|
3271 |
|
3272 | }, {
|
3273 | key: 'isManagedRepo',
|
3274 | value: function isManagedRepo(owner, repo, cb) {
|
3275 | log('Getting repo management by Team ' + this.__teamId + ' for repo ' + owner + '/' + repo);
|
3276 | return this._request204or404('/teams/' + this.__teamId + '/repos/' + owner + '/' + repo, undefined, cb);
|
3277 | }
|
3278 |
|
3279 | |
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 |
|
3288 |
|
3289 |
|
3290 |
|
3291 | }, {
|
3292 | key: 'manageRepo',
|
3293 | value: function manageRepo(owner, repo, options, cb) {
|
3294 | log('Adding or Updating repo management by Team ' + this.__teamId + ' for repo ' + owner + '/' + repo);
|
3295 | return this._request204or404('/teams/' + this.__teamId + '/repos/' + owner + '/' + repo, options, cb, 'PUT');
|
3296 | }
|
3297 |
|
3298 | |
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 |
|
3304 |
|
3305 |
|
3306 |
|
3307 | }, {
|
3308 | key: 'unmanageRepo',
|
3309 | value: function unmanageRepo(owner, repo, cb) {
|
3310 | log('Remove repo management by Team ' + this.__teamId + ' for repo ' + owner + '/' + repo);
|
3311 | return this._request204or404('/teams/' + this.__teamId + '/repos/' + owner + '/' + repo, undefined, cb, 'DELETE');
|
3312 | }
|
3313 |
|
3314 | |
3315 |
|
3316 |
|
3317 |
|
3318 |
|
3319 |
|
3320 |
|
3321 | }, {
|
3322 | key: 'deleteTeam',
|
3323 | value: function deleteTeam(cb) {
|
3324 | log('Deleting Team ' + this.__teamId);
|
3325 | return this._request204or404('/teams/' + this.__teamId, undefined, cb, 'DELETE');
|
3326 | }
|
3327 | }]);
|
3328 |
|
3329 | return Team;
|
3330 | }(_Requestable3.default);
|
3331 |
|
3332 | module.exports = Team;
|
3333 |
|
3334 | },{"./Requestable":9,"debug":42}],12:[function(require,module,exports){
|
3335 | 'use strict';
|
3336 |
|
3337 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
3338 |
|
3339 | var _Requestable2 = require('./Requestable');
|
3340 |
|
3341 | var _Requestable3 = _interopRequireDefault(_Requestable2);
|
3342 |
|
3343 | var _debug = require('debug');
|
3344 |
|
3345 | var _debug2 = _interopRequireDefault(_debug);
|
3346 |
|
3347 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
3348 |
|
3349 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3350 |
|
3351 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
3352 |
|
3353 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 | var log = (0, _debug2.default)('github:user');
|
3361 |
|
3362 |
|
3363 |
|
3364 |
|
3365 |
|
3366 | var User = function (_Requestable) {
|
3367 | _inherits(User, _Requestable);
|
3368 |
|
3369 | |
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 |
|
3375 | function User(username, auth, apiBase) {
|
3376 | _classCallCheck(this, User);
|
3377 |
|
3378 | var _this = _possibleConstructorReturn(this, (User.__proto__ || Object.getPrototypeOf(User)).call(this, auth, apiBase));
|
3379 |
|
3380 | _this.__user = username;
|
3381 | return _this;
|
3382 | }
|
3383 |
|
3384 | |
3385 |
|
3386 |
|
3387 |
|
3388 |
|
3389 |
|
3390 |
|
3391 |
|
3392 | _createClass(User, [{
|
3393 | key: '__getScopedUrl',
|
3394 | value: function __getScopedUrl(endpoint) {
|
3395 | if (this.__user) {
|
3396 | return endpoint ? '/users/' + this.__user + '/' + endpoint : '/users/' + this.__user;
|
3397 | } else {
|
3398 |
|
3399 | switch (endpoint) {
|
3400 | case '':
|
3401 | return '/user';
|
3402 |
|
3403 | case 'notifications':
|
3404 | case 'gists':
|
3405 | return '/' + endpoint;
|
3406 |
|
3407 | default:
|
3408 | return '/user/' + endpoint;
|
3409 | }
|
3410 | }
|
3411 | }
|
3412 |
|
3413 | |
3414 |
|
3415 |
|
3416 |
|
3417 |
|
3418 |
|
3419 |
|
3420 |
|
3421 | }, {
|
3422 | key: 'listRepos',
|
3423 | value: function listRepos(options, cb) {
|
3424 | if (typeof options === 'function') {
|
3425 | cb = options;
|
3426 | options = {};
|
3427 | }
|
3428 |
|
3429 | options = this._getOptionsWithDefaults(options);
|
3430 |
|
3431 | log('Fetching repositories with options: ' + JSON.stringify(options));
|
3432 | return this._requestAllPages(this.__getScopedUrl('repos'), options, cb);
|
3433 | }
|
3434 |
|
3435 | |
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 | }, {
|
3443 | key: 'listOrgs',
|
3444 | value: function listOrgs(cb) {
|
3445 | return this._request('GET', this.__getScopedUrl('orgs'), null, cb);
|
3446 | }
|
3447 |
|
3448 | |
3449 |
|
3450 |
|
3451 |
|
3452 |
|
3453 |
|
3454 |
|
3455 | }, {
|
3456 | key: 'listFollowers',
|
3457 | value: function listFollowers(cb) {
|
3458 | return this._request('GET', this.__getScopedUrl('followers'), null, cb);
|
3459 | }
|
3460 |
|
3461 | |
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 |
|
3468 | }, {
|
3469 | key: 'listFollowing',
|
3470 | value: function listFollowing(cb) {
|
3471 | return this._request('GET', this.__getScopedUrl('following'), null, cb);
|
3472 | }
|
3473 |
|
3474 | |
3475 |
|
3476 |
|
3477 |
|
3478 |
|
3479 |
|
3480 |
|
3481 | }, {
|
3482 | key: 'listGists',
|
3483 | value: function listGists(cb) {
|
3484 | return this._request('GET', this.__getScopedUrl('gists'), null, cb);
|
3485 | }
|
3486 |
|
3487 | |
3488 |
|
3489 |
|
3490 |
|
3491 |
|
3492 |
|
3493 |
|
3494 |
|
3495 | }, {
|
3496 | key: 'listNotifications',
|
3497 | value: function listNotifications(options, cb) {
|
3498 | options = options || {};
|
3499 | if (typeof options === 'function') {
|
3500 | cb = options;
|
3501 | options = {};
|
3502 | }
|
3503 |
|
3504 | options.since = this._dateToISO(options.since);
|
3505 | options.before = this._dateToISO(options.before);
|
3506 |
|
3507 | return this._request('GET', this.__getScopedUrl('notifications'), options, cb);
|
3508 | }
|
3509 |
|
3510 | |
3511 |
|
3512 |
|
3513 |
|
3514 |
|
3515 |
|
3516 |
|
3517 | }, {
|
3518 | key: 'getProfile',
|
3519 | value: function getProfile(cb) {
|
3520 | return this._request('GET', this.__getScopedUrl(''), null, cb);
|
3521 | }
|
3522 |
|
3523 | |
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 | }, {
|
3531 | key: 'listStarredRepos',
|
3532 | value: function listStarredRepos(cb) {
|
3533 | var requestOptions = this._getOptionsWithDefaults();
|
3534 | return this._requestAllPages(this.__getScopedUrl('starred'), requestOptions, cb);
|
3535 | }
|
3536 |
|
3537 | |
3538 |
|
3539 |
|
3540 |
|
3541 |
|
3542 |
|
3543 |
|
3544 |
|
3545 | }, {
|
3546 | key: 'listStarredGists',
|
3547 | value: function listStarredGists(options, cb) {
|
3548 | options = options || {};
|
3549 | if (typeof options === 'function') {
|
3550 | cb = options;
|
3551 | options = {};
|
3552 | }
|
3553 | options.since = this._dateToISO(options.since);
|
3554 | return this._request('GET', '/gists/starred', options, cb);
|
3555 | }
|
3556 |
|
3557 | |
3558 |
|
3559 |
|
3560 |
|
3561 |
|
3562 |
|
3563 |
|
3564 | }, {
|
3565 | key: 'getEmails',
|
3566 | value: function getEmails(cb) {
|
3567 | return this._request('GET', '/user/emails', null, cb);
|
3568 | }
|
3569 |
|
3570 | |
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 |
|
3576 |
|
3577 |
|
3578 | }, {
|
3579 | key: 'follow',
|
3580 | value: function follow(username, cb) {
|
3581 | return this._request('PUT', '/user/following/' + username, null, cb);
|
3582 | }
|
3583 |
|
3584 | |
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 | }, {
|
3593 | key: 'unfollow',
|
3594 | value: function unfollow(username, cb) {
|
3595 | return this._request('DELETE', '/user/following/' + username, null, cb);
|
3596 | }
|
3597 |
|
3598 | |
3599 |
|
3600 |
|
3601 |
|
3602 |
|
3603 |
|
3604 |
|
3605 |
|
3606 | }, {
|
3607 | key: 'createRepo',
|
3608 | value: function createRepo(options, cb) {
|
3609 | return this._request('POST', '/user/repos', options, cb);
|
3610 | }
|
3611 | }]);
|
3612 |
|
3613 | return User;
|
3614 | }(_Requestable3.default);
|
3615 |
|
3616 | module.exports = User;
|
3617 |
|
3618 | },{"./Requestable":9,"debug":42}],13:[function(require,module,exports){
|
3619 | module.exports = require('./lib/axios');
|
3620 | },{"./lib/axios":15}],14:[function(require,module,exports){
|
3621 | 'use strict';
|
3622 |
|
3623 | var utils = require('./../utils');
|
3624 | var settle = require('./../core/settle');
|
3625 | var cookies = require('./../helpers/cookies');
|
3626 | var buildURL = require('./../helpers/buildURL');
|
3627 | var buildFullPath = require('../core/buildFullPath');
|
3628 | var parseHeaders = require('./../helpers/parseHeaders');
|
3629 | var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
|
3630 | var createError = require('../core/createError');
|
3631 |
|
3632 | module.exports = function xhrAdapter(config) {
|
3633 | return new Promise(function dispatchXhrRequest(resolve, reject) {
|
3634 | var requestData = config.data;
|
3635 | var requestHeaders = config.headers;
|
3636 |
|
3637 | if (utils.isFormData(requestData)) {
|
3638 | delete requestHeaders['Content-Type'];
|
3639 | }
|
3640 |
|
3641 | var request = new XMLHttpRequest();
|
3642 |
|
3643 |
|
3644 | if (config.auth) {
|
3645 | var username = config.auth.username || '';
|
3646 | var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
3647 | requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
3648 | }
|
3649 |
|
3650 | var fullPath = buildFullPath(config.baseURL, config.url);
|
3651 | request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
3652 |
|
3653 |
|
3654 | request.timeout = config.timeout;
|
3655 |
|
3656 |
|
3657 | request.onreadystatechange = function handleLoad() {
|
3658 | if (!request || request.readyState !== 4) {
|
3659 | return;
|
3660 | }
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 | if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
3667 | return;
|
3668 | }
|
3669 |
|
3670 |
|
3671 | var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
3672 | var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
3673 | var response = {
|
3674 | data: responseData,
|
3675 | status: request.status,
|
3676 | statusText: request.statusText,
|
3677 | headers: responseHeaders,
|
3678 | config: config,
|
3679 | request: request
|
3680 | };
|
3681 |
|
3682 | settle(resolve, reject, response);
|
3683 |
|
3684 |
|
3685 | request = null;
|
3686 | };
|
3687 |
|
3688 |
|
3689 | request.onabort = function handleAbort() {
|
3690 | if (!request) {
|
3691 | return;
|
3692 | }
|
3693 |
|
3694 | reject(createError('Request aborted', config, 'ECONNABORTED', request));
|
3695 |
|
3696 |
|
3697 | request = null;
|
3698 | };
|
3699 |
|
3700 |
|
3701 | request.onerror = function handleError() {
|
3702 |
|
3703 |
|
3704 | reject(createError('Network Error', config, null, request));
|
3705 |
|
3706 |
|
3707 | request = null;
|
3708 | };
|
3709 |
|
3710 |
|
3711 | request.ontimeout = function handleTimeout() {
|
3712 | var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
|
3713 | if (config.timeoutErrorMessage) {
|
3714 | timeoutErrorMessage = config.timeoutErrorMessage;
|
3715 | }
|
3716 | reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
|
3717 | request));
|
3718 |
|
3719 |
|
3720 | request = null;
|
3721 | };
|
3722 |
|
3723 |
|
3724 |
|
3725 |
|
3726 | if (utils.isStandardBrowserEnv()) {
|
3727 |
|
3728 | var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
|
3729 | cookies.read(config.xsrfCookieName) :
|
3730 | undefined;
|
3731 |
|
3732 | if (xsrfValue) {
|
3733 | requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
3734 | }
|
3735 | }
|
3736 |
|
3737 |
|
3738 | if ('setRequestHeader' in request) {
|
3739 | utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
3740 | if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
3741 |
|
3742 | delete requestHeaders[key];
|
3743 | } else {
|
3744 |
|
3745 | request.setRequestHeader(key, val);
|
3746 | }
|
3747 | });
|
3748 | }
|
3749 |
|
3750 |
|
3751 | if (!utils.isUndefined(config.withCredentials)) {
|
3752 | request.withCredentials = !!config.withCredentials;
|
3753 | }
|
3754 |
|
3755 |
|
3756 | if (config.responseType) {
|
3757 | try {
|
3758 | request.responseType = config.responseType;
|
3759 | } catch (e) {
|
3760 |
|
3761 |
|
3762 | if (config.responseType !== 'json') {
|
3763 | throw e;
|
3764 | }
|
3765 | }
|
3766 | }
|
3767 |
|
3768 |
|
3769 | if (typeof config.onDownloadProgress === 'function') {
|
3770 | request.addEventListener('progress', config.onDownloadProgress);
|
3771 | }
|
3772 |
|
3773 |
|
3774 | if (typeof config.onUploadProgress === 'function' && request.upload) {
|
3775 | request.upload.addEventListener('progress', config.onUploadProgress);
|
3776 | }
|
3777 |
|
3778 | if (config.cancelToken) {
|
3779 |
|
3780 | config.cancelToken.promise.then(function onCanceled(cancel) {
|
3781 | if (!request) {
|
3782 | return;
|
3783 | }
|
3784 |
|
3785 | request.abort();
|
3786 | reject(cancel);
|
3787 |
|
3788 | request = null;
|
3789 | });
|
3790 | }
|
3791 |
|
3792 | if (!requestData) {
|
3793 | requestData = null;
|
3794 | }
|
3795 |
|
3796 |
|
3797 | request.send(requestData);
|
3798 | });
|
3799 | };
|
3800 |
|
3801 | },{"../core/buildFullPath":21,"../core/createError":22,"./../core/settle":26,"./../helpers/buildURL":30,"./../helpers/cookies":32,"./../helpers/isURLSameOrigin":35,"./../helpers/parseHeaders":37,"./../utils":39}],15:[function(require,module,exports){
|
3802 | 'use strict';
|
3803 |
|
3804 | var utils = require('./utils');
|
3805 | var bind = require('./helpers/bind');
|
3806 | var Axios = require('./core/Axios');
|
3807 | var mergeConfig = require('./core/mergeConfig');
|
3808 | var defaults = require('./defaults');
|
3809 |
|
3810 |
|
3811 |
|
3812 |
|
3813 |
|
3814 |
|
3815 |
|
3816 | function createInstance(defaultConfig) {
|
3817 | var context = new Axios(defaultConfig);
|
3818 | var instance = bind(Axios.prototype.request, context);
|
3819 |
|
3820 |
|
3821 | utils.extend(instance, Axios.prototype, context);
|
3822 |
|
3823 |
|
3824 | utils.extend(instance, context);
|
3825 |
|
3826 | return instance;
|
3827 | }
|
3828 |
|
3829 |
|
3830 | var axios = createInstance(defaults);
|
3831 |
|
3832 |
|
3833 | axios.Axios = Axios;
|
3834 |
|
3835 |
|
3836 | axios.create = function create(instanceConfig) {
|
3837 | return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
3838 | };
|
3839 |
|
3840 |
|
3841 | axios.Cancel = require('./cancel/Cancel');
|
3842 | axios.CancelToken = require('./cancel/CancelToken');
|
3843 | axios.isCancel = require('./cancel/isCancel');
|
3844 |
|
3845 |
|
3846 | axios.all = function all(promises) {
|
3847 | return Promise.all(promises);
|
3848 | };
|
3849 | axios.spread = require('./helpers/spread');
|
3850 |
|
3851 |
|
3852 | axios.isAxiosError = require('./helpers/isAxiosError');
|
3853 |
|
3854 | module.exports = axios;
|
3855 |
|
3856 |
|
3857 | module.exports.default = axios;
|
3858 |
|
3859 | },{"./cancel/Cancel":16,"./cancel/CancelToken":17,"./cancel/isCancel":18,"./core/Axios":19,"./core/mergeConfig":25,"./defaults":28,"./helpers/bind":29,"./helpers/isAxiosError":34,"./helpers/spread":38,"./utils":39}],16:[function(require,module,exports){
|
3860 | 'use strict';
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 | function Cancel(message) {
|
3869 | this.message = message;
|
3870 | }
|
3871 |
|
3872 | Cancel.prototype.toString = function toString() {
|
3873 | return 'Cancel' + (this.message ? ': ' + this.message : '');
|
3874 | };
|
3875 |
|
3876 | Cancel.prototype.__CANCEL__ = true;
|
3877 |
|
3878 | module.exports = Cancel;
|
3879 |
|
3880 | },{}],17:[function(require,module,exports){
|
3881 | 'use strict';
|
3882 |
|
3883 | var Cancel = require('./Cancel');
|
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 |
|
3889 |
|
3890 |
|
3891 | function CancelToken(executor) {
|
3892 | if (typeof executor !== 'function') {
|
3893 | throw new TypeError('executor must be a function.');
|
3894 | }
|
3895 |
|
3896 | var resolvePromise;
|
3897 | this.promise = new Promise(function promiseExecutor(resolve) {
|
3898 | resolvePromise = resolve;
|
3899 | });
|
3900 |
|
3901 | var token = this;
|
3902 | executor(function cancel(message) {
|
3903 | if (token.reason) {
|
3904 |
|
3905 | return;
|
3906 | }
|
3907 |
|
3908 | token.reason = new Cancel(message);
|
3909 | resolvePromise(token.reason);
|
3910 | });
|
3911 | }
|
3912 |
|
3913 |
|
3914 |
|
3915 |
|
3916 | CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
3917 | if (this.reason) {
|
3918 | throw this.reason;
|
3919 | }
|
3920 | };
|
3921 |
|
3922 |
|
3923 |
|
3924 |
|
3925 |
|
3926 | CancelToken.source = function source() {
|
3927 | var cancel;
|
3928 | var token = new CancelToken(function executor(c) {
|
3929 | cancel = c;
|
3930 | });
|
3931 | return {
|
3932 | token: token,
|
3933 | cancel: cancel
|
3934 | };
|
3935 | };
|
3936 |
|
3937 | module.exports = CancelToken;
|
3938 |
|
3939 | },{"./Cancel":16}],18:[function(require,module,exports){
|
3940 | 'use strict';
|
3941 |
|
3942 | module.exports = function isCancel(value) {
|
3943 | return !!(value && value.__CANCEL__);
|
3944 | };
|
3945 |
|
3946 | },{}],19:[function(require,module,exports){
|
3947 | 'use strict';
|
3948 |
|
3949 | var utils = require('./../utils');
|
3950 | var buildURL = require('../helpers/buildURL');
|
3951 | var InterceptorManager = require('./InterceptorManager');
|
3952 | var dispatchRequest = require('./dispatchRequest');
|
3953 | var mergeConfig = require('./mergeConfig');
|
3954 |
|
3955 |
|
3956 |
|
3957 |
|
3958 |
|
3959 |
|
3960 | function Axios(instanceConfig) {
|
3961 | this.defaults = instanceConfig;
|
3962 | this.interceptors = {
|
3963 | request: new InterceptorManager(),
|
3964 | response: new InterceptorManager()
|
3965 | };
|
3966 | }
|
3967 |
|
3968 |
|
3969 |
|
3970 |
|
3971 |
|
3972 |
|
3973 | Axios.prototype.request = function request(config) {
|
3974 |
|
3975 |
|
3976 | if (typeof config === 'string') {
|
3977 | config = arguments[1] || {};
|
3978 | config.url = arguments[0];
|
3979 | } else {
|
3980 | config = config || {};
|
3981 | }
|
3982 |
|
3983 | config = mergeConfig(this.defaults, config);
|
3984 |
|
3985 |
|
3986 | if (config.method) {
|
3987 | config.method = config.method.toLowerCase();
|
3988 | } else if (this.defaults.method) {
|
3989 | config.method = this.defaults.method.toLowerCase();
|
3990 | } else {
|
3991 | config.method = 'get';
|
3992 | }
|
3993 |
|
3994 |
|
3995 | var chain = [dispatchRequest, undefined];
|
3996 | var promise = Promise.resolve(config);
|
3997 |
|
3998 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
3999 | chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
4000 | });
|
4001 |
|
4002 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
4003 | chain.push(interceptor.fulfilled, interceptor.rejected);
|
4004 | });
|
4005 |
|
4006 | while (chain.length) {
|
4007 | promise = promise.then(chain.shift(), chain.shift());
|
4008 | }
|
4009 |
|
4010 | return promise;
|
4011 | };
|
4012 |
|
4013 | Axios.prototype.getUri = function getUri(config) {
|
4014 | config = mergeConfig(this.defaults, config);
|
4015 | return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
|
4016 | };
|
4017 |
|
4018 |
|
4019 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
4020 |
|
4021 | Axios.prototype[method] = function(url, config) {
|
4022 | return this.request(mergeConfig(config || {}, {
|
4023 | method: method,
|
4024 | url: url,
|
4025 | data: (config || {}).data
|
4026 | }));
|
4027 | };
|
4028 | });
|
4029 |
|
4030 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
4031 |
|
4032 | Axios.prototype[method] = function(url, data, config) {
|
4033 | return this.request(mergeConfig(config || {}, {
|
4034 | method: method,
|
4035 | url: url,
|
4036 | data: data
|
4037 | }));
|
4038 | };
|
4039 | });
|
4040 |
|
4041 | module.exports = Axios;
|
4042 |
|
4043 | },{"../helpers/buildURL":30,"./../utils":39,"./InterceptorManager":20,"./dispatchRequest":23,"./mergeConfig":25}],20:[function(require,module,exports){
|
4044 | 'use strict';
|
4045 |
|
4046 | var utils = require('./../utils');
|
4047 |
|
4048 | function InterceptorManager() {
|
4049 | this.handlers = [];
|
4050 | }
|
4051 |
|
4052 |
|
4053 |
|
4054 |
|
4055 |
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 | InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
4061 | this.handlers.push({
|
4062 | fulfilled: fulfilled,
|
4063 | rejected: rejected
|
4064 | });
|
4065 | return this.handlers.length - 1;
|
4066 | };
|
4067 |
|
4068 |
|
4069 |
|
4070 |
|
4071 |
|
4072 |
|
4073 | InterceptorManager.prototype.eject = function eject(id) {
|
4074 | if (this.handlers[id]) {
|
4075 | this.handlers[id] = null;
|
4076 | }
|
4077 | };
|
4078 |
|
4079 |
|
4080 |
|
4081 |
|
4082 |
|
4083 |
|
4084 |
|
4085 |
|
4086 |
|
4087 | InterceptorManager.prototype.forEach = function forEach(fn) {
|
4088 | utils.forEach(this.handlers, function forEachHandler(h) {
|
4089 | if (h !== null) {
|
4090 | fn(h);
|
4091 | }
|
4092 | });
|
4093 | };
|
4094 |
|
4095 | module.exports = InterceptorManager;
|
4096 |
|
4097 | },{"./../utils":39}],21:[function(require,module,exports){
|
4098 | 'use strict';
|
4099 |
|
4100 | var isAbsoluteURL = require('../helpers/isAbsoluteURL');
|
4101 | var combineURLs = require('../helpers/combineURLs');
|
4102 |
|
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 |
|
4108 |
|
4109 |
|
4110 |
|
4111 |
|
4112 | module.exports = function buildFullPath(baseURL, requestedURL) {
|
4113 | if (baseURL && !isAbsoluteURL(requestedURL)) {
|
4114 | return combineURLs(baseURL, requestedURL);
|
4115 | }
|
4116 | return requestedURL;
|
4117 | };
|
4118 |
|
4119 | },{"../helpers/combineURLs":31,"../helpers/isAbsoluteURL":33}],22:[function(require,module,exports){
|
4120 | 'use strict';
|
4121 |
|
4122 | var enhanceError = require('./enhanceError');
|
4123 |
|
4124 |
|
4125 |
|
4126 |
|
4127 |
|
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 |
|
4133 |
|
4134 | module.exports = function createError(message, config, code, request, response) {
|
4135 | var error = new Error(message);
|
4136 | return enhanceError(error, config, code, request, response);
|
4137 | };
|
4138 |
|
4139 | },{"./enhanceError":24}],23:[function(require,module,exports){
|
4140 | 'use strict';
|
4141 |
|
4142 | var utils = require('./../utils');
|
4143 | var transformData = require('./transformData');
|
4144 | var isCancel = require('../cancel/isCancel');
|
4145 | var defaults = require('../defaults');
|
4146 |
|
4147 |
|
4148 |
|
4149 |
|
4150 | function throwIfCancellationRequested(config) {
|
4151 | if (config.cancelToken) {
|
4152 | config.cancelToken.throwIfRequested();
|
4153 | }
|
4154 | }
|
4155 |
|
4156 |
|
4157 |
|
4158 |
|
4159 |
|
4160 |
|
4161 |
|
4162 | module.exports = function dispatchRequest(config) {
|
4163 | throwIfCancellationRequested(config);
|
4164 |
|
4165 |
|
4166 | config.headers = config.headers || {};
|
4167 |
|
4168 |
|
4169 | config.data = transformData(
|
4170 | config.data,
|
4171 | config.headers,
|
4172 | config.transformRequest
|
4173 | );
|
4174 |
|
4175 |
|
4176 | config.headers = utils.merge(
|
4177 | config.headers.common || {},
|
4178 | config.headers[config.method] || {},
|
4179 | config.headers
|
4180 | );
|
4181 |
|
4182 | utils.forEach(
|
4183 | ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
4184 | function cleanHeaderConfig(method) {
|
4185 | delete config.headers[method];
|
4186 | }
|
4187 | );
|
4188 |
|
4189 | var adapter = config.adapter || defaults.adapter;
|
4190 |
|
4191 | return adapter(config).then(function onAdapterResolution(response) {
|
4192 | throwIfCancellationRequested(config);
|
4193 |
|
4194 |
|
4195 | response.data = transformData(
|
4196 | response.data,
|
4197 | response.headers,
|
4198 | config.transformResponse
|
4199 | );
|
4200 |
|
4201 | return response;
|
4202 | }, function onAdapterRejection(reason) {
|
4203 | if (!isCancel(reason)) {
|
4204 | throwIfCancellationRequested(config);
|
4205 |
|
4206 |
|
4207 | if (reason && reason.response) {
|
4208 | reason.response.data = transformData(
|
4209 | reason.response.data,
|
4210 | reason.response.headers,
|
4211 | config.transformResponse
|
4212 | );
|
4213 | }
|
4214 | }
|
4215 |
|
4216 | return Promise.reject(reason);
|
4217 | });
|
4218 | };
|
4219 |
|
4220 | },{"../cancel/isCancel":18,"../defaults":28,"./../utils":39,"./transformData":27}],24:[function(require,module,exports){
|
4221 | 'use strict';
|
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 |
|
4232 |
|
4233 | module.exports = function enhanceError(error, config, code, request, response) {
|
4234 | error.config = config;
|
4235 | if (code) {
|
4236 | error.code = code;
|
4237 | }
|
4238 |
|
4239 | error.request = request;
|
4240 | error.response = response;
|
4241 | error.isAxiosError = true;
|
4242 |
|
4243 | error.toJSON = function toJSON() {
|
4244 | return {
|
4245 |
|
4246 | message: this.message,
|
4247 | name: this.name,
|
4248 |
|
4249 | description: this.description,
|
4250 | number: this.number,
|
4251 |
|
4252 | fileName: this.fileName,
|
4253 | lineNumber: this.lineNumber,
|
4254 | columnNumber: this.columnNumber,
|
4255 | stack: this.stack,
|
4256 |
|
4257 | config: this.config,
|
4258 | code: this.code
|
4259 | };
|
4260 | };
|
4261 | return error;
|
4262 | };
|
4263 |
|
4264 | },{}],25:[function(require,module,exports){
|
4265 | 'use strict';
|
4266 |
|
4267 | var utils = require('../utils');
|
4268 |
|
4269 |
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 | module.exports = function mergeConfig(config1, config2) {
|
4278 |
|
4279 | config2 = config2 || {};
|
4280 | var config = {};
|
4281 |
|
4282 | var valueFromConfig2Keys = ['url', 'method', 'data'];
|
4283 | var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
|
4284 | var defaultToConfig2Keys = [
|
4285 | 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
|
4286 | 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
|
4287 | 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
|
4288 | 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
|
4289 | 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
|
4290 | ];
|
4291 | var directMergeKeys = ['validateStatus'];
|
4292 |
|
4293 | function getMergedValue(target, source) {
|
4294 | if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
4295 | return utils.merge(target, source);
|
4296 | } else if (utils.isPlainObject(source)) {
|
4297 | return utils.merge({}, source);
|
4298 | } else if (utils.isArray(source)) {
|
4299 | return source.slice();
|
4300 | }
|
4301 | return source;
|
4302 | }
|
4303 |
|
4304 | function mergeDeepProperties(prop) {
|
4305 | if (!utils.isUndefined(config2[prop])) {
|
4306 | config[prop] = getMergedValue(config1[prop], config2[prop]);
|
4307 | } else if (!utils.isUndefined(config1[prop])) {
|
4308 | config[prop] = getMergedValue(undefined, config1[prop]);
|
4309 | }
|
4310 | }
|
4311 |
|
4312 | utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
4313 | if (!utils.isUndefined(config2[prop])) {
|
4314 | config[prop] = getMergedValue(undefined, config2[prop]);
|
4315 | }
|
4316 | });
|
4317 |
|
4318 | utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
4319 |
|
4320 | utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
4321 | if (!utils.isUndefined(config2[prop])) {
|
4322 | config[prop] = getMergedValue(undefined, config2[prop]);
|
4323 | } else if (!utils.isUndefined(config1[prop])) {
|
4324 | config[prop] = getMergedValue(undefined, config1[prop]);
|
4325 | }
|
4326 | });
|
4327 |
|
4328 | utils.forEach(directMergeKeys, function merge(prop) {
|
4329 | if (prop in config2) {
|
4330 | config[prop] = getMergedValue(config1[prop], config2[prop]);
|
4331 | } else if (prop in config1) {
|
4332 | config[prop] = getMergedValue(undefined, config1[prop]);
|
4333 | }
|
4334 | });
|
4335 |
|
4336 | var axiosKeys = valueFromConfig2Keys
|
4337 | .concat(mergeDeepPropertiesKeys)
|
4338 | .concat(defaultToConfig2Keys)
|
4339 | .concat(directMergeKeys);
|
4340 |
|
4341 | var otherKeys = Object
|
4342 | .keys(config1)
|
4343 | .concat(Object.keys(config2))
|
4344 | .filter(function filterAxiosKeys(key) {
|
4345 | return axiosKeys.indexOf(key) === -1;
|
4346 | });
|
4347 |
|
4348 | utils.forEach(otherKeys, mergeDeepProperties);
|
4349 |
|
4350 | return config;
|
4351 | };
|
4352 |
|
4353 | },{"../utils":39}],26:[function(require,module,exports){
|
4354 | 'use strict';
|
4355 |
|
4356 | var createError = require('./createError');
|
4357 |
|
4358 |
|
4359 |
|
4360 |
|
4361 |
|
4362 |
|
4363 |
|
4364 |
|
4365 | module.exports = function settle(resolve, reject, response) {
|
4366 | var validateStatus = response.config.validateStatus;
|
4367 | if (!response.status || !validateStatus || validateStatus(response.status)) {
|
4368 | resolve(response);
|
4369 | } else {
|
4370 | reject(createError(
|
4371 | 'Request failed with status code ' + response.status,
|
4372 | response.config,
|
4373 | null,
|
4374 | response.request,
|
4375 | response
|
4376 | ));
|
4377 | }
|
4378 | };
|
4379 |
|
4380 | },{"./createError":22}],27:[function(require,module,exports){
|
4381 | 'use strict';
|
4382 |
|
4383 | var utils = require('./../utils');
|
4384 |
|
4385 |
|
4386 |
|
4387 |
|
4388 |
|
4389 |
|
4390 |
|
4391 |
|
4392 |
|
4393 | module.exports = function transformData(data, headers, fns) {
|
4394 |
|
4395 | utils.forEach(fns, function transform(fn) {
|
4396 | data = fn(data, headers);
|
4397 | });
|
4398 |
|
4399 | return data;
|
4400 | };
|
4401 |
|
4402 | },{"./../utils":39}],28:[function(require,module,exports){
|
4403 | (function (process){(function (){
|
4404 | 'use strict';
|
4405 |
|
4406 | var utils = require('./utils');
|
4407 | var normalizeHeaderName = require('./helpers/normalizeHeaderName');
|
4408 |
|
4409 | var DEFAULT_CONTENT_TYPE = {
|
4410 | 'Content-Type': 'application/x-www-form-urlencoded'
|
4411 | };
|
4412 |
|
4413 | function setContentTypeIfUnset(headers, value) {
|
4414 | if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
4415 | headers['Content-Type'] = value;
|
4416 | }
|
4417 | }
|
4418 |
|
4419 | function getDefaultAdapter() {
|
4420 | var adapter;
|
4421 | if (typeof XMLHttpRequest !== 'undefined') {
|
4422 |
|
4423 | adapter = require('./adapters/xhr');
|
4424 | } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
4425 |
|
4426 | adapter = require('./adapters/http');
|
4427 | }
|
4428 | return adapter;
|
4429 | }
|
4430 |
|
4431 | var defaults = {
|
4432 | adapter: getDefaultAdapter(),
|
4433 |
|
4434 | transformRequest: [function transformRequest(data, headers) {
|
4435 | normalizeHeaderName(headers, 'Accept');
|
4436 | normalizeHeaderName(headers, 'Content-Type');
|
4437 | if (utils.isFormData(data) ||
|
4438 | utils.isArrayBuffer(data) ||
|
4439 | utils.isBuffer(data) ||
|
4440 | utils.isStream(data) ||
|
4441 | utils.isFile(data) ||
|
4442 | utils.isBlob(data)
|
4443 | ) {
|
4444 | return data;
|
4445 | }
|
4446 | if (utils.isArrayBufferView(data)) {
|
4447 | return data.buffer;
|
4448 | }
|
4449 | if (utils.isURLSearchParams(data)) {
|
4450 | setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
4451 | return data.toString();
|
4452 | }
|
4453 | if (utils.isObject(data)) {
|
4454 | setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
4455 | return JSON.stringify(data);
|
4456 | }
|
4457 | return data;
|
4458 | }],
|
4459 |
|
4460 | transformResponse: [function transformResponse(data) {
|
4461 |
|
4462 | if (typeof data === 'string') {
|
4463 | try {
|
4464 | data = JSON.parse(data);
|
4465 | } catch (e) { }
|
4466 | }
|
4467 | return data;
|
4468 | }],
|
4469 |
|
4470 | |
4471 |
|
4472 |
|
4473 |
|
4474 | timeout: 0,
|
4475 |
|
4476 | xsrfCookieName: 'XSRF-TOKEN',
|
4477 | xsrfHeaderName: 'X-XSRF-TOKEN',
|
4478 |
|
4479 | maxContentLength: -1,
|
4480 | maxBodyLength: -1,
|
4481 |
|
4482 | validateStatus: function validateStatus(status) {
|
4483 | return status >= 200 && status < 300;
|
4484 | }
|
4485 | };
|
4486 |
|
4487 | defaults.headers = {
|
4488 | common: {
|
4489 | 'Accept': 'application/json, text/plain, */*'
|
4490 | }
|
4491 | };
|
4492 |
|
4493 | utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
4494 | defaults.headers[method] = {};
|
4495 | });
|
4496 |
|
4497 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
4498 | defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
4499 | });
|
4500 |
|
4501 | module.exports = defaults;
|
4502 |
|
4503 | }).call(this)}).call(this,require('_process'))
|
4504 |
|
4505 | },{"./adapters/http":14,"./adapters/xhr":14,"./helpers/normalizeHeaderName":36,"./utils":39,"_process":48}],29:[function(require,module,exports){
|
4506 | 'use strict';
|
4507 |
|
4508 | module.exports = function bind(fn, thisArg) {
|
4509 | return function wrap() {
|
4510 | var args = new Array(arguments.length);
|
4511 | for (var i = 0; i < args.length; i++) {
|
4512 | args[i] = arguments[i];
|
4513 | }
|
4514 | return fn.apply(thisArg, args);
|
4515 | };
|
4516 | };
|
4517 |
|
4518 | },{}],30:[function(require,module,exports){
|
4519 | 'use strict';
|
4520 |
|
4521 | var utils = require('./../utils');
|
4522 |
|
4523 | function encode(val) {
|
4524 | return encodeURIComponent(val).
|
4525 | replace(/%3A/gi, ':').
|
4526 | replace(/%24/g, '$').
|
4527 | replace(/%2C/gi, ',').
|
4528 | replace(/%20/g, '+').
|
4529 | replace(/%5B/gi, '[').
|
4530 | replace(/%5D/gi, ']');
|
4531 | }
|
4532 |
|
4533 |
|
4534 |
|
4535 |
|
4536 |
|
4537 |
|
4538 |
|
4539 |
|
4540 | module.exports = function buildURL(url, params, paramsSerializer) {
|
4541 |
|
4542 | if (!params) {
|
4543 | return url;
|
4544 | }
|
4545 |
|
4546 | var serializedParams;
|
4547 | if (paramsSerializer) {
|
4548 | serializedParams = paramsSerializer(params);
|
4549 | } else if (utils.isURLSearchParams(params)) {
|
4550 | serializedParams = params.toString();
|
4551 | } else {
|
4552 | var parts = [];
|
4553 |
|
4554 | utils.forEach(params, function serialize(val, key) {
|
4555 | if (val === null || typeof val === 'undefined') {
|
4556 | return;
|
4557 | }
|
4558 |
|
4559 | if (utils.isArray(val)) {
|
4560 | key = key + '[]';
|
4561 | } else {
|
4562 | val = [val];
|
4563 | }
|
4564 |
|
4565 | utils.forEach(val, function parseValue(v) {
|
4566 | if (utils.isDate(v)) {
|
4567 | v = v.toISOString();
|
4568 | } else if (utils.isObject(v)) {
|
4569 | v = JSON.stringify(v);
|
4570 | }
|
4571 | parts.push(encode(key) + '=' + encode(v));
|
4572 | });
|
4573 | });
|
4574 |
|
4575 | serializedParams = parts.join('&');
|
4576 | }
|
4577 |
|
4578 | if (serializedParams) {
|
4579 | var hashmarkIndex = url.indexOf('#');
|
4580 | if (hashmarkIndex !== -1) {
|
4581 | url = url.slice(0, hashmarkIndex);
|
4582 | }
|
4583 |
|
4584 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
4585 | }
|
4586 |
|
4587 | return url;
|
4588 | };
|
4589 |
|
4590 | },{"./../utils":39}],31:[function(require,module,exports){
|
4591 | 'use strict';
|
4592 |
|
4593 |
|
4594 |
|
4595 |
|
4596 |
|
4597 |
|
4598 |
|
4599 |
|
4600 | module.exports = function combineURLs(baseURL, relativeURL) {
|
4601 | return relativeURL
|
4602 | ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
4603 | : baseURL;
|
4604 | };
|
4605 |
|
4606 | },{}],32:[function(require,module,exports){
|
4607 | 'use strict';
|
4608 |
|
4609 | var utils = require('./../utils');
|
4610 |
|
4611 | module.exports = (
|
4612 | utils.isStandardBrowserEnv() ?
|
4613 |
|
4614 |
|
4615 | (function standardBrowserEnv() {
|
4616 | return {
|
4617 | write: function write(name, value, expires, path, domain, secure) {
|
4618 | var cookie = [];
|
4619 | cookie.push(name + '=' + encodeURIComponent(value));
|
4620 |
|
4621 | if (utils.isNumber(expires)) {
|
4622 | cookie.push('expires=' + new Date(expires).toGMTString());
|
4623 | }
|
4624 |
|
4625 | if (utils.isString(path)) {
|
4626 | cookie.push('path=' + path);
|
4627 | }
|
4628 |
|
4629 | if (utils.isString(domain)) {
|
4630 | cookie.push('domain=' + domain);
|
4631 | }
|
4632 |
|
4633 | if (secure === true) {
|
4634 | cookie.push('secure');
|
4635 | }
|
4636 |
|
4637 | document.cookie = cookie.join('; ');
|
4638 | },
|
4639 |
|
4640 | read: function read(name) {
|
4641 | var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
4642 | return (match ? decodeURIComponent(match[3]) : null);
|
4643 | },
|
4644 |
|
4645 | remove: function remove(name) {
|
4646 | this.write(name, '', Date.now() - 86400000);
|
4647 | }
|
4648 | };
|
4649 | })() :
|
4650 |
|
4651 |
|
4652 | (function nonStandardBrowserEnv() {
|
4653 | return {
|
4654 | write: function write() {},
|
4655 | read: function read() { return null; },
|
4656 | remove: function remove() {}
|
4657 | };
|
4658 | })()
|
4659 | );
|
4660 |
|
4661 | },{"./../utils":39}],33:[function(require,module,exports){
|
4662 | 'use strict';
|
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 |
|
4670 | module.exports = function isAbsoluteURL(url) {
|
4671 |
|
4672 |
|
4673 |
|
4674 | return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
4675 | };
|
4676 |
|
4677 | },{}],34:[function(require,module,exports){
|
4678 | 'use strict';
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 |
|
4685 |
|
4686 | module.exports = function isAxiosError(payload) {
|
4687 | return (typeof payload === 'object') && (payload.isAxiosError === true);
|
4688 | };
|
4689 |
|
4690 | },{}],35:[function(require,module,exports){
|
4691 | 'use strict';
|
4692 |
|
4693 | var utils = require('./../utils');
|
4694 |
|
4695 | module.exports = (
|
4696 | utils.isStandardBrowserEnv() ?
|
4697 |
|
4698 |
|
4699 |
|
4700 | (function standardBrowserEnv() {
|
4701 | var msie = /(msie|trident)/i.test(navigator.userAgent);
|
4702 | var urlParsingNode = document.createElement('a');
|
4703 | var originURL;
|
4704 |
|
4705 | |
4706 |
|
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 | function resolveURL(url) {
|
4712 | var href = url;
|
4713 |
|
4714 | if (msie) {
|
4715 |
|
4716 | urlParsingNode.setAttribute('href', href);
|
4717 | href = urlParsingNode.href;
|
4718 | }
|
4719 |
|
4720 | urlParsingNode.setAttribute('href', href);
|
4721 |
|
4722 |
|
4723 | return {
|
4724 | href: urlParsingNode.href,
|
4725 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
4726 | host: urlParsingNode.host,
|
4727 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
4728 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
4729 | hostname: urlParsingNode.hostname,
|
4730 | port: urlParsingNode.port,
|
4731 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
4732 | urlParsingNode.pathname :
|
4733 | '/' + urlParsingNode.pathname
|
4734 | };
|
4735 | }
|
4736 |
|
4737 | originURL = resolveURL(window.location.href);
|
4738 |
|
4739 | |
4740 |
|
4741 |
|
4742 |
|
4743 |
|
4744 |
|
4745 | return function isURLSameOrigin(requestURL) {
|
4746 | var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
4747 | return (parsed.protocol === originURL.protocol &&
|
4748 | parsed.host === originURL.host);
|
4749 | };
|
4750 | })() :
|
4751 |
|
4752 |
|
4753 | (function nonStandardBrowserEnv() {
|
4754 | return function isURLSameOrigin() {
|
4755 | return true;
|
4756 | };
|
4757 | })()
|
4758 | );
|
4759 |
|
4760 | },{"./../utils":39}],36:[function(require,module,exports){
|
4761 | 'use strict';
|
4762 |
|
4763 | var utils = require('../utils');
|
4764 |
|
4765 | module.exports = function normalizeHeaderName(headers, normalizedName) {
|
4766 | utils.forEach(headers, function processHeader(value, name) {
|
4767 | if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
4768 | headers[normalizedName] = value;
|
4769 | delete headers[name];
|
4770 | }
|
4771 | });
|
4772 | };
|
4773 |
|
4774 | },{"../utils":39}],37:[function(require,module,exports){
|
4775 | 'use strict';
|
4776 |
|
4777 | var utils = require('./../utils');
|
4778 |
|
4779 |
|
4780 |
|
4781 | var ignoreDuplicateOf = [
|
4782 | 'age', 'authorization', 'content-length', 'content-type', 'etag',
|
4783 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
4784 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
4785 | 'referer', 'retry-after', 'user-agent'
|
4786 | ];
|
4787 |
|
4788 |
|
4789 |
|
4790 |
|
4791 |
|
4792 |
|
4793 |
|
4794 |
|
4795 |
|
4796 |
|
4797 |
|
4798 |
|
4799 |
|
4800 |
|
4801 | module.exports = function parseHeaders(headers) {
|
4802 | var parsed = {};
|
4803 | var key;
|
4804 | var val;
|
4805 | var i;
|
4806 |
|
4807 | if (!headers) { return parsed; }
|
4808 |
|
4809 | utils.forEach(headers.split('\n'), function parser(line) {
|
4810 | i = line.indexOf(':');
|
4811 | key = utils.trim(line.substr(0, i)).toLowerCase();
|
4812 | val = utils.trim(line.substr(i + 1));
|
4813 |
|
4814 | if (key) {
|
4815 | if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
4816 | return;
|
4817 | }
|
4818 | if (key === 'set-cookie') {
|
4819 | parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
4820 | } else {
|
4821 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
4822 | }
|
4823 | }
|
4824 | });
|
4825 |
|
4826 | return parsed;
|
4827 | };
|
4828 |
|
4829 | },{"./../utils":39}],38:[function(require,module,exports){
|
4830 | 'use strict';
|
4831 |
|
4832 |
|
4833 |
|
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 |
|
4839 |
|
4840 |
|
4841 |
|
4842 |
|
4843 |
|
4844 |
|
4845 |
|
4846 |
|
4847 |
|
4848 |
|
4849 |
|
4850 |
|
4851 |
|
4852 | module.exports = function spread(callback) {
|
4853 | return function wrap(arr) {
|
4854 | return callback.apply(null, arr);
|
4855 | };
|
4856 | };
|
4857 |
|
4858 | },{}],39:[function(require,module,exports){
|
4859 | 'use strict';
|
4860 |
|
4861 | var bind = require('./helpers/bind');
|
4862 |
|
4863 |
|
4864 |
|
4865 |
|
4866 |
|
4867 | var toString = Object.prototype.toString;
|
4868 |
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 |
|
4874 |
|
4875 | function isArray(val) {
|
4876 | return toString.call(val) === '[object Array]';
|
4877 | }
|
4878 |
|
4879 |
|
4880 |
|
4881 |
|
4882 |
|
4883 |
|
4884 |
|
4885 | function isUndefined(val) {
|
4886 | return typeof val === 'undefined';
|
4887 | }
|
4888 |
|
4889 |
|
4890 |
|
4891 |
|
4892 |
|
4893 |
|
4894 |
|
4895 | function isBuffer(val) {
|
4896 | return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
4897 | && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
|
4898 | }
|
4899 |
|
4900 |
|
4901 |
|
4902 |
|
4903 |
|
4904 |
|
4905 |
|
4906 | function isArrayBuffer(val) {
|
4907 | return toString.call(val) === '[object ArrayBuffer]';
|
4908 | }
|
4909 |
|
4910 |
|
4911 |
|
4912 |
|
4913 |
|
4914 |
|
4915 |
|
4916 | function isFormData(val) {
|
4917 | return (typeof FormData !== 'undefined') && (val instanceof FormData);
|
4918 | }
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 |
|
4925 |
|
4926 | function isArrayBufferView(val) {
|
4927 | var result;
|
4928 | if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
4929 | result = ArrayBuffer.isView(val);
|
4930 | } else {
|
4931 | result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
4932 | }
|
4933 | return result;
|
4934 | }
|
4935 |
|
4936 |
|
4937 |
|
4938 |
|
4939 |
|
4940 |
|
4941 |
|
4942 | function isString(val) {
|
4943 | return typeof val === 'string';
|
4944 | }
|
4945 |
|
4946 |
|
4947 |
|
4948 |
|
4949 |
|
4950 |
|
4951 |
|
4952 | function isNumber(val) {
|
4953 | return typeof val === 'number';
|
4954 | }
|
4955 |
|
4956 |
|
4957 |
|
4958 |
|
4959 |
|
4960 |
|
4961 |
|
4962 | function isObject(val) {
|
4963 | return val !== null && typeof val === 'object';
|
4964 | }
|
4965 |
|
4966 |
|
4967 |
|
4968 |
|
4969 |
|
4970 |
|
4971 |
|
4972 | function isPlainObject(val) {
|
4973 | if (toString.call(val) !== '[object Object]') {
|
4974 | return false;
|
4975 | }
|
4976 |
|
4977 | var prototype = Object.getPrototypeOf(val);
|
4978 | return prototype === null || prototype === Object.prototype;
|
4979 | }
|
4980 |
|
4981 |
|
4982 |
|
4983 |
|
4984 |
|
4985 |
|
4986 |
|
4987 | function isDate(val) {
|
4988 | return toString.call(val) === '[object Date]';
|
4989 | }
|
4990 |
|
4991 |
|
4992 |
|
4993 |
|
4994 |
|
4995 |
|
4996 |
|
4997 | function isFile(val) {
|
4998 | return toString.call(val) === '[object File]';
|
4999 | }
|
5000 |
|
5001 |
|
5002 |
|
5003 |
|
5004 |
|
5005 |
|
5006 |
|
5007 | function isBlob(val) {
|
5008 | return toString.call(val) === '[object Blob]';
|
5009 | }
|
5010 |
|
5011 |
|
5012 |
|
5013 |
|
5014 |
|
5015 |
|
5016 |
|
5017 | function isFunction(val) {
|
5018 | return toString.call(val) === '[object Function]';
|
5019 | }
|
5020 |
|
5021 |
|
5022 |
|
5023 |
|
5024 |
|
5025 |
|
5026 |
|
5027 | function isStream(val) {
|
5028 | return isObject(val) && isFunction(val.pipe);
|
5029 | }
|
5030 |
|
5031 |
|
5032 |
|
5033 |
|
5034 |
|
5035 |
|
5036 |
|
5037 | function isURLSearchParams(val) {
|
5038 | return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
|
5039 | }
|
5040 |
|
5041 |
|
5042 |
|
5043 |
|
5044 |
|
5045 |
|
5046 |
|
5047 | function trim(str) {
|
5048 | return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
5049 | }
|
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 |
|
5058 |
|
5059 |
|
5060 |
|
5061 |
|
5062 |
|
5063 |
|
5064 |
|
5065 |
|
5066 | function isStandardBrowserEnv() {
|
5067 | if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
|
5068 | navigator.product === 'NativeScript' ||
|
5069 | navigator.product === 'NS')) {
|
5070 | return false;
|
5071 | }
|
5072 | return (
|
5073 | typeof window !== 'undefined' &&
|
5074 | typeof document !== 'undefined'
|
5075 | );
|
5076 | }
|
5077 |
|
5078 |
|
5079 |
|
5080 |
|
5081 |
|
5082 |
|
5083 |
|
5084 |
|
5085 |
|
5086 |
|
5087 |
|
5088 |
|
5089 |
|
5090 | function forEach(obj, fn) {
|
5091 |
|
5092 | if (obj === null || typeof obj === 'undefined') {
|
5093 | return;
|
5094 | }
|
5095 |
|
5096 |
|
5097 | if (typeof obj !== 'object') {
|
5098 |
|
5099 | obj = [obj];
|
5100 | }
|
5101 |
|
5102 | if (isArray(obj)) {
|
5103 |
|
5104 | for (var i = 0, l = obj.length; i < l; i++) {
|
5105 | fn.call(null, obj[i], i, obj);
|
5106 | }
|
5107 | } else {
|
5108 |
|
5109 | for (var key in obj) {
|
5110 | if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
5111 | fn.call(null, obj[key], key, obj);
|
5112 | }
|
5113 | }
|
5114 | }
|
5115 | }
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 |
|
5121 |
|
5122 |
|
5123 |
|
5124 |
|
5125 |
|
5126 |
|
5127 |
|
5128 |
|
5129 |
|
5130 |
|
5131 |
|
5132 |
|
5133 |
|
5134 | function merge(/* obj1, obj2, obj3, ... */) {
|
5135 | var result = {};
|
5136 | function assignValue(val, key) {
|
5137 | if (isPlainObject(result[key]) && isPlainObject(val)) {
|
5138 | result[key] = merge(result[key], val);
|
5139 | } else if (isPlainObject(val)) {
|
5140 | result[key] = merge({}, val);
|
5141 | } else if (isArray(val)) {
|
5142 | result[key] = val.slice();
|
5143 | } else {
|
5144 | result[key] = val;
|
5145 | }
|
5146 | }
|
5147 |
|
5148 | for (var i = 0, l = arguments.length; i < l; i++) {
|
5149 | forEach(arguments[i], assignValue);
|
5150 | }
|
5151 | return result;
|
5152 | }
|
5153 |
|
5154 |
|
5155 |
|
5156 |
|
5157 |
|
5158 |
|
5159 |
|
5160 |
|
5161 |
|
5162 | function extend(a, b, thisArg) {
|
5163 | forEach(b, function assignValue(val, key) {
|
5164 | if (thisArg && typeof val === 'function') {
|
5165 | a[key] = bind(val, thisArg);
|
5166 | } else {
|
5167 | a[key] = val;
|
5168 | }
|
5169 | });
|
5170 | return a;
|
5171 | }
|
5172 |
|
5173 |
|
5174 |
|
5175 |
|
5176 |
|
5177 |
|
5178 |
|
5179 | function stripBOM(content) {
|
5180 | if (content.charCodeAt(0) === 0xFEFF) {
|
5181 | content = content.slice(1);
|
5182 | }
|
5183 | return content;
|
5184 | }
|
5185 |
|
5186 | module.exports = {
|
5187 | isArray: isArray,
|
5188 | isArrayBuffer: isArrayBuffer,
|
5189 | isBuffer: isBuffer,
|
5190 | isFormData: isFormData,
|
5191 | isArrayBufferView: isArrayBufferView,
|
5192 | isString: isString,
|
5193 | isNumber: isNumber,
|
5194 | isObject: isObject,
|
5195 | isPlainObject: isPlainObject,
|
5196 | isUndefined: isUndefined,
|
5197 | isDate: isDate,
|
5198 | isFile: isFile,
|
5199 | isBlob: isBlob,
|
5200 | isFunction: isFunction,
|
5201 | isStream: isStream,
|
5202 | isURLSearchParams: isURLSearchParams,
|
5203 | isStandardBrowserEnv: isStandardBrowserEnv,
|
5204 | forEach: forEach,
|
5205 | merge: merge,
|
5206 | extend: extend,
|
5207 | trim: trim,
|
5208 | stripBOM: stripBOM
|
5209 | };
|
5210 |
|
5211 | },{"./helpers/bind":29}],40:[function(require,module,exports){
|
5212 | 'use strict'
|
5213 |
|
5214 | exports.byteLength = byteLength
|
5215 | exports.toByteArray = toByteArray
|
5216 | exports.fromByteArray = fromByteArray
|
5217 |
|
5218 | var lookup = []
|
5219 | var revLookup = []
|
5220 | var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
5221 |
|
5222 | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
5223 | for (var i = 0, len = code.length; i < len; ++i) {
|
5224 | lookup[i] = code[i]
|
5225 | revLookup[code.charCodeAt(i)] = i
|
5226 | }
|
5227 |
|
5228 |
|
5229 |
|
5230 | revLookup['-'.charCodeAt(0)] = 62
|
5231 | revLookup['_'.charCodeAt(0)] = 63
|
5232 |
|
5233 | function getLens (b64) {
|
5234 | var len = b64.length
|
5235 |
|
5236 | if (len % 4 > 0) {
|
5237 | throw new Error('Invalid string. Length must be a multiple of 4')
|
5238 | }
|
5239 |
|
5240 |
|
5241 |
|
5242 | var validLen = b64.indexOf('=')
|
5243 | if (validLen === -1) validLen = len
|
5244 |
|
5245 | var placeHoldersLen = validLen === len
|
5246 | ? 0
|
5247 | : 4 - (validLen % 4)
|
5248 |
|
5249 | return [validLen, placeHoldersLen]
|
5250 | }
|
5251 |
|
5252 |
|
5253 | function byteLength (b64) {
|
5254 | var lens = getLens(b64)
|
5255 | var validLen = lens[0]
|
5256 | var placeHoldersLen = lens[1]
|
5257 | return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
5258 | }
|
5259 |
|
5260 | function _byteLength (b64, validLen, placeHoldersLen) {
|
5261 | return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
5262 | }
|
5263 |
|
5264 | function toByteArray (b64) {
|
5265 | var tmp
|
5266 | var lens = getLens(b64)
|
5267 | var validLen = lens[0]
|
5268 | var placeHoldersLen = lens[1]
|
5269 |
|
5270 | var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
5271 |
|
5272 | var curByte = 0
|
5273 |
|
5274 |
|
5275 | var len = placeHoldersLen > 0
|
5276 | ? validLen - 4
|
5277 | : validLen
|
5278 |
|
5279 | var i
|
5280 | for (i = 0; i < len; i += 4) {
|
5281 | tmp =
|
5282 | (revLookup[b64.charCodeAt(i)] << 18) |
|
5283 | (revLookup[b64.charCodeAt(i + 1)] << 12) |
|
5284 | (revLookup[b64.charCodeAt(i + 2)] << 6) |
|
5285 | revLookup[b64.charCodeAt(i + 3)]
|
5286 | arr[curByte++] = (tmp >> 16) & 0xFF
|
5287 | arr[curByte++] = (tmp >> 8) & 0xFF
|
5288 | arr[curByte++] = tmp & 0xFF
|
5289 | }
|
5290 |
|
5291 | if (placeHoldersLen === 2) {
|
5292 | tmp =
|
5293 | (revLookup[b64.charCodeAt(i)] << 2) |
|
5294 | (revLookup[b64.charCodeAt(i + 1)] >> 4)
|
5295 | arr[curByte++] = tmp & 0xFF
|
5296 | }
|
5297 |
|
5298 | if (placeHoldersLen === 1) {
|
5299 | tmp =
|
5300 | (revLookup[b64.charCodeAt(i)] << 10) |
|
5301 | (revLookup[b64.charCodeAt(i + 1)] << 4) |
|
5302 | (revLookup[b64.charCodeAt(i + 2)] >> 2)
|
5303 | arr[curByte++] = (tmp >> 8) & 0xFF
|
5304 | arr[curByte++] = tmp & 0xFF
|
5305 | }
|
5306 |
|
5307 | return arr
|
5308 | }
|
5309 |
|
5310 | function tripletToBase64 (num) {
|
5311 | return lookup[num >> 18 & 0x3F] +
|
5312 | lookup[num >> 12 & 0x3F] +
|
5313 | lookup[num >> 6 & 0x3F] +
|
5314 | lookup[num & 0x3F]
|
5315 | }
|
5316 |
|
5317 | function encodeChunk (uint8, start, end) {
|
5318 | var tmp
|
5319 | var output = []
|
5320 | for (var i = start; i < end; i += 3) {
|
5321 | tmp =
|
5322 | ((uint8[i] << 16) & 0xFF0000) +
|
5323 | ((uint8[i + 1] << 8) & 0xFF00) +
|
5324 | (uint8[i + 2] & 0xFF)
|
5325 | output.push(tripletToBase64(tmp))
|
5326 | }
|
5327 | return output.join('')
|
5328 | }
|
5329 |
|
5330 | function fromByteArray (uint8) {
|
5331 | var tmp
|
5332 | var len = uint8.length
|
5333 | var extraBytes = len % 3
|
5334 | var parts = []
|
5335 | var maxChunkLength = 16383
|
5336 |
|
5337 |
|
5338 | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
5339 | parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
|
5340 | }
|
5341 |
|
5342 |
|
5343 | if (extraBytes === 1) {
|
5344 | tmp = uint8[len - 1]
|
5345 | parts.push(
|
5346 | lookup[tmp >> 2] +
|
5347 | lookup[(tmp << 4) & 0x3F] +
|
5348 | '=='
|
5349 | )
|
5350 | } else if (extraBytes === 2) {
|
5351 | tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
5352 | parts.push(
|
5353 | lookup[tmp >> 10] +
|
5354 | lookup[(tmp >> 4) & 0x3F] +
|
5355 | lookup[(tmp << 2) & 0x3F] +
|
5356 | '='
|
5357 | )
|
5358 | }
|
5359 |
|
5360 | return parts.join('')
|
5361 | }
|
5362 |
|
5363 | },{}],41:[function(require,module,exports){
|
5364 | (function (global,Buffer){(function (){
|
5365 |
|
5366 |
|
5367 |
|
5368 |
|
5369 |
|
5370 |
|
5371 |
|
5372 |
|
5373 | 'use strict'
|
5374 |
|
5375 | var base64 = require('base64-js')
|
5376 | var ieee754 = require('ieee754')
|
5377 | var isArray = require('isarray')
|
5378 |
|
5379 | exports.Buffer = Buffer
|
5380 | exports.SlowBuffer = SlowBuffer
|
5381 | exports.INSPECT_MAX_BYTES = 50
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 |
|
5387 |
|
5388 |
|
5389 |
|
5390 |
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 |
|
5398 |
|
5399 |
|
5400 |
|
5401 |
|
5402 |
|
5403 |
|
5404 |
|
5405 |
|
5406 |
|
5407 | Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
5408 | ? global.TYPED_ARRAY_SUPPORT
|
5409 | : typedArraySupport()
|
5410 |
|
5411 |
|
5412 |
|
5413 |
|
5414 | exports.kMaxLength = kMaxLength()
|
5415 |
|
5416 | function typedArraySupport () {
|
5417 | try {
|
5418 | var arr = new Uint8Array(1)
|
5419 | arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
5420 | return arr.foo() === 42 &&
|
5421 | typeof arr.subarray === 'function' &&
|
5422 | arr.subarray(1, 1).byteLength === 0
|
5423 | } catch (e) {
|
5424 | return false
|
5425 | }
|
5426 | }
|
5427 |
|
5428 | function kMaxLength () {
|
5429 | return Buffer.TYPED_ARRAY_SUPPORT
|
5430 | ? 0x7fffffff
|
5431 | : 0x3fffffff
|
5432 | }
|
5433 |
|
5434 | function createBuffer (that, length) {
|
5435 | if (kMaxLength() < length) {
|
5436 | throw new RangeError('Invalid typed array length')
|
5437 | }
|
5438 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
5439 |
|
5440 | that = new Uint8Array(length)
|
5441 | that.__proto__ = Buffer.prototype
|
5442 | } else {
|
5443 |
|
5444 | if (that === null) {
|
5445 | that = new Buffer(length)
|
5446 | }
|
5447 | that.length = length
|
5448 | }
|
5449 |
|
5450 | return that
|
5451 | }
|
5452 |
|
5453 |
|
5454 |
|
5455 |
|
5456 |
|
5457 |
|
5458 |
|
5459 |
|
5460 |
|
5461 |
|
5462 |
|
5463 | function Buffer (arg, encodingOrOffset, length) {
|
5464 | if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
5465 | return new Buffer(arg, encodingOrOffset, length)
|
5466 | }
|
5467 |
|
5468 |
|
5469 | if (typeof arg === 'number') {
|
5470 | if (typeof encodingOrOffset === 'string') {
|
5471 | throw new Error(
|
5472 | 'If encoding is specified then the first argument must be a string'
|
5473 | )
|
5474 | }
|
5475 | return allocUnsafe(this, arg)
|
5476 | }
|
5477 | return from(this, arg, encodingOrOffset, length)
|
5478 | }
|
5479 |
|
5480 | Buffer.poolSize = 8192
|
5481 |
|
5482 |
|
5483 | Buffer._augment = function (arr) {
|
5484 | arr.__proto__ = Buffer.prototype
|
5485 | return arr
|
5486 | }
|
5487 |
|
5488 | function from (that, value, encodingOrOffset, length) {
|
5489 | if (typeof value === 'number') {
|
5490 | throw new TypeError('"value" argument must not be a number')
|
5491 | }
|
5492 |
|
5493 | if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
|
5494 | return fromArrayBuffer(that, value, encodingOrOffset, length)
|
5495 | }
|
5496 |
|
5497 | if (typeof value === 'string') {
|
5498 | return fromString(that, value, encodingOrOffset)
|
5499 | }
|
5500 |
|
5501 | return fromObject(that, value)
|
5502 | }
|
5503 |
|
5504 |
|
5505 |
|
5506 |
|
5507 |
|
5508 |
|
5509 |
|
5510 |
|
5511 |
|
5512 | Buffer.from = function (value, encodingOrOffset, length) {
|
5513 | return from(null, value, encodingOrOffset, length)
|
5514 | }
|
5515 |
|
5516 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
5517 | Buffer.prototype.__proto__ = Uint8Array.prototype
|
5518 | Buffer.__proto__ = Uint8Array
|
5519 | if (typeof Symbol !== 'undefined' && Symbol.species &&
|
5520 | Buffer[Symbol.species] === Buffer) {
|
5521 |
|
5522 | Object.defineProperty(Buffer, Symbol.species, {
|
5523 | value: null,
|
5524 | configurable: true
|
5525 | })
|
5526 | }
|
5527 | }
|
5528 |
|
5529 | function assertSize (size) {
|
5530 | if (typeof size !== 'number') {
|
5531 | throw new TypeError('"size" argument must be a number')
|
5532 | } else if (size < 0) {
|
5533 | throw new RangeError('"size" argument must not be negative')
|
5534 | }
|
5535 | }
|
5536 |
|
5537 | function alloc (that, size, fill, encoding) {
|
5538 | assertSize(size)
|
5539 | if (size <= 0) {
|
5540 | return createBuffer(that, size)
|
5541 | }
|
5542 | if (fill !== undefined) {
|
5543 |
|
5544 |
|
5545 |
|
5546 | return typeof encoding === 'string'
|
5547 | ? createBuffer(that, size).fill(fill, encoding)
|
5548 | : createBuffer(that, size).fill(fill)
|
5549 | }
|
5550 | return createBuffer(that, size)
|
5551 | }
|
5552 |
|
5553 |
|
5554 |
|
5555 |
|
5556 |
|
5557 | Buffer.alloc = function (size, fill, encoding) {
|
5558 | return alloc(null, size, fill, encoding)
|
5559 | }
|
5560 |
|
5561 | function allocUnsafe (that, size) {
|
5562 | assertSize(size)
|
5563 | that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
|
5564 | if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
5565 | for (var i = 0; i < size; ++i) {
|
5566 | that[i] = 0
|
5567 | }
|
5568 | }
|
5569 | return that
|
5570 | }
|
5571 |
|
5572 |
|
5573 |
|
5574 |
|
5575 | Buffer.allocUnsafe = function (size) {
|
5576 | return allocUnsafe(null, size)
|
5577 | }
|
5578 |
|
5579 |
|
5580 |
|
5581 | Buffer.allocUnsafeSlow = function (size) {
|
5582 | return allocUnsafe(null, size)
|
5583 | }
|
5584 |
|
5585 | function fromString (that, string, encoding) {
|
5586 | if (typeof encoding !== 'string' || encoding === '') {
|
5587 | encoding = 'utf8'
|
5588 | }
|
5589 |
|
5590 | if (!Buffer.isEncoding(encoding)) {
|
5591 | throw new TypeError('"encoding" must be a valid string encoding')
|
5592 | }
|
5593 |
|
5594 | var length = byteLength(string, encoding) | 0
|
5595 | that = createBuffer(that, length)
|
5596 |
|
5597 | var actual = that.write(string, encoding)
|
5598 |
|
5599 | if (actual !== length) {
|
5600 |
|
5601 |
|
5602 |
|
5603 | that = that.slice(0, actual)
|
5604 | }
|
5605 |
|
5606 | return that
|
5607 | }
|
5608 |
|
5609 | function fromArrayLike (that, array) {
|
5610 | var length = array.length < 0 ? 0 : checked(array.length) | 0
|
5611 | that = createBuffer(that, length)
|
5612 | for (var i = 0; i < length; i += 1) {
|
5613 | that[i] = array[i] & 255
|
5614 | }
|
5615 | return that
|
5616 | }
|
5617 |
|
5618 | function fromArrayBuffer (that, array, byteOffset, length) {
|
5619 | array.byteLength
|
5620 |
|
5621 | if (byteOffset < 0 || array.byteLength < byteOffset) {
|
5622 | throw new RangeError('\'offset\' is out of bounds')
|
5623 | }
|
5624 |
|
5625 | if (array.byteLength < byteOffset + (length || 0)) {
|
5626 | throw new RangeError('\'length\' is out of bounds')
|
5627 | }
|
5628 |
|
5629 | if (byteOffset === undefined && length === undefined) {
|
5630 | array = new Uint8Array(array)
|
5631 | } else if (length === undefined) {
|
5632 | array = new Uint8Array(array, byteOffset)
|
5633 | } else {
|
5634 | array = new Uint8Array(array, byteOffset, length)
|
5635 | }
|
5636 |
|
5637 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
5638 |
|
5639 | that = array
|
5640 | that.__proto__ = Buffer.prototype
|
5641 | } else {
|
5642 |
|
5643 | that = fromArrayLike(that, array)
|
5644 | }
|
5645 | return that
|
5646 | }
|
5647 |
|
5648 | function fromObject (that, obj) {
|
5649 | if (Buffer.isBuffer(obj)) {
|
5650 | var len = checked(obj.length) | 0
|
5651 | that = createBuffer(that, len)
|
5652 |
|
5653 | if (that.length === 0) {
|
5654 | return that
|
5655 | }
|
5656 |
|
5657 | obj.copy(that, 0, 0, len)
|
5658 | return that
|
5659 | }
|
5660 |
|
5661 | if (obj) {
|
5662 | if ((typeof ArrayBuffer !== 'undefined' &&
|
5663 | obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
|
5664 | if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
5665 | return createBuffer(that, 0)
|
5666 | }
|
5667 | return fromArrayLike(that, obj)
|
5668 | }
|
5669 |
|
5670 | if (obj.type === 'Buffer' && isArray(obj.data)) {
|
5671 | return fromArrayLike(that, obj.data)
|
5672 | }
|
5673 | }
|
5674 |
|
5675 | throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
5676 | }
|
5677 |
|
5678 | function checked (length) {
|
5679 |
|
5680 |
|
5681 | if (length >= kMaxLength()) {
|
5682 | throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
5683 | 'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
5684 | }
|
5685 | return length | 0
|
5686 | }
|
5687 |
|
5688 | function SlowBuffer (length) {
|
5689 | if (+length != length) {
|
5690 | length = 0
|
5691 | }
|
5692 | return Buffer.alloc(+length)
|
5693 | }
|
5694 |
|
5695 | Buffer.isBuffer = function isBuffer (b) {
|
5696 | return !!(b != null && b._isBuffer)
|
5697 | }
|
5698 |
|
5699 | Buffer.compare = function compare (a, b) {
|
5700 | if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
5701 | throw new TypeError('Arguments must be Buffers')
|
5702 | }
|
5703 |
|
5704 | if (a === b) return 0
|
5705 |
|
5706 | var x = a.length
|
5707 | var y = b.length
|
5708 |
|
5709 | for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
5710 | if (a[i] !== b[i]) {
|
5711 | x = a[i]
|
5712 | y = b[i]
|
5713 | break
|
5714 | }
|
5715 | }
|
5716 |
|
5717 | if (x < y) return -1
|
5718 | if (y < x) return 1
|
5719 | return 0
|
5720 | }
|
5721 |
|
5722 | Buffer.isEncoding = function isEncoding (encoding) {
|
5723 | switch (String(encoding).toLowerCase()) {
|
5724 | case 'hex':
|
5725 | case 'utf8':
|
5726 | case 'utf-8':
|
5727 | case 'ascii':
|
5728 | case 'latin1':
|
5729 | case 'binary':
|
5730 | case 'base64':
|
5731 | case 'ucs2':
|
5732 | case 'ucs-2':
|
5733 | case 'utf16le':
|
5734 | case 'utf-16le':
|
5735 | return true
|
5736 | default:
|
5737 | return false
|
5738 | }
|
5739 | }
|
5740 |
|
5741 | Buffer.concat = function concat (list, length) {
|
5742 | if (!isArray(list)) {
|
5743 | throw new TypeError('"list" argument must be an Array of Buffers')
|
5744 | }
|
5745 |
|
5746 | if (list.length === 0) {
|
5747 | return Buffer.alloc(0)
|
5748 | }
|
5749 |
|
5750 | var i
|
5751 | if (length === undefined) {
|
5752 | length = 0
|
5753 | for (i = 0; i < list.length; ++i) {
|
5754 | length += list[i].length
|
5755 | }
|
5756 | }
|
5757 |
|
5758 | var buffer = Buffer.allocUnsafe(length)
|
5759 | var pos = 0
|
5760 | for (i = 0; i < list.length; ++i) {
|
5761 | var buf = list[i]
|
5762 | if (!Buffer.isBuffer(buf)) {
|
5763 | throw new TypeError('"list" argument must be an Array of Buffers')
|
5764 | }
|
5765 | buf.copy(buffer, pos)
|
5766 | pos += buf.length
|
5767 | }
|
5768 | return buffer
|
5769 | }
|
5770 |
|
5771 | function byteLength (string, encoding) {
|
5772 | if (Buffer.isBuffer(string)) {
|
5773 | return string.length
|
5774 | }
|
5775 | if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
|
5776 | (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
5777 | return string.byteLength
|
5778 | }
|
5779 | if (typeof string !== 'string') {
|
5780 | string = '' + string
|
5781 | }
|
5782 |
|
5783 | var len = string.length
|
5784 | if (len === 0) return 0
|
5785 |
|
5786 |
|
5787 | var loweredCase = false
|
5788 | for (;;) {
|
5789 | switch (encoding) {
|
5790 | case 'ascii':
|
5791 | case 'latin1':
|
5792 | case 'binary':
|
5793 | return len
|
5794 | case 'utf8':
|
5795 | case 'utf-8':
|
5796 | case undefined:
|
5797 | return utf8ToBytes(string).length
|
5798 | case 'ucs2':
|
5799 | case 'ucs-2':
|
5800 | case 'utf16le':
|
5801 | case 'utf-16le':
|
5802 | return len * 2
|
5803 | case 'hex':
|
5804 | return len >>> 1
|
5805 | case 'base64':
|
5806 | return base64ToBytes(string).length
|
5807 | default:
|
5808 | if (loweredCase) return utf8ToBytes(string).length
|
5809 | encoding = ('' + encoding).toLowerCase()
|
5810 | loweredCase = true
|
5811 | }
|
5812 | }
|
5813 | }
|
5814 | Buffer.byteLength = byteLength
|
5815 |
|
5816 | function slowToString (encoding, start, end) {
|
5817 | var loweredCase = false
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 |
|
5823 |
|
5824 |
|
5825 |
|
5826 | if (start === undefined || start < 0) {
|
5827 | start = 0
|
5828 | }
|
5829 |
|
5830 |
|
5831 | if (start > this.length) {
|
5832 | return ''
|
5833 | }
|
5834 |
|
5835 | if (end === undefined || end > this.length) {
|
5836 | end = this.length
|
5837 | }
|
5838 |
|
5839 | if (end <= 0) {
|
5840 | return ''
|
5841 | }
|
5842 |
|
5843 |
|
5844 | end >>>= 0
|
5845 | start >>>= 0
|
5846 |
|
5847 | if (end <= start) {
|
5848 | return ''
|
5849 | }
|
5850 |
|
5851 | if (!encoding) encoding = 'utf8'
|
5852 |
|
5853 | while (true) {
|
5854 | switch (encoding) {
|
5855 | case 'hex':
|
5856 | return hexSlice(this, start, end)
|
5857 |
|
5858 | case 'utf8':
|
5859 | case 'utf-8':
|
5860 | return utf8Slice(this, start, end)
|
5861 |
|
5862 | case 'ascii':
|
5863 | return asciiSlice(this, start, end)
|
5864 |
|
5865 | case 'latin1':
|
5866 | case 'binary':
|
5867 | return latin1Slice(this, start, end)
|
5868 |
|
5869 | case 'base64':
|
5870 | return base64Slice(this, start, end)
|
5871 |
|
5872 | case 'ucs2':
|
5873 | case 'ucs-2':
|
5874 | case 'utf16le':
|
5875 | case 'utf-16le':
|
5876 | return utf16leSlice(this, start, end)
|
5877 |
|
5878 | default:
|
5879 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
5880 | encoding = (encoding + '').toLowerCase()
|
5881 | loweredCase = true
|
5882 | }
|
5883 | }
|
5884 | }
|
5885 |
|
5886 |
|
5887 |
|
5888 | Buffer.prototype._isBuffer = true
|
5889 |
|
5890 | function swap (b, n, m) {
|
5891 | var i = b[n]
|
5892 | b[n] = b[m]
|
5893 | b[m] = i
|
5894 | }
|
5895 |
|
5896 | Buffer.prototype.swap16 = function swap16 () {
|
5897 | var len = this.length
|
5898 | if (len % 2 !== 0) {
|
5899 | throw new RangeError('Buffer size must be a multiple of 16-bits')
|
5900 | }
|
5901 | for (var i = 0; i < len; i += 2) {
|
5902 | swap(this, i, i + 1)
|
5903 | }
|
5904 | return this
|
5905 | }
|
5906 |
|
5907 | Buffer.prototype.swap32 = function swap32 () {
|
5908 | var len = this.length
|
5909 | if (len % 4 !== 0) {
|
5910 | throw new RangeError('Buffer size must be a multiple of 32-bits')
|
5911 | }
|
5912 | for (var i = 0; i < len; i += 4) {
|
5913 | swap(this, i, i + 3)
|
5914 | swap(this, i + 1, i + 2)
|
5915 | }
|
5916 | return this
|
5917 | }
|
5918 |
|
5919 | Buffer.prototype.swap64 = function swap64 () {
|
5920 | var len = this.length
|
5921 | if (len % 8 !== 0) {
|
5922 | throw new RangeError('Buffer size must be a multiple of 64-bits')
|
5923 | }
|
5924 | for (var i = 0; i < len; i += 8) {
|
5925 | swap(this, i, i + 7)
|
5926 | swap(this, i + 1, i + 6)
|
5927 | swap(this, i + 2, i + 5)
|
5928 | swap(this, i + 3, i + 4)
|
5929 | }
|
5930 | return this
|
5931 | }
|
5932 |
|
5933 | Buffer.prototype.toString = function toString () {
|
5934 | var length = this.length | 0
|
5935 | if (length === 0) return ''
|
5936 | if (arguments.length === 0) return utf8Slice(this, 0, length)
|
5937 | return slowToString.apply(this, arguments)
|
5938 | }
|
5939 |
|
5940 | Buffer.prototype.equals = function equals (b) {
|
5941 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
5942 | if (this === b) return true
|
5943 | return Buffer.compare(this, b) === 0
|
5944 | }
|
5945 |
|
5946 | Buffer.prototype.inspect = function inspect () {
|
5947 | var str = ''
|
5948 | var max = exports.INSPECT_MAX_BYTES
|
5949 | if (this.length > 0) {
|
5950 | str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
5951 | if (this.length > max) str += ' ... '
|
5952 | }
|
5953 | return '<Buffer ' + str + '>'
|
5954 | }
|
5955 |
|
5956 | Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
5957 | if (!Buffer.isBuffer(target)) {
|
5958 | throw new TypeError('Argument must be a Buffer')
|
5959 | }
|
5960 |
|
5961 | if (start === undefined) {
|
5962 | start = 0
|
5963 | }
|
5964 | if (end === undefined) {
|
5965 | end = target ? target.length : 0
|
5966 | }
|
5967 | if (thisStart === undefined) {
|
5968 | thisStart = 0
|
5969 | }
|
5970 | if (thisEnd === undefined) {
|
5971 | thisEnd = this.length
|
5972 | }
|
5973 |
|
5974 | if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
5975 | throw new RangeError('out of range index')
|
5976 | }
|
5977 |
|
5978 | if (thisStart >= thisEnd && start >= end) {
|
5979 | return 0
|
5980 | }
|
5981 | if (thisStart >= thisEnd) {
|
5982 | return -1
|
5983 | }
|
5984 | if (start >= end) {
|
5985 | return 1
|
5986 | }
|
5987 |
|
5988 | start >>>= 0
|
5989 | end >>>= 0
|
5990 | thisStart >>>= 0
|
5991 | thisEnd >>>= 0
|
5992 |
|
5993 | if (this === target) return 0
|
5994 |
|
5995 | var x = thisEnd - thisStart
|
5996 | var y = end - start
|
5997 | var len = Math.min(x, y)
|
5998 |
|
5999 | var thisCopy = this.slice(thisStart, thisEnd)
|
6000 | var targetCopy = target.slice(start, end)
|
6001 |
|
6002 | for (var i = 0; i < len; ++i) {
|
6003 | if (thisCopy[i] !== targetCopy[i]) {
|
6004 | x = thisCopy[i]
|
6005 | y = targetCopy[i]
|
6006 | break
|
6007 | }
|
6008 | }
|
6009 |
|
6010 | if (x < y) return -1
|
6011 | if (y < x) return 1
|
6012 | return 0
|
6013 | }
|
6014 |
|
6015 |
|
6016 |
|
6017 |
|
6018 |
|
6019 |
|
6020 |
|
6021 |
|
6022 |
|
6023 |
|
6024 | function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
6025 |
|
6026 | if (buffer.length === 0) return -1
|
6027 |
|
6028 |
|
6029 | if (typeof byteOffset === 'string') {
|
6030 | encoding = byteOffset
|
6031 | byteOffset = 0
|
6032 | } else if (byteOffset > 0x7fffffff) {
|
6033 | byteOffset = 0x7fffffff
|
6034 | } else if (byteOffset < -0x80000000) {
|
6035 | byteOffset = -0x80000000
|
6036 | }
|
6037 | byteOffset = +byteOffset
|
6038 | if (isNaN(byteOffset)) {
|
6039 |
|
6040 | byteOffset = dir ? 0 : (buffer.length - 1)
|
6041 | }
|
6042 |
|
6043 |
|
6044 | if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
6045 | if (byteOffset >= buffer.length) {
|
6046 | if (dir) return -1
|
6047 | else byteOffset = buffer.length - 1
|
6048 | } else if (byteOffset < 0) {
|
6049 | if (dir) byteOffset = 0
|
6050 | else return -1
|
6051 | }
|
6052 |
|
6053 |
|
6054 | if (typeof val === 'string') {
|
6055 | val = Buffer.from(val, encoding)
|
6056 | }
|
6057 |
|
6058 |
|
6059 | if (Buffer.isBuffer(val)) {
|
6060 |
|
6061 | if (val.length === 0) {
|
6062 | return -1
|
6063 | }
|
6064 | return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
6065 | } else if (typeof val === 'number') {
|
6066 | val = val & 0xFF
|
6067 | if (Buffer.TYPED_ARRAY_SUPPORT &&
|
6068 | typeof Uint8Array.prototype.indexOf === 'function') {
|
6069 | if (dir) {
|
6070 | return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
6071 | } else {
|
6072 | return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
6073 | }
|
6074 | }
|
6075 | return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
6076 | }
|
6077 |
|
6078 | throw new TypeError('val must be string, number or Buffer')
|
6079 | }
|
6080 |
|
6081 | function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
6082 | var indexSize = 1
|
6083 | var arrLength = arr.length
|
6084 | var valLength = val.length
|
6085 |
|
6086 | if (encoding !== undefined) {
|
6087 | encoding = String(encoding).toLowerCase()
|
6088 | if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
6089 | encoding === 'utf16le' || encoding === 'utf-16le') {
|
6090 | if (arr.length < 2 || val.length < 2) {
|
6091 | return -1
|
6092 | }
|
6093 | indexSize = 2
|
6094 | arrLength /= 2
|
6095 | valLength /= 2
|
6096 | byteOffset /= 2
|
6097 | }
|
6098 | }
|
6099 |
|
6100 | function read (buf, i) {
|
6101 | if (indexSize === 1) {
|
6102 | return buf[i]
|
6103 | } else {
|
6104 | return buf.readUInt16BE(i * indexSize)
|
6105 | }
|
6106 | }
|
6107 |
|
6108 | var i
|
6109 | if (dir) {
|
6110 | var foundIndex = -1
|
6111 | for (i = byteOffset; i < arrLength; i++) {
|
6112 | if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
6113 | if (foundIndex === -1) foundIndex = i
|
6114 | if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
6115 | } else {
|
6116 | if (foundIndex !== -1) i -= i - foundIndex
|
6117 | foundIndex = -1
|
6118 | }
|
6119 | }
|
6120 | } else {
|
6121 | if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
6122 | for (i = byteOffset; i >= 0; i--) {
|
6123 | var found = true
|
6124 | for (var j = 0; j < valLength; j++) {
|
6125 | if (read(arr, i + j) !== read(val, j)) {
|
6126 | found = false
|
6127 | break
|
6128 | }
|
6129 | }
|
6130 | if (found) return i
|
6131 | }
|
6132 | }
|
6133 |
|
6134 | return -1
|
6135 | }
|
6136 |
|
6137 | Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
6138 | return this.indexOf(val, byteOffset, encoding) !== -1
|
6139 | }
|
6140 |
|
6141 | Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
6142 | return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
6143 | }
|
6144 |
|
6145 | Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
6146 | return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
6147 | }
|
6148 |
|
6149 | function hexWrite (buf, string, offset, length) {
|
6150 | offset = Number(offset) || 0
|
6151 | var remaining = buf.length - offset
|
6152 | if (!length) {
|
6153 | length = remaining
|
6154 | } else {
|
6155 | length = Number(length)
|
6156 | if (length > remaining) {
|
6157 | length = remaining
|
6158 | }
|
6159 | }
|
6160 |
|
6161 |
|
6162 | var strLen = string.length
|
6163 | if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
6164 |
|
6165 | if (length > strLen / 2) {
|
6166 | length = strLen / 2
|
6167 | }
|
6168 | for (var i = 0; i < length; ++i) {
|
6169 | var parsed = parseInt(string.substr(i * 2, 2), 16)
|
6170 | if (isNaN(parsed)) return i
|
6171 | buf[offset + i] = parsed
|
6172 | }
|
6173 | return i
|
6174 | }
|
6175 |
|
6176 | function utf8Write (buf, string, offset, length) {
|
6177 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
6178 | }
|
6179 |
|
6180 | function asciiWrite (buf, string, offset, length) {
|
6181 | return blitBuffer(asciiToBytes(string), buf, offset, length)
|
6182 | }
|
6183 |
|
6184 | function latin1Write (buf, string, offset, length) {
|
6185 | return asciiWrite(buf, string, offset, length)
|
6186 | }
|
6187 |
|
6188 | function base64Write (buf, string, offset, length) {
|
6189 | return blitBuffer(base64ToBytes(string), buf, offset, length)
|
6190 | }
|
6191 |
|
6192 | function ucs2Write (buf, string, offset, length) {
|
6193 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
6194 | }
|
6195 |
|
6196 | Buffer.prototype.write = function write (string, offset, length, encoding) {
|
6197 |
|
6198 | if (offset === undefined) {
|
6199 | encoding = 'utf8'
|
6200 | length = this.length
|
6201 | offset = 0
|
6202 |
|
6203 | } else if (length === undefined && typeof offset === 'string') {
|
6204 | encoding = offset
|
6205 | length = this.length
|
6206 | offset = 0
|
6207 |
|
6208 | } else if (isFinite(offset)) {
|
6209 | offset = offset | 0
|
6210 | if (isFinite(length)) {
|
6211 | length = length | 0
|
6212 | if (encoding === undefined) encoding = 'utf8'
|
6213 | } else {
|
6214 | encoding = length
|
6215 | length = undefined
|
6216 | }
|
6217 |
|
6218 | } else {
|
6219 | throw new Error(
|
6220 | 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
6221 | )
|
6222 | }
|
6223 |
|
6224 | var remaining = this.length - offset
|
6225 | if (length === undefined || length > remaining) length = remaining
|
6226 |
|
6227 | if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
6228 | throw new RangeError('Attempt to write outside buffer bounds')
|
6229 | }
|
6230 |
|
6231 | if (!encoding) encoding = 'utf8'
|
6232 |
|
6233 | var loweredCase = false
|
6234 | for (;;) {
|
6235 | switch (encoding) {
|
6236 | case 'hex':
|
6237 | return hexWrite(this, string, offset, length)
|
6238 |
|
6239 | case 'utf8':
|
6240 | case 'utf-8':
|
6241 | return utf8Write(this, string, offset, length)
|
6242 |
|
6243 | case 'ascii':
|
6244 | return asciiWrite(this, string, offset, length)
|
6245 |
|
6246 | case 'latin1':
|
6247 | case 'binary':
|
6248 | return latin1Write(this, string, offset, length)
|
6249 |
|
6250 | case 'base64':
|
6251 |
|
6252 | return base64Write(this, string, offset, length)
|
6253 |
|
6254 | case 'ucs2':
|
6255 | case 'ucs-2':
|
6256 | case 'utf16le':
|
6257 | case 'utf-16le':
|
6258 | return ucs2Write(this, string, offset, length)
|
6259 |
|
6260 | default:
|
6261 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
6262 | encoding = ('' + encoding).toLowerCase()
|
6263 | loweredCase = true
|
6264 | }
|
6265 | }
|
6266 | }
|
6267 |
|
6268 | Buffer.prototype.toJSON = function toJSON () {
|
6269 | return {
|
6270 | type: 'Buffer',
|
6271 | data: Array.prototype.slice.call(this._arr || this, 0)
|
6272 | }
|
6273 | }
|
6274 |
|
6275 | function base64Slice (buf, start, end) {
|
6276 | if (start === 0 && end === buf.length) {
|
6277 | return base64.fromByteArray(buf)
|
6278 | } else {
|
6279 | return base64.fromByteArray(buf.slice(start, end))
|
6280 | }
|
6281 | }
|
6282 |
|
6283 | function utf8Slice (buf, start, end) {
|
6284 | end = Math.min(buf.length, end)
|
6285 | var res = []
|
6286 |
|
6287 | var i = start
|
6288 | while (i < end) {
|
6289 | var firstByte = buf[i]
|
6290 | var codePoint = null
|
6291 | var bytesPerSequence = (firstByte > 0xEF) ? 4
|
6292 | : (firstByte > 0xDF) ? 3
|
6293 | : (firstByte > 0xBF) ? 2
|
6294 | : 1
|
6295 |
|
6296 | if (i + bytesPerSequence <= end) {
|
6297 | var secondByte, thirdByte, fourthByte, tempCodePoint
|
6298 |
|
6299 | switch (bytesPerSequence) {
|
6300 | case 1:
|
6301 | if (firstByte < 0x80) {
|
6302 | codePoint = firstByte
|
6303 | }
|
6304 | break
|
6305 | case 2:
|
6306 | secondByte = buf[i + 1]
|
6307 | if ((secondByte & 0xC0) === 0x80) {
|
6308 | tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
6309 | if (tempCodePoint > 0x7F) {
|
6310 | codePoint = tempCodePoint
|
6311 | }
|
6312 | }
|
6313 | break
|
6314 | case 3:
|
6315 | secondByte = buf[i + 1]
|
6316 | thirdByte = buf[i + 2]
|
6317 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
6318 | tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
6319 | if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
6320 | codePoint = tempCodePoint
|
6321 | }
|
6322 | }
|
6323 | break
|
6324 | case 4:
|
6325 | secondByte = buf[i + 1]
|
6326 | thirdByte = buf[i + 2]
|
6327 | fourthByte = buf[i + 3]
|
6328 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
6329 | tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
6330 | if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
6331 | codePoint = tempCodePoint
|
6332 | }
|
6333 | }
|
6334 | }
|
6335 | }
|
6336 |
|
6337 | if (codePoint === null) {
|
6338 |
|
6339 |
|
6340 | codePoint = 0xFFFD
|
6341 | bytesPerSequence = 1
|
6342 | } else if (codePoint > 0xFFFF) {
|
6343 |
|
6344 | codePoint -= 0x10000
|
6345 | res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
6346 | codePoint = 0xDC00 | codePoint & 0x3FF
|
6347 | }
|
6348 |
|
6349 | res.push(codePoint)
|
6350 | i += bytesPerSequence
|
6351 | }
|
6352 |
|
6353 | return decodeCodePointsArray(res)
|
6354 | }
|
6355 |
|
6356 |
|
6357 |
|
6358 |
|
6359 | var MAX_ARGUMENTS_LENGTH = 0x1000
|
6360 |
|
6361 | function decodeCodePointsArray (codePoints) {
|
6362 | var len = codePoints.length
|
6363 | if (len <= MAX_ARGUMENTS_LENGTH) {
|
6364 | return String.fromCharCode.apply(String, codePoints)
|
6365 | }
|
6366 |
|
6367 |
|
6368 | var res = ''
|
6369 | var i = 0
|
6370 | while (i < len) {
|
6371 | res += String.fromCharCode.apply(
|
6372 | String,
|
6373 | codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
6374 | )
|
6375 | }
|
6376 | return res
|
6377 | }
|
6378 |
|
6379 | function asciiSlice (buf, start, end) {
|
6380 | var ret = ''
|
6381 | end = Math.min(buf.length, end)
|
6382 |
|
6383 | for (var i = start; i < end; ++i) {
|
6384 | ret += String.fromCharCode(buf[i] & 0x7F)
|
6385 | }
|
6386 | return ret
|
6387 | }
|
6388 |
|
6389 | function latin1Slice (buf, start, end) {
|
6390 | var ret = ''
|
6391 | end = Math.min(buf.length, end)
|
6392 |
|
6393 | for (var i = start; i < end; ++i) {
|
6394 | ret += String.fromCharCode(buf[i])
|
6395 | }
|
6396 | return ret
|
6397 | }
|
6398 |
|
6399 | function hexSlice (buf, start, end) {
|
6400 | var len = buf.length
|
6401 |
|
6402 | if (!start || start < 0) start = 0
|
6403 | if (!end || end < 0 || end > len) end = len
|
6404 |
|
6405 | var out = ''
|
6406 | for (var i = start; i < end; ++i) {
|
6407 | out += toHex(buf[i])
|
6408 | }
|
6409 | return out
|
6410 | }
|
6411 |
|
6412 | function utf16leSlice (buf, start, end) {
|
6413 | var bytes = buf.slice(start, end)
|
6414 | var res = ''
|
6415 | for (var i = 0; i < bytes.length; i += 2) {
|
6416 | res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
6417 | }
|
6418 | return res
|
6419 | }
|
6420 |
|
6421 | Buffer.prototype.slice = function slice (start, end) {
|
6422 | var len = this.length
|
6423 | start = ~~start
|
6424 | end = end === undefined ? len : ~~end
|
6425 |
|
6426 | if (start < 0) {
|
6427 | start += len
|
6428 | if (start < 0) start = 0
|
6429 | } else if (start > len) {
|
6430 | start = len
|
6431 | }
|
6432 |
|
6433 | if (end < 0) {
|
6434 | end += len
|
6435 | if (end < 0) end = 0
|
6436 | } else if (end > len) {
|
6437 | end = len
|
6438 | }
|
6439 |
|
6440 | if (end < start) end = start
|
6441 |
|
6442 | var newBuf
|
6443 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6444 | newBuf = this.subarray(start, end)
|
6445 | newBuf.__proto__ = Buffer.prototype
|
6446 | } else {
|
6447 | var sliceLen = end - start
|
6448 | newBuf = new Buffer(sliceLen, undefined)
|
6449 | for (var i = 0; i < sliceLen; ++i) {
|
6450 | newBuf[i] = this[i + start]
|
6451 | }
|
6452 | }
|
6453 |
|
6454 | return newBuf
|
6455 | }
|
6456 |
|
6457 |
|
6458 |
|
6459 |
|
6460 | function checkOffset (offset, ext, length) {
|
6461 | if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
6462 | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
6463 | }
|
6464 |
|
6465 | Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
6466 | offset = offset | 0
|
6467 | byteLength = byteLength | 0
|
6468 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
6469 |
|
6470 | var val = this[offset]
|
6471 | var mul = 1
|
6472 | var i = 0
|
6473 | while (++i < byteLength && (mul *= 0x100)) {
|
6474 | val += this[offset + i] * mul
|
6475 | }
|
6476 |
|
6477 | return val
|
6478 | }
|
6479 |
|
6480 | Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
6481 | offset = offset | 0
|
6482 | byteLength = byteLength | 0
|
6483 | if (!noAssert) {
|
6484 | checkOffset(offset, byteLength, this.length)
|
6485 | }
|
6486 |
|
6487 | var val = this[offset + --byteLength]
|
6488 | var mul = 1
|
6489 | while (byteLength > 0 && (mul *= 0x100)) {
|
6490 | val += this[offset + --byteLength] * mul
|
6491 | }
|
6492 |
|
6493 | return val
|
6494 | }
|
6495 |
|
6496 | Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
6497 | if (!noAssert) checkOffset(offset, 1, this.length)
|
6498 | return this[offset]
|
6499 | }
|
6500 |
|
6501 | Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
6502 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6503 | return this[offset] | (this[offset + 1] << 8)
|
6504 | }
|
6505 |
|
6506 | Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
6507 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6508 | return (this[offset] << 8) | this[offset + 1]
|
6509 | }
|
6510 |
|
6511 | Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
6512 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6513 |
|
6514 | return ((this[offset]) |
|
6515 | (this[offset + 1] << 8) |
|
6516 | (this[offset + 2] << 16)) +
|
6517 | (this[offset + 3] * 0x1000000)
|
6518 | }
|
6519 |
|
6520 | Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
6521 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6522 |
|
6523 | return (this[offset] * 0x1000000) +
|
6524 | ((this[offset + 1] << 16) |
|
6525 | (this[offset + 2] << 8) |
|
6526 | this[offset + 3])
|
6527 | }
|
6528 |
|
6529 | Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
6530 | offset = offset | 0
|
6531 | byteLength = byteLength | 0
|
6532 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
6533 |
|
6534 | var val = this[offset]
|
6535 | var mul = 1
|
6536 | var i = 0
|
6537 | while (++i < byteLength && (mul *= 0x100)) {
|
6538 | val += this[offset + i] * mul
|
6539 | }
|
6540 | mul *= 0x80
|
6541 |
|
6542 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
6543 |
|
6544 | return val
|
6545 | }
|
6546 |
|
6547 | Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
6548 | offset = offset | 0
|
6549 | byteLength = byteLength | 0
|
6550 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
6551 |
|
6552 | var i = byteLength
|
6553 | var mul = 1
|
6554 | var val = this[offset + --i]
|
6555 | while (i > 0 && (mul *= 0x100)) {
|
6556 | val += this[offset + --i] * mul
|
6557 | }
|
6558 | mul *= 0x80
|
6559 |
|
6560 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
6561 |
|
6562 | return val
|
6563 | }
|
6564 |
|
6565 | Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
6566 | if (!noAssert) checkOffset(offset, 1, this.length)
|
6567 | if (!(this[offset] & 0x80)) return (this[offset])
|
6568 | return ((0xff - this[offset] + 1) * -1)
|
6569 | }
|
6570 |
|
6571 | Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
6572 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6573 | var val = this[offset] | (this[offset + 1] << 8)
|
6574 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
6575 | }
|
6576 |
|
6577 | Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
6578 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6579 | var val = this[offset + 1] | (this[offset] << 8)
|
6580 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
6581 | }
|
6582 |
|
6583 | Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
6584 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6585 |
|
6586 | return (this[offset]) |
|
6587 | (this[offset + 1] << 8) |
|
6588 | (this[offset + 2] << 16) |
|
6589 | (this[offset + 3] << 24)
|
6590 | }
|
6591 |
|
6592 | Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
6593 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6594 |
|
6595 | return (this[offset] << 24) |
|
6596 | (this[offset + 1] << 16) |
|
6597 | (this[offset + 2] << 8) |
|
6598 | (this[offset + 3])
|
6599 | }
|
6600 |
|
6601 | Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
6602 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6603 | return ieee754.read(this, offset, true, 23, 4)
|
6604 | }
|
6605 |
|
6606 | Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
6607 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6608 | return ieee754.read(this, offset, false, 23, 4)
|
6609 | }
|
6610 |
|
6611 | Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
6612 | if (!noAssert) checkOffset(offset, 8, this.length)
|
6613 | return ieee754.read(this, offset, true, 52, 8)
|
6614 | }
|
6615 |
|
6616 | Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
6617 | if (!noAssert) checkOffset(offset, 8, this.length)
|
6618 | return ieee754.read(this, offset, false, 52, 8)
|
6619 | }
|
6620 |
|
6621 | function checkInt (buf, value, offset, ext, max, min) {
|
6622 | if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
6623 | if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
6624 | if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
6625 | }
|
6626 |
|
6627 | Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
6628 | value = +value
|
6629 | offset = offset | 0
|
6630 | byteLength = byteLength | 0
|
6631 | if (!noAssert) {
|
6632 | var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
6633 | checkInt(this, value, offset, byteLength, maxBytes, 0)
|
6634 | }
|
6635 |
|
6636 | var mul = 1
|
6637 | var i = 0
|
6638 | this[offset] = value & 0xFF
|
6639 | while (++i < byteLength && (mul *= 0x100)) {
|
6640 | this[offset + i] = (value / mul) & 0xFF
|
6641 | }
|
6642 |
|
6643 | return offset + byteLength
|
6644 | }
|
6645 |
|
6646 | Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
6647 | value = +value
|
6648 | offset = offset | 0
|
6649 | byteLength = byteLength | 0
|
6650 | if (!noAssert) {
|
6651 | var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
6652 | checkInt(this, value, offset, byteLength, maxBytes, 0)
|
6653 | }
|
6654 |
|
6655 | var i = byteLength - 1
|
6656 | var mul = 1
|
6657 | this[offset + i] = value & 0xFF
|
6658 | while (--i >= 0 && (mul *= 0x100)) {
|
6659 | this[offset + i] = (value / mul) & 0xFF
|
6660 | }
|
6661 |
|
6662 | return offset + byteLength
|
6663 | }
|
6664 |
|
6665 | Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
6666 | value = +value
|
6667 | offset = offset | 0
|
6668 | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
6669 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
6670 | this[offset] = (value & 0xff)
|
6671 | return offset + 1
|
6672 | }
|
6673 |
|
6674 | function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
6675 | if (value < 0) value = 0xffff + value + 1
|
6676 | for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
6677 | buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
6678 | (littleEndian ? i : 1 - i) * 8
|
6679 | }
|
6680 | }
|
6681 |
|
6682 | Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
6683 | value = +value
|
6684 | offset = offset | 0
|
6685 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
6686 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6687 | this[offset] = (value & 0xff)
|
6688 | this[offset + 1] = (value >>> 8)
|
6689 | } else {
|
6690 | objectWriteUInt16(this, value, offset, true)
|
6691 | }
|
6692 | return offset + 2
|
6693 | }
|
6694 |
|
6695 | Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
6696 | value = +value
|
6697 | offset = offset | 0
|
6698 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
6699 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6700 | this[offset] = (value >>> 8)
|
6701 | this[offset + 1] = (value & 0xff)
|
6702 | } else {
|
6703 | objectWriteUInt16(this, value, offset, false)
|
6704 | }
|
6705 | return offset + 2
|
6706 | }
|
6707 |
|
6708 | function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
6709 | if (value < 0) value = 0xffffffff + value + 1
|
6710 | for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
6711 | buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
6712 | }
|
6713 | }
|
6714 |
|
6715 | Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
6716 | value = +value
|
6717 | offset = offset | 0
|
6718 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
6719 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6720 | this[offset + 3] = (value >>> 24)
|
6721 | this[offset + 2] = (value >>> 16)
|
6722 | this[offset + 1] = (value >>> 8)
|
6723 | this[offset] = (value & 0xff)
|
6724 | } else {
|
6725 | objectWriteUInt32(this, value, offset, true)
|
6726 | }
|
6727 | return offset + 4
|
6728 | }
|
6729 |
|
6730 | Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
6731 | value = +value
|
6732 | offset = offset | 0
|
6733 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
6734 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6735 | this[offset] = (value >>> 24)
|
6736 | this[offset + 1] = (value >>> 16)
|
6737 | this[offset + 2] = (value >>> 8)
|
6738 | this[offset + 3] = (value & 0xff)
|
6739 | } else {
|
6740 | objectWriteUInt32(this, value, offset, false)
|
6741 | }
|
6742 | return offset + 4
|
6743 | }
|
6744 |
|
6745 | Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
6746 | value = +value
|
6747 | offset = offset | 0
|
6748 | if (!noAssert) {
|
6749 | var limit = Math.pow(2, 8 * byteLength - 1)
|
6750 |
|
6751 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
6752 | }
|
6753 |
|
6754 | var i = 0
|
6755 | var mul = 1
|
6756 | var sub = 0
|
6757 | this[offset] = value & 0xFF
|
6758 | while (++i < byteLength && (mul *= 0x100)) {
|
6759 | if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
6760 | sub = 1
|
6761 | }
|
6762 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
6763 | }
|
6764 |
|
6765 | return offset + byteLength
|
6766 | }
|
6767 |
|
6768 | Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
6769 | value = +value
|
6770 | offset = offset | 0
|
6771 | if (!noAssert) {
|
6772 | var limit = Math.pow(2, 8 * byteLength - 1)
|
6773 |
|
6774 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
6775 | }
|
6776 |
|
6777 | var i = byteLength - 1
|
6778 | var mul = 1
|
6779 | var sub = 0
|
6780 | this[offset + i] = value & 0xFF
|
6781 | while (--i >= 0 && (mul *= 0x100)) {
|
6782 | if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
6783 | sub = 1
|
6784 | }
|
6785 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
6786 | }
|
6787 |
|
6788 | return offset + byteLength
|
6789 | }
|
6790 |
|
6791 | Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
6792 | value = +value
|
6793 | offset = offset | 0
|
6794 | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
6795 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
6796 | if (value < 0) value = 0xff + value + 1
|
6797 | this[offset] = (value & 0xff)
|
6798 | return offset + 1
|
6799 | }
|
6800 |
|
6801 | Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
6802 | value = +value
|
6803 | offset = offset | 0
|
6804 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
6805 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6806 | this[offset] = (value & 0xff)
|
6807 | this[offset + 1] = (value >>> 8)
|
6808 | } else {
|
6809 | objectWriteUInt16(this, value, offset, true)
|
6810 | }
|
6811 | return offset + 2
|
6812 | }
|
6813 |
|
6814 | Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
6815 | value = +value
|
6816 | offset = offset | 0
|
6817 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
6818 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6819 | this[offset] = (value >>> 8)
|
6820 | this[offset + 1] = (value & 0xff)
|
6821 | } else {
|
6822 | objectWriteUInt16(this, value, offset, false)
|
6823 | }
|
6824 | return offset + 2
|
6825 | }
|
6826 |
|
6827 | Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
6828 | value = +value
|
6829 | offset = offset | 0
|
6830 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
6831 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6832 | this[offset] = (value & 0xff)
|
6833 | this[offset + 1] = (value >>> 8)
|
6834 | this[offset + 2] = (value >>> 16)
|
6835 | this[offset + 3] = (value >>> 24)
|
6836 | } else {
|
6837 | objectWriteUInt32(this, value, offset, true)
|
6838 | }
|
6839 | return offset + 4
|
6840 | }
|
6841 |
|
6842 | Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
6843 | value = +value
|
6844 | offset = offset | 0
|
6845 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
6846 | if (value < 0) value = 0xffffffff + value + 1
|
6847 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6848 | this[offset] = (value >>> 24)
|
6849 | this[offset + 1] = (value >>> 16)
|
6850 | this[offset + 2] = (value >>> 8)
|
6851 | this[offset + 3] = (value & 0xff)
|
6852 | } else {
|
6853 | objectWriteUInt32(this, value, offset, false)
|
6854 | }
|
6855 | return offset + 4
|
6856 | }
|
6857 |
|
6858 | function checkIEEE754 (buf, value, offset, ext, max, min) {
|
6859 | if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
6860 | if (offset < 0) throw new RangeError('Index out of range')
|
6861 | }
|
6862 |
|
6863 | function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
6864 | if (!noAssert) {
|
6865 | checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
6866 | }
|
6867 | ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
6868 | return offset + 4
|
6869 | }
|
6870 |
|
6871 | Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
6872 | return writeFloat(this, value, offset, true, noAssert)
|
6873 | }
|
6874 |
|
6875 | Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
6876 | return writeFloat(this, value, offset, false, noAssert)
|
6877 | }
|
6878 |
|
6879 | function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
6880 | if (!noAssert) {
|
6881 | checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
6882 | }
|
6883 | ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
6884 | return offset + 8
|
6885 | }
|
6886 |
|
6887 | Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
6888 | return writeDouble(this, value, offset, true, noAssert)
|
6889 | }
|
6890 |
|
6891 | Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
6892 | return writeDouble(this, value, offset, false, noAssert)
|
6893 | }
|
6894 |
|
6895 |
|
6896 | Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
6897 | if (!start) start = 0
|
6898 | if (!end && end !== 0) end = this.length
|
6899 | if (targetStart >= target.length) targetStart = target.length
|
6900 | if (!targetStart) targetStart = 0
|
6901 | if (end > 0 && end < start) end = start
|
6902 |
|
6903 |
|
6904 | if (end === start) return 0
|
6905 | if (target.length === 0 || this.length === 0) return 0
|
6906 |
|
6907 |
|
6908 | if (targetStart < 0) {
|
6909 | throw new RangeError('targetStart out of bounds')
|
6910 | }
|
6911 | if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
6912 | if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
6913 |
|
6914 |
|
6915 | if (end > this.length) end = this.length
|
6916 | if (target.length - targetStart < end - start) {
|
6917 | end = target.length - targetStart + start
|
6918 | }
|
6919 |
|
6920 | var len = end - start
|
6921 | var i
|
6922 |
|
6923 | if (this === target && start < targetStart && targetStart < end) {
|
6924 |
|
6925 | for (i = len - 1; i >= 0; --i) {
|
6926 | target[i + targetStart] = this[i + start]
|
6927 | }
|
6928 | } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
6929 |
|
6930 | for (i = 0; i < len; ++i) {
|
6931 | target[i + targetStart] = this[i + start]
|
6932 | }
|
6933 | } else {
|
6934 | Uint8Array.prototype.set.call(
|
6935 | target,
|
6936 | this.subarray(start, start + len),
|
6937 | targetStart
|
6938 | )
|
6939 | }
|
6940 |
|
6941 | return len
|
6942 | }
|
6943 |
|
6944 |
|
6945 |
|
6946 |
|
6947 |
|
6948 | Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
6949 |
|
6950 | if (typeof val === 'string') {
|
6951 | if (typeof start === 'string') {
|
6952 | encoding = start
|
6953 | start = 0
|
6954 | end = this.length
|
6955 | } else if (typeof end === 'string') {
|
6956 | encoding = end
|
6957 | end = this.length
|
6958 | }
|
6959 | if (val.length === 1) {
|
6960 | var code = val.charCodeAt(0)
|
6961 | if (code < 256) {
|
6962 | val = code
|
6963 | }
|
6964 | }
|
6965 | if (encoding !== undefined && typeof encoding !== 'string') {
|
6966 | throw new TypeError('encoding must be a string')
|
6967 | }
|
6968 | if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
6969 | throw new TypeError('Unknown encoding: ' + encoding)
|
6970 | }
|
6971 | } else if (typeof val === 'number') {
|
6972 | val = val & 255
|
6973 | }
|
6974 |
|
6975 |
|
6976 | if (start < 0 || this.length < start || this.length < end) {
|
6977 | throw new RangeError('Out of range index')
|
6978 | }
|
6979 |
|
6980 | if (end <= start) {
|
6981 | return this
|
6982 | }
|
6983 |
|
6984 | start = start >>> 0
|
6985 | end = end === undefined ? this.length : end >>> 0
|
6986 |
|
6987 | if (!val) val = 0
|
6988 |
|
6989 | var i
|
6990 | if (typeof val === 'number') {
|
6991 | for (i = start; i < end; ++i) {
|
6992 | this[i] = val
|
6993 | }
|
6994 | } else {
|
6995 | var bytes = Buffer.isBuffer(val)
|
6996 | ? val
|
6997 | : utf8ToBytes(new Buffer(val, encoding).toString())
|
6998 | var len = bytes.length
|
6999 | for (i = 0; i < end - start; ++i) {
|
7000 | this[i + start] = bytes[i % len]
|
7001 | }
|
7002 | }
|
7003 |
|
7004 | return this
|
7005 | }
|
7006 |
|
7007 |
|
7008 |
|
7009 |
|
7010 | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
7011 |
|
7012 | function base64clean (str) {
|
7013 |
|
7014 | str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
7015 |
|
7016 | if (str.length < 2) return ''
|
7017 |
|
7018 | while (str.length % 4 !== 0) {
|
7019 | str = str + '='
|
7020 | }
|
7021 | return str
|
7022 | }
|
7023 |
|
7024 | function stringtrim (str) {
|
7025 | if (str.trim) return str.trim()
|
7026 | return str.replace(/^\s+|\s+$/g, '')
|
7027 | }
|
7028 |
|
7029 | function toHex (n) {
|
7030 | if (n < 16) return '0' + n.toString(16)
|
7031 | return n.toString(16)
|
7032 | }
|
7033 |
|
7034 | function utf8ToBytes (string, units) {
|
7035 | units = units || Infinity
|
7036 | var codePoint
|
7037 | var length = string.length
|
7038 | var leadSurrogate = null
|
7039 | var bytes = []
|
7040 |
|
7041 | for (var i = 0; i < length; ++i) {
|
7042 | codePoint = string.charCodeAt(i)
|
7043 |
|
7044 |
|
7045 | if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
7046 |
|
7047 | if (!leadSurrogate) {
|
7048 |
|
7049 | if (codePoint > 0xDBFF) {
|
7050 |
|
7051 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7052 | continue
|
7053 | } else if (i + 1 === length) {
|
7054 |
|
7055 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7056 | continue
|
7057 | }
|
7058 |
|
7059 |
|
7060 | leadSurrogate = codePoint
|
7061 |
|
7062 | continue
|
7063 | }
|
7064 |
|
7065 |
|
7066 | if (codePoint < 0xDC00) {
|
7067 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7068 | leadSurrogate = codePoint
|
7069 | continue
|
7070 | }
|
7071 |
|
7072 |
|
7073 | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
7074 | } else if (leadSurrogate) {
|
7075 |
|
7076 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7077 | }
|
7078 |
|
7079 | leadSurrogate = null
|
7080 |
|
7081 |
|
7082 | if (codePoint < 0x80) {
|
7083 | if ((units -= 1) < 0) break
|
7084 | bytes.push(codePoint)
|
7085 | } else if (codePoint < 0x800) {
|
7086 | if ((units -= 2) < 0) break
|
7087 | bytes.push(
|
7088 | codePoint >> 0x6 | 0xC0,
|
7089 | codePoint & 0x3F | 0x80
|
7090 | )
|
7091 | } else if (codePoint < 0x10000) {
|
7092 | if ((units -= 3) < 0) break
|
7093 | bytes.push(
|
7094 | codePoint >> 0xC | 0xE0,
|
7095 | codePoint >> 0x6 & 0x3F | 0x80,
|
7096 | codePoint & 0x3F | 0x80
|
7097 | )
|
7098 | } else if (codePoint < 0x110000) {
|
7099 | if ((units -= 4) < 0) break
|
7100 | bytes.push(
|
7101 | codePoint >> 0x12 | 0xF0,
|
7102 | codePoint >> 0xC & 0x3F | 0x80,
|
7103 | codePoint >> 0x6 & 0x3F | 0x80,
|
7104 | codePoint & 0x3F | 0x80
|
7105 | )
|
7106 | } else {
|
7107 | throw new Error('Invalid code point')
|
7108 | }
|
7109 | }
|
7110 |
|
7111 | return bytes
|
7112 | }
|
7113 |
|
7114 | function asciiToBytes (str) {
|
7115 | var byteArray = []
|
7116 | for (var i = 0; i < str.length; ++i) {
|
7117 |
|
7118 | byteArray.push(str.charCodeAt(i) & 0xFF)
|
7119 | }
|
7120 | return byteArray
|
7121 | }
|
7122 |
|
7123 | function utf16leToBytes (str, units) {
|
7124 | var c, hi, lo
|
7125 | var byteArray = []
|
7126 | for (var i = 0; i < str.length; ++i) {
|
7127 | if ((units -= 2) < 0) break
|
7128 |
|
7129 | c = str.charCodeAt(i)
|
7130 | hi = c >> 8
|
7131 | lo = c % 256
|
7132 | byteArray.push(lo)
|
7133 | byteArray.push(hi)
|
7134 | }
|
7135 |
|
7136 | return byteArray
|
7137 | }
|
7138 |
|
7139 | function base64ToBytes (str) {
|
7140 | return base64.toByteArray(base64clean(str))
|
7141 | }
|
7142 |
|
7143 | function blitBuffer (src, dst, offset, length) {
|
7144 | for (var i = 0; i < length; ++i) {
|
7145 | if ((i + offset >= dst.length) || (i >= src.length)) break
|
7146 | dst[i + offset] = src[i]
|
7147 | }
|
7148 | return i
|
7149 | }
|
7150 |
|
7151 | function isnan (val) {
|
7152 | return val !== val
|
7153 | }
|
7154 |
|
7155 | }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
|
7156 |
|
7157 | },{"base64-js":40,"buffer":41,"ieee754":44,"isarray":45}],42:[function(require,module,exports){
|
7158 | (function (process){(function (){
|
7159 |
|
7160 |
|
7161 |
|
7162 |
|
7163 |
|
7164 |
|
7165 | exports = module.exports = require('./debug');
|
7166 | exports.log = log;
|
7167 | exports.formatArgs = formatArgs;
|
7168 | exports.save = save;
|
7169 | exports.load = load;
|
7170 | exports.useColors = useColors;
|
7171 | exports.storage = 'undefined' != typeof chrome
|
7172 | && 'undefined' != typeof chrome.storage
|
7173 | ? chrome.storage.local
|
7174 | : localstorage();
|
7175 |
|
7176 |
|
7177 |
|
7178 |
|
7179 |
|
7180 | exports.colors = [
|
7181 | 'lightseagreen',
|
7182 | 'forestgreen',
|
7183 | 'goldenrod',
|
7184 | 'dodgerblue',
|
7185 | 'darkorchid',
|
7186 | 'crimson'
|
7187 | ];
|
7188 |
|
7189 |
|
7190 |
|
7191 |
|
7192 |
|
7193 |
|
7194 |
|
7195 |
|
7196 |
|
7197 | function useColors() {
|
7198 |
|
7199 |
|
7200 |
|
7201 | if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
|
7202 | return true;
|
7203 | }
|
7204 |
|
7205 |
|
7206 |
|
7207 | return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
7208 |
|
7209 | (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
7210 |
|
7211 |
|
7212 | (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
7213 |
|
7214 | (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
7215 | }
|
7216 |
|
7217 |
|
7218 |
|
7219 |
|
7220 |
|
7221 | exports.formatters.j = function(v) {
|
7222 | try {
|
7223 | return JSON.stringify(v);
|
7224 | } catch (err) {
|
7225 | return '[UnexpectedJSONParseError]: ' + err.message;
|
7226 | }
|
7227 | };
|
7228 |
|
7229 |
|
7230 |
|
7231 |
|
7232 |
|
7233 |
|
7234 |
|
7235 |
|
7236 | function formatArgs(args) {
|
7237 | var useColors = this.useColors;
|
7238 |
|
7239 | args[0] = (useColors ? '%c' : '')
|
7240 | + this.namespace
|
7241 | + (useColors ? ' %c' : ' ')
|
7242 | + args[0]
|
7243 | + (useColors ? '%c ' : ' ')
|
7244 | + '+' + exports.humanize(this.diff);
|
7245 |
|
7246 | if (!useColors) return;
|
7247 |
|
7248 | var c = 'color: ' + this.color;
|
7249 | args.splice(1, 0, c, 'color: inherit')
|
7250 |
|
7251 |
|
7252 |
|
7253 |
|
7254 | var index = 0;
|
7255 | var lastC = 0;
|
7256 | args[0].replace(/%[a-zA-Z%]/g, function(match) {
|
7257 | if ('%%' === match) return;
|
7258 | index++;
|
7259 | if ('%c' === match) {
|
7260 |
|
7261 |
|
7262 | lastC = index;
|
7263 | }
|
7264 | });
|
7265 |
|
7266 | args.splice(lastC, 0, c);
|
7267 | }
|
7268 |
|
7269 |
|
7270 |
|
7271 |
|
7272 |
|
7273 |
|
7274 |
|
7275 |
|
7276 | function log() {
|
7277 |
|
7278 |
|
7279 | return 'object' === typeof console
|
7280 | && console.log
|
7281 | && Function.prototype.apply.call(console.log, console, arguments);
|
7282 | }
|
7283 |
|
7284 |
|
7285 |
|
7286 |
|
7287 |
|
7288 |
|
7289 |
|
7290 |
|
7291 | function save(namespaces) {
|
7292 | try {
|
7293 | if (null == namespaces) {
|
7294 | exports.storage.removeItem('debug');
|
7295 | } else {
|
7296 | exports.storage.debug = namespaces;
|
7297 | }
|
7298 | } catch(e) {}
|
7299 | }
|
7300 |
|
7301 |
|
7302 |
|
7303 |
|
7304 |
|
7305 |
|
7306 |
|
7307 |
|
7308 | function load() {
|
7309 | var r;
|
7310 | try {
|
7311 | r = exports.storage.debug;
|
7312 | } catch(e) {}
|
7313 |
|
7314 |
|
7315 | if (!r && typeof process !== 'undefined' && 'env' in process) {
|
7316 | r = process.env.DEBUG;
|
7317 | }
|
7318 |
|
7319 | return r;
|
7320 | }
|
7321 |
|
7322 |
|
7323 |
|
7324 |
|
7325 |
|
7326 | exports.enable(load());
|
7327 |
|
7328 |
|
7329 |
|
7330 |
|
7331 |
|
7332 |
|
7333 |
|
7334 |
|
7335 |
|
7336 |
|
7337 |
|
7338 |
|
7339 | function localstorage() {
|
7340 | try {
|
7341 | return window.localStorage;
|
7342 | } catch (e) {}
|
7343 | }
|
7344 |
|
7345 | }).call(this)}).call(this,require('_process'))
|
7346 |
|
7347 | },{"./debug":43,"_process":48}],43:[function(require,module,exports){
|
7348 |
|
7349 |
|
7350 |
|
7351 |
|
7352 |
|
7353 |
|
7354 |
|
7355 |
|
7356 | exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
|
7357 | exports.coerce = coerce;
|
7358 | exports.disable = disable;
|
7359 | exports.enable = enable;
|
7360 | exports.enabled = enabled;
|
7361 | exports.humanize = require('ms');
|
7362 |
|
7363 |
|
7364 |
|
7365 |
|
7366 |
|
7367 | exports.names = [];
|
7368 | exports.skips = [];
|
7369 |
|
7370 |
|
7371 |
|
7372 |
|
7373 |
|
7374 |
|
7375 |
|
7376 | exports.formatters = {};
|
7377 |
|
7378 |
|
7379 |
|
7380 |
|
7381 |
|
7382 | var prevTime;
|
7383 |
|
7384 |
|
7385 |
|
7386 |
|
7387 |
|
7388 |
|
7389 |
|
7390 |
|
7391 | function selectColor(namespace) {
|
7392 | var hash = 0, i;
|
7393 |
|
7394 | for (i in namespace) {
|
7395 | hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
7396 | hash |= 0;
|
7397 | }
|
7398 |
|
7399 | return exports.colors[Math.abs(hash) % exports.colors.length];
|
7400 | }
|
7401 |
|
7402 |
|
7403 |
|
7404 |
|
7405 |
|
7406 |
|
7407 |
|
7408 |
|
7409 |
|
7410 | function createDebug(namespace) {
|
7411 |
|
7412 | function debug() {
|
7413 |
|
7414 | if (!debug.enabled) return;
|
7415 |
|
7416 | var self = debug;
|
7417 |
|
7418 |
|
7419 | var curr = +new Date();
|
7420 | var ms = curr - (prevTime || curr);
|
7421 | self.diff = ms;
|
7422 | self.prev = prevTime;
|
7423 | self.curr = curr;
|
7424 | prevTime = curr;
|
7425 |
|
7426 |
|
7427 | var args = new Array(arguments.length);
|
7428 | for (var i = 0; i < args.length; i++) {
|
7429 | args[i] = arguments[i];
|
7430 | }
|
7431 |
|
7432 | args[0] = exports.coerce(args[0]);
|
7433 |
|
7434 | if ('string' !== typeof args[0]) {
|
7435 |
|
7436 | args.unshift('%O');
|
7437 | }
|
7438 |
|
7439 |
|
7440 | var index = 0;
|
7441 | args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
7442 |
|
7443 | if (match === '%%') return match;
|
7444 | index++;
|
7445 | var formatter = exports.formatters[format];
|
7446 | if ('function' === typeof formatter) {
|
7447 | var val = args[index];
|
7448 | match = formatter.call(self, val);
|
7449 |
|
7450 |
|
7451 | args.splice(index, 1);
|
7452 | index--;
|
7453 | }
|
7454 | return match;
|
7455 | });
|
7456 |
|
7457 |
|
7458 | exports.formatArgs.call(self, args);
|
7459 |
|
7460 | var logFn = debug.log || exports.log || console.log.bind(console);
|
7461 | logFn.apply(self, args);
|
7462 | }
|
7463 |
|
7464 | debug.namespace = namespace;
|
7465 | debug.enabled = exports.enabled(namespace);
|
7466 | debug.useColors = exports.useColors();
|
7467 | debug.color = selectColor(namespace);
|
7468 |
|
7469 |
|
7470 | if ('function' === typeof exports.init) {
|
7471 | exports.init(debug);
|
7472 | }
|
7473 |
|
7474 | return debug;
|
7475 | }
|
7476 |
|
7477 |
|
7478 |
|
7479 |
|
7480 |
|
7481 |
|
7482 |
|
7483 |
|
7484 |
|
7485 | function enable(namespaces) {
|
7486 | exports.save(namespaces);
|
7487 |
|
7488 | exports.names = [];
|
7489 | exports.skips = [];
|
7490 |
|
7491 | var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
7492 | var len = split.length;
|
7493 |
|
7494 | for (var i = 0; i < len; i++) {
|
7495 | if (!split[i]) continue;
|
7496 | namespaces = split[i].replace(/\*/g, '.*?');
|
7497 | if (namespaces[0] === '-') {
|
7498 | exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
7499 | } else {
|
7500 | exports.names.push(new RegExp('^' + namespaces + '$'));
|
7501 | }
|
7502 | }
|
7503 | }
|
7504 |
|
7505 |
|
7506 |
|
7507 |
|
7508 |
|
7509 |
|
7510 |
|
7511 | function disable() {
|
7512 | exports.enable('');
|
7513 | }
|
7514 |
|
7515 |
|
7516 |
|
7517 |
|
7518 |
|
7519 |
|
7520 |
|
7521 |
|
7522 |
|
7523 | function enabled(name) {
|
7524 | var i, len;
|
7525 | for (i = 0, len = exports.skips.length; i < len; i++) {
|
7526 | if (exports.skips[i].test(name)) {
|
7527 | return false;
|
7528 | }
|
7529 | }
|
7530 | for (i = 0, len = exports.names.length; i < len; i++) {
|
7531 | if (exports.names[i].test(name)) {
|
7532 | return true;
|
7533 | }
|
7534 | }
|
7535 | return false;
|
7536 | }
|
7537 |
|
7538 |
|
7539 |
|
7540 |
|
7541 |
|
7542 |
|
7543 |
|
7544 |
|
7545 |
|
7546 | function coerce(val) {
|
7547 | if (val instanceof Error) return val.stack || val.message;
|
7548 | return val;
|
7549 | }
|
7550 |
|
7551 | },{"ms":47}],44:[function(require,module,exports){
|
7552 |
|
7553 | exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
7554 | var e, m
|
7555 | var eLen = (nBytes * 8) - mLen - 1
|
7556 | var eMax = (1 << eLen) - 1
|
7557 | var eBias = eMax >> 1
|
7558 | var nBits = -7
|
7559 | var i = isLE ? (nBytes - 1) : 0
|
7560 | var d = isLE ? -1 : 1
|
7561 | var s = buffer[offset + i]
|
7562 |
|
7563 | i += d
|
7564 |
|
7565 | e = s & ((1 << (-nBits)) - 1)
|
7566 | s >>= (-nBits)
|
7567 | nBits += eLen
|
7568 | for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
7569 |
|
7570 | m = e & ((1 << (-nBits)) - 1)
|
7571 | e >>= (-nBits)
|
7572 | nBits += mLen
|
7573 | for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
7574 |
|
7575 | if (e === 0) {
|
7576 | e = 1 - eBias
|
7577 | } else if (e === eMax) {
|
7578 | return m ? NaN : ((s ? -1 : 1) * Infinity)
|
7579 | } else {
|
7580 | m = m + Math.pow(2, mLen)
|
7581 | e = e - eBias
|
7582 | }
|
7583 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
7584 | }
|
7585 |
|
7586 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
7587 | var e, m, c
|
7588 | var eLen = (nBytes * 8) - mLen - 1
|
7589 | var eMax = (1 << eLen) - 1
|
7590 | var eBias = eMax >> 1
|
7591 | var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
7592 | var i = isLE ? 0 : (nBytes - 1)
|
7593 | var d = isLE ? 1 : -1
|
7594 | var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
7595 |
|
7596 | value = Math.abs(value)
|
7597 |
|
7598 | if (isNaN(value) || value === Infinity) {
|
7599 | m = isNaN(value) ? 1 : 0
|
7600 | e = eMax
|
7601 | } else {
|
7602 | e = Math.floor(Math.log(value) / Math.LN2)
|
7603 | if (value * (c = Math.pow(2, -e)) < 1) {
|
7604 | e--
|
7605 | c *= 2
|
7606 | }
|
7607 | if (e + eBias >= 1) {
|
7608 | value += rt / c
|
7609 | } else {
|
7610 | value += rt * Math.pow(2, 1 - eBias)
|
7611 | }
|
7612 | if (value * c >= 2) {
|
7613 | e++
|
7614 | c /= 2
|
7615 | }
|
7616 |
|
7617 | if (e + eBias >= eMax) {
|
7618 | m = 0
|
7619 | e = eMax
|
7620 | } else if (e + eBias >= 1) {
|
7621 | m = ((value * c) - 1) * Math.pow(2, mLen)
|
7622 | e = e + eBias
|
7623 | } else {
|
7624 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
7625 | e = 0
|
7626 | }
|
7627 | }
|
7628 |
|
7629 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
7630 |
|
7631 | e = (e << mLen) | m
|
7632 | eLen += mLen
|
7633 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
7634 |
|
7635 | buffer[offset + i - d] |= s * 128
|
7636 | }
|
7637 |
|
7638 | },{}],45:[function(require,module,exports){
|
7639 | var toString = {}.toString;
|
7640 |
|
7641 | module.exports = Array.isArray || function (arr) {
|
7642 | return toString.call(arr) == '[object Array]';
|
7643 | };
|
7644 |
|
7645 | },{}],46:[function(require,module,exports){
|
7646 | (function (global){(function (){
|
7647 |
|
7648 |
|
7649 |
|
7650 |
|
7651 |
|
7652 |
|
7653 |
|
7654 |
|
7655 |
|
7656 | ;(function (global, factory) {
|
7657 | typeof exports === 'object' && typeof module !== 'undefined'
|
7658 | ? module.exports = factory(global)
|
7659 | : typeof define === 'function' && define.amd
|
7660 | ? define(factory) : factory(global)
|
7661 | }((
|
7662 | typeof self !== 'undefined' ? self
|
7663 | : typeof window !== 'undefined' ? window
|
7664 | : typeof global !== 'undefined' ? global
|
7665 | : this
|
7666 | ), function(global) {
|
7667 | 'use strict';
|
7668 |
|
7669 | global = global || {};
|
7670 | var _Base64 = global.Base64;
|
7671 | var version = "2.6.4";
|
7672 |
|
7673 | var b64chars
|
7674 | = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
7675 | var b64tab = function(bin) {
|
7676 | var t = {};
|
7677 | for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
|
7678 | return t;
|
7679 | }(b64chars);
|
7680 | var fromCharCode = String.fromCharCode;
|
7681 |
|
7682 | var cb_utob = function(c) {
|
7683 | if (c.length < 2) {
|
7684 | var cc = c.charCodeAt(0);
|
7685 | return cc < 0x80 ? c
|
7686 | : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
|
7687 | + fromCharCode(0x80 | (cc & 0x3f)))
|
7688 | : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
|
7689 | + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
7690 | + fromCharCode(0x80 | ( cc & 0x3f)));
|
7691 | } else {
|
7692 | var cc = 0x10000
|
7693 | + (c.charCodeAt(0) - 0xD800) * 0x400
|
7694 | + (c.charCodeAt(1) - 0xDC00);
|
7695 | return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
|
7696 | + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
|
7697 | + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
7698 | + fromCharCode(0x80 | ( cc & 0x3f)));
|
7699 | }
|
7700 | };
|
7701 | var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
7702 | var utob = function(u) {
|
7703 | return u.replace(re_utob, cb_utob);
|
7704 | };
|
7705 | var cb_encode = function(ccc) {
|
7706 | var padlen = [0, 2, 1][ccc.length % 3],
|
7707 | ord = ccc.charCodeAt(0) << 16
|
7708 | | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
|
7709 | | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
|
7710 | chars = [
|
7711 | b64chars.charAt( ord >>> 18),
|
7712 | b64chars.charAt((ord >>> 12) & 63),
|
7713 | padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
|
7714 | padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
|
7715 | ];
|
7716 | return chars.join('');
|
7717 | };
|
7718 | var btoa = global.btoa && typeof global.btoa == 'function'
|
7719 | ? function(b){ return global.btoa(b) } : function(b) {
|
7720 | if (b.match(/[^\x00-\xFF]/)) throw new RangeError(
|
7721 | 'The string contains invalid characters.'
|
7722 | );
|
7723 | return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
7724 | };
|
7725 | var _encode = function(u) {
|
7726 | return btoa(utob(String(u)));
|
7727 | };
|
7728 | var mkUriSafe = function (b64) {
|
7729 | return b64.replace(/[+\/]/g, function(m0) {
|
7730 | return m0 == '+' ? '-' : '_';
|
7731 | }).replace(/=/g, '');
|
7732 | };
|
7733 | var encode = function(u, urisafe) {
|
7734 | return urisafe ? mkUriSafe(_encode(u)) : _encode(u);
|
7735 | };
|
7736 | var encodeURI = function(u) { return encode(u, true) };
|
7737 | var fromUint8Array;
|
7738 | if (global.Uint8Array) fromUint8Array = function(a, urisafe) {
|
7739 |
|
7740 | var b64 = '';
|
7741 | for (var i = 0, l = a.length; i < l; i += 3) {
|
7742 | var a0 = a[i], a1 = a[i+1], a2 = a[i+2];
|
7743 | var ord = a0 << 16 | a1 << 8 | a2;
|
7744 | b64 += b64chars.charAt( ord >>> 18)
|
7745 | + b64chars.charAt((ord >>> 12) & 63)
|
7746 | + ( typeof a1 != 'undefined'
|
7747 | ? b64chars.charAt((ord >>> 6) & 63) : '=')
|
7748 | + ( typeof a2 != 'undefined'
|
7749 | ? b64chars.charAt( ord & 63) : '=');
|
7750 | }
|
7751 | return urisafe ? mkUriSafe(b64) : b64;
|
7752 | };
|
7753 |
|
7754 | var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
7755 | var cb_btou = function(cccc) {
|
7756 | switch(cccc.length) {
|
7757 | case 4:
|
7758 | var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
|
7759 | | ((0x3f & cccc.charCodeAt(1)) << 12)
|
7760 | | ((0x3f & cccc.charCodeAt(2)) << 6)
|
7761 | | (0x3f & cccc.charCodeAt(3)),
|
7762 | offset = cp - 0x10000;
|
7763 | return (fromCharCode((offset >>> 10) + 0xD800)
|
7764 | + fromCharCode((offset & 0x3FF) + 0xDC00));
|
7765 | case 3:
|
7766 | return fromCharCode(
|
7767 | ((0x0f & cccc.charCodeAt(0)) << 12)
|
7768 | | ((0x3f & cccc.charCodeAt(1)) << 6)
|
7769 | | (0x3f & cccc.charCodeAt(2))
|
7770 | );
|
7771 | default:
|
7772 | return fromCharCode(
|
7773 | ((0x1f & cccc.charCodeAt(0)) << 6)
|
7774 | | (0x3f & cccc.charCodeAt(1))
|
7775 | );
|
7776 | }
|
7777 | };
|
7778 | var btou = function(b) {
|
7779 | return b.replace(re_btou, cb_btou);
|
7780 | };
|
7781 | var cb_decode = function(cccc) {
|
7782 | var len = cccc.length,
|
7783 | padlen = len % 4,
|
7784 | n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
|
7785 | | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
|
7786 | | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
|
7787 | | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
|
7788 | chars = [
|
7789 | fromCharCode( n >>> 16),
|
7790 | fromCharCode((n >>> 8) & 0xff),
|
7791 | fromCharCode( n & 0xff)
|
7792 | ];
|
7793 | chars.length -= [0, 0, 2, 1][padlen];
|
7794 | return chars.join('');
|
7795 | };
|
7796 | var _atob = global.atob && typeof global.atob == 'function'
|
7797 | ? function(a){ return global.atob(a) } : function(a){
|
7798 | return a.replace(/\S{1,4}/g, cb_decode);
|
7799 | };
|
7800 | var atob = function(a) {
|
7801 | return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
|
7802 | };
|
7803 | var _decode = function(a) { return btou(_atob(a)) };
|
7804 | var _fromURI = function(a) {
|
7805 | return String(a).replace(/[-_]/g, function(m0) {
|
7806 | return m0 == '-' ? '+' : '/'
|
7807 | }).replace(/[^A-Za-z0-9\+\/]/g, '');
|
7808 | };
|
7809 | var decode = function(a){
|
7810 | return _decode(_fromURI(a));
|
7811 | };
|
7812 | var toUint8Array;
|
7813 | if (global.Uint8Array) toUint8Array = function(a) {
|
7814 | return Uint8Array.from(atob(_fromURI(a)), function(c) {
|
7815 | return c.charCodeAt(0);
|
7816 | });
|
7817 | };
|
7818 | var noConflict = function() {
|
7819 | var Base64 = global.Base64;
|
7820 | global.Base64 = _Base64;
|
7821 | return Base64;
|
7822 | };
|
7823 |
|
7824 | global.Base64 = {
|
7825 | VERSION: version,
|
7826 | atob: atob,
|
7827 | btoa: btoa,
|
7828 | fromBase64: decode,
|
7829 | toBase64: encode,
|
7830 | utob: utob,
|
7831 | encode: encode,
|
7832 | encodeURI: encodeURI,
|
7833 | btou: btou,
|
7834 | decode: decode,
|
7835 | noConflict: noConflict,
|
7836 | fromUint8Array: fromUint8Array,
|
7837 | toUint8Array: toUint8Array
|
7838 | };
|
7839 |
|
7840 | if (typeof Object.defineProperty === 'function') {
|
7841 | var noEnum = function(v){
|
7842 | return {value:v,enumerable:false,writable:true,configurable:true};
|
7843 | };
|
7844 | global.Base64.extendString = function () {
|
7845 | Object.defineProperty(
|
7846 | String.prototype, 'fromBase64', noEnum(function () {
|
7847 | return decode(this)
|
7848 | }));
|
7849 | Object.defineProperty(
|
7850 | String.prototype, 'toBase64', noEnum(function (urisafe) {
|
7851 | return encode(this, urisafe)
|
7852 | }));
|
7853 | Object.defineProperty(
|
7854 | String.prototype, 'toBase64URI', noEnum(function () {
|
7855 | return encode(this, true)
|
7856 | }));
|
7857 | };
|
7858 | }
|
7859 |
|
7860 |
|
7861 |
|
7862 | if (global['Meteor']) {
|
7863 | Base64 = global.Base64;
|
7864 | }
|
7865 |
|
7866 |
|
7867 | if (typeof module !== 'undefined' && module.exports) {
|
7868 | module.exports.Base64 = global.Base64;
|
7869 | }
|
7870 | else if (typeof define === 'function' && define.amd) {
|
7871 |
|
7872 | define([], function(){ return global.Base64 });
|
7873 | }
|
7874 |
|
7875 | return {Base64: global.Base64}
|
7876 | }));
|
7877 |
|
7878 | }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
7879 |
|
7880 | },{}],47:[function(require,module,exports){
|
7881 |
|
7882 |
|
7883 |
|
7884 |
|
7885 | var s = 1000;
|
7886 | var m = s * 60;
|
7887 | var h = m * 60;
|
7888 | var d = h * 24;
|
7889 | var y = d * 365.25;
|
7890 |
|
7891 |
|
7892 |
|
7893 |
|
7894 |
|
7895 |
|
7896 |
|
7897 |
|
7898 |
|
7899 |
|
7900 |
|
7901 |
|
7902 |
|
7903 |
|
7904 |
|
7905 | module.exports = function(val, options) {
|
7906 | options = options || {};
|
7907 | var type = typeof val;
|
7908 | if (type === 'string' && val.length > 0) {
|
7909 | return parse(val);
|
7910 | } else if (type === 'number' && isNaN(val) === false) {
|
7911 | return options.long ? fmtLong(val) : fmtShort(val);
|
7912 | }
|
7913 | throw new Error(
|
7914 | 'val is not a non-empty string or a valid number. val=' +
|
7915 | JSON.stringify(val)
|
7916 | );
|
7917 | };
|
7918 |
|
7919 |
|
7920 |
|
7921 |
|
7922 |
|
7923 |
|
7924 |
|
7925 |
|
7926 |
|
7927 | function parse(str) {
|
7928 | str = String(str);
|
7929 | if (str.length > 100) {
|
7930 | return;
|
7931 | }
|
7932 | var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
|
7933 | str
|
7934 | );
|
7935 | if (!match) {
|
7936 | return;
|
7937 | }
|
7938 | var n = parseFloat(match[1]);
|
7939 | var type = (match[2] || 'ms').toLowerCase();
|
7940 | switch (type) {
|
7941 | case 'years':
|
7942 | case 'year':
|
7943 | case 'yrs':
|
7944 | case 'yr':
|
7945 | case 'y':
|
7946 | return n * y;
|
7947 | case 'days':
|
7948 | case 'day':
|
7949 | case 'd':
|
7950 | return n * d;
|
7951 | case 'hours':
|
7952 | case 'hour':
|
7953 | case 'hrs':
|
7954 | case 'hr':
|
7955 | case 'h':
|
7956 | return n * h;
|
7957 | case 'minutes':
|
7958 | case 'minute':
|
7959 | case 'mins':
|
7960 | case 'min':
|
7961 | case 'm':
|
7962 | return n * m;
|
7963 | case 'seconds':
|
7964 | case 'second':
|
7965 | case 'secs':
|
7966 | case 'sec':
|
7967 | case 's':
|
7968 | return n * s;
|
7969 | case 'milliseconds':
|
7970 | case 'millisecond':
|
7971 | case 'msecs':
|
7972 | case 'msec':
|
7973 | case 'ms':
|
7974 | return n;
|
7975 | default:
|
7976 | return undefined;
|
7977 | }
|
7978 | }
|
7979 |
|
7980 |
|
7981 |
|
7982 |
|
7983 |
|
7984 |
|
7985 |
|
7986 |
|
7987 |
|
7988 | function fmtShort(ms) {
|
7989 | if (ms >= d) {
|
7990 | return Math.round(ms / d) + 'd';
|
7991 | }
|
7992 | if (ms >= h) {
|
7993 | return Math.round(ms / h) + 'h';
|
7994 | }
|
7995 | if (ms >= m) {
|
7996 | return Math.round(ms / m) + 'm';
|
7997 | }
|
7998 | if (ms >= s) {
|
7999 | return Math.round(ms / s) + 's';
|
8000 | }
|
8001 | return ms + 'ms';
|
8002 | }
|
8003 |
|
8004 |
|
8005 |
|
8006 |
|
8007 |
|
8008 |
|
8009 |
|
8010 |
|
8011 |
|
8012 | function fmtLong(ms) {
|
8013 | return plural(ms, d, 'day') ||
|
8014 | plural(ms, h, 'hour') ||
|
8015 | plural(ms, m, 'minute') ||
|
8016 | plural(ms, s, 'second') ||
|
8017 | ms + ' ms';
|
8018 | }
|
8019 |
|
8020 |
|
8021 |
|
8022 |
|
8023 |
|
8024 | function plural(ms, n, name) {
|
8025 | if (ms < n) {
|
8026 | return;
|
8027 | }
|
8028 | if (ms < n * 1.5) {
|
8029 | return Math.floor(ms / n) + ' ' + name;
|
8030 | }
|
8031 | return Math.ceil(ms / n) + ' ' + name + 's';
|
8032 | }
|
8033 |
|
8034 | },{}],48:[function(require,module,exports){
|
8035 |
|
8036 | var process = module.exports = {};
|
8037 |
|
8038 |
|
8039 |
|
8040 |
|
8041 |
|
8042 |
|
8043 | var cachedSetTimeout;
|
8044 | var cachedClearTimeout;
|
8045 |
|
8046 | function defaultSetTimout() {
|
8047 | throw new Error('setTimeout has not been defined');
|
8048 | }
|
8049 | function defaultClearTimeout () {
|
8050 | throw new Error('clearTimeout has not been defined');
|
8051 | }
|
8052 | (function () {
|
8053 | try {
|
8054 | if (typeof setTimeout === 'function') {
|
8055 | cachedSetTimeout = setTimeout;
|
8056 | } else {
|
8057 | cachedSetTimeout = defaultSetTimout;
|
8058 | }
|
8059 | } catch (e) {
|
8060 | cachedSetTimeout = defaultSetTimout;
|
8061 | }
|
8062 | try {
|
8063 | if (typeof clearTimeout === 'function') {
|
8064 | cachedClearTimeout = clearTimeout;
|
8065 | } else {
|
8066 | cachedClearTimeout = defaultClearTimeout;
|
8067 | }
|
8068 | } catch (e) {
|
8069 | cachedClearTimeout = defaultClearTimeout;
|
8070 | }
|
8071 | } ())
|
8072 | function runTimeout(fun) {
|
8073 | if (cachedSetTimeout === setTimeout) {
|
8074 |
|
8075 | return setTimeout(fun, 0);
|
8076 | }
|
8077 |
|
8078 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
8079 | cachedSetTimeout = setTimeout;
|
8080 | return setTimeout(fun, 0);
|
8081 | }
|
8082 | try {
|
8083 |
|
8084 | return cachedSetTimeout(fun, 0);
|
8085 | } catch(e){
|
8086 | try {
|
8087 |
|
8088 | return cachedSetTimeout.call(null, fun, 0);
|
8089 | } catch(e){
|
8090 |
|
8091 | return cachedSetTimeout.call(this, fun, 0);
|
8092 | }
|
8093 | }
|
8094 |
|
8095 |
|
8096 | }
|
8097 | function runClearTimeout(marker) {
|
8098 | if (cachedClearTimeout === clearTimeout) {
|
8099 |
|
8100 | return clearTimeout(marker);
|
8101 | }
|
8102 |
|
8103 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
8104 | cachedClearTimeout = clearTimeout;
|
8105 | return clearTimeout(marker);
|
8106 | }
|
8107 | try {
|
8108 |
|
8109 | return cachedClearTimeout(marker);
|
8110 | } catch (e){
|
8111 | try {
|
8112 |
|
8113 | return cachedClearTimeout.call(null, marker);
|
8114 | } catch (e){
|
8115 |
|
8116 |
|
8117 | return cachedClearTimeout.call(this, marker);
|
8118 | }
|
8119 | }
|
8120 |
|
8121 |
|
8122 |
|
8123 | }
|
8124 | var queue = [];
|
8125 | var draining = false;
|
8126 | var currentQueue;
|
8127 | var queueIndex = -1;
|
8128 |
|
8129 | function cleanUpNextTick() {
|
8130 | if (!draining || !currentQueue) {
|
8131 | return;
|
8132 | }
|
8133 | draining = false;
|
8134 | if (currentQueue.length) {
|
8135 | queue = currentQueue.concat(queue);
|
8136 | } else {
|
8137 | queueIndex = -1;
|
8138 | }
|
8139 | if (queue.length) {
|
8140 | drainQueue();
|
8141 | }
|
8142 | }
|
8143 |
|
8144 | function drainQueue() {
|
8145 | if (draining) {
|
8146 | return;
|
8147 | }
|
8148 | var timeout = runTimeout(cleanUpNextTick);
|
8149 | draining = true;
|
8150 |
|
8151 | var len = queue.length;
|
8152 | while(len) {
|
8153 | currentQueue = queue;
|
8154 | queue = [];
|
8155 | while (++queueIndex < len) {
|
8156 | if (currentQueue) {
|
8157 | currentQueue[queueIndex].run();
|
8158 | }
|
8159 | }
|
8160 | queueIndex = -1;
|
8161 | len = queue.length;
|
8162 | }
|
8163 | currentQueue = null;
|
8164 | draining = false;
|
8165 | runClearTimeout(timeout);
|
8166 | }
|
8167 |
|
8168 | process.nextTick = function (fun) {
|
8169 | var args = new Array(arguments.length - 1);
|
8170 | if (arguments.length > 1) {
|
8171 | for (var i = 1; i < arguments.length; i++) {
|
8172 | args[i - 1] = arguments[i];
|
8173 | }
|
8174 | }
|
8175 | queue.push(new Item(fun, args));
|
8176 | if (queue.length === 1 && !draining) {
|
8177 | runTimeout(drainQueue);
|
8178 | }
|
8179 | };
|
8180 |
|
8181 |
|
8182 | function Item(fun, array) {
|
8183 | this.fun = fun;
|
8184 | this.array = array;
|
8185 | }
|
8186 | Item.prototype.run = function () {
|
8187 | this.fun.apply(null, this.array);
|
8188 | };
|
8189 | process.title = 'browser';
|
8190 | process.browser = true;
|
8191 | process.env = {};
|
8192 | process.argv = [];
|
8193 | process.version = '';
|
8194 | process.versions = {};
|
8195 |
|
8196 | function noop() {}
|
8197 |
|
8198 | process.on = noop;
|
8199 | process.addListener = noop;
|
8200 | process.once = noop;
|
8201 | process.off = noop;
|
8202 | process.removeListener = noop;
|
8203 | process.removeAllListeners = noop;
|
8204 | process.emit = noop;
|
8205 | process.prependListener = noop;
|
8206 | process.prependOnceListener = noop;
|
8207 |
|
8208 | process.listeners = function (name) { return [] }
|
8209 |
|
8210 | process.binding = function (name) {
|
8211 | throw new Error('process.binding is not supported');
|
8212 | };
|
8213 |
|
8214 | process.cwd = function () { return '/' };
|
8215 | process.chdir = function (dir) {
|
8216 | throw new Error('process.chdir is not supported');
|
8217 | };
|
8218 | process.umask = function() { return 0; };
|
8219 |
|
8220 | },{}],49:[function(require,module,exports){
|
8221 | (function (global){(function (){
|
8222 |
|
8223 | ;(function(root) {
|
8224 |
|
8225 |
|
8226 | var freeExports = typeof exports == 'object' && exports;
|
8227 |
|
8228 |
|
8229 | var freeModule = typeof module == 'object' && module &&
|
8230 | module.exports == freeExports && module;
|
8231 |
|
8232 |
|
8233 |
|
8234 | var freeGlobal = typeof global == 'object' && global;
|
8235 | if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
8236 | root = freeGlobal;
|
8237 | }
|
8238 |
|
8239 |
|
8240 |
|
8241 | var stringFromCharCode = String.fromCharCode;
|
8242 |
|
8243 |
|
8244 | function ucs2decode(string) {
|
8245 | var output = [];
|
8246 | var counter = 0;
|
8247 | var length = string.length;
|
8248 | var value;
|
8249 | var extra;
|
8250 | while (counter < length) {
|
8251 | value = string.charCodeAt(counter++);
|
8252 | if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
8253 |
|
8254 | extra = string.charCodeAt(counter++);
|
8255 | if ((extra & 0xFC00) == 0xDC00) {
|
8256 | output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
8257 | } else {
|
8258 |
|
8259 |
|
8260 | output.push(value);
|
8261 | counter--;
|
8262 | }
|
8263 | } else {
|
8264 | output.push(value);
|
8265 | }
|
8266 | }
|
8267 | return output;
|
8268 | }
|
8269 |
|
8270 |
|
8271 | function ucs2encode(array) {
|
8272 | var length = array.length;
|
8273 | var index = -1;
|
8274 | var value;
|
8275 | var output = '';
|
8276 | while (++index < length) {
|
8277 | value = array[index];
|
8278 | if (value > 0xFFFF) {
|
8279 | value -= 0x10000;
|
8280 | output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
8281 | value = 0xDC00 | value & 0x3FF;
|
8282 | }
|
8283 | output += stringFromCharCode(value);
|
8284 | }
|
8285 | return output;
|
8286 | }
|
8287 |
|
8288 | function checkScalarValue(codePoint) {
|
8289 | if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
|
8290 | throw Error(
|
8291 | 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
|
8292 | ' is not a scalar value'
|
8293 | );
|
8294 | }
|
8295 | }
|
8296 |
|
8297 |
|
8298 | function createByte(codePoint, shift) {
|
8299 | return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
|
8300 | }
|
8301 |
|
8302 | function encodeCodePoint(codePoint) {
|
8303 | if ((codePoint & 0xFFFFFF80) == 0) {
|
8304 | return stringFromCharCode(codePoint);
|
8305 | }
|
8306 | var symbol = '';
|
8307 | if ((codePoint & 0xFFFFF800) == 0) {
|
8308 | symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
|
8309 | }
|
8310 | else if ((codePoint & 0xFFFF0000) == 0) {
|
8311 | checkScalarValue(codePoint);
|
8312 | symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
|
8313 | symbol += createByte(codePoint, 6);
|
8314 | }
|
8315 | else if ((codePoint & 0xFFE00000) == 0) {
|
8316 | symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
|
8317 | symbol += createByte(codePoint, 12);
|
8318 | symbol += createByte(codePoint, 6);
|
8319 | }
|
8320 | symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
|
8321 | return symbol;
|
8322 | }
|
8323 |
|
8324 | function utf8encode(string) {
|
8325 | var codePoints = ucs2decode(string);
|
8326 | var length = codePoints.length;
|
8327 | var index = -1;
|
8328 | var codePoint;
|
8329 | var byteString = '';
|
8330 | while (++index < length) {
|
8331 | codePoint = codePoints[index];
|
8332 | byteString += encodeCodePoint(codePoint);
|
8333 | }
|
8334 | return byteString;
|
8335 | }
|
8336 |
|
8337 |
|
8338 |
|
8339 | function readContinuationByte() {
|
8340 | if (byteIndex >= byteCount) {
|
8341 | throw Error('Invalid byte index');
|
8342 | }
|
8343 |
|
8344 | var continuationByte = byteArray[byteIndex] & 0xFF;
|
8345 | byteIndex++;
|
8346 |
|
8347 | if ((continuationByte & 0xC0) == 0x80) {
|
8348 | return continuationByte & 0x3F;
|
8349 | }
|
8350 |
|
8351 |
|
8352 | throw Error('Invalid continuation byte');
|
8353 | }
|
8354 |
|
8355 | function decodeSymbol() {
|
8356 | var byte1;
|
8357 | var byte2;
|
8358 | var byte3;
|
8359 | var byte4;
|
8360 | var codePoint;
|
8361 |
|
8362 | if (byteIndex > byteCount) {
|
8363 | throw Error('Invalid byte index');
|
8364 | }
|
8365 |
|
8366 | if (byteIndex == byteCount) {
|
8367 | return false;
|
8368 | }
|
8369 |
|
8370 |
|
8371 | byte1 = byteArray[byteIndex] & 0xFF;
|
8372 | byteIndex++;
|
8373 |
|
8374 |
|
8375 | if ((byte1 & 0x80) == 0) {
|
8376 | return byte1;
|
8377 | }
|
8378 |
|
8379 |
|
8380 | if ((byte1 & 0xE0) == 0xC0) {
|
8381 | byte2 = readContinuationByte();
|
8382 | codePoint = ((byte1 & 0x1F) << 6) | byte2;
|
8383 | if (codePoint >= 0x80) {
|
8384 | return codePoint;
|
8385 | } else {
|
8386 | throw Error('Invalid continuation byte');
|
8387 | }
|
8388 | }
|
8389 |
|
8390 |
|
8391 | if ((byte1 & 0xF0) == 0xE0) {
|
8392 | byte2 = readContinuationByte();
|
8393 | byte3 = readContinuationByte();
|
8394 | codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
|
8395 | if (codePoint >= 0x0800) {
|
8396 | checkScalarValue(codePoint);
|
8397 | return codePoint;
|
8398 | } else {
|
8399 | throw Error('Invalid continuation byte');
|
8400 | }
|
8401 | }
|
8402 |
|
8403 |
|
8404 | if ((byte1 & 0xF8) == 0xF0) {
|
8405 | byte2 = readContinuationByte();
|
8406 | byte3 = readContinuationByte();
|
8407 | byte4 = readContinuationByte();
|
8408 | codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
|
8409 | (byte3 << 0x06) | byte4;
|
8410 | if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
|
8411 | return codePoint;
|
8412 | }
|
8413 | }
|
8414 |
|
8415 | throw Error('Invalid UTF-8 detected');
|
8416 | }
|
8417 |
|
8418 | var byteArray;
|
8419 | var byteCount;
|
8420 | var byteIndex;
|
8421 | function utf8decode(byteString) {
|
8422 | byteArray = ucs2decode(byteString);
|
8423 | byteCount = byteArray.length;
|
8424 | byteIndex = 0;
|
8425 | var codePoints = [];
|
8426 | var tmp;
|
8427 | while ((tmp = decodeSymbol()) !== false) {
|
8428 | codePoints.push(tmp);
|
8429 | }
|
8430 | return ucs2encode(codePoints);
|
8431 | }
|
8432 |
|
8433 |
|
8434 |
|
8435 | var utf8 = {
|
8436 | 'version': '2.1.2',
|
8437 | 'encode': utf8encode,
|
8438 | 'decode': utf8decode
|
8439 | };
|
8440 |
|
8441 |
|
8442 |
|
8443 | if (
|
8444 | typeof define == 'function' &&
|
8445 | typeof define.amd == 'object' &&
|
8446 | define.amd
|
8447 | ) {
|
8448 | define(function() {
|
8449 | return utf8;
|
8450 | });
|
8451 | } else if (freeExports && !freeExports.nodeType) {
|
8452 | if (freeModule) {
|
8453 | freeModule.exports = utf8;
|
8454 | } else {
|
8455 | var object = {};
|
8456 | var hasOwnProperty = object.hasOwnProperty;
|
8457 | for (var key in utf8) {
|
8458 | hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
|
8459 | }
|
8460 | }
|
8461 | } else {
|
8462 | root.utf8 = utf8;
|
8463 | }
|
8464 |
|
8465 | }(this));
|
8466 |
|
8467 | }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
8468 |
|
8469 | },{}]},{},[2])(2)
|
8470 | });
|
8471 |
|
8472 |
|