엄성진

Enhance Security

Showing 1000 changed files with 4789 additions and 3 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 *.json 1 *.json
2 node_modules/ 2 node_modules/
3 vscode/ 3 vscode/
4 - Info.js 4 + Info.js
...\ No newline at end of file ...\ No newline at end of file
......
1 +//라인 고유 토큰
2 +exports.TOKEN = 'Kb1/rQYz4MUhF8XyKQv7z9x0MxVQ5bX/XO8S/yt/1qQEJVAbsEFAaMvXKEOx9Umr7KhivfyDPfZHRRLFPngR0O4ZGWV2VFses8ufPE7uAdvYr4G6keBNAU69nBz5IC71HfbIrUHxXYqD7GfhVwXzpwdB04t89/1O/w1cDnyilFU='
3 +exports.YoutubeKey = 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518'
4 +exports.domain='2020105631.oss2021.tk'
...\ No newline at end of file ...\ No newline at end of file
...@@ -225,7 +225,7 @@ exports.check = function (message, replyToken, userId) { ...@@ -225,7 +225,7 @@ exports.check = function (message, replyToken, userId) {
225 var optionParams={ 225 var optionParams={
226 q:message, 226 q:message,
227 part:"snippet", 227 part:"snippet",
228 - key:"AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518", 228 + key:Info.YoutubeKey,
229 maxResults:10 229 maxResults:10
230 }; 230 };
231 optionParams.q=encodeURI(optionParams.q); 231 optionParams.q=encodeURI(optionParams.q);
...@@ -294,7 +294,7 @@ exports.check = function (message, replyToken, userId) { ...@@ -294,7 +294,7 @@ exports.check = function (message, replyToken, userId) {
294 else { //플레이리스트 294 else { //플레이리스트
295 service.playlistItems.list( 295 service.playlistItems.list(
296 { 296 {
297 - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', 297 + key: Info.YoutubeKey,
298 part: 'snippet', 298 part: 'snippet',
299 fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보. 299 fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
300 maxResults: 10, 300 maxResults: 10,
......
1 +../google-p12-pem/build/src/bin/gp12-pem.js
...\ No newline at end of file ...\ No newline at end of file
1 +../mime/cli.js
...\ No newline at end of file ...\ No newline at end of file
1 +../sshpk/bin/sshpk-conv
...\ No newline at end of file ...\ No newline at end of file
1 +../sshpk/bin/sshpk-sign
...\ No newline at end of file ...\ No newline at end of file
1 +../sshpk/bin/sshpk-verify
...\ No newline at end of file ...\ No newline at end of file
1 +../uuid/bin/uuid
...\ No newline at end of file ...\ No newline at end of file
1 +MIT License
2 +
3 +Copyright (c) 2017 Toru Nagashima
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +# abort-controller
2 +
3 +[![npm version](https://img.shields.io/npm/v/abort-controller.svg)](https://www.npmjs.com/package/abort-controller)
4 +[![Downloads/month](https://img.shields.io/npm/dm/abort-controller.svg)](http://www.npmtrends.com/abort-controller)
5 +[![Build Status](https://travis-ci.org/mysticatea/abort-controller.svg?branch=master)](https://travis-ci.org/mysticatea/abort-controller)
6 +[![Coverage Status](https://codecov.io/gh/mysticatea/abort-controller/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/abort-controller)
7 +[![Dependency Status](https://david-dm.org/mysticatea/abort-controller.svg)](https://david-dm.org/mysticatea/abort-controller)
8 +
9 +An implementation of [WHATWG AbortController interface](https://dom.spec.whatwg.org/#interface-abortcontroller).
10 +
11 +```js
12 +import AbortController from "abort-controller"
13 +
14 +const controller = new AbortController()
15 +const signal = controller.signal
16 +
17 +signal.addEventListener("abort", () => {
18 + console.log("aborted!")
19 +})
20 +
21 +controller.abort()
22 +```
23 +
24 +> https://jsfiddle.net/1r2994qp/1/
25 +
26 +## 💿 Installation
27 +
28 +Use [npm](https://www.npmjs.com/) to install then use a bundler.
29 +
30 +```
31 +npm install abort-controller
32 +```
33 +
34 +Or download from [`dist` directory](./dist).
35 +
36 +- [dist/abort-controller.mjs](dist/abort-controller.mjs) ... ES modules version.
37 +- [dist/abort-controller.js](dist/abort-controller.js) ... Common JS version.
38 +- [dist/abort-controller.umd.js](dist/abort-controller.umd.js) ... UMD (Universal Module Definition) version. This is transpiled by [Babel](https://babeljs.io/) for IE 11.
39 +
40 +## 📖 Usage
41 +
42 +### Basic
43 +
44 +```js
45 +import AbortController from "abort-controller"
46 +// or
47 +const AbortController = require("abort-controller")
48 +
49 +// or UMD version defines a global variable:
50 +const AbortController = window.AbortControllerShim
51 +```
52 +
53 +If your bundler recognizes `browser` field of `package.json`, the imported `AbortController` is the native one and it doesn't contain shim (even if the native implementation was nothing).
54 +If you wanted to polyfill `AbortController` for IE, use `abort-controller/polyfill`.
55 +
56 +### Polyfilling
57 +
58 +Importing `abort-controller/polyfill` assigns the `AbortController` shim to the `AbortController` global variable if the native implementation was nothing.
59 +
60 +```js
61 +import "abort-controller/polyfill"
62 +// or
63 +require("abort-controller/polyfill")
64 +```
65 +
66 +### API
67 +
68 +#### AbortController
69 +
70 +> https://dom.spec.whatwg.org/#interface-abortcontroller
71 +
72 +##### controller.signal
73 +
74 +The [AbortSignal](https://dom.spec.whatwg.org/#interface-AbortSignal) object which is associated to this controller.
75 +
76 +##### controller.abort()
77 +
78 +Notify `abort` event to listeners that the `signal` has.
79 +
80 +## 📰 Changelog
81 +
82 +- See [GitHub releases](https://github.com/mysticatea/abort-controller/releases).
83 +
84 +## 🍻 Contributing
85 +
86 +Contributing is welcome ❤️
87 +
88 +Please use GitHub issues/PRs.
89 +
90 +### Development tools
91 +
92 +- `npm install` installs dependencies for development.
93 +- `npm test` runs tests and measures code coverage.
94 +- `npm run clean` removes temporary files of tests.
95 +- `npm run coverage` opens code coverage of the previous test with your default browser.
96 +- `npm run lint` runs ESLint.
97 +- `npm run build` generates `dist` codes.
98 +- `npm run watch` runs tests on each file change.
1 +/*globals self, window */
2 +"use strict"
3 +
4 +/*eslint-disable @mysticatea/prettier */
5 +const { AbortController, AbortSignal } =
6 + typeof self !== "undefined" ? self :
7 + typeof window !== "undefined" ? window :
8 + /* otherwise */ undefined
9 +/*eslint-enable @mysticatea/prettier */
10 +
11 +module.exports = AbortController
12 +module.exports.AbortSignal = AbortSignal
13 +module.exports.default = AbortController
1 +/*globals self, window */
2 +
3 +/*eslint-disable @mysticatea/prettier */
4 +const { AbortController, AbortSignal } =
5 + typeof self !== "undefined" ? self :
6 + typeof window !== "undefined" ? window :
7 + /* otherwise */ undefined
8 +/*eslint-enable @mysticatea/prettier */
9 +
10 +export default AbortController
11 +export { AbortController, AbortSignal }
1 +import { EventTarget } from "event-target-shim"
2 +
3 +type Events = {
4 + abort: any
5 +}
6 +type EventAttributes = {
7 + onabort: any
8 +}
9 +/**
10 + * The signal class.
11 + * @see https://dom.spec.whatwg.org/#abortsignal
12 + */
13 +declare class AbortSignal extends EventTarget<Events, EventAttributes> {
14 + /**
15 + * AbortSignal cannot be constructed directly.
16 + */
17 + constructor()
18 + /**
19 + * Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise.
20 + */
21 + readonly aborted: boolean
22 +}
23 +/**
24 + * The AbortController.
25 + * @see https://dom.spec.whatwg.org/#abortcontroller
26 + */
27 +declare class AbortController {
28 + /**
29 + * Initialize this controller.
30 + */
31 + constructor()
32 + /**
33 + * Returns the `AbortSignal` object associated with this object.
34 + */
35 + readonly signal: AbortSignal
36 + /**
37 + * Abort and signal to any observers that the associated activity is to be aborted.
38 + */
39 + abort(): void
40 +}
41 +
42 +export default AbortController
43 +export { AbortController, AbortSignal }
1 +/**
2 + * @author Toru Nagashima <https://github.com/mysticatea>
3 + * See LICENSE file in root directory for full license.
4 + */
5 +'use strict';
6 +
7 +Object.defineProperty(exports, '__esModule', { value: true });
8 +
9 +var eventTargetShim = require('event-target-shim');
10 +
11 +/**
12 + * The signal class.
13 + * @see https://dom.spec.whatwg.org/#abortsignal
14 + */
15 +class AbortSignal extends eventTargetShim.EventTarget {
16 + /**
17 + * AbortSignal cannot be constructed directly.
18 + */
19 + constructor() {
20 + super();
21 + throw new TypeError("AbortSignal cannot be constructed directly");
22 + }
23 + /**
24 + * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.
25 + */
26 + get aborted() {
27 + const aborted = abortedFlags.get(this);
28 + if (typeof aborted !== "boolean") {
29 + throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`);
30 + }
31 + return aborted;
32 + }
33 +}
34 +eventTargetShim.defineEventAttribute(AbortSignal.prototype, "abort");
35 +/**
36 + * Create an AbortSignal object.
37 + */
38 +function createAbortSignal() {
39 + const signal = Object.create(AbortSignal.prototype);
40 + eventTargetShim.EventTarget.call(signal);
41 + abortedFlags.set(signal, false);
42 + return signal;
43 +}
44 +/**
45 + * Abort a given signal.
46 + */
47 +function abortSignal(signal) {
48 + if (abortedFlags.get(signal) !== false) {
49 + return;
50 + }
51 + abortedFlags.set(signal, true);
52 + signal.dispatchEvent({ type: "abort" });
53 +}
54 +/**
55 + * Aborted flag for each instances.
56 + */
57 +const abortedFlags = new WeakMap();
58 +// Properties should be enumerable.
59 +Object.defineProperties(AbortSignal.prototype, {
60 + aborted: { enumerable: true },
61 +});
62 +// `toString()` should return `"[object AbortSignal]"`
63 +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
64 + Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {
65 + configurable: true,
66 + value: "AbortSignal",
67 + });
68 +}
69 +
70 +/**
71 + * The AbortController.
72 + * @see https://dom.spec.whatwg.org/#abortcontroller
73 + */
74 +class AbortController {
75 + /**
76 + * Initialize this controller.
77 + */
78 + constructor() {
79 + signals.set(this, createAbortSignal());
80 + }
81 + /**
82 + * Returns the `AbortSignal` object associated with this object.
83 + */
84 + get signal() {
85 + return getSignal(this);
86 + }
87 + /**
88 + * Abort and signal to any observers that the associated activity is to be aborted.
89 + */
90 + abort() {
91 + abortSignal(getSignal(this));
92 + }
93 +}
94 +/**
95 + * Associated signals.
96 + */
97 +const signals = new WeakMap();
98 +/**
99 + * Get the associated signal of a given controller.
100 + */
101 +function getSignal(controller) {
102 + const signal = signals.get(controller);
103 + if (signal == null) {
104 + throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`);
105 + }
106 + return signal;
107 +}
108 +// Properties should be enumerable.
109 +Object.defineProperties(AbortController.prototype, {
110 + signal: { enumerable: true },
111 + abort: { enumerable: true },
112 +});
113 +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
114 + Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {
115 + configurable: true,
116 + value: "AbortController",
117 + });
118 +}
119 +
120 +exports.AbortController = AbortController;
121 +exports.AbortSignal = AbortSignal;
122 +exports.default = AbortController;
123 +
124 +module.exports = AbortController
125 +module.exports.AbortController = module.exports["default"] = AbortController
126 +module.exports.AbortSignal = AbortSignal
127 +//# sourceMappingURL=abort-controller.js.map
1 +{"version":3,"file":"abort-controller.js","sources":["../src/abort-signal.ts","../src/abort-controller.ts"],"sourcesContent":["import {\n // Event,\n EventTarget,\n // Type,\n defineEventAttribute,\n} from \"event-target-shim\"\n\n// Known Limitation\n// Use `any` because the type of `AbortSignal` in `lib.dom.d.ts` is wrong and\n// to make assignable our `AbortSignal` into that.\n// https://github.com/Microsoft/TSJS-lib-generator/pull/623\ntype Events = {\n abort: any // Event & Type<\"abort\">\n}\ntype EventAttributes = {\n onabort: any // Event & Type<\"abort\">\n}\n\n/**\n * The signal class.\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\nexport default class AbortSignal extends EventTarget<Events, EventAttributes> {\n /**\n * AbortSignal cannot be constructed directly.\n */\n public constructor() {\n super()\n throw new TypeError(\"AbortSignal cannot be constructed directly\")\n }\n\n /**\n * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.\n */\n public get aborted(): boolean {\n const aborted = abortedFlags.get(this)\n if (typeof aborted !== \"boolean\") {\n throw new TypeError(\n `Expected 'this' to be an 'AbortSignal' object, but got ${\n this === null ? \"null\" : typeof this\n }`,\n )\n }\n return aborted\n }\n}\ndefineEventAttribute(AbortSignal.prototype, \"abort\")\n\n/**\n * Create an AbortSignal object.\n */\nexport function createAbortSignal(): AbortSignal {\n const signal = Object.create(AbortSignal.prototype)\n EventTarget.call(signal)\n abortedFlags.set(signal, false)\n return signal\n}\n\n/**\n * Abort a given signal.\n */\nexport function abortSignal(signal: AbortSignal): void {\n if (abortedFlags.get(signal) !== false) {\n return\n }\n\n abortedFlags.set(signal, true)\n signal.dispatchEvent<\"abort\">({ type: \"abort\" })\n}\n\n/**\n * Aborted flag for each instances.\n */\nconst abortedFlags = new WeakMap<AbortSignal, boolean>()\n\n// Properties should be enumerable.\nObject.defineProperties(AbortSignal.prototype, {\n aborted: { enumerable: true },\n})\n\n// `toString()` should return `\"[object AbortSignal]\"`\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortSignal\",\n })\n}\n","import AbortSignal, { abortSignal, createAbortSignal } from \"./abort-signal\"\n\n/**\n * The AbortController.\n * @see https://dom.spec.whatwg.org/#abortcontroller\n */\nexport default class AbortController {\n /**\n * Initialize this controller.\n */\n public constructor() {\n signals.set(this, createAbortSignal())\n }\n\n /**\n * Returns the `AbortSignal` object associated with this object.\n */\n public get signal(): AbortSignal {\n return getSignal(this)\n }\n\n /**\n * Abort and signal to any observers that the associated activity is to be aborted.\n */\n public abort(): void {\n abortSignal(getSignal(this))\n }\n}\n\n/**\n * Associated signals.\n */\nconst signals = new WeakMap<AbortController, AbortSignal>()\n\n/**\n * Get the associated signal of a given controller.\n */\nfunction getSignal(controller: AbortController): AbortSignal {\n const signal = signals.get(controller)\n if (signal == null) {\n throw new TypeError(\n `Expected 'this' to be an 'AbortController' object, but got ${\n controller === null ? \"null\" : typeof controller\n }`,\n )\n }\n return signal\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortController.prototype, {\n signal: { enumerable: true },\n abort: { enumerable: true },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortController\",\n })\n}\n\nexport { AbortController, AbortSignal }\n"],"names":["EventTarget","defineEventAttribute"],"mappings":"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"}
...\ No newline at end of file ...\ No newline at end of file
1 +/**
2 + * @author Toru Nagashima <https://github.com/mysticatea>
3 + * See LICENSE file in root directory for full license.
4 + */
5 +import { EventTarget, defineEventAttribute } from 'event-target-shim';
6 +
7 +/**
8 + * The signal class.
9 + * @see https://dom.spec.whatwg.org/#abortsignal
10 + */
11 +class AbortSignal extends EventTarget {
12 + /**
13 + * AbortSignal cannot be constructed directly.
14 + */
15 + constructor() {
16 + super();
17 + throw new TypeError("AbortSignal cannot be constructed directly");
18 + }
19 + /**
20 + * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.
21 + */
22 + get aborted() {
23 + const aborted = abortedFlags.get(this);
24 + if (typeof aborted !== "boolean") {
25 + throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`);
26 + }
27 + return aborted;
28 + }
29 +}
30 +defineEventAttribute(AbortSignal.prototype, "abort");
31 +/**
32 + * Create an AbortSignal object.
33 + */
34 +function createAbortSignal() {
35 + const signal = Object.create(AbortSignal.prototype);
36 + EventTarget.call(signal);
37 + abortedFlags.set(signal, false);
38 + return signal;
39 +}
40 +/**
41 + * Abort a given signal.
42 + */
43 +function abortSignal(signal) {
44 + if (abortedFlags.get(signal) !== false) {
45 + return;
46 + }
47 + abortedFlags.set(signal, true);
48 + signal.dispatchEvent({ type: "abort" });
49 +}
50 +/**
51 + * Aborted flag for each instances.
52 + */
53 +const abortedFlags = new WeakMap();
54 +// Properties should be enumerable.
55 +Object.defineProperties(AbortSignal.prototype, {
56 + aborted: { enumerable: true },
57 +});
58 +// `toString()` should return `"[object AbortSignal]"`
59 +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
60 + Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {
61 + configurable: true,
62 + value: "AbortSignal",
63 + });
64 +}
65 +
66 +/**
67 + * The AbortController.
68 + * @see https://dom.spec.whatwg.org/#abortcontroller
69 + */
70 +class AbortController {
71 + /**
72 + * Initialize this controller.
73 + */
74 + constructor() {
75 + signals.set(this, createAbortSignal());
76 + }
77 + /**
78 + * Returns the `AbortSignal` object associated with this object.
79 + */
80 + get signal() {
81 + return getSignal(this);
82 + }
83 + /**
84 + * Abort and signal to any observers that the associated activity is to be aborted.
85 + */
86 + abort() {
87 + abortSignal(getSignal(this));
88 + }
89 +}
90 +/**
91 + * Associated signals.
92 + */
93 +const signals = new WeakMap();
94 +/**
95 + * Get the associated signal of a given controller.
96 + */
97 +function getSignal(controller) {
98 + const signal = signals.get(controller);
99 + if (signal == null) {
100 + throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`);
101 + }
102 + return signal;
103 +}
104 +// Properties should be enumerable.
105 +Object.defineProperties(AbortController.prototype, {
106 + signal: { enumerable: true },
107 + abort: { enumerable: true },
108 +});
109 +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
110 + Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {
111 + configurable: true,
112 + value: "AbortController",
113 + });
114 +}
115 +
116 +export default AbortController;
117 +export { AbortController, AbortSignal };
118 +//# sourceMappingURL=abort-controller.mjs.map
1 +{"version":3,"file":"abort-controller.mjs","sources":["../src/abort-signal.ts","../src/abort-controller.ts"],"sourcesContent":["import {\n // Event,\n EventTarget,\n // Type,\n defineEventAttribute,\n} from \"event-target-shim\"\n\n// Known Limitation\n// Use `any` because the type of `AbortSignal` in `lib.dom.d.ts` is wrong and\n// to make assignable our `AbortSignal` into that.\n// https://github.com/Microsoft/TSJS-lib-generator/pull/623\ntype Events = {\n abort: any // Event & Type<\"abort\">\n}\ntype EventAttributes = {\n onabort: any // Event & Type<\"abort\">\n}\n\n/**\n * The signal class.\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\nexport default class AbortSignal extends EventTarget<Events, EventAttributes> {\n /**\n * AbortSignal cannot be constructed directly.\n */\n public constructor() {\n super()\n throw new TypeError(\"AbortSignal cannot be constructed directly\")\n }\n\n /**\n * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.\n */\n public get aborted(): boolean {\n const aborted = abortedFlags.get(this)\n if (typeof aborted !== \"boolean\") {\n throw new TypeError(\n `Expected 'this' to be an 'AbortSignal' object, but got ${\n this === null ? \"null\" : typeof this\n }`,\n )\n }\n return aborted\n }\n}\ndefineEventAttribute(AbortSignal.prototype, \"abort\")\n\n/**\n * Create an AbortSignal object.\n */\nexport function createAbortSignal(): AbortSignal {\n const signal = Object.create(AbortSignal.prototype)\n EventTarget.call(signal)\n abortedFlags.set(signal, false)\n return signal\n}\n\n/**\n * Abort a given signal.\n */\nexport function abortSignal(signal: AbortSignal): void {\n if (abortedFlags.get(signal) !== false) {\n return\n }\n\n abortedFlags.set(signal, true)\n signal.dispatchEvent<\"abort\">({ type: \"abort\" })\n}\n\n/**\n * Aborted flag for each instances.\n */\nconst abortedFlags = new WeakMap<AbortSignal, boolean>()\n\n// Properties should be enumerable.\nObject.defineProperties(AbortSignal.prototype, {\n aborted: { enumerable: true },\n})\n\n// `toString()` should return `\"[object AbortSignal]\"`\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortSignal\",\n })\n}\n","import AbortSignal, { abortSignal, createAbortSignal } from \"./abort-signal\"\n\n/**\n * The AbortController.\n * @see https://dom.spec.whatwg.org/#abortcontroller\n */\nexport default class AbortController {\n /**\n * Initialize this controller.\n */\n public constructor() {\n signals.set(this, createAbortSignal())\n }\n\n /**\n * Returns the `AbortSignal` object associated with this object.\n */\n public get signal(): AbortSignal {\n return getSignal(this)\n }\n\n /**\n * Abort and signal to any observers that the associated activity is to be aborted.\n */\n public abort(): void {\n abortSignal(getSignal(this))\n }\n}\n\n/**\n * Associated signals.\n */\nconst signals = new WeakMap<AbortController, AbortSignal>()\n\n/**\n * Get the associated signal of a given controller.\n */\nfunction getSignal(controller: AbortController): AbortSignal {\n const signal = signals.get(controller)\n if (signal == null) {\n throw new TypeError(\n `Expected 'this' to be an 'AbortController' object, but got ${\n controller === null ? \"null\" : typeof controller\n }`,\n )\n }\n return signal\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortController.prototype, {\n signal: { enumerable: true },\n abort: { enumerable: true },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortController\",\n })\n}\n\nexport { AbortController, AbortSignal }\n"],"names":[],"mappings":"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"}
...\ No newline at end of file ...\ No newline at end of file
1 +/**
2 + * @author Toru Nagashima <https://github.com/mysticatea>
3 + * See LICENSE file in root directory for full license.
4 + */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.AbortControllerShim={}))})(this,function(a){'use strict';function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function d(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function e(a,b,c){return b&&d(a.prototype,b),c&&d(a,c),a}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&h(a,b)}function g(a){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},g(a)}function h(a,b){return h=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},h(a,b)}function i(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function j(a,b){return b&&("object"==typeof b||"function"==typeof b)?b:i(a)}function k(a){var b=F.get(a);return console.assert(null!=b,"'this' is expected an Event object, but got",a),b}function l(a){return null==a.passiveListener?void(!a.event.cancelable||(a.canceled=!0,"function"==typeof a.event.preventDefault&&a.event.preventDefault())):void("undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",a.passiveListener))}function m(a,b){F.set(this,{eventTarget:a,event:b,eventPhase:2,currentTarget:a,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:b.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});for(var c,d=Object.keys(b),e=0;e<d.length;++e)c=d[e],c in this||Object.defineProperty(this,c,n(c))}function n(a){return{get:function(){return k(this).event[a]},set:function(b){k(this).event[a]=b},configurable:!0,enumerable:!0}}function o(a){return{value:function(){var b=k(this).event;return b[a].apply(b,arguments)},configurable:!0,enumerable:!0}}function p(a,b){function c(b,c){a.call(this,b,c)}var d=Object.keys(b);if(0===d.length)return a;c.prototype=Object.create(a.prototype,{constructor:{value:c,configurable:!0,writable:!0}});for(var e,f=0;f<d.length;++f)if(e=d[f],!(e in a.prototype)){var g=Object.getOwnPropertyDescriptor(b,e),h="function"==typeof g.value;Object.defineProperty(c.prototype,e,h?o(e):n(e))}return c}function q(a){if(null==a||a===Object.prototype)return m;var b=G.get(a);return null==b&&(b=p(q(Object.getPrototypeOf(a)),a),G.set(a,b)),b}function r(a,b){var c=q(Object.getPrototypeOf(b));return new c(a,b)}function s(a){return k(a).immediateStopped}function t(a,b){k(a).eventPhase=b}function u(a,b){k(a).currentTarget=b}function v(a,b){k(a).passiveListener=b}function w(a){return null!==a&&"object"===b(a)}function x(a){var b=H.get(a);if(null==b)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return b}function y(a){return{get:function(){for(var b=x(this),c=b.get(a);null!=c;){if(3===c.listenerType)return c.listener;c=c.next}return null},set:function(b){"function"==typeof b||w(b)||(b=null);for(var c=x(this),d=null,e=c.get(a);null!=e;)3===e.listenerType?null===d?null===e.next?c.delete(a):c.set(a,e.next):d.next=e.next:d=e,e=e.next;if(null!==b){var f={listener:b,listenerType:3,passive:!1,once:!1,next:null};null===d?c.set(a,f):d.next=f}},configurable:!0,enumerable:!0}}function z(a,b){Object.defineProperty(a,"on".concat(b),y(b))}function A(a){function b(){B.call(this)}b.prototype=Object.create(B.prototype,{constructor:{value:b,configurable:!0,writable:!0}});for(var c=0;c<a.length;++c)z(b.prototype,a[c]);return b}function B(){if(this instanceof B)return void H.set(this,new Map);if(1===arguments.length&&Array.isArray(arguments[0]))return A(arguments[0]);if(0<arguments.length){for(var a=Array(arguments.length),b=0;b<arguments.length;++b)a[b]=arguments[b];return A(a)}throw new TypeError("Cannot call a class as a function")}function C(){var a=Object.create(K.prototype);return B.call(a),L.set(a,!1),a}function D(a){!1!==L.get(a)||(L.set(a,!0),a.dispatchEvent({type:"abort"}))}function E(a){var c=N.get(a);if(null==c)throw new TypeError("Expected 'this' to be an 'AbortController' object, but got ".concat(null===a?"null":b(a)));return c}var F=new WeakMap,G=new WeakMap;m.prototype={get type(){return k(this).event.type},get target(){return k(this).eventTarget},get currentTarget(){return k(this).currentTarget},composedPath:function(){var a=k(this).currentTarget;return null==a?[]:[a]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return k(this).eventPhase},stopPropagation:function(){var a=k(this);a.stopped=!0,"function"==typeof a.event.stopPropagation&&a.event.stopPropagation()},stopImmediatePropagation:function(){var a=k(this);a.stopped=!0,a.immediateStopped=!0,"function"==typeof a.event.stopImmediatePropagation&&a.event.stopImmediatePropagation()},get bubbles(){return!!k(this).event.bubbles},get cancelable(){return!!k(this).event.cancelable},preventDefault:function(){l(k(this))},get defaultPrevented(){return k(this).canceled},get composed(){return!!k(this).event.composed},get timeStamp(){return k(this).timeStamp},get srcElement(){return k(this).eventTarget},get cancelBubble(){return k(this).stopped},set cancelBubble(a){if(a){var b=k(this);b.stopped=!0,"boolean"==typeof b.event.cancelBubble&&(b.event.cancelBubble=!0)}},get returnValue(){return!k(this).canceled},set returnValue(a){a||l(k(this))},initEvent:function(){}},Object.defineProperty(m.prototype,"constructor",{value:m,configurable:!0,writable:!0}),"undefined"!=typeof window&&"undefined"!=typeof window.Event&&(Object.setPrototypeOf(m.prototype,window.Event.prototype),G.set(window.Event.prototype,m));var H=new WeakMap,I=1,J=2;B.prototype={addEventListener:function(a,b,c){if(null!=b){if("function"!=typeof b&&!w(b))throw new TypeError("'listener' should be a function or an object.");var d=x(this),e=w(c),f=e?!!c.capture:!!c,g=f?I:J,h={listener:b,listenerType:g,passive:e&&!!c.passive,once:e&&!!c.once,next:null},i=d.get(a);if(void 0===i)return void d.set(a,h);for(var j=null;null!=i;){if(i.listener===b&&i.listenerType===g)return;j=i,i=i.next}j.next=h}},removeEventListener:function(a,b,c){if(null!=b)for(var d=x(this),e=w(c)?!!c.capture:!!c,f=e?I:J,g=null,h=d.get(a);null!=h;){if(h.listener===b&&h.listenerType===f)return void(null===g?null===h.next?d.delete(a):d.set(a,h.next):g.next=h.next);g=h,h=h.next}},dispatchEvent:function(a){if(null==a||"string"!=typeof a.type)throw new TypeError("\"event.type\" should be a string.");var b=x(this),c=a.type,d=b.get(c);if(null==d)return!0;for(var e=r(this,a),f=null;null!=d;){if(d.once?null===f?null===d.next?b.delete(c):b.set(c,d.next):f.next=d.next:f=d,v(e,d.passive?d.listener:null),"function"==typeof d.listener)try{d.listener.call(this,e)}catch(a){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(a)}else d.listenerType!==3&&"function"==typeof d.listener.handleEvent&&d.listener.handleEvent(e);if(s(e))break;d=d.next}return v(e,null),t(e,0),u(e,null),!e.defaultPrevented}},Object.defineProperty(B.prototype,"constructor",{value:B,configurable:!0,writable:!0}),"undefined"!=typeof window&&"undefined"!=typeof window.EventTarget&&Object.setPrototypeOf(B.prototype,window.EventTarget.prototype);var K=function(a){function d(){var a;throw c(this,d),a=j(this,g(d).call(this)),new TypeError("AbortSignal cannot be constructed directly")}return f(d,a),e(d,[{key:"aborted",get:function(){var a=L.get(this);if("boolean"!=typeof a)throw new TypeError("Expected 'this' to be an 'AbortSignal' object, but got ".concat(null===this?"null":b(this)));return a}}]),d}(B);z(K.prototype,"abort");var L=new WeakMap;Object.defineProperties(K.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"===b(Symbol.toStringTag)&&Object.defineProperty(K.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});var M=function(){function a(){c(this,a),N.set(this,C())}return e(a,[{key:"abort",value:function(){D(E(this))}},{key:"signal",get:function(){return E(this)}}]),a}(),N=new WeakMap;if(Object.defineProperties(M.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"===b(Symbol.toStringTag)&&Object.defineProperty(M.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"}),a.AbortController=M,a.AbortSignal=K,a.default=M,Object.defineProperty(a,"__esModule",{value:!0}),"undefined"==typeof module&&"undefined"==typeof define){var O=Function("return this")();"undefined"==typeof O.AbortController&&(O.AbortController=M,O.AbortSignal=K)}});
5 +//# sourceMappingURL=abort-controller.umd.js.map
This diff is collapsed. Click to expand it.
1 +{
2 + "_args": [
3 + [
4 + "abort-controller@3.0.0",
5 + "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot"
6 + ]
7 + ],
8 + "_from": "abort-controller@3.0.0",
9 + "_id": "abort-controller@3.0.0",
10 + "_inBundle": false,
11 + "_integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
12 + "_location": "/abort-controller",
13 + "_phantomChildren": {},
14 + "_requested": {
15 + "type": "version",
16 + "registry": true,
17 + "raw": "abort-controller@3.0.0",
18 + "name": "abort-controller",
19 + "escapedName": "abort-controller",
20 + "rawSpec": "3.0.0",
21 + "saveSpec": null,
22 + "fetchSpec": "3.0.0"
23 + },
24 + "_requiredBy": [
25 + "/gaxios"
26 + ],
27 + "_resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
28 + "_spec": "3.0.0",
29 + "_where": "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot",
30 + "author": {
31 + "name": "Toru Nagashima",
32 + "url": "https://github.com/mysticatea"
33 + },
34 + "browser": "./browser.js",
35 + "bugs": {
36 + "url": "https://github.com/mysticatea/abort-controller/issues"
37 + },
38 + "dependencies": {
39 + "event-target-shim": "^5.0.0"
40 + },
41 + "description": "An implementation of WHATWG AbortController interface.",
42 + "devDependencies": {
43 + "@babel/core": "^7.2.2",
44 + "@babel/plugin-transform-modules-commonjs": "^7.2.0",
45 + "@babel/preset-env": "^7.3.0",
46 + "@babel/register": "^7.0.0",
47 + "@mysticatea/eslint-plugin": "^8.0.1",
48 + "@mysticatea/spy": "^0.1.2",
49 + "@types/mocha": "^5.2.5",
50 + "@types/node": "^10.12.18",
51 + "assert": "^1.4.1",
52 + "codecov": "^3.1.0",
53 + "dts-bundle-generator": "^2.0.0",
54 + "eslint": "^5.12.1",
55 + "karma": "^3.1.4",
56 + "karma-chrome-launcher": "^2.2.0",
57 + "karma-coverage": "^1.1.2",
58 + "karma-firefox-launcher": "^1.1.0",
59 + "karma-growl-reporter": "^1.0.0",
60 + "karma-ie-launcher": "^1.0.0",
61 + "karma-mocha": "^1.3.0",
62 + "karma-rollup-preprocessor": "^7.0.0-rc.2",
63 + "mocha": "^5.2.0",
64 + "npm-run-all": "^4.1.5",
65 + "nyc": "^13.1.0",
66 + "opener": "^1.5.1",
67 + "rimraf": "^2.6.3",
68 + "rollup": "^1.1.2",
69 + "rollup-plugin-babel": "^4.3.2",
70 + "rollup-plugin-babel-minify": "^7.0.0",
71 + "rollup-plugin-commonjs": "^9.2.0",
72 + "rollup-plugin-node-resolve": "^4.0.0",
73 + "rollup-plugin-sourcemaps": "^0.4.2",
74 + "rollup-plugin-typescript": "^1.0.0",
75 + "rollup-watch": "^4.3.1",
76 + "ts-node": "^8.0.1",
77 + "type-tester": "^1.0.0",
78 + "typescript": "^3.2.4"
79 + },
80 + "engines": {
81 + "node": ">=6.5"
82 + },
83 + "files": [
84 + "dist",
85 + "polyfill.*",
86 + "browser.*"
87 + ],
88 + "homepage": "https://github.com/mysticatea/abort-controller#readme",
89 + "keywords": [
90 + "w3c",
91 + "whatwg",
92 + "event",
93 + "events",
94 + "abort",
95 + "cancel",
96 + "abortcontroller",
97 + "abortsignal",
98 + "controller",
99 + "signal",
100 + "shim"
101 + ],
102 + "license": "MIT",
103 + "main": "dist/abort-controller",
104 + "name": "abort-controller",
105 + "repository": {
106 + "type": "git",
107 + "url": "git+https://github.com/mysticatea/abort-controller.git"
108 + },
109 + "scripts": {
110 + "build": "run-s -s build:*",
111 + "build:dts": "dts-bundle-generator -o dist/abort-controller.d.ts src/abort-controller.ts && ts-node scripts/fix-dts",
112 + "build:rollup": "rollup -c",
113 + "clean": "rimraf .nyc_output coverage",
114 + "codecov": "codecov",
115 + "coverage": "opener coverage/lcov-report/index.html",
116 + "lint": "eslint . --ext .ts",
117 + "postversion": "git push && git push --tags",
118 + "preversion": "npm test",
119 + "test": "run-s -s lint test:*",
120 + "test:karma": "karma start --single-run",
121 + "test:mocha": "nyc mocha test/*.ts",
122 + "version": "npm run -s build && git add dist/*",
123 + "watch": "run-p -s watch:*",
124 + "watch:karma": "karma start --watch",
125 + "watch:mocha": "mocha test/*.ts --require ts-node/register --watch-extensions ts --watch --growl"
126 + },
127 + "version": "3.0.0"
128 +}
1 +/*globals require, self, window */
2 +"use strict"
3 +
4 +const ac = require("./dist/abort-controller")
5 +
6 +/*eslint-disable @mysticatea/prettier */
7 +const g =
8 + typeof self !== "undefined" ? self :
9 + typeof window !== "undefined" ? window :
10 + typeof global !== "undefined" ? global :
11 + /* otherwise */ undefined
12 +/*eslint-enable @mysticatea/prettier */
13 +
14 +if (g) {
15 + if (typeof g.AbortController === "undefined") {
16 + g.AbortController = ac.AbortController
17 + }
18 + if (typeof g.AbortSignal === "undefined") {
19 + g.AbortSignal = ac.AbortSignal
20 + }
21 +}
1 +/*globals self, window */
2 +import * as ac from "./dist/abort-controller"
3 +
4 +/*eslint-disable @mysticatea/prettier */
5 +const g =
6 + typeof self !== "undefined" ? self :
7 + typeof window !== "undefined" ? window :
8 + typeof global !== "undefined" ? global :
9 + /* otherwise */ undefined
10 +/*eslint-enable @mysticatea/prettier */
11 +
12 +if (g) {
13 + if (typeof g.AbortController === "undefined") {
14 + g.AbortController = ac.AbortController
15 + }
16 + if (typeof g.AbortSignal === "undefined") {
17 + g.AbortSignal = ac.AbortSignal
18 + }
19 +}
1 +1.3.7 / 2019-04-29
2 +==================
3 +
4 + * deps: negotiator@0.6.2
5 + - Fix sorting charset, encoding, and language with extra parameters
6 +
7 +1.3.6 / 2019-04-28
8 +==================
9 +
10 + * deps: mime-types@~2.1.24
11 + - deps: mime-db@~1.40.0
12 +
13 +1.3.5 / 2018-02-28
14 +==================
15 +
16 + * deps: mime-types@~2.1.18
17 + - deps: mime-db@~1.33.0
18 +
19 +1.3.4 / 2017-08-22
20 +==================
21 +
22 + * deps: mime-types@~2.1.16
23 + - deps: mime-db@~1.29.0
24 +
25 +1.3.3 / 2016-05-02
26 +==================
27 +
28 + * deps: mime-types@~2.1.11
29 + - deps: mime-db@~1.23.0
30 + * deps: negotiator@0.6.1
31 + - perf: improve `Accept` parsing speed
32 + - perf: improve `Accept-Charset` parsing speed
33 + - perf: improve `Accept-Encoding` parsing speed
34 + - perf: improve `Accept-Language` parsing speed
35 +
36 +1.3.2 / 2016-03-08
37 +==================
38 +
39 + * deps: mime-types@~2.1.10
40 + - Fix extension of `application/dash+xml`
41 + - Update primary extension for `audio/mp4`
42 + - deps: mime-db@~1.22.0
43 +
44 +1.3.1 / 2016-01-19
45 +==================
46 +
47 + * deps: mime-types@~2.1.9
48 + - deps: mime-db@~1.21.0
49 +
50 +1.3.0 / 2015-09-29
51 +==================
52 +
53 + * deps: mime-types@~2.1.7
54 + - deps: mime-db@~1.19.0
55 + * deps: negotiator@0.6.0
56 + - Fix including type extensions in parameters in `Accept` parsing
57 + - Fix parsing `Accept` parameters with quoted equals
58 + - Fix parsing `Accept` parameters with quoted semicolons
59 + - Lazy-load modules from main entry point
60 + - perf: delay type concatenation until needed
61 + - perf: enable strict mode
62 + - perf: hoist regular expressions
63 + - perf: remove closures getting spec properties
64 + - perf: remove a closure from media type parsing
65 + - perf: remove property delete from media type parsing
66 +
67 +1.2.13 / 2015-09-06
68 +===================
69 +
70 + * deps: mime-types@~2.1.6
71 + - deps: mime-db@~1.18.0
72 +
73 +1.2.12 / 2015-07-30
74 +===================
75 +
76 + * deps: mime-types@~2.1.4
77 + - deps: mime-db@~1.16.0
78 +
79 +1.2.11 / 2015-07-16
80 +===================
81 +
82 + * deps: mime-types@~2.1.3
83 + - deps: mime-db@~1.15.0
84 +
85 +1.2.10 / 2015-07-01
86 +===================
87 +
88 + * deps: mime-types@~2.1.2
89 + - deps: mime-db@~1.14.0
90 +
91 +1.2.9 / 2015-06-08
92 +==================
93 +
94 + * deps: mime-types@~2.1.1
95 + - perf: fix deopt during mapping
96 +
97 +1.2.8 / 2015-06-07
98 +==================
99 +
100 + * deps: mime-types@~2.1.0
101 + - deps: mime-db@~1.13.0
102 + * perf: avoid argument reassignment & argument slice
103 + * perf: avoid negotiator recursive construction
104 + * perf: enable strict mode
105 + * perf: remove unnecessary bitwise operator
106 +
107 +1.2.7 / 2015-05-10
108 +==================
109 +
110 + * deps: negotiator@0.5.3
111 + - Fix media type parameter matching to be case-insensitive
112 +
113 +1.2.6 / 2015-05-07
114 +==================
115 +
116 + * deps: mime-types@~2.0.11
117 + - deps: mime-db@~1.9.1
118 + * deps: negotiator@0.5.2
119 + - Fix comparing media types with quoted values
120 + - Fix splitting media types with quoted commas
121 +
122 +1.2.5 / 2015-03-13
123 +==================
124 +
125 + * deps: mime-types@~2.0.10
126 + - deps: mime-db@~1.8.0
127 +
128 +1.2.4 / 2015-02-14
129 +==================
130 +
131 + * Support Node.js 0.6
132 + * deps: mime-types@~2.0.9
133 + - deps: mime-db@~1.7.0
134 + * deps: negotiator@0.5.1
135 + - Fix preference sorting to be stable for long acceptable lists
136 +
137 +1.2.3 / 2015-01-31
138 +==================
139 +
140 + * deps: mime-types@~2.0.8
141 + - deps: mime-db@~1.6.0
142 +
143 +1.2.2 / 2014-12-30
144 +==================
145 +
146 + * deps: mime-types@~2.0.7
147 + - deps: mime-db@~1.5.0
148 +
149 +1.2.1 / 2014-12-30
150 +==================
151 +
152 + * deps: mime-types@~2.0.5
153 + - deps: mime-db@~1.3.1
154 +
155 +1.2.0 / 2014-12-19
156 +==================
157 +
158 + * deps: negotiator@0.5.0
159 + - Fix list return order when large accepted list
160 + - Fix missing identity encoding when q=0 exists
161 + - Remove dynamic building of Negotiator class
162 +
163 +1.1.4 / 2014-12-10
164 +==================
165 +
166 + * deps: mime-types@~2.0.4
167 + - deps: mime-db@~1.3.0
168 +
169 +1.1.3 / 2014-11-09
170 +==================
171 +
172 + * deps: mime-types@~2.0.3
173 + - deps: mime-db@~1.2.0
174 +
175 +1.1.2 / 2014-10-14
176 +==================
177 +
178 + * deps: negotiator@0.4.9
179 + - Fix error when media type has invalid parameter
180 +
181 +1.1.1 / 2014-09-28
182 +==================
183 +
184 + * deps: mime-types@~2.0.2
185 + - deps: mime-db@~1.1.0
186 + * deps: negotiator@0.4.8
187 + - Fix all negotiations to be case-insensitive
188 + - Stable sort preferences of same quality according to client order
189 +
190 +1.1.0 / 2014-09-02
191 +==================
192 +
193 + * update `mime-types`
194 +
195 +1.0.7 / 2014-07-04
196 +==================
197 +
198 + * Fix wrong type returned from `type` when match after unknown extension
199 +
200 +1.0.6 / 2014-06-24
201 +==================
202 +
203 + * deps: negotiator@0.4.7
204 +
205 +1.0.5 / 2014-06-20
206 +==================
207 +
208 + * fix crash when unknown extension given
209 +
210 +1.0.4 / 2014-06-19
211 +==================
212 +
213 + * use `mime-types`
214 +
215 +1.0.3 / 2014-06-11
216 +==================
217 +
218 + * deps: negotiator@0.4.6
219 + - Order by specificity when quality is the same
220 +
221 +1.0.2 / 2014-05-29
222 +==================
223 +
224 + * Fix interpretation when header not in request
225 + * deps: pin negotiator@0.4.5
226 +
227 +1.0.1 / 2014-01-18
228 +==================
229 +
230 + * Identity encoding isn't always acceptable
231 + * deps: negotiator@~0.4.0
232 +
233 +1.0.0 / 2013-12-27
234 +==================
235 +
236 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-version-image]][npm-url]
4 +[![NPM Downloads][npm-downloads-image]][npm-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +<!-- eslint-disable no-unused-vars -->
33 +
34 +```js
35 +var accepts = require('accepts')
36 +```
37 +
38 +### accepts(req)
39 +
40 +Create a new `Accepts` object for the given `req`.
41 +
42 +#### .charset(charsets)
43 +
44 +Return the first accepted charset. If nothing in `charsets` is accepted,
45 +then `false` is returned.
46 +
47 +#### .charsets()
48 +
49 +Return the charsets that the request accepts, in the order of the client's
50 +preference (most preferred first).
51 +
52 +#### .encoding(encodings)
53 +
54 +Return the first accepted encoding. If nothing in `encodings` is accepted,
55 +then `false` is returned.
56 +
57 +#### .encodings()
58 +
59 +Return the encodings that the request accepts, in the order of the client's
60 +preference (most preferred first).
61 +
62 +#### .language(languages)
63 +
64 +Return the first accepted language. If nothing in `languages` is accepted,
65 +then `false` is returned.
66 +
67 +#### .languages()
68 +
69 +Return the languages that the request accepts, in the order of the client's
70 +preference (most preferred first).
71 +
72 +#### .type(types)
73 +
74 +Return the first accepted type (and it is returned as the same text as what
75 +appears in the `types` array). If nothing in `types` is accepted, then `false`
76 +is returned.
77 +
78 +The `types` array can contain full MIME types or file extensions. Any value
79 +that is not a full MIME types is passed to `require('mime-types').lookup`.
80 +
81 +#### .types()
82 +
83 +Return the types that the request accepts, in the order of the client's
84 +preference (most preferred first).
85 +
86 +## Examples
87 +
88 +### Simple type negotiation
89 +
90 +This simple example shows how to use `accepts` to return a different typed
91 +respond body based on what the client wants to accept. The server lists it's
92 +preferences in order and will get back the best match between the client and
93 +server.
94 +
95 +```js
96 +var accepts = require('accepts')
97 +var http = require('http')
98 +
99 +function app (req, res) {
100 + var accept = accepts(req)
101 +
102 + // the order of this list is significant; should be server preferred order
103 + switch (accept.type(['json', 'html'])) {
104 + case 'json':
105 + res.setHeader('Content-Type', 'application/json')
106 + res.write('{"hello":"world!"}')
107 + break
108 + case 'html':
109 + res.setHeader('Content-Type', 'text/html')
110 + res.write('<b>hello, world!</b>')
111 + break
112 + default:
113 + // the fallback is text/plain, so no need to specify it above
114 + res.setHeader('Content-Type', 'text/plain')
115 + res.write('hello, world!')
116 + break
117 + }
118 +
119 + res.end()
120 +}
121 +
122 +http.createServer(app).listen(3000)
123 +```
124 +
125 +You can test this out with the cURL program:
126 +```sh
127 +curl -I -H'Accept: text/html' http://localhost:3000/
128 +```
129 +
130 +## License
131 +
132 +[MIT](LICENSE)
133 +
134 +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
135 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
136 +[node-version-image]: https://badgen.net/npm/node/accepts
137 +[node-version-url]: https://nodejs.org/en/download
138 +[npm-downloads-image]: https://badgen.net/npm/dm/accepts
139 +[npm-url]: https://npmjs.org/package/accepts
140 +[npm-version-image]: https://badgen.net/npm/v/accepts
141 +[travis-image]: https://badgen.net/travis/jshttp/accepts/master
142 +[travis-url]: https://travis-ci.org/jshttp/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "_args": [
3 + [
4 + "accepts@1.3.7",
5 + "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot"
6 + ]
7 + ],
8 + "_from": "accepts@1.3.7",
9 + "_id": "accepts@1.3.7",
10 + "_inBundle": false,
11 + "_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
12 + "_location": "/accepts",
13 + "_phantomChildren": {},
14 + "_requested": {
15 + "type": "version",
16 + "registry": true,
17 + "raw": "accepts@1.3.7",
18 + "name": "accepts",
19 + "escapedName": "accepts",
20 + "rawSpec": "1.3.7",
21 + "saveSpec": null,
22 + "fetchSpec": "1.3.7"
23 + },
24 + "_requiredBy": [
25 + "/express"
26 + ],
27 + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
28 + "_spec": "1.3.7",
29 + "_where": "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot",
30 + "bugs": {
31 + "url": "https://github.com/jshttp/accepts/issues"
32 + },
33 + "contributors": [
34 + {
35 + "name": "Douglas Christopher Wilson",
36 + "email": "doug@somethingdoug.com"
37 + },
38 + {
39 + "name": "Jonathan Ong",
40 + "email": "me@jongleberry.com",
41 + "url": "http://jongleberry.com"
42 + }
43 + ],
44 + "dependencies": {
45 + "mime-types": "~2.1.24",
46 + "negotiator": "0.6.2"
47 + },
48 + "description": "Higher-level content negotiation",
49 + "devDependencies": {
50 + "deep-equal": "1.0.1",
51 + "eslint": "5.16.0",
52 + "eslint-config-standard": "12.0.0",
53 + "eslint-plugin-import": "2.17.2",
54 + "eslint-plugin-markdown": "1.0.0",
55 + "eslint-plugin-node": "8.0.1",
56 + "eslint-plugin-promise": "4.1.1",
57 + "eslint-plugin-standard": "4.0.0",
58 + "mocha": "6.1.4",
59 + "nyc": "14.0.0"
60 + },
61 + "engines": {
62 + "node": ">= 0.6"
63 + },
64 + "files": [
65 + "LICENSE",
66 + "HISTORY.md",
67 + "index.js"
68 + ],
69 + "homepage": "https://github.com/jshttp/accepts#readme",
70 + "keywords": [
71 + "content",
72 + "negotiation",
73 + "accept",
74 + "accepts"
75 + ],
76 + "license": "MIT",
77 + "name": "accepts",
78 + "repository": {
79 + "type": "git",
80 + "url": "git+https://github.com/jshttp/accepts.git"
81 + },
82 + "scripts": {
83 + "lint": "eslint --plugin markdown --ext js,md .",
84 + "test": "mocha --reporter spec --check-leaks --bail test/",
85 + "test-cov": "nyc --reporter=html --reporter=text npm test",
86 + "test-travis": "nyc --reporter=text npm test"
87 + },
88 + "version": "1.3.7"
89 +}
1 +agent-base
2 +==========
3 +### Turn a function into an [`http.Agent`][http.Agent] instance
4 +[![Build Status](https://github.com/TooTallNate/node-agent-base/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/node-agent-base/actions?workflow=Node+CI)
5 +
6 +This module provides an `http.Agent` generator. That is, you pass it an async
7 +callback function, and it returns a new `http.Agent` instance that will invoke the
8 +given callback function when sending outbound HTTP requests.
9 +
10 +#### Some subclasses:
11 +
12 +Here's some more interesting uses of `agent-base`.
13 +Send a pull request to list yours!
14 +
15 + * [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
16 + * [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
17 + * [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
18 + * [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
19 +
20 +
21 +Installation
22 +------------
23 +
24 +Install with `npm`:
25 +
26 +``` bash
27 +$ npm install agent-base
28 +```
29 +
30 +
31 +Example
32 +-------
33 +
34 +Here's a minimal example that creates a new `net.Socket` connection to the server
35 +for every HTTP request (i.e. the equivalent of `agent: false` option):
36 +
37 +```js
38 +var net = require('net');
39 +var tls = require('tls');
40 +var url = require('url');
41 +var http = require('http');
42 +var agent = require('agent-base');
43 +
44 +var endpoint = 'http://nodejs.org/api/';
45 +var parsed = url.parse(endpoint);
46 +
47 +// This is the important part!
48 +parsed.agent = agent(function (req, opts) {
49 + var socket;
50 + // `secureEndpoint` is true when using the https module
51 + if (opts.secureEndpoint) {
52 + socket = tls.connect(opts);
53 + } else {
54 + socket = net.connect(opts);
55 + }
56 + return socket;
57 +});
58 +
59 +// Everything else works just like normal...
60 +http.get(parsed, function (res) {
61 + console.log('"response" event!', res.headers);
62 + res.pipe(process.stdout);
63 +});
64 +```
65 +
66 +Returning a Promise or using an `async` function is also supported:
67 +
68 +```js
69 +agent(async function (req, opts) {
70 + await sleep(1000);
71 + // etc…
72 +});
73 +```
74 +
75 +Return another `http.Agent` instance to "pass through" the responsibility
76 +for that HTTP request to that agent:
77 +
78 +```js
79 +agent(function (req, opts) {
80 + return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
81 +});
82 +```
83 +
84 +
85 +API
86 +---
87 +
88 +## Agent(Function callback[, Object options]) → [http.Agent][]
89 +
90 +Creates a base `http.Agent` that will execute the callback function `callback`
91 +for every HTTP request that it is used as the `agent` for. The callback function
92 +is responsible for creating a `stream.Duplex` instance of some kind that will be
93 +used as the underlying socket in the HTTP request.
94 +
95 +The `options` object accepts the following properties:
96 +
97 + * `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
98 +
99 +The callback function should have the following signature:
100 +
101 +### callback(http.ClientRequest req, Object options, Function cb) → undefined
102 +
103 +The ClientRequest `req` can be accessed to read request headers and
104 +and the path, etc. The `options` object contains the options passed
105 +to the `http.request()`/`https.request()` function call, and is formatted
106 +to be directly passed to `net.connect()`/`tls.connect()`, or however
107 +else you want a Socket to be created. Pass the created socket to
108 +the callback function `cb` once created, and the HTTP request will
109 +continue to proceed.
110 +
111 +If the `https` module is used to invoke the HTTP request, then the
112 +`secureEndpoint` property on `options` _will be set to `true`_.
113 +
114 +
115 +License
116 +-------
117 +
118 +(The MIT License)
119 +
120 +Copyright (c) 2013 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
121 +
122 +Permission is hereby granted, free of charge, to any person obtaining
123 +a copy of this software and associated documentation files (the
124 +'Software'), to deal in the Software without restriction, including
125 +without limitation the rights to use, copy, modify, merge, publish,
126 +distribute, sublicense, and/or sell copies of the Software, and to
127 +permit persons to whom the Software is furnished to do so, subject to
128 +the following conditions:
129 +
130 +The above copyright notice and this permission notice shall be
131 +included in all copies or substantial portions of the Software.
132 +
133 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
134 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
135 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
136 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
137 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
138 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
139 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
140 +
141 +[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
142 +[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
143 +[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
144 +[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
145 +[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
1 +/// <reference types="node" />
2 +import net from 'net';
3 +import http from 'http';
4 +import https from 'https';
5 +import { Duplex } from 'stream';
6 +import { EventEmitter } from 'events';
7 +declare function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
8 +declare function createAgent(callback: createAgent.AgentCallback, opts?: createAgent.AgentOptions): createAgent.Agent;
9 +declare namespace createAgent {
10 + interface ClientRequest extends http.ClientRequest {
11 + _last?: boolean;
12 + _hadError?: boolean;
13 + method: string;
14 + }
15 + interface AgentRequestOptions {
16 + host?: string;
17 + path?: string;
18 + port: number;
19 + }
20 + interface HttpRequestOptions extends AgentRequestOptions, Omit<http.RequestOptions, keyof AgentRequestOptions> {
21 + secureEndpoint: false;
22 + }
23 + interface HttpsRequestOptions extends AgentRequestOptions, Omit<https.RequestOptions, keyof AgentRequestOptions> {
24 + secureEndpoint: true;
25 + }
26 + type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
27 + type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
28 + type AgentCallbackReturn = Duplex | AgentLike;
29 + type AgentCallbackCallback = (err?: Error | null, socket?: createAgent.AgentCallbackReturn) => void;
30 + type AgentCallbackPromise = (req: createAgent.ClientRequest, opts: createAgent.RequestOptions) => createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
31 + type AgentCallback = typeof Agent.prototype.callback;
32 + type AgentOptions = {
33 + timeout?: number;
34 + };
35 + /**
36 + * Base `http.Agent` implementation.
37 + * No pooling/keep-alive is implemented by default.
38 + *
39 + * @param {Function} callback
40 + * @api public
41 + */
42 + class Agent extends EventEmitter {
43 + timeout: number | null;
44 + maxFreeSockets: number;
45 + maxTotalSockets: number;
46 + maxSockets: number;
47 + sockets: {
48 + [key: string]: net.Socket[];
49 + };
50 + freeSockets: {
51 + [key: string]: net.Socket[];
52 + };
53 + requests: {
54 + [key: string]: http.IncomingMessage[];
55 + };
56 + options: https.AgentOptions;
57 + private promisifiedCallback?;
58 + private explicitDefaultPort?;
59 + private explicitProtocol?;
60 + constructor(callback?: createAgent.AgentCallback | createAgent.AgentOptions, _opts?: createAgent.AgentOptions);
61 + get defaultPort(): number;
62 + set defaultPort(v: number);
63 + get protocol(): string;
64 + set protocol(v: string);
65 + callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions, fn: createAgent.AgentCallbackCallback): void;
66 + callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions): createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
67 + /**
68 + * Called by node-core's "_http_client.js" module when creating
69 + * a new HTTP request with this Agent instance.
70 + *
71 + * @api public
72 + */
73 + addRequest(req: ClientRequest, _opts: RequestOptions): void;
74 + freeSocket(socket: net.Socket, opts: AgentOptions): void;
75 + destroy(): void;
76 + }
77 +}
78 +export = createAgent;
1 +"use strict";
2 +var __importDefault = (this && this.__importDefault) || function (mod) {
3 + return (mod && mod.__esModule) ? mod : { "default": mod };
4 +};
5 +const events_1 = require("events");
6 +const debug_1 = __importDefault(require("debug"));
7 +const promisify_1 = __importDefault(require("./promisify"));
8 +const debug = debug_1.default('agent-base');
9 +function isAgent(v) {
10 + return Boolean(v) && typeof v.addRequest === 'function';
11 +}
12 +function isSecureEndpoint() {
13 + const { stack } = new Error();
14 + if (typeof stack !== 'string')
15 + return false;
16 + return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
17 +}
18 +function createAgent(callback, opts) {
19 + return new createAgent.Agent(callback, opts);
20 +}
21 +(function (createAgent) {
22 + /**
23 + * Base `http.Agent` implementation.
24 + * No pooling/keep-alive is implemented by default.
25 + *
26 + * @param {Function} callback
27 + * @api public
28 + */
29 + class Agent extends events_1.EventEmitter {
30 + constructor(callback, _opts) {
31 + super();
32 + let opts = _opts;
33 + if (typeof callback === 'function') {
34 + this.callback = callback;
35 + }
36 + else if (callback) {
37 + opts = callback;
38 + }
39 + // Timeout for the socket to be returned from the callback
40 + this.timeout = null;
41 + if (opts && typeof opts.timeout === 'number') {
42 + this.timeout = opts.timeout;
43 + }
44 + // These aren't actually used by `agent-base`, but are required
45 + // for the TypeScript definition files in `@types/node` :/
46 + this.maxFreeSockets = 1;
47 + this.maxSockets = 1;
48 + this.maxTotalSockets = Infinity;
49 + this.sockets = {};
50 + this.freeSockets = {};
51 + this.requests = {};
52 + this.options = {};
53 + }
54 + get defaultPort() {
55 + if (typeof this.explicitDefaultPort === 'number') {
56 + return this.explicitDefaultPort;
57 + }
58 + return isSecureEndpoint() ? 443 : 80;
59 + }
60 + set defaultPort(v) {
61 + this.explicitDefaultPort = v;
62 + }
63 + get protocol() {
64 + if (typeof this.explicitProtocol === 'string') {
65 + return this.explicitProtocol;
66 + }
67 + return isSecureEndpoint() ? 'https:' : 'http:';
68 + }
69 + set protocol(v) {
70 + this.explicitProtocol = v;
71 + }
72 + callback(req, opts, fn) {
73 + throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
74 + }
75 + /**
76 + * Called by node-core's "_http_client.js" module when creating
77 + * a new HTTP request with this Agent instance.
78 + *
79 + * @api public
80 + */
81 + addRequest(req, _opts) {
82 + const opts = Object.assign({}, _opts);
83 + if (typeof opts.secureEndpoint !== 'boolean') {
84 + opts.secureEndpoint = isSecureEndpoint();
85 + }
86 + if (opts.host == null) {
87 + opts.host = 'localhost';
88 + }
89 + if (opts.port == null) {
90 + opts.port = opts.secureEndpoint ? 443 : 80;
91 + }
92 + if (opts.protocol == null) {
93 + opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
94 + }
95 + if (opts.host && opts.path) {
96 + // If both a `host` and `path` are specified then it's most
97 + // likely the result of a `url.parse()` call... we need to
98 + // remove the `path` portion so that `net.connect()` doesn't
99 + // attempt to open that as a unix socket file.
100 + delete opts.path;
101 + }
102 + delete opts.agent;
103 + delete opts.hostname;
104 + delete opts._defaultAgent;
105 + delete opts.defaultPort;
106 + delete opts.createConnection;
107 + // Hint to use "Connection: close"
108 + // XXX: non-documented `http` module API :(
109 + req._last = true;
110 + req.shouldKeepAlive = false;
111 + let timedOut = false;
112 + let timeoutId = null;
113 + const timeoutMs = opts.timeout || this.timeout;
114 + const onerror = (err) => {
115 + if (req._hadError)
116 + return;
117 + req.emit('error', err);
118 + // For Safety. Some additional errors might fire later on
119 + // and we need to make sure we don't double-fire the error event.
120 + req._hadError = true;
121 + };
122 + const ontimeout = () => {
123 + timeoutId = null;
124 + timedOut = true;
125 + const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
126 + err.code = 'ETIMEOUT';
127 + onerror(err);
128 + };
129 + const callbackError = (err) => {
130 + if (timedOut)
131 + return;
132 + if (timeoutId !== null) {
133 + clearTimeout(timeoutId);
134 + timeoutId = null;
135 + }
136 + onerror(err);
137 + };
138 + const onsocket = (socket) => {
139 + if (timedOut)
140 + return;
141 + if (timeoutId != null) {
142 + clearTimeout(timeoutId);
143 + timeoutId = null;
144 + }
145 + if (isAgent(socket)) {
146 + // `socket` is actually an `http.Agent` instance, so
147 + // relinquish responsibility for this `req` to the Agent
148 + // from here on
149 + debug('Callback returned another Agent instance %o', socket.constructor.name);
150 + socket.addRequest(req, opts);
151 + return;
152 + }
153 + if (socket) {
154 + socket.once('free', () => {
155 + this.freeSocket(socket, opts);
156 + });
157 + req.onSocket(socket);
158 + return;
159 + }
160 + const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
161 + onerror(err);
162 + };
163 + if (typeof this.callback !== 'function') {
164 + onerror(new Error('`callback` is not defined'));
165 + return;
166 + }
167 + if (!this.promisifiedCallback) {
168 + if (this.callback.length >= 3) {
169 + debug('Converting legacy callback function to promise');
170 + this.promisifiedCallback = promisify_1.default(this.callback);
171 + }
172 + else {
173 + this.promisifiedCallback = this.callback;
174 + }
175 + }
176 + if (typeof timeoutMs === 'number' && timeoutMs > 0) {
177 + timeoutId = setTimeout(ontimeout, timeoutMs);
178 + }
179 + if ('port' in opts && typeof opts.port !== 'number') {
180 + opts.port = Number(opts.port);
181 + }
182 + try {
183 + debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
184 + Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
185 + }
186 + catch (err) {
187 + Promise.reject(err).catch(callbackError);
188 + }
189 + }
190 + freeSocket(socket, opts) {
191 + debug('Freeing socket %o %o', socket.constructor.name, opts);
192 + socket.destroy();
193 + }
194 + destroy() {
195 + debug('Destroying agent %o', this.constructor.name);
196 + }
197 + }
198 + createAgent.Agent = Agent;
199 + // So that `instanceof` works correctly
200 + createAgent.prototype = createAgent.Agent.prototype;
201 +})(createAgent || (createAgent = {}));
202 +module.exports = createAgent;
203 +//# sourceMappingURL=index.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
...\ No newline at end of file ...\ No newline at end of file
1 +import { ClientRequest, RequestOptions, AgentCallbackCallback, AgentCallbackPromise } from './index';
2 +declare type LegacyCallback = (req: ClientRequest, opts: RequestOptions, fn: AgentCallbackCallback) => void;
3 +export default function promisify(fn: LegacyCallback): AgentCallbackPromise;
4 +export {};
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +function promisify(fn) {
4 + return function (req, opts) {
5 + return new Promise((resolve, reject) => {
6 + fn.call(this, req, opts, (err, rtn) => {
7 + if (err) {
8 + reject(err);
9 + }
10 + else {
11 + resolve(rtn);
12 + }
13 + });
14 + });
15 + };
16 +}
17 +exports.default = promisify;
18 +//# sourceMappingURL=promisify.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"promisify.js","sourceRoot":"","sources":["../../src/promisify.ts"],"names":[],"mappings":";;AAeA,SAAwB,SAAS,CAAC,EAAkB;IACnD,OAAO,UAAsB,GAAkB,EAAE,IAAoB;QACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,EAAE,CAAC,IAAI,CACN,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,CAAC,GAA6B,EAAE,GAAyB,EAAE,EAAE;gBAC5D,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;iBACZ;qBAAM;oBACN,OAAO,CAAC,GAAG,CAAC,CAAC;iBACb;YACF,CAAC,CACD,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAjBD,4BAiBC"}
...\ No newline at end of file ...\ No newline at end of file
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software
6 +and associated documentation files (the 'Software'), to deal in the Software without restriction,
7 +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 +subject to the following conditions:
10 +
11 +The above copyright notice and this permission notice shall be included in all copies or substantial
12 +portions of the Software.
13 +
14 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 +
This diff is collapsed. Click to expand it.
1 +{
2 + "_args": [
3 + [
4 + "debug@4.3.1",
5 + "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot"
6 + ]
7 + ],
8 + "_from": "debug@4.3.1",
9 + "_id": "debug@4.3.1",
10 + "_inBundle": false,
11 + "_integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
12 + "_location": "/agent-base/debug",
13 + "_phantomChildren": {},
14 + "_requested": {
15 + "type": "version",
16 + "registry": true,
17 + "raw": "debug@4.3.1",
18 + "name": "debug",
19 + "escapedName": "debug",
20 + "rawSpec": "4.3.1",
21 + "saveSpec": null,
22 + "fetchSpec": "4.3.1"
23 + },
24 + "_requiredBy": [
25 + "/agent-base"
26 + ],
27 + "_resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
28 + "_spec": "4.3.1",
29 + "_where": "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot",
30 + "author": {
31 + "name": "TJ Holowaychuk",
32 + "email": "tj@vision-media.ca"
33 + },
34 + "browser": "./src/browser.js",
35 + "bugs": {
36 + "url": "https://github.com/visionmedia/debug/issues"
37 + },
38 + "contributors": [
39 + {
40 + "name": "Nathan Rajlich",
41 + "email": "nathan@tootallnate.net",
42 + "url": "http://n8.io"
43 + },
44 + {
45 + "name": "Andrew Rhyne",
46 + "email": "rhyneandrew@gmail.com"
47 + },
48 + {
49 + "name": "Josh Junon",
50 + "email": "josh@junon.me"
51 + }
52 + ],
53 + "dependencies": {
54 + "ms": "2.1.2"
55 + },
56 + "description": "small debugging utility",
57 + "devDependencies": {
58 + "brfs": "^2.0.1",
59 + "browserify": "^16.2.3",
60 + "coveralls": "^3.0.2",
61 + "istanbul": "^0.4.5",
62 + "karma": "^3.1.4",
63 + "karma-browserify": "^6.0.0",
64 + "karma-chrome-launcher": "^2.2.0",
65 + "karma-mocha": "^1.3.0",
66 + "mocha": "^5.2.0",
67 + "mocha-lcov-reporter": "^1.2.0",
68 + "xo": "^0.23.0"
69 + },
70 + "engines": {
71 + "node": ">=6.0"
72 + },
73 + "files": [
74 + "src",
75 + "LICENSE",
76 + "README.md"
77 + ],
78 + "homepage": "https://github.com/visionmedia/debug#readme",
79 + "keywords": [
80 + "debug",
81 + "log",
82 + "debugger"
83 + ],
84 + "license": "MIT",
85 + "main": "./src/index.js",
86 + "name": "debug",
87 + "peerDependenciesMeta": {
88 + "supports-color": {
89 + "optional": true
90 + }
91 + },
92 + "repository": {
93 + "type": "git",
94 + "url": "git://github.com/visionmedia/debug.git"
95 + },
96 + "scripts": {
97 + "lint": "xo",
98 + "test": "npm run test:node && npm run test:browser && npm run lint",
99 + "test:browser": "karma start --single-run",
100 + "test:coverage": "cat ./coverage/lcov.info | coveralls",
101 + "test:node": "istanbul cover _mocha -- test.js"
102 + },
103 + "version": "4.3.1"
104 +}
1 +/* eslint-env browser */
2 +
3 +/**
4 + * This is the web browser implementation of `debug()`.
5 + */
6 +
7 +exports.formatArgs = formatArgs;
8 +exports.save = save;
9 +exports.load = load;
10 +exports.useColors = useColors;
11 +exports.storage = localstorage();
12 +exports.destroy = (() => {
13 + let warned = false;
14 +
15 + return () => {
16 + if (!warned) {
17 + warned = true;
18 + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
19 + }
20 + };
21 +})();
22 +
23 +/**
24 + * Colors.
25 + */
26 +
27 +exports.colors = [
28 + '#0000CC',
29 + '#0000FF',
30 + '#0033CC',
31 + '#0033FF',
32 + '#0066CC',
33 + '#0066FF',
34 + '#0099CC',
35 + '#0099FF',
36 + '#00CC00',
37 + '#00CC33',
38 + '#00CC66',
39 + '#00CC99',
40 + '#00CCCC',
41 + '#00CCFF',
42 + '#3300CC',
43 + '#3300FF',
44 + '#3333CC',
45 + '#3333FF',
46 + '#3366CC',
47 + '#3366FF',
48 + '#3399CC',
49 + '#3399FF',
50 + '#33CC00',
51 + '#33CC33',
52 + '#33CC66',
53 + '#33CC99',
54 + '#33CCCC',
55 + '#33CCFF',
56 + '#6600CC',
57 + '#6600FF',
58 + '#6633CC',
59 + '#6633FF',
60 + '#66CC00',
61 + '#66CC33',
62 + '#9900CC',
63 + '#9900FF',
64 + '#9933CC',
65 + '#9933FF',
66 + '#99CC00',
67 + '#99CC33',
68 + '#CC0000',
69 + '#CC0033',
70 + '#CC0066',
71 + '#CC0099',
72 + '#CC00CC',
73 + '#CC00FF',
74 + '#CC3300',
75 + '#CC3333',
76 + '#CC3366',
77 + '#CC3399',
78 + '#CC33CC',
79 + '#CC33FF',
80 + '#CC6600',
81 + '#CC6633',
82 + '#CC9900',
83 + '#CC9933',
84 + '#CCCC00',
85 + '#CCCC33',
86 + '#FF0000',
87 + '#FF0033',
88 + '#FF0066',
89 + '#FF0099',
90 + '#FF00CC',
91 + '#FF00FF',
92 + '#FF3300',
93 + '#FF3333',
94 + '#FF3366',
95 + '#FF3399',
96 + '#FF33CC',
97 + '#FF33FF',
98 + '#FF6600',
99 + '#FF6633',
100 + '#FF9900',
101 + '#FF9933',
102 + '#FFCC00',
103 + '#FFCC33'
104 +];
105 +
106 +/**
107 + * Currently only WebKit-based Web Inspectors, Firefox >= v31,
108 + * and the Firebug extension (any Firefox version) are known
109 + * to support "%c" CSS customizations.
110 + *
111 + * TODO: add a `localStorage` variable to explicitly enable/disable colors
112 + */
113 +
114 +// eslint-disable-next-line complexity
115 +function useColors() {
116 + // NB: In an Electron preload script, document will be defined but not fully
117 + // initialized. Since we know we're in Chrome, we'll just detect this case
118 + // explicitly
119 + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
120 + return true;
121 + }
122 +
123 + // Internet Explorer and Edge do not support colors.
124 + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
125 + return false;
126 + }
127 +
128 + // Is webkit? http://stackoverflow.com/a/16459606/376773
129 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
130 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
131 + // Is firebug? http://stackoverflow.com/a/398120/376773
132 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
133 + // Is firefox >= v31?
134 + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
135 + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
136 + // Double check webkit in userAgent just in case we are in a worker
137 + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
138 +}
139 +
140 +/**
141 + * Colorize log arguments if enabled.
142 + *
143 + * @api public
144 + */
145 +
146 +function formatArgs(args) {
147 + args[0] = (this.useColors ? '%c' : '') +
148 + this.namespace +
149 + (this.useColors ? ' %c' : ' ') +
150 + args[0] +
151 + (this.useColors ? '%c ' : ' ') +
152 + '+' + module.exports.humanize(this.diff);
153 +
154 + if (!this.useColors) {
155 + return;
156 + }
157 +
158 + const c = 'color: ' + this.color;
159 + args.splice(1, 0, c, 'color: inherit');
160 +
161 + // The final "%c" is somewhat tricky, because there could be other
162 + // arguments passed either before or after the %c, so we need to
163 + // figure out the correct index to insert the CSS into
164 + let index = 0;
165 + let lastC = 0;
166 + args[0].replace(/%[a-zA-Z%]/g, match => {
167 + if (match === '%%') {
168 + return;
169 + }
170 + index++;
171 + if (match === '%c') {
172 + // We only are interested in the *last* %c
173 + // (the user may have provided their own)
174 + lastC = index;
175 + }
176 + });
177 +
178 + args.splice(lastC, 0, c);
179 +}
180 +
181 +/**
182 + * Invokes `console.debug()` when available.
183 + * No-op when `console.debug` is not a "function".
184 + * If `console.debug` is not available, falls back
185 + * to `console.log`.
186 + *
187 + * @api public
188 + */
189 +exports.log = console.debug || console.log || (() => {});
190 +
191 +/**
192 + * Save `namespaces`.
193 + *
194 + * @param {String} namespaces
195 + * @api private
196 + */
197 +function save(namespaces) {
198 + try {
199 + if (namespaces) {
200 + exports.storage.setItem('debug', namespaces);
201 + } else {
202 + exports.storage.removeItem('debug');
203 + }
204 + } catch (error) {
205 + // Swallow
206 + // XXX (@Qix-) should we be logging these?
207 + }
208 +}
209 +
210 +/**
211 + * Load `namespaces`.
212 + *
213 + * @return {String} returns the previously persisted debug modes
214 + * @api private
215 + */
216 +function load() {
217 + let r;
218 + try {
219 + r = exports.storage.getItem('debug');
220 + } catch (error) {
221 + // Swallow
222 + // XXX (@Qix-) should we be logging these?
223 + }
224 +
225 + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
226 + if (!r && typeof process !== 'undefined' && 'env' in process) {
227 + r = process.env.DEBUG;
228 + }
229 +
230 + return r;
231 +}
232 +
233 +/**
234 + * Localstorage attempts to return the localstorage.
235 + *
236 + * This is necessary because safari throws
237 + * when a user disables cookies/localstorage
238 + * and you attempt to access it.
239 + *
240 + * @return {LocalStorage}
241 + * @api private
242 + */
243 +
244 +function localstorage() {
245 + try {
246 + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
247 + // The Browser also has localStorage in the global context.
248 + return localStorage;
249 + } catch (error) {
250 + // Swallow
251 + // XXX (@Qix-) should we be logging these?
252 + }
253 +}
254 +
255 +module.exports = require('./common')(exports);
256 +
257 +const {formatters} = module.exports;
258 +
259 +/**
260 + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
261 + */
262 +
263 +formatters.j = function (v) {
264 + try {
265 + return JSON.stringify(v);
266 + } catch (error) {
267 + return '[UnexpectedJSONParseError]: ' + error.message;
268 + }
269 +};
1 +
2 +/**
3 + * This is the common logic for both the Node.js and web browser
4 + * implementations of `debug()`.
5 + */
6 +
7 +function setup(env) {
8 + createDebug.debug = createDebug;
9 + createDebug.default = createDebug;
10 + createDebug.coerce = coerce;
11 + createDebug.disable = disable;
12 + createDebug.enable = enable;
13 + createDebug.enabled = enabled;
14 + createDebug.humanize = require('ms');
15 + createDebug.destroy = destroy;
16 +
17 + Object.keys(env).forEach(key => {
18 + createDebug[key] = env[key];
19 + });
20 +
21 + /**
22 + * The currently active debug mode names, and names to skip.
23 + */
24 +
25 + createDebug.names = [];
26 + createDebug.skips = [];
27 +
28 + /**
29 + * Map of special "%n" handling functions, for the debug "format" argument.
30 + *
31 + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
32 + */
33 + createDebug.formatters = {};
34 +
35 + /**
36 + * Selects a color for a debug namespace
37 + * @param {String} namespace The namespace string for the for the debug instance to be colored
38 + * @return {Number|String} An ANSI color code for the given namespace
39 + * @api private
40 + */
41 + function selectColor(namespace) {
42 + let hash = 0;
43 +
44 + for (let i = 0; i < namespace.length; i++) {
45 + hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
46 + hash |= 0; // Convert to 32bit integer
47 + }
48 +
49 + return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
50 + }
51 + createDebug.selectColor = selectColor;
52 +
53 + /**
54 + * Create a debugger with the given `namespace`.
55 + *
56 + * @param {String} namespace
57 + * @return {Function}
58 + * @api public
59 + */
60 + function createDebug(namespace) {
61 + let prevTime;
62 + let enableOverride = null;
63 +
64 + function debug(...args) {
65 + // Disabled?
66 + if (!debug.enabled) {
67 + return;
68 + }
69 +
70 + const self = debug;
71 +
72 + // Set `diff` timestamp
73 + const curr = Number(new Date());
74 + const ms = curr - (prevTime || curr);
75 + self.diff = ms;
76 + self.prev = prevTime;
77 + self.curr = curr;
78 + prevTime = curr;
79 +
80 + args[0] = createDebug.coerce(args[0]);
81 +
82 + if (typeof args[0] !== 'string') {
83 + // Anything else let's inspect with %O
84 + args.unshift('%O');
85 + }
86 +
87 + // Apply any `formatters` transformations
88 + let index = 0;
89 + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
90 + // If we encounter an escaped % then don't increase the array index
91 + if (match === '%%') {
92 + return '%';
93 + }
94 + index++;
95 + const formatter = createDebug.formatters[format];
96 + if (typeof formatter === 'function') {
97 + const val = args[index];
98 + match = formatter.call(self, val);
99 +
100 + // Now we need to remove `args[index]` since it's inlined in the `format`
101 + args.splice(index, 1);
102 + index--;
103 + }
104 + return match;
105 + });
106 +
107 + // Apply env-specific formatting (colors, etc.)
108 + createDebug.formatArgs.call(self, args);
109 +
110 + const logFn = self.log || createDebug.log;
111 + logFn.apply(self, args);
112 + }
113 +
114 + debug.namespace = namespace;
115 + debug.useColors = createDebug.useColors();
116 + debug.color = createDebug.selectColor(namespace);
117 + debug.extend = extend;
118 + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
119 +
120 + Object.defineProperty(debug, 'enabled', {
121 + enumerable: true,
122 + configurable: false,
123 + get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
124 + set: v => {
125 + enableOverride = v;
126 + }
127 + });
128 +
129 + // Env-specific initialization logic for debug instances
130 + if (typeof createDebug.init === 'function') {
131 + createDebug.init(debug);
132 + }
133 +
134 + return debug;
135 + }
136 +
137 + function extend(namespace, delimiter) {
138 + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
139 + newDebug.log = this.log;
140 + return newDebug;
141 + }
142 +
143 + /**
144 + * Enables a debug mode by namespaces. This can include modes
145 + * separated by a colon and wildcards.
146 + *
147 + * @param {String} namespaces
148 + * @api public
149 + */
150 + function enable(namespaces) {
151 + createDebug.save(namespaces);
152 +
153 + createDebug.names = [];
154 + createDebug.skips = [];
155 +
156 + let i;
157 + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
158 + const len = split.length;
159 +
160 + for (i = 0; i < len; i++) {
161 + if (!split[i]) {
162 + // ignore empty strings
163 + continue;
164 + }
165 +
166 + namespaces = split[i].replace(/\*/g, '.*?');
167 +
168 + if (namespaces[0] === '-') {
169 + createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
170 + } else {
171 + createDebug.names.push(new RegExp('^' + namespaces + '$'));
172 + }
173 + }
174 + }
175 +
176 + /**
177 + * Disable debug output.
178 + *
179 + * @return {String} namespaces
180 + * @api public
181 + */
182 + function disable() {
183 + const namespaces = [
184 + ...createDebug.names.map(toNamespace),
185 + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
186 + ].join(',');
187 + createDebug.enable('');
188 + return namespaces;
189 + }
190 +
191 + /**
192 + * Returns true if the given mode name is enabled, false otherwise.
193 + *
194 + * @param {String} name
195 + * @return {Boolean}
196 + * @api public
197 + */
198 + function enabled(name) {
199 + if (name[name.length - 1] === '*') {
200 + return true;
201 + }
202 +
203 + let i;
204 + let len;
205 +
206 + for (i = 0, len = createDebug.skips.length; i < len; i++) {
207 + if (createDebug.skips[i].test(name)) {
208 + return false;
209 + }
210 + }
211 +
212 + for (i = 0, len = createDebug.names.length; i < len; i++) {
213 + if (createDebug.names[i].test(name)) {
214 + return true;
215 + }
216 + }
217 +
218 + return false;
219 + }
220 +
221 + /**
222 + * Convert regexp to namespace
223 + *
224 + * @param {RegExp} regxep
225 + * @return {String} namespace
226 + * @api private
227 + */
228 + function toNamespace(regexp) {
229 + return regexp.toString()
230 + .substring(2, regexp.toString().length - 2)
231 + .replace(/\.\*\?$/, '*');
232 + }
233 +
234 + /**
235 + * Coerce `val`.
236 + *
237 + * @param {Mixed} val
238 + * @return {Mixed}
239 + * @api private
240 + */
241 + function coerce(val) {
242 + if (val instanceof Error) {
243 + return val.stack || val.message;
244 + }
245 + return val;
246 + }
247 +
248 + /**
249 + * XXX DO NOT USE. This is a temporary stub function.
250 + * XXX It WILL be removed in the next major release.
251 + */
252 + function destroy() {
253 + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
254 + }
255 +
256 + createDebug.enable(createDebug.load());
257 +
258 + return createDebug;
259 +}
260 +
261 +module.exports = setup;
1 +/**
2 + * Detect Electron renderer / nwjs process, which is node, but we should
3 + * treat as a browser.
4 + */
5 +
6 +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
7 + module.exports = require('./browser.js');
8 +} else {
9 + module.exports = require('./node.js');
10 +}
1 +/**
2 + * Module dependencies.
3 + */
4 +
5 +const tty = require('tty');
6 +const util = require('util');
7 +
8 +/**
9 + * This is the Node.js implementation of `debug()`.
10 + */
11 +
12 +exports.init = init;
13 +exports.log = log;
14 +exports.formatArgs = formatArgs;
15 +exports.save = save;
16 +exports.load = load;
17 +exports.useColors = useColors;
18 +exports.destroy = util.deprecate(
19 + () => {},
20 + 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
21 +);
22 +
23 +/**
24 + * Colors.
25 + */
26 +
27 +exports.colors = [6, 2, 3, 4, 5, 1];
28 +
29 +try {
30 + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
31 + // eslint-disable-next-line import/no-extraneous-dependencies
32 + const supportsColor = require('supports-color');
33 +
34 + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
35 + exports.colors = [
36 + 20,
37 + 21,
38 + 26,
39 + 27,
40 + 32,
41 + 33,
42 + 38,
43 + 39,
44 + 40,
45 + 41,
46 + 42,
47 + 43,
48 + 44,
49 + 45,
50 + 56,
51 + 57,
52 + 62,
53 + 63,
54 + 68,
55 + 69,
56 + 74,
57 + 75,
58 + 76,
59 + 77,
60 + 78,
61 + 79,
62 + 80,
63 + 81,
64 + 92,
65 + 93,
66 + 98,
67 + 99,
68 + 112,
69 + 113,
70 + 128,
71 + 129,
72 + 134,
73 + 135,
74 + 148,
75 + 149,
76 + 160,
77 + 161,
78 + 162,
79 + 163,
80 + 164,
81 + 165,
82 + 166,
83 + 167,
84 + 168,
85 + 169,
86 + 170,
87 + 171,
88 + 172,
89 + 173,
90 + 178,
91 + 179,
92 + 184,
93 + 185,
94 + 196,
95 + 197,
96 + 198,
97 + 199,
98 + 200,
99 + 201,
100 + 202,
101 + 203,
102 + 204,
103 + 205,
104 + 206,
105 + 207,
106 + 208,
107 + 209,
108 + 214,
109 + 215,
110 + 220,
111 + 221
112 + ];
113 + }
114 +} catch (error) {
115 + // Swallow - we only care if `supports-color` is available; it doesn't have to be.
116 +}
117 +
118 +/**
119 + * Build up the default `inspectOpts` object from the environment variables.
120 + *
121 + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
122 + */
123 +
124 +exports.inspectOpts = Object.keys(process.env).filter(key => {
125 + return /^debug_/i.test(key);
126 +}).reduce((obj, key) => {
127 + // Camel-case
128 + const prop = key
129 + .substring(6)
130 + .toLowerCase()
131 + .replace(/_([a-z])/g, (_, k) => {
132 + return k.toUpperCase();
133 + });
134 +
135 + // Coerce string value into JS value
136 + let val = process.env[key];
137 + if (/^(yes|on|true|enabled)$/i.test(val)) {
138 + val = true;
139 + } else if (/^(no|off|false|disabled)$/i.test(val)) {
140 + val = false;
141 + } else if (val === 'null') {
142 + val = null;
143 + } else {
144 + val = Number(val);
145 + }
146 +
147 + obj[prop] = val;
148 + return obj;
149 +}, {});
150 +
151 +/**
152 + * Is stdout a TTY? Colored output is enabled when `true`.
153 + */
154 +
155 +function useColors() {
156 + return 'colors' in exports.inspectOpts ?
157 + Boolean(exports.inspectOpts.colors) :
158 + tty.isatty(process.stderr.fd);
159 +}
160 +
161 +/**
162 + * Adds ANSI color escape codes if enabled.
163 + *
164 + * @api public
165 + */
166 +
167 +function formatArgs(args) {
168 + const {namespace: name, useColors} = this;
169 +
170 + if (useColors) {
171 + const c = this.color;
172 + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
173 + const prefix = ` ${colorCode};1m${name} \u001B[0m`;
174 +
175 + args[0] = prefix + args[0].split('\n').join('\n' + prefix);
176 + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
177 + } else {
178 + args[0] = getDate() + name + ' ' + args[0];
179 + }
180 +}
181 +
182 +function getDate() {
183 + if (exports.inspectOpts.hideDate) {
184 + return '';
185 + }
186 + return new Date().toISOString() + ' ';
187 +}
188 +
189 +/**
190 + * Invokes `util.format()` with the specified arguments and writes to stderr.
191 + */
192 +
193 +function log(...args) {
194 + return process.stderr.write(util.format(...args) + '\n');
195 +}
196 +
197 +/**
198 + * Save `namespaces`.
199 + *
200 + * @param {String} namespaces
201 + * @api private
202 + */
203 +function save(namespaces) {
204 + if (namespaces) {
205 + process.env.DEBUG = namespaces;
206 + } else {
207 + // If you set a process.env field to null or undefined, it gets cast to the
208 + // string 'null' or 'undefined'. Just delete instead.
209 + delete process.env.DEBUG;
210 + }
211 +}
212 +
213 +/**
214 + * Load `namespaces`.
215 + *
216 + * @return {String} returns the previously persisted debug modes
217 + * @api private
218 + */
219 +
220 +function load() {
221 + return process.env.DEBUG;
222 +}
223 +
224 +/**
225 + * Init logic for `debug` instances.
226 + *
227 + * Create a new `inspectOpts` object in case `useColors` is set
228 + * differently for a particular `debug` instance.
229 + */
230 +
231 +function init(debug) {
232 + debug.inspectOpts = {};
233 +
234 + const keys = Object.keys(exports.inspectOpts);
235 + for (let i = 0; i < keys.length; i++) {
236 + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
237 + }
238 +}
239 +
240 +module.exports = require('./common')(exports);
241 +
242 +const {formatters} = module.exports;
243 +
244 +/**
245 + * Map %o to `util.inspect()`, all on a single line.
246 + */
247 +
248 +formatters.o = function (v) {
249 + this.inspectOpts.colors = this.useColors;
250 + return util.inspect(v, this.inspectOpts)
251 + .split('\n')
252 + .map(str => str.trim())
253 + .join(' ');
254 +};
255 +
256 +/**
257 + * Map %O to `util.inspect()`, allowing multiple lines if needed.
258 + */
259 +
260 +formatters.O = function (v) {
261 + this.inspectOpts.colors = this.useColors;
262 + return util.inspect(v, this.inspectOpts);
263 +};
1 +/**
2 + * Helpers.
3 + */
4 +
5 +var s = 1000;
6 +var m = s * 60;
7 +var h = m * 60;
8 +var d = h * 24;
9 +var w = d * 7;
10 +var y = d * 365.25;
11 +
12 +/**
13 + * Parse or format the given `val`.
14 + *
15 + * Options:
16 + *
17 + * - `long` verbose formatting [false]
18 + *
19 + * @param {String|Number} val
20 + * @param {Object} [options]
21 + * @throws {Error} throw an error if val is not a non-empty string or a number
22 + * @return {String|Number}
23 + * @api public
24 + */
25 +
26 +module.exports = function(val, options) {
27 + options = options || {};
28 + var type = typeof val;
29 + if (type === 'string' && val.length > 0) {
30 + return parse(val);
31 + } else if (type === 'number' && isFinite(val)) {
32 + return options.long ? fmtLong(val) : fmtShort(val);
33 + }
34 + throw new Error(
35 + 'val is not a non-empty string or a valid number. val=' +
36 + JSON.stringify(val)
37 + );
38 +};
39 +
40 +/**
41 + * Parse the given `str` and return milliseconds.
42 + *
43 + * @param {String} str
44 + * @return {Number}
45 + * @api private
46 + */
47 +
48 +function parse(str) {
49 + str = String(str);
50 + if (str.length > 100) {
51 + return;
52 + }
53 + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
54 + str
55 + );
56 + if (!match) {
57 + return;
58 + }
59 + var n = parseFloat(match[1]);
60 + var type = (match[2] || 'ms').toLowerCase();
61 + switch (type) {
62 + case 'years':
63 + case 'year':
64 + case 'yrs':
65 + case 'yr':
66 + case 'y':
67 + return n * y;
68 + case 'weeks':
69 + case 'week':
70 + case 'w':
71 + return n * w;
72 + case 'days':
73 + case 'day':
74 + case 'd':
75 + return n * d;
76 + case 'hours':
77 + case 'hour':
78 + case 'hrs':
79 + case 'hr':
80 + case 'h':
81 + return n * h;
82 + case 'minutes':
83 + case 'minute':
84 + case 'mins':
85 + case 'min':
86 + case 'm':
87 + return n * m;
88 + case 'seconds':
89 + case 'second':
90 + case 'secs':
91 + case 'sec':
92 + case 's':
93 + return n * s;
94 + case 'milliseconds':
95 + case 'millisecond':
96 + case 'msecs':
97 + case 'msec':
98 + case 'ms':
99 + return n;
100 + default:
101 + return undefined;
102 + }
103 +}
104 +
105 +/**
106 + * Short format for `ms`.
107 + *
108 + * @param {Number} ms
109 + * @return {String}
110 + * @api private
111 + */
112 +
113 +function fmtShort(ms) {
114 + var msAbs = Math.abs(ms);
115 + if (msAbs >= d) {
116 + return Math.round(ms / d) + 'd';
117 + }
118 + if (msAbs >= h) {
119 + return Math.round(ms / h) + 'h';
120 + }
121 + if (msAbs >= m) {
122 + return Math.round(ms / m) + 'm';
123 + }
124 + if (msAbs >= s) {
125 + return Math.round(ms / s) + 's';
126 + }
127 + return ms + 'ms';
128 +}
129 +
130 +/**
131 + * Long format for `ms`.
132 + *
133 + * @param {Number} ms
134 + * @return {String}
135 + * @api private
136 + */
137 +
138 +function fmtLong(ms) {
139 + var msAbs = Math.abs(ms);
140 + if (msAbs >= d) {
141 + return plural(ms, msAbs, d, 'day');
142 + }
143 + if (msAbs >= h) {
144 + return plural(ms, msAbs, h, 'hour');
145 + }
146 + if (msAbs >= m) {
147 + return plural(ms, msAbs, m, 'minute');
148 + }
149 + if (msAbs >= s) {
150 + return plural(ms, msAbs, s, 'second');
151 + }
152 + return ms + ' ms';
153 +}
154 +
155 +/**
156 + * Pluralization helper.
157 + */
158 +
159 +function plural(ms, msAbs, n, name) {
160 + var isPlural = msAbs >= n * 1.5;
161 + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
162 +}
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2016 Zeit, Inc.
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +{
2 + "_args": [
3 + [
4 + "ms@2.1.2",
5 + "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot"
6 + ]
7 + ],
8 + "_from": "ms@2.1.2",
9 + "_id": "ms@2.1.2",
10 + "_inBundle": false,
11 + "_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
12 + "_location": "/agent-base/ms",
13 + "_phantomChildren": {},
14 + "_requested": {
15 + "type": "version",
16 + "registry": true,
17 + "raw": "ms@2.1.2",
18 + "name": "ms",
19 + "escapedName": "ms",
20 + "rawSpec": "2.1.2",
21 + "saveSpec": null,
22 + "fetchSpec": "2.1.2"
23 + },
24 + "_requiredBy": [
25 + "/agent-base/debug"
26 + ],
27 + "_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
28 + "_spec": "2.1.2",
29 + "_where": "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot",
30 + "bugs": {
31 + "url": "https://github.com/zeit/ms/issues"
32 + },
33 + "description": "Tiny millisecond conversion utility",
34 + "devDependencies": {
35 + "eslint": "4.12.1",
36 + "expect.js": "0.3.1",
37 + "husky": "0.14.3",
38 + "lint-staged": "5.0.0",
39 + "mocha": "4.0.1"
40 + },
41 + "eslintConfig": {
42 + "extends": "eslint:recommended",
43 + "env": {
44 + "node": true,
45 + "es6": true
46 + }
47 + },
48 + "files": [
49 + "index.js"
50 + ],
51 + "homepage": "https://github.com/zeit/ms#readme",
52 + "license": "MIT",
53 + "lint-staged": {
54 + "*.js": [
55 + "npm run lint",
56 + "prettier --single-quote --write",
57 + "git add"
58 + ]
59 + },
60 + "main": "./index",
61 + "name": "ms",
62 + "repository": {
63 + "type": "git",
64 + "url": "git+https://github.com/zeit/ms.git"
65 + },
66 + "scripts": {
67 + "lint": "eslint lib/* bin/*",
68 + "precommit": "lint-staged",
69 + "test": "mocha tests.js"
70 + },
71 + "version": "2.1.2"
72 +}
1 +# ms
2 +
3 +[![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms)
4 +[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)
5 +
6 +Use this package to easily convert various time formats to milliseconds.
7 +
8 +## Examples
9 +
10 +```js
11 +ms('2 days') // 172800000
12 +ms('1d') // 86400000
13 +ms('10h') // 36000000
14 +ms('2.5 hrs') // 9000000
15 +ms('2h') // 7200000
16 +ms('1m') // 60000
17 +ms('5s') // 5000
18 +ms('1y') // 31557600000
19 +ms('100') // 100
20 +ms('-3 days') // -259200000
21 +ms('-1h') // -3600000
22 +ms('-200') // -200
23 +```
24 +
25 +### Convert from Milliseconds
26 +
27 +```js
28 +ms(60000) // "1m"
29 +ms(2 * 60000) // "2m"
30 +ms(-3 * 60000) // "-3m"
31 +ms(ms('10 hours')) // "10h"
32 +```
33 +
34 +### Time Format Written-Out
35 +
36 +```js
37 +ms(60000, { long: true }) // "1 minute"
38 +ms(2 * 60000, { long: true }) // "2 minutes"
39 +ms(-3 * 60000, { long: true }) // "-3 minutes"
40 +ms(ms('10 hours'), { long: true }) // "10 hours"
41 +```
42 +
43 +## Features
44 +
45 +- Works both in [Node.js](https://nodejs.org) and in the browser
46 +- If a number is supplied to `ms`, a string with a unit is returned
47 +- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
48 +- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
49 +
50 +## Related Packages
51 +
52 +- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
53 +
54 +## Caught a Bug?
55 +
56 +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
57 +2. Link the package to the global module directory: `npm link`
58 +3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
59 +
60 +As always, you can run the tests using: `npm test`
1 +{
2 + "_args": [
3 + [
4 + "agent-base@6.0.2",
5 + "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot"
6 + ]
7 + ],
8 + "_from": "agent-base@6.0.2",
9 + "_id": "agent-base@6.0.2",
10 + "_inBundle": false,
11 + "_integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
12 + "_location": "/agent-base",
13 + "_phantomChildren": {},
14 + "_requested": {
15 + "type": "version",
16 + "registry": true,
17 + "raw": "agent-base@6.0.2",
18 + "name": "agent-base",
19 + "escapedName": "agent-base",
20 + "rawSpec": "6.0.2",
21 + "saveSpec": null,
22 + "fetchSpec": "6.0.2"
23 + },
24 + "_requiredBy": [
25 + "/https-proxy-agent"
26 + ],
27 + "_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
28 + "_spec": "6.0.2",
29 + "_where": "/home/ubuntu/FORDEVELOP/ESJ/LineMusicChatbot",
30 + "author": {
31 + "name": "Nathan Rajlich",
32 + "email": "nathan@tootallnate.net",
33 + "url": "http://n8.io/"
34 + },
35 + "bugs": {
36 + "url": "https://github.com/TooTallNate/node-agent-base/issues"
37 + },
38 + "dependencies": {
39 + "debug": "4"
40 + },
41 + "description": "Turn a function into an `http.Agent` instance",
42 + "devDependencies": {
43 + "@types/debug": "4",
44 + "@types/mocha": "^5.2.7",
45 + "@types/node": "^14.0.20",
46 + "@types/semver": "^7.1.0",
47 + "@types/ws": "^6.0.3",
48 + "@typescript-eslint/eslint-plugin": "1.6.0",
49 + "@typescript-eslint/parser": "1.1.0",
50 + "async-listen": "^1.2.0",
51 + "cpy-cli": "^2.0.0",
52 + "eslint": "5.16.0",
53 + "eslint-config-airbnb": "17.1.0",
54 + "eslint-config-prettier": "4.1.0",
55 + "eslint-import-resolver-typescript": "1.1.1",
56 + "eslint-plugin-import": "2.16.0",
57 + "eslint-plugin-jsx-a11y": "6.2.1",
58 + "eslint-plugin-react": "7.12.4",
59 + "mocha": "^6.2.0",
60 + "rimraf": "^3.0.0",
61 + "semver": "^7.1.2",
62 + "typescript": "^3.5.3",
63 + "ws": "^3.0.0"
64 + },
65 + "engines": {
66 + "node": ">= 6.0.0"
67 + },
68 + "files": [
69 + "dist/src",
70 + "src"
71 + ],
72 + "homepage": "https://github.com/TooTallNate/node-agent-base#readme",
73 + "keywords": [
74 + "http",
75 + "agent",
76 + "base",
77 + "barebones",
78 + "https"
79 + ],
80 + "license": "MIT",
81 + "main": "dist/src/index",
82 + "name": "agent-base",
83 + "repository": {
84 + "type": "git",
85 + "url": "git://github.com/TooTallNate/node-agent-base.git"
86 + },
87 + "scripts": {
88 + "build": "tsc",
89 + "postbuild": "cpy --parents src test '!**/*.ts' dist",
90 + "prebuild": "rimraf dist",
91 + "prepublishOnly": "npm run build",
92 + "test": "mocha --reporter spec dist/test/*.js",
93 + "test-lint": "eslint src --ext .js,.ts"
94 + },
95 + "typings": "dist/src/index",
96 + "version": "6.0.2"
97 +}
1 +import net from 'net';
2 +import http from 'http';
3 +import https from 'https';
4 +import { Duplex } from 'stream';
5 +import { EventEmitter } from 'events';
6 +import createDebug from 'debug';
7 +import promisify from './promisify';
8 +
9 +const debug = createDebug('agent-base');
10 +
11 +function isAgent(v: any): v is createAgent.AgentLike {
12 + return Boolean(v) && typeof v.addRequest === 'function';
13 +}
14 +
15 +function isSecureEndpoint(): boolean {
16 + const { stack } = new Error();
17 + if (typeof stack !== 'string') return false;
18 + return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
19 +}
20 +
21 +function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
22 +function createAgent(
23 + callback: createAgent.AgentCallback,
24 + opts?: createAgent.AgentOptions
25 +): createAgent.Agent;
26 +function createAgent(
27 + callback?: createAgent.AgentCallback | createAgent.AgentOptions,
28 + opts?: createAgent.AgentOptions
29 +) {
30 + return new createAgent.Agent(callback, opts);
31 +}
32 +
33 +namespace createAgent {
34 + export interface ClientRequest extends http.ClientRequest {
35 + _last?: boolean;
36 + _hadError?: boolean;
37 + method: string;
38 + }
39 +
40 + export interface AgentRequestOptions {
41 + host?: string;
42 + path?: string;
43 + // `port` on `http.RequestOptions` can be a string or undefined,
44 + // but `net.TcpNetConnectOpts` expects only a number
45 + port: number;
46 + }
47 +
48 + export interface HttpRequestOptions
49 + extends AgentRequestOptions,
50 + Omit<http.RequestOptions, keyof AgentRequestOptions> {
51 + secureEndpoint: false;
52 + }
53 +
54 + export interface HttpsRequestOptions
55 + extends AgentRequestOptions,
56 + Omit<https.RequestOptions, keyof AgentRequestOptions> {
57 + secureEndpoint: true;
58 + }
59 +
60 + export type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
61 +
62 + export type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
63 +
64 + export type AgentCallbackReturn = Duplex | AgentLike;
65 +
66 + export type AgentCallbackCallback = (
67 + err?: Error | null,
68 + socket?: createAgent.AgentCallbackReturn
69 + ) => void;
70 +
71 + export type AgentCallbackPromise = (
72 + req: createAgent.ClientRequest,
73 + opts: createAgent.RequestOptions
74 + ) =>
75 + | createAgent.AgentCallbackReturn
76 + | Promise<createAgent.AgentCallbackReturn>;
77 +
78 + export type AgentCallback = typeof Agent.prototype.callback;
79 +
80 + export type AgentOptions = {
81 + timeout?: number;
82 + };
83 +
84 + /**
85 + * Base `http.Agent` implementation.
86 + * No pooling/keep-alive is implemented by default.
87 + *
88 + * @param {Function} callback
89 + * @api public
90 + */
91 + export class Agent extends EventEmitter {
92 + public timeout: number | null;
93 + public maxFreeSockets: number;
94 + public maxTotalSockets: number;
95 + public maxSockets: number;
96 + public sockets: {
97 + [key: string]: net.Socket[];
98 + };
99 + public freeSockets: {
100 + [key: string]: net.Socket[];
101 + };
102 + public requests: {
103 + [key: string]: http.IncomingMessage[];
104 + };
105 + public options: https.AgentOptions;
106 + private promisifiedCallback?: createAgent.AgentCallbackPromise;
107 + private explicitDefaultPort?: number;
108 + private explicitProtocol?: string;
109 +
110 + constructor(
111 + callback?: createAgent.AgentCallback | createAgent.AgentOptions,
112 + _opts?: createAgent.AgentOptions
113 + ) {
114 + super();
115 +
116 + let opts = _opts;
117 + if (typeof callback === 'function') {
118 + this.callback = callback;
119 + } else if (callback) {
120 + opts = callback;
121 + }
122 +
123 + // Timeout for the socket to be returned from the callback
124 + this.timeout = null;
125 + if (opts && typeof opts.timeout === 'number') {
126 + this.timeout = opts.timeout;
127 + }
128 +
129 + // These aren't actually used by `agent-base`, but are required
130 + // for the TypeScript definition files in `@types/node` :/
131 + this.maxFreeSockets = 1;
132 + this.maxSockets = 1;
133 + this.maxTotalSockets = Infinity;
134 + this.sockets = {};
135 + this.freeSockets = {};
136 + this.requests = {};
137 + this.options = {};
138 + }
139 +
140 + get defaultPort(): number {
141 + if (typeof this.explicitDefaultPort === 'number') {
142 + return this.explicitDefaultPort;
143 + }
144 + return isSecureEndpoint() ? 443 : 80;
145 + }
146 +
147 + set defaultPort(v: number) {
148 + this.explicitDefaultPort = v;
149 + }
150 +
151 + get protocol(): string {
152 + if (typeof this.explicitProtocol === 'string') {
153 + return this.explicitProtocol;
154 + }
155 + return isSecureEndpoint() ? 'https:' : 'http:';
156 + }
157 +
158 + set protocol(v: string) {
159 + this.explicitProtocol = v;
160 + }
161 +
162 + callback(
163 + req: createAgent.ClientRequest,
164 + opts: createAgent.RequestOptions,
165 + fn: createAgent.AgentCallbackCallback
166 + ): void;
167 + callback(
168 + req: createAgent.ClientRequest,
169 + opts: createAgent.RequestOptions
170 + ):
171 + | createAgent.AgentCallbackReturn
172 + | Promise<createAgent.AgentCallbackReturn>;
173 + callback(
174 + req: createAgent.ClientRequest,
175 + opts: createAgent.AgentOptions,
176 + fn?: createAgent.AgentCallbackCallback
177 + ):
178 + | createAgent.AgentCallbackReturn
179 + | Promise<createAgent.AgentCallbackReturn>
180 + | void {
181 + throw new Error(
182 + '"agent-base" has no default implementation, you must subclass and override `callback()`'
183 + );
184 + }
185 +
186 + /**
187 + * Called by node-core's "_http_client.js" module when creating
188 + * a new HTTP request with this Agent instance.
189 + *
190 + * @api public
191 + */
192 + addRequest(req: ClientRequest, _opts: RequestOptions): void {
193 + const opts: RequestOptions = { ..._opts };
194 +
195 + if (typeof opts.secureEndpoint !== 'boolean') {
196 + opts.secureEndpoint = isSecureEndpoint();
197 + }
198 +
199 + if (opts.host == null) {
200 + opts.host = 'localhost';
201 + }
202 +
203 + if (opts.port == null) {
204 + opts.port = opts.secureEndpoint ? 443 : 80;
205 + }
206 +
207 + if (opts.protocol == null) {
208 + opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
209 + }
210 +
211 + if (opts.host && opts.path) {
212 + // If both a `host` and `path` are specified then it's most
213 + // likely the result of a `url.parse()` call... we need to
214 + // remove the `path` portion so that `net.connect()` doesn't
215 + // attempt to open that as a unix socket file.
216 + delete opts.path;
217 + }
218 +
219 + delete opts.agent;
220 + delete opts.hostname;
221 + delete opts._defaultAgent;
222 + delete opts.defaultPort;
223 + delete opts.createConnection;
224 +
225 + // Hint to use "Connection: close"
226 + // XXX: non-documented `http` module API :(
227 + req._last = true;
228 + req.shouldKeepAlive = false;
229 +
230 + let timedOut = false;
231 + let timeoutId: ReturnType<typeof setTimeout> | null = null;
232 + const timeoutMs = opts.timeout || this.timeout;
233 +
234 + const onerror = (err: NodeJS.ErrnoException) => {
235 + if (req._hadError) return;
236 + req.emit('error', err);
237 + // For Safety. Some additional errors might fire later on
238 + // and we need to make sure we don't double-fire the error event.
239 + req._hadError = true;
240 + };
241 +
242 + const ontimeout = () => {
243 + timeoutId = null;
244 + timedOut = true;
245 + const err: NodeJS.ErrnoException = new Error(
246 + `A "socket" was not created for HTTP request before ${timeoutMs}ms`
247 + );
248 + err.code = 'ETIMEOUT';
249 + onerror(err);
250 + };
251 +
252 + const callbackError = (err: NodeJS.ErrnoException) => {
253 + if (timedOut) return;
254 + if (timeoutId !== null) {
255 + clearTimeout(timeoutId);
256 + timeoutId = null;
257 + }
258 + onerror(err);
259 + };
260 +
261 + const onsocket = (socket: AgentCallbackReturn) => {
262 + if (timedOut) return;
263 + if (timeoutId != null) {
264 + clearTimeout(timeoutId);
265 + timeoutId = null;
266 + }
267 +
268 + if (isAgent(socket)) {
269 + // `socket` is actually an `http.Agent` instance, so
270 + // relinquish responsibility for this `req` to the Agent
271 + // from here on
272 + debug(
273 + 'Callback returned another Agent instance %o',
274 + socket.constructor.name
275 + );
276 + (socket as createAgent.Agent).addRequest(req, opts);
277 + return;
278 + }
279 +
280 + if (socket) {
281 + socket.once('free', () => {
282 + this.freeSocket(socket as net.Socket, opts);
283 + });
284 + req.onSocket(socket as net.Socket);
285 + return;
286 + }
287 +
288 + const err = new Error(
289 + `no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``
290 + );
291 + onerror(err);
292 + };
293 +
294 + if (typeof this.callback !== 'function') {
295 + onerror(new Error('`callback` is not defined'));
296 + return;
297 + }
298 +
299 + if (!this.promisifiedCallback) {
300 + if (this.callback.length >= 3) {
301 + debug('Converting legacy callback function to promise');
302 + this.promisifiedCallback = promisify(this.callback);
303 + } else {
304 + this.promisifiedCallback = this.callback;
305 + }
306 + }
307 +
308 + if (typeof timeoutMs === 'number' && timeoutMs > 0) {
309 + timeoutId = setTimeout(ontimeout, timeoutMs);
310 + }
311 +
312 + if ('port' in opts && typeof opts.port !== 'number') {
313 + opts.port = Number(opts.port);
314 + }
315 +
316 + try {
317 + debug(
318 + 'Resolving socket for %o request: %o',
319 + opts.protocol,
320 + `${req.method} ${req.path}`
321 + );
322 + Promise.resolve(this.promisifiedCallback(req, opts)).then(
323 + onsocket,
324 + callbackError
325 + );
326 + } catch (err) {
327 + Promise.reject(err).catch(callbackError);
328 + }
329 + }
330 +
331 + freeSocket(socket: net.Socket, opts: AgentOptions) {
332 + debug('Freeing socket %o %o', socket.constructor.name, opts);
333 + socket.destroy();
334 + }
335 +
336 + destroy() {
337 + debug('Destroying agent %o', this.constructor.name);
338 + }
339 + }
340 +
341 + // So that `instanceof` works correctly
342 + createAgent.prototype = createAgent.Agent.prototype;
343 +}
344 +
345 +export = createAgent;
1 +import {
2 + Agent,
3 + ClientRequest,
4 + RequestOptions,
5 + AgentCallbackCallback,
6 + AgentCallbackPromise,
7 + AgentCallbackReturn
8 +} from './index';
9 +
10 +type LegacyCallback = (
11 + req: ClientRequest,
12 + opts: RequestOptions,
13 + fn: AgentCallbackCallback
14 +) => void;
15 +
16 +export default function promisify(fn: LegacyCallback): AgentCallbackPromise {
17 + return function(this: Agent, req: ClientRequest, opts: RequestOptions) {
18 + return new Promise((resolve, reject) => {
19 + fn.call(
20 + this,
21 + req,
22 + opts,
23 + (err: Error | null | undefined, rtn?: AgentCallbackReturn) => {
24 + if (err) {
25 + reject(err);
26 + } else {
27 + resolve(rtn);
28 + }
29 + }
30 + );
31 + });
32 + };
33 +}
1 +var Ajv = require('ajv');
2 +var ajv = new Ajv({allErrors: true});
3 +
4 +var schema = {
5 + "properties": {
6 + "foo": { "type": "string" },
7 + "bar": { "type": "number", "maximum": 3 }
8 + }
9 +};
10 +
11 +var validate = ajv.compile(schema);
12 +
13 +test({"foo": "abc", "bar": 2});
14 +test({"foo": 2, "bar": 4});
15 +
16 +function test(data) {
17 + var valid = validate(data);
18 + if (valid) console.log('Valid!');
19 + else console.log('Invalid: ' + ajv.errorsText(validate.errors));
20 +}
...\ No newline at end of file ...\ No newline at end of file
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2015-2017 Evgeny Poberezkin
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
22 +
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +
4 +var Cache = module.exports = function Cache() {
5 + this._cache = {};
6 +};
7 +
8 +
9 +Cache.prototype.put = function Cache_put(key, value) {
10 + this._cache[key] = value;
11 +};
12 +
13 +
14 +Cache.prototype.get = function Cache_get(key) {
15 + return this._cache[key];
16 +};
17 +
18 +
19 +Cache.prototype.del = function Cache_del(key) {
20 + delete this._cache[key];
21 +};
22 +
23 +
24 +Cache.prototype.clear = function Cache_clear() {
25 + this._cache = {};
26 +};
1 +'use strict';
2 +
3 +var MissingRefError = require('./error_classes').MissingRef;
4 +
5 +module.exports = compileAsync;
6 +
7 +
8 +/**
9 + * Creates validating function for passed schema with asynchronous loading of missing schemas.
10 + * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
11 + * @this Ajv
12 + * @param {Object} schema schema object
13 + * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
14 + * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
15 + * @return {Promise} promise that resolves with a validating function.
16 + */
17 +function compileAsync(schema, meta, callback) {
18 + /* eslint no-shadow: 0 */
19 + /* global Promise */
20 + /* jshint validthis: true */
21 + var self = this;
22 + if (typeof this._opts.loadSchema != 'function')
23 + throw new Error('options.loadSchema should be a function');
24 +
25 + if (typeof meta == 'function') {
26 + callback = meta;
27 + meta = undefined;
28 + }
29 +
30 + var p = loadMetaSchemaOf(schema).then(function () {
31 + var schemaObj = self._addSchema(schema, undefined, meta);
32 + return schemaObj.validate || _compileAsync(schemaObj);
33 + });
34 +
35 + if (callback) {
36 + p.then(
37 + function(v) { callback(null, v); },
38 + callback
39 + );
40 + }
41 +
42 + return p;
43 +
44 +
45 + function loadMetaSchemaOf(sch) {
46 + var $schema = sch.$schema;
47 + return $schema && !self.getSchema($schema)
48 + ? compileAsync.call(self, { $ref: $schema }, true)
49 + : Promise.resolve();
50 + }
51 +
52 +
53 + function _compileAsync(schemaObj) {
54 + try { return self._compile(schemaObj); }
55 + catch(e) {
56 + if (e instanceof MissingRefError) return loadMissingSchema(e);
57 + throw e;
58 + }
59 +
60 +
61 + function loadMissingSchema(e) {
62 + var ref = e.missingSchema;
63 + if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
64 +
65 + var schemaPromise = self._loadingSchemas[ref];
66 + if (!schemaPromise) {
67 + schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
68 + schemaPromise.then(removePromise, removePromise);
69 + }
70 +
71 + return schemaPromise.then(function (sch) {
72 + if (!added(ref)) {
73 + return loadMetaSchemaOf(sch).then(function () {
74 + if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
75 + });
76 + }
77 + }).then(function() {
78 + return _compileAsync(schemaObj);
79 + });
80 +
81 + function removePromise() {
82 + delete self._loadingSchemas[ref];
83 + }
84 +
85 + function added(ref) {
86 + return self._refs[ref] || self._schemas[ref];
87 + }
88 + }
89 + }
90 +}
1 +'use strict';
2 +
3 +// do NOT remove this file - it would break pre-compiled schemas
4 +// https://github.com/epoberezkin/ajv/issues/889
5 +module.exports = require('fast-deep-equal');
1 +'use strict';
2 +
3 +var resolve = require('./resolve');
4 +
5 +module.exports = {
6 + Validation: errorSubclass(ValidationError),
7 + MissingRef: errorSubclass(MissingRefError)
8 +};
9 +
10 +
11 +function ValidationError(errors) {
12 + this.message = 'validation failed';
13 + this.errors = errors;
14 + this.ajv = this.validation = true;
15 +}
16 +
17 +
18 +MissingRefError.message = function (baseId, ref) {
19 + return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
20 +};
21 +
22 +
23 +function MissingRefError(baseId, ref, message) {
24 + this.message = message || MissingRefError.message(baseId, ref);
25 + this.missingRef = resolve.url(baseId, ref);
26 + this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
27 +}
28 +
29 +
30 +function errorSubclass(Subclass) {
31 + Subclass.prototype = Object.create(Error.prototype);
32 + Subclass.prototype.constructor = Subclass;
33 + return Subclass;
34 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +var URI = require('uri-js')
4 + , equal = require('fast-deep-equal')
5 + , util = require('./util')
6 + , SchemaObject = require('./schema_obj')
7 + , traverse = require('json-schema-traverse');
8 +
9 +module.exports = resolve;
10 +
11 +resolve.normalizeId = normalizeId;
12 +resolve.fullPath = getFullPath;
13 +resolve.url = resolveUrl;
14 +resolve.ids = resolveIds;
15 +resolve.inlineRef = inlineRef;
16 +resolve.schema = resolveSchema;
17 +
18 +/**
19 + * [resolve and compile the references ($ref)]
20 + * @this Ajv
21 + * @param {Function} compile reference to schema compilation funciton (localCompile)
22 + * @param {Object} root object with information about the root schema for the current schema
23 + * @param {String} ref reference to resolve
24 + * @return {Object|Function} schema object (if the schema can be inlined) or validation function
25 + */
26 +function resolve(compile, root, ref) {
27 + /* jshint validthis: true */
28 + var refVal = this._refs[ref];
29 + if (typeof refVal == 'string') {
30 + if (this._refs[refVal]) refVal = this._refs[refVal];
31 + else return resolve.call(this, compile, root, refVal);
32 + }
33 +
34 + refVal = refVal || this._schemas[ref];
35 + if (refVal instanceof SchemaObject) {
36 + return inlineRef(refVal.schema, this._opts.inlineRefs)
37 + ? refVal.schema
38 + : refVal.validate || this._compile(refVal);
39 + }
40 +
41 + var res = resolveSchema.call(this, root, ref);
42 + var schema, v, baseId;
43 + if (res) {
44 + schema = res.schema;
45 + root = res.root;
46 + baseId = res.baseId;
47 + }
48 +
49 + if (schema instanceof SchemaObject) {
50 + v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
51 + } else if (schema !== undefined) {
52 + v = inlineRef(schema, this._opts.inlineRefs)
53 + ? schema
54 + : compile.call(this, schema, root, undefined, baseId);
55 + }
56 +
57 + return v;
58 +}
59 +
60 +
61 +/**
62 + * Resolve schema, its root and baseId
63 + * @this Ajv
64 + * @param {Object} root root object with properties schema, refVal, refs
65 + * @param {String} ref reference to resolve
66 + * @return {Object} object with properties schema, root, baseId
67 + */
68 +function resolveSchema(root, ref) {
69 + /* jshint validthis: true */
70 + var p = URI.parse(ref)
71 + , refPath = _getFullPath(p)
72 + , baseId = getFullPath(this._getId(root.schema));
73 + if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
74 + var id = normalizeId(refPath);
75 + var refVal = this._refs[id];
76 + if (typeof refVal == 'string') {
77 + return resolveRecursive.call(this, root, refVal, p);
78 + } else if (refVal instanceof SchemaObject) {
79 + if (!refVal.validate) this._compile(refVal);
80 + root = refVal;
81 + } else {
82 + refVal = this._schemas[id];
83 + if (refVal instanceof SchemaObject) {
84 + if (!refVal.validate) this._compile(refVal);
85 + if (id == normalizeId(ref))
86 + return { schema: refVal, root: root, baseId: baseId };
87 + root = refVal;
88 + } else {
89 + return;
90 + }
91 + }
92 + if (!root.schema) return;
93 + baseId = getFullPath(this._getId(root.schema));
94 + }
95 + return getJsonPointer.call(this, p, baseId, root.schema, root);
96 +}
97 +
98 +
99 +/* @this Ajv */
100 +function resolveRecursive(root, ref, parsedRef) {
101 + /* jshint validthis: true */
102 + var res = resolveSchema.call(this, root, ref);
103 + if (res) {
104 + var schema = res.schema;
105 + var baseId = res.baseId;
106 + root = res.root;
107 + var id = this._getId(schema);
108 + if (id) baseId = resolveUrl(baseId, id);
109 + return getJsonPointer.call(this, parsedRef, baseId, schema, root);
110 + }
111 +}
112 +
113 +
114 +var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
115 +/* @this Ajv */
116 +function getJsonPointer(parsedRef, baseId, schema, root) {
117 + /* jshint validthis: true */
118 + parsedRef.fragment = parsedRef.fragment || '';
119 + if (parsedRef.fragment.slice(0,1) != '/') return;
120 + var parts = parsedRef.fragment.split('/');
121 +
122 + for (var i = 1; i < parts.length; i++) {
123 + var part = parts[i];
124 + if (part) {
125 + part = util.unescapeFragment(part);
126 + schema = schema[part];
127 + if (schema === undefined) break;
128 + var id;
129 + if (!PREVENT_SCOPE_CHANGE[part]) {
130 + id = this._getId(schema);
131 + if (id) baseId = resolveUrl(baseId, id);
132 + if (schema.$ref) {
133 + var $ref = resolveUrl(baseId, schema.$ref);
134 + var res = resolveSchema.call(this, root, $ref);
135 + if (res) {
136 + schema = res.schema;
137 + root = res.root;
138 + baseId = res.baseId;
139 + }
140 + }
141 + }
142 + }
143 + }
144 + if (schema !== undefined && schema !== root.schema)
145 + return { schema: schema, root: root, baseId: baseId };
146 +}
147 +
148 +
149 +var SIMPLE_INLINED = util.toHash([
150 + 'type', 'format', 'pattern',
151 + 'maxLength', 'minLength',
152 + 'maxProperties', 'minProperties',
153 + 'maxItems', 'minItems',
154 + 'maximum', 'minimum',
155 + 'uniqueItems', 'multipleOf',
156 + 'required', 'enum'
157 +]);
158 +function inlineRef(schema, limit) {
159 + if (limit === false) return false;
160 + if (limit === undefined || limit === true) return checkNoRef(schema);
161 + else if (limit) return countKeys(schema) <= limit;
162 +}
163 +
164 +
165 +function checkNoRef(schema) {
166 + var item;
167 + if (Array.isArray(schema)) {
168 + for (var i=0; i<schema.length; i++) {
169 + item = schema[i];
170 + if (typeof item == 'object' && !checkNoRef(item)) return false;
171 + }
172 + } else {
173 + for (var key in schema) {
174 + if (key == '$ref') return false;
175 + item = schema[key];
176 + if (typeof item == 'object' && !checkNoRef(item)) return false;
177 + }
178 + }
179 + return true;
180 +}
181 +
182 +
183 +function countKeys(schema) {
184 + var count = 0, item;
185 + if (Array.isArray(schema)) {
186 + for (var i=0; i<schema.length; i++) {
187 + item = schema[i];
188 + if (typeof item == 'object') count += countKeys(item);
189 + if (count == Infinity) return Infinity;
190 + }
191 + } else {
192 + for (var key in schema) {
193 + if (key == '$ref') return Infinity;
194 + if (SIMPLE_INLINED[key]) {
195 + count++;
196 + } else {
197 + item = schema[key];
198 + if (typeof item == 'object') count += countKeys(item) + 1;
199 + if (count == Infinity) return Infinity;
200 + }
201 + }
202 + }
203 + return count;
204 +}
205 +
206 +
207 +function getFullPath(id, normalize) {
208 + if (normalize !== false) id = normalizeId(id);
209 + var p = URI.parse(id);
210 + return _getFullPath(p);
211 +}
212 +
213 +
214 +function _getFullPath(p) {
215 + return URI.serialize(p).split('#')[0] + '#';
216 +}
217 +
218 +
219 +var TRAILING_SLASH_HASH = /#\/?$/;
220 +function normalizeId(id) {
221 + return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
222 +}
223 +
224 +
225 +function resolveUrl(baseId, id) {
226 + id = normalizeId(id);
227 + return URI.resolve(baseId, id);
228 +}
229 +
230 +
231 +/* @this Ajv */
232 +function resolveIds(schema) {
233 + var schemaId = normalizeId(this._getId(schema));
234 + var baseIds = {'': schemaId};
235 + var fullPaths = {'': getFullPath(schemaId, false)};
236 + var localRefs = {};
237 + var self = this;
238 +
239 + traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
240 + if (jsonPtr === '') return;
241 + var id = self._getId(sch);
242 + var baseId = baseIds[parentJsonPtr];
243 + var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
244 + if (keyIndex !== undefined)
245 + fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
246 +
247 + if (typeof id == 'string') {
248 + id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
249 +
250 + var refVal = self._refs[id];
251 + if (typeof refVal == 'string') refVal = self._refs[refVal];
252 + if (refVal && refVal.schema) {
253 + if (!equal(sch, refVal.schema))
254 + throw new Error('id "' + id + '" resolves to more than one schema');
255 + } else if (id != normalizeId(fullPath)) {
256 + if (id[0] == '#') {
257 + if (localRefs[id] && !equal(sch, localRefs[id]))
258 + throw new Error('id "' + id + '" resolves to more than one schema');
259 + localRefs[id] = sch;
260 + } else {
261 + self._refs[id] = fullPath;
262 + }
263 + }
264 + }
265 + baseIds[jsonPtr] = baseId;
266 + fullPaths[jsonPtr] = fullPath;
267 + });
268 +
269 + return localRefs;
270 +}
1 +'use strict';
2 +
3 +var ruleModules = require('../dotjs')
4 + , toHash = require('./util').toHash;
5 +
6 +module.exports = function rules() {
7 + var RULES = [
8 + { type: 'number',
9 + rules: [ { 'maximum': ['exclusiveMaximum'] },
10 + { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
11 + { type: 'string',
12 + rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
13 + { type: 'array',
14 + rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
15 + { type: 'object',
16 + rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
17 + { 'properties': ['additionalProperties', 'patternProperties'] } ] },
18 + { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
19 + ];
20 +
21 + var ALL = [ 'type', '$comment' ];
22 + var KEYWORDS = [
23 + '$schema', '$id', 'id', '$data', '$async', 'title',
24 + 'description', 'default', 'definitions',
25 + 'examples', 'readOnly', 'writeOnly',
26 + 'contentMediaType', 'contentEncoding',
27 + 'additionalItems', 'then', 'else'
28 + ];
29 + var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
30 + RULES.all = toHash(ALL);
31 + RULES.types = toHash(TYPES);
32 +
33 + RULES.forEach(function (group) {
34 + group.rules = group.rules.map(function (keyword) {
35 + var implKeywords;
36 + if (typeof keyword == 'object') {
37 + var key = Object.keys(keyword)[0];
38 + implKeywords = keyword[key];
39 + keyword = key;
40 + implKeywords.forEach(function (k) {
41 + ALL.push(k);
42 + RULES.all[k] = true;
43 + });
44 + }
45 + ALL.push(keyword);
46 + var rule = RULES.all[keyword] = {
47 + keyword: keyword,
48 + code: ruleModules[keyword],
49 + implements: implKeywords
50 + };
51 + return rule;
52 + });
53 +
54 + RULES.all.$comment = {
55 + keyword: '$comment',
56 + code: ruleModules.$comment
57 + };
58 +
59 + if (group.type) RULES.types[group.type] = group;
60 + });
61 +
62 + RULES.keywords = toHash(ALL.concat(KEYWORDS));
63 + RULES.custom = {};
64 +
65 + return RULES;
66 +};
1 +'use strict';
2 +
3 +var util = require('./util');
4 +
5 +module.exports = SchemaObject;
6 +
7 +function SchemaObject(obj) {
8 + util.copy(obj, this);
9 +}
1 +'use strict';
2 +
3 +// https://mathiasbynens.be/notes/javascript-encoding
4 +// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
5 +module.exports = function ucs2length(str) {
6 + var length = 0
7 + , len = str.length
8 + , pos = 0
9 + , value;
10 + while (pos < len) {
11 + length++;
12 + value = str.charCodeAt(pos++);
13 + if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
14 + // high surrogate, and there is a next character
15 + value = str.charCodeAt(pos);
16 + if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
17 + }
18 + }
19 + return length;
20 +};
1 +'use strict';
2 +
3 +
4 +module.exports = {
5 + copy: copy,
6 + checkDataType: checkDataType,
7 + checkDataTypes: checkDataTypes,
8 + coerceToTypes: coerceToTypes,
9 + toHash: toHash,
10 + getProperty: getProperty,
11 + escapeQuotes: escapeQuotes,
12 + equal: require('fast-deep-equal'),
13 + ucs2length: require('./ucs2length'),
14 + varOccurences: varOccurences,
15 + varReplace: varReplace,
16 + cleanUpCode: cleanUpCode,
17 + finalCleanUpCode: finalCleanUpCode,
18 + schemaHasRules: schemaHasRules,
19 + schemaHasRulesExcept: schemaHasRulesExcept,
20 + schemaUnknownRules: schemaUnknownRules,
21 + toQuotedString: toQuotedString,
22 + getPathExpr: getPathExpr,
23 + getPath: getPath,
24 + getData: getData,
25 + unescapeFragment: unescapeFragment,
26 + unescapeJsonPointer: unescapeJsonPointer,
27 + escapeFragment: escapeFragment,
28 + escapeJsonPointer: escapeJsonPointer
29 +};
30 +
31 +
32 +function copy(o, to) {
33 + to = to || {};
34 + for (var key in o) to[key] = o[key];
35 + return to;
36 +}
37 +
38 +
39 +function checkDataType(dataType, data, negate) {
40 + var EQUAL = negate ? ' !== ' : ' === '
41 + , AND = negate ? ' || ' : ' && '
42 + , OK = negate ? '!' : ''
43 + , NOT = negate ? '' : '!';
44 + switch (dataType) {
45 + case 'null': return data + EQUAL + 'null';
46 + case 'array': return OK + 'Array.isArray(' + data + ')';
47 + case 'object': return '(' + OK + data + AND +
48 + 'typeof ' + data + EQUAL + '"object"' + AND +
49 + NOT + 'Array.isArray(' + data + '))';
50 + case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
51 + NOT + '(' + data + ' % 1)' +
52 + AND + data + EQUAL + data + ')';
53 + default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
54 + }
55 +}
56 +
57 +
58 +function checkDataTypes(dataTypes, data) {
59 + switch (dataTypes.length) {
60 + case 1: return checkDataType(dataTypes[0], data, true);
61 + default:
62 + var code = '';
63 + var types = toHash(dataTypes);
64 + if (types.array && types.object) {
65 + code = types.null ? '(': '(!' + data + ' || ';
66 + code += 'typeof ' + data + ' !== "object")';
67 + delete types.null;
68 + delete types.array;
69 + delete types.object;
70 + }
71 + if (types.number) delete types.integer;
72 + for (var t in types)
73 + code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
74 +
75 + return code;
76 + }
77 +}
78 +
79 +
80 +var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
81 +function coerceToTypes(optionCoerceTypes, dataTypes) {
82 + if (Array.isArray(dataTypes)) {
83 + var types = [];
84 + for (var i=0; i<dataTypes.length; i++) {
85 + var t = dataTypes[i];
86 + if (COERCE_TO_TYPES[t]) types[types.length] = t;
87 + else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
88 + }
89 + if (types.length) return types;
90 + } else if (COERCE_TO_TYPES[dataTypes]) {
91 + return [dataTypes];
92 + } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
93 + return ['array'];
94 + }
95 +}
96 +
97 +
98 +function toHash(arr) {
99 + var hash = {};
100 + for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
101 + return hash;
102 +}
103 +
104 +
105 +var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
106 +var SINGLE_QUOTE = /'|\\/g;
107 +function getProperty(key) {
108 + return typeof key == 'number'
109 + ? '[' + key + ']'
110 + : IDENTIFIER.test(key)
111 + ? '.' + key
112 + : "['" + escapeQuotes(key) + "']";
113 +}
114 +
115 +
116 +function escapeQuotes(str) {
117 + return str.replace(SINGLE_QUOTE, '\\$&')
118 + .replace(/\n/g, '\\n')
119 + .replace(/\r/g, '\\r')
120 + .replace(/\f/g, '\\f')
121 + .replace(/\t/g, '\\t');
122 +}
123 +
124 +
125 +function varOccurences(str, dataVar) {
126 + dataVar += '[^0-9]';
127 + var matches = str.match(new RegExp(dataVar, 'g'));
128 + return matches ? matches.length : 0;
129 +}
130 +
131 +
132 +function varReplace(str, dataVar, expr) {
133 + dataVar += '([^0-9])';
134 + expr = expr.replace(/\$/g, '$$$$');
135 + return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
136 +}
137 +
138 +
139 +var EMPTY_ELSE = /else\s*{\s*}/g
140 + , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
141 + , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
142 +function cleanUpCode(out) {
143 + return out.replace(EMPTY_ELSE, '')
144 + .replace(EMPTY_IF_NO_ELSE, '')
145 + .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
146 +}
147 +
148 +
149 +var ERRORS_REGEXP = /[^v.]errors/g
150 + , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
151 + , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
152 + , RETURN_VALID = 'return errors === 0;'
153 + , RETURN_TRUE = 'validate.errors = null; return true;'
154 + , RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
155 + , RETURN_DATA_ASYNC = 'return data;'
156 + , ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
157 + , REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
158 +
159 +function finalCleanUpCode(out, async) {
160 + var matches = out.match(ERRORS_REGEXP);
161 + if (matches && matches.length == 2) {
162 + out = async
163 + ? out.replace(REMOVE_ERRORS_ASYNC, '')
164 + .replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
165 + : out.replace(REMOVE_ERRORS, '')
166 + .replace(RETURN_VALID, RETURN_TRUE);
167 + }
168 +
169 + matches = out.match(ROOTDATA_REGEXP);
170 + if (!matches || matches.length !== 3) return out;
171 + return out.replace(REMOVE_ROOTDATA, '');
172 +}
173 +
174 +
175 +function schemaHasRules(schema, rules) {
176 + if (typeof schema == 'boolean') return !schema;
177 + for (var key in schema) if (rules[key]) return true;
178 +}
179 +
180 +
181 +function schemaHasRulesExcept(schema, rules, exceptKeyword) {
182 + if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
183 + for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
184 +}
185 +
186 +
187 +function schemaUnknownRules(schema, rules) {
188 + if (typeof schema == 'boolean') return;
189 + for (var key in schema) if (!rules[key]) return key;
190 +}
191 +
192 +
193 +function toQuotedString(str) {
194 + return '\'' + escapeQuotes(str) + '\'';
195 +}
196 +
197 +
198 +function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
199 + var path = jsonPointers // false by default
200 + ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
201 + : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
202 + return joinPaths(currentPath, path);
203 +}
204 +
205 +
206 +function getPath(currentPath, prop, jsonPointers) {
207 + var path = jsonPointers // false by default
208 + ? toQuotedString('/' + escapeJsonPointer(prop))
209 + : toQuotedString(getProperty(prop));
210 + return joinPaths(currentPath, path);
211 +}
212 +
213 +
214 +var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
215 +var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
216 +function getData($data, lvl, paths) {
217 + var up, jsonPointer, data, matches;
218 + if ($data === '') return 'rootData';
219 + if ($data[0] == '/') {
220 + if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
221 + jsonPointer = $data;
222 + data = 'rootData';
223 + } else {
224 + matches = $data.match(RELATIVE_JSON_POINTER);
225 + if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
226 + up = +matches[1];
227 + jsonPointer = matches[2];
228 + if (jsonPointer == '#') {
229 + if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
230 + return paths[lvl - up];
231 + }
232 +
233 + if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
234 + data = 'data' + ((lvl - up) || '');
235 + if (!jsonPointer) return data;
236 + }
237 +
238 + var expr = data;
239 + var segments = jsonPointer.split('/');
240 + for (var i=0; i<segments.length; i++) {
241 + var segment = segments[i];
242 + if (segment) {
243 + data += getProperty(unescapeJsonPointer(segment));
244 + expr += ' && ' + data;
245 + }
246 + }
247 + return expr;
248 +}
249 +
250 +
251 +function joinPaths (a, b) {
252 + if (a == '""') return b;
253 + return (a + ' + ' + b).replace(/' \+ '/g, '');
254 +}
255 +
256 +
257 +function unescapeFragment(str) {
258 + return unescapeJsonPointer(decodeURIComponent(str));
259 +}
260 +
261 +
262 +function escapeFragment(str) {
263 + return encodeURIComponent(escapeJsonPointer(str));
264 +}
265 +
266 +
267 +function escapeJsonPointer(str) {
268 + return str.replace(/~/g, '~0').replace(/\//g, '~1');
269 +}
270 +
271 +
272 +function unescapeJsonPointer(str) {
273 + return str.replace(/~1/g, '/').replace(/~0/g, '~');
274 +}
1 +'use strict';
2 +
3 +var KEYWORDS = [
4 + 'multipleOf',
5 + 'maximum',
6 + 'exclusiveMaximum',
7 + 'minimum',
8 + 'exclusiveMinimum',
9 + 'maxLength',
10 + 'minLength',
11 + 'pattern',
12 + 'additionalItems',
13 + 'maxItems',
14 + 'minItems',
15 + 'uniqueItems',
16 + 'maxProperties',
17 + 'minProperties',
18 + 'required',
19 + 'additionalProperties',
20 + 'enum',
21 + 'format',
22 + 'const'
23 +];
24 +
25 +module.exports = function (metaSchema, keywordsJsonPointers) {
26 + for (var i=0; i<keywordsJsonPointers.length; i++) {
27 + metaSchema = JSON.parse(JSON.stringify(metaSchema));
28 + var segments = keywordsJsonPointers[i].split('/');
29 + var keywords = metaSchema;
30 + var j;
31 + for (j=1; j<segments.length; j++)
32 + keywords = keywords[segments[j]];
33 +
34 + for (j=0; j<KEYWORDS.length; j++) {
35 + var key = KEYWORDS[j];
36 + var schema = keywords[key];
37 + if (schema) {
38 + keywords[key] = {
39 + anyOf: [
40 + schema,
41 + { $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
42 + ]
43 + };
44 + }
45 + }
46 + }
47 +
48 + return metaSchema;
49 +};
1 +'use strict';
2 +
3 +var metaSchema = require('./refs/json-schema-draft-07.json');
4 +
5 +module.exports = {
6 + $id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js',
7 + definitions: {
8 + simpleTypes: metaSchema.definitions.simpleTypes
9 + },
10 + type: 'object',
11 + dependencies: {
12 + schema: ['validate'],
13 + $data: ['validate'],
14 + statements: ['inline'],
15 + valid: {not: {required: ['macro']}}
16 + },
17 + properties: {
18 + type: metaSchema.properties.type,
19 + schema: {type: 'boolean'},
20 + statements: {type: 'boolean'},
21 + dependencies: {
22 + type: 'array',
23 + items: {type: 'string'}
24 + },
25 + metaSchema: {type: 'object'},
26 + modifying: {type: 'boolean'},
27 + valid: {type: 'boolean'},
28 + $data: {type: 'boolean'},
29 + async: {type: 'boolean'},
30 + errors: {
31 + anyOf: [
32 + {type: 'boolean'},
33 + {const: 'full'}
34 + ]
35 + }
36 + }
37 +};
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{## def.setExclusiveLimit:
7 + $exclusive = true;
8 + $errorKeyword = $exclusiveKeyword;
9 + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
10 +#}}
11 +
12 +{{
13 + var $isMax = $keyword == 'maximum'
14 + , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
15 + , $schemaExcl = it.schema[$exclusiveKeyword]
16 + , $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
17 + , $op = $isMax ? '<' : '>'
18 + , $notOp = $isMax ? '>' : '<'
19 + , $errorKeyword = undefined;
20 +}}
21 +
22 +{{? $isDataExcl }}
23 + {{
24 + var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
25 + , $exclusive = 'exclusive' + $lvl
26 + , $exclType = 'exclType' + $lvl
27 + , $exclIsNumber = 'exclIsNumber' + $lvl
28 + , $opExpr = 'op' + $lvl
29 + , $opStr = '\' + ' + $opExpr + ' + \'';
30 + }}
31 + var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
32 + {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
33 +
34 + var {{=$exclusive}};
35 + var {{=$exclType}} = typeof {{=$schemaValueExcl}};
36 + if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
37 + {{ var $errorKeyword = $exclusiveKeyword; }}
38 + {{# def.error:'_exclusiveLimit' }}
39 + } else if ({{# def.$dataNotType:'number' }}
40 + {{=$exclType}} == 'number'
41 + ? (
42 + ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
43 + ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
44 + : {{=$data}} {{=$notOp}} {{=$schemaValue}}
45 + )
46 + : (
47 + ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
48 + ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
49 + : {{=$data}} {{=$notOp}} {{=$schemaValue}}
50 + )
51 + || {{=$data}} !== {{=$data}}) {
52 + var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
53 + {{
54 + if ($schema === undefined) {
55 + $errorKeyword = $exclusiveKeyword;
56 + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
57 + $schemaValue = $schemaValueExcl;
58 + $isData = $isDataExcl;
59 + }
60 + }}
61 +{{??}}
62 + {{
63 + var $exclIsNumber = typeof $schemaExcl == 'number'
64 + , $opStr = $op; /*used in error*/
65 + }}
66 +
67 + {{? $exclIsNumber && $isData }}
68 + {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
69 + if ({{# def.$dataNotType:'number' }}
70 + ( {{=$schemaValue}} === undefined
71 + || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
72 + ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
73 + : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
74 + || {{=$data}} !== {{=$data}}) {
75 + {{??}}
76 + {{
77 + if ($exclIsNumber && $schema === undefined) {
78 + {{# def.setExclusiveLimit }}
79 + $schemaValue = $schemaExcl;
80 + $notOp += '=';
81 + } else {
82 + if ($exclIsNumber)
83 + $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
84 +
85 + if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
86 + {{# def.setExclusiveLimit }}
87 + $notOp += '=';
88 + } else {
89 + $exclusive = false;
90 + $opStr += '=';
91 + }
92 + }
93 +
94 + var $opExpr = '\'' + $opStr + '\''; /*used in error*/
95 + }}
96 +
97 + if ({{# def.$dataNotType:'number' }}
98 + {{=$data}} {{=$notOp}} {{=$schemaValue}}
99 + || {{=$data}} !== {{=$data}}) {
100 + {{?}}
101 +{{?}}
102 + {{ $errorKeyword = $errorKeyword || $keyword; }}
103 + {{# def.error:'_limit' }}
104 + } {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
7 +if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
8 + {{ var $errorKeyword = $keyword; }}
9 + {{# def.error:'_limitItems' }}
10 +} {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
7 +if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
8 + {{ var $errorKeyword = $keyword; }}
9 + {{# def.error:'_limitLength' }}
10 +} {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
7 +if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
8 + {{ var $errorKeyword = $keyword; }}
9 + {{# def.error:'_limitProperties' }}
10 +} {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.setupNextLevel }}
5 +
6 +{{
7 + var $currentBaseId = $it.baseId
8 + , $allSchemasEmpty = true;
9 +}}
10 +
11 +{{~ $schema:$sch:$i }}
12 + {{? {{# def.nonEmptySchema:$sch }} }}
13 + {{
14 + $allSchemasEmpty = false;
15 + $it.schema = $sch;
16 + $it.schemaPath = $schemaPath + '[' + $i + ']';
17 + $it.errSchemaPath = $errSchemaPath + '/' + $i;
18 + }}
19 +
20 + {{# def.insertSubschemaCode }}
21 +
22 + {{# def.ifResultValid }}
23 + {{?}}
24 +{{~}}
25 +
26 +{{? $breakOnError }}
27 + {{? $allSchemasEmpty }}
28 + if (true) {
29 + {{??}}
30 + {{= $closingBraces.slice(0,-1) }}
31 + {{?}}
32 +{{?}}
33 +
34 +{{# def.cleanUp }}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.setupNextLevel }}
5 +
6 +{{
7 + var $noEmptySchema = $schema.every(function($sch) {
8 + return {{# def.nonEmptySchema:$sch }};
9 + });
10 +}}
11 +{{? $noEmptySchema }}
12 + {{ var $currentBaseId = $it.baseId; }}
13 + var {{=$errs}} = errors;
14 + var {{=$valid}} = false;
15 +
16 + {{# def.setCompositeRule }}
17 +
18 + {{~ $schema:$sch:$i }}
19 + {{
20 + $it.schema = $sch;
21 + $it.schemaPath = $schemaPath + '[' + $i + ']';
22 + $it.errSchemaPath = $errSchemaPath + '/' + $i;
23 + }}
24 +
25 + {{# def.insertSubschemaCode }}
26 +
27 + {{=$valid}} = {{=$valid}} || {{=$nextValid}};
28 +
29 + if (!{{=$valid}}) {
30 + {{ $closingBraces += '}'; }}
31 + {{~}}
32 +
33 + {{# def.resetCompositeRule }}
34 +
35 + {{= $closingBraces }}
36 +
37 + if (!{{=$valid}}) {
38 + {{# def.extraError:'anyOf' }}
39 + } else {
40 + {{# def.resetErrors }}
41 + {{? it.opts.allErrors }} } {{?}}
42 +
43 + {{# def.cleanUp }}
44 +{{??}}
45 + {{? $breakOnError }}
46 + if (true) {
47 + {{?}}
48 +{{?}}
1 +{{## def.coerceType:
2 + {{
3 + var $dataType = 'dataType' + $lvl
4 + , $coerced = 'coerced' + $lvl;
5 + }}
6 + var {{=$dataType}} = typeof {{=$data}};
7 + {{? it.opts.coerceTypes == 'array'}}
8 + if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';
9 + {{?}}
10 +
11 + var {{=$coerced}} = undefined;
12 +
13 + {{ var $bracesCoercion = ''; }}
14 + {{~ $coerceToTypes:$type:$i }}
15 + {{? $i }}
16 + if ({{=$coerced}} === undefined) {
17 + {{ $bracesCoercion += '}'; }}
18 + {{?}}
19 +
20 + {{? it.opts.coerceTypes == 'array' && $type != 'array' }}
21 + if ({{=$dataType}} == 'array' && {{=$data}}.length == 1) {
22 + {{=$coerced}} = {{=$data}} = {{=$data}}[0];
23 + {{=$dataType}} = typeof {{=$data}};
24 + /*if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';*/
25 + }
26 + {{?}}
27 +
28 + {{? $type == 'string' }}
29 + if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean')
30 + {{=$coerced}} = '' + {{=$data}};
31 + else if ({{=$data}} === null) {{=$coerced}} = '';
32 + {{?? $type == 'number' || $type == 'integer' }}
33 + if ({{=$dataType}} == 'boolean' || {{=$data}} === null
34 + || ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}}
35 + {{? $type == 'integer' }} && !({{=$data}} % 1){{?}}))
36 + {{=$coerced}} = +{{=$data}};
37 + {{?? $type == 'boolean' }}
38 + if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null)
39 + {{=$coerced}} = false;
40 + else if ({{=$data}} === 'true' || {{=$data}} === 1)
41 + {{=$coerced}} = true;
42 + {{?? $type == 'null' }}
43 + if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false)
44 + {{=$coerced}} = null;
45 + {{?? it.opts.coerceTypes == 'array' && $type == 'array' }}
46 + if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null)
47 + {{=$coerced}} = [{{=$data}}];
48 + {{?}}
49 + {{~}}
50 +
51 + {{= $bracesCoercion }}
52 +
53 + if ({{=$coerced}} === undefined) {
54 + {{# def.error:'type' }}
55 + } else {
56 + {{# def.setParentData }}
57 + {{=$data}} = {{=$coerced}};
58 + {{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}}
59 + {{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}};
60 + }
61 +#}}
1 +{{# def.definitions }}
2 +{{# def.setupKeyword }}
3 +
4 +{{ var $comment = it.util.toQuotedString($schema); }}
5 +{{? it.opts.$comment === true }}
6 + console.log({{=$comment}});
7 +{{?? typeof it.opts.$comment == 'function' }}
8 + self._opts.$comment({{=$comment}}, {{=it.util.toQuotedString($errSchemaPath)}}, validate.root.schema);
9 +{{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{? !$isData }}
7 + var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
8 +{{?}}
9 +var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
10 +{{# def.checkError:'const' }}
11 +{{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.setupNextLevel }}
5 +
6 +
7 +{{
8 + var $idx = 'i' + $lvl
9 + , $dataNxt = $it.dataLevel = it.dataLevel + 1
10 + , $nextData = 'data' + $dataNxt
11 + , $currentBaseId = it.baseId
12 + , $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
13 +}}
14 +
15 +var {{=$errs}} = errors;
16 +var {{=$valid}};
17 +
18 +{{? $nonEmptySchema }}
19 + {{# def.setCompositeRule }}
20 +
21 + {{
22 + $it.schema = $schema;
23 + $it.schemaPath = $schemaPath;
24 + $it.errSchemaPath = $errSchemaPath;
25 + }}
26 +
27 + var {{=$nextValid}} = false;
28 +
29 + for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
30 + {{
31 + $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
32 + var $passData = $data + '[' + $idx + ']';
33 + $it.dataPathArr[$dataNxt] = $idx;
34 + }}
35 +
36 + {{# def.generateSubschemaCode }}
37 + {{# def.optimizeValidate }}
38 +
39 + if ({{=$nextValid}}) break;
40 + }
41 +
42 + {{# def.resetCompositeRule }}
43 + {{= $closingBraces }}
44 +
45 + if (!{{=$nextValid}}) {
46 +{{??}}
47 + if ({{=$data}}.length == 0) {
48 +{{?}}
49 +
50 + {{# def.error:'contains' }}
51 + } else {
52 + {{? $nonEmptySchema }}
53 + {{# def.resetErrors }}
54 + {{?}}
55 + {{? it.opts.allErrors }} } {{?}}
56 +
57 +{{# def.cleanUp }}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.