diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity index 514d8b9c..238d55c2 100644 --- a/node_modules/.yarn-integrity +++ b/node_modules/.yarn-integrity @@ -20,11 +20,13 @@ "prettier@^1.18.2", "sequelize-cli@^5.5.0", "sequelize@^5.10.1", - "sucrase@^3.10.1" + "sucrase@^3.10.1", + "yup@^0.27.0" ], "lockfileEntries": { "@babel/code-frame@^7.0.0": "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d", "@babel/highlight@^7.0.0": "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540", + "@babel/runtime@^7.0.0": "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132", "@types/node@*": "https://registry.yarnpkg.com/@types/node/-/node-12.6.8.tgz#e469b4bf9d1c9832aee4907ba8a051494357c12c", "abbrev@1": "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8", "accepts@~1.3.7": "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd", @@ -207,6 +209,7 @@ "find-up@^3.0.0": "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73", "flat-cache@^2.0.1": "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0", "flatted@^2.0.0": "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08", + "fn-name@~2.0.1": "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7", "for-in@^1.0.2": "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80", "forwarded@~0.1.2": "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84", "fragment-cache@^0.2.1": "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19", @@ -464,6 +467,7 @@ "prettier@^1.18.2": "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea", "process-nextick-args@~2.0.0": "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2", "progress@^2.0.0": "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8", + "property-expr@^1.5.0": "https://registry.yarnpkg.com/property-expr/-/property-expr-1.5.1.tgz#22e8706894a0c8e28d58735804f6ba3a3673314f", "proto-list@~1.2.1": "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849", "proxy-addr@~2.0.5": "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.5.tgz#34cbd64a2d81f4b1fd21e76f9f06c8a45299ee34", "pseudomap@^1.0.2": "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3", @@ -481,6 +485,7 @@ "readable-stream@^2.0.6": "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf", "readdirp@^2.2.1": "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525", "regenerator-runtime@^0.11.0": "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9", + "regenerator-runtime@^0.13.2": "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5", "regex-not@^1.0.0": "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c", "regex-not@^1.0.2": "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c", "regexpp@^2.0.1": "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f", @@ -576,6 +581,7 @@ "sucrase@^3.10.1": "https://registry.yarnpkg.com/sucrase/-/sucrase-3.10.1.tgz#70ce0bad0e4c8fbc3c3184dbd1797e82990d0602", "supports-color@^5.2.0": "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f", "supports-color@^5.3.0": "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f", + "synchronous-promise@^2.0.6": "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.9.tgz#b83db98e9e7ae826bf9c8261fd8ac859126c780a", "table@^5.2.3": "https://registry.yarnpkg.com/table/-/table-5.4.4.tgz#6e0f88fdae3692793d1077fd172a4667afe986a6", "tar@^4": "https://registry.yarnpkg.com/tar/-/tar-4.4.10.tgz#946b2810b9a5e0b26140cf78bea6b0b0d689eba1", "term-size@^1.2.0": "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69", @@ -593,6 +599,7 @@ "to-regex@^3.0.2": "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce", "toidentifier@1.0.0": "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553", "toposort-class@^1.0.1": "https://registry.yarnpkg.com/toposort-class/-/toposort-class-1.0.1.tgz#7ffd1f78c8be28c3ba45cd4e1a3f5ee193bd9988", + "toposort@^2.0.2": "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330", "touch@^3.1.0": "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b", "tslib@^1.9.0": "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a", "type-check@~0.3.2": "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72", @@ -638,7 +645,8 @@ "yallist@^3.0.0": "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9", "yallist@^3.0.3": "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9", "yargs-parser@^13.1.1": "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0", - "yargs@^13.1.0": "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83" + "yargs@^13.1.0": "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83", + "yup@^0.27.0": "https://registry.yarnpkg.com/yup/-/yup-0.27.0.tgz#f8cb198c8e7dd2124beddc2457571329096b06e7" }, "files": [], "artifacts": { diff --git a/node_modules/@babel/runtime/LICENSE b/node_modules/@babel/runtime/LICENSE new file mode 100644 index 00000000..f31575ec --- /dev/null +++ b/node_modules/@babel/runtime/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2014-present Sebastian McKenzie and other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@babel/runtime/README.md b/node_modules/@babel/runtime/README.md new file mode 100644 index 00000000..72e8daa3 --- /dev/null +++ b/node_modules/@babel/runtime/README.md @@ -0,0 +1,19 @@ +# @babel/runtime + +> babel's modular runtime helpers + +See our website [@babel/runtime](https://babeljs.io/docs/en/next/babel-runtime.html) for more information. + +## Install + +Using npm: + +```sh +npm install --save @babel/runtime +``` + +or using yarn: + +```sh +yarn add @babel/runtime +``` diff --git a/node_modules/@babel/runtime/helpers/AsyncGenerator.js b/node_modules/@babel/runtime/helpers/AsyncGenerator.js new file mode 100644 index 00000000..0365c437 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/AsyncGenerator.js @@ -0,0 +1,100 @@ +var AwaitValue = require("./AwaitValue"); + +function AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume("next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen["return"] !== "function") { + this["return"] = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +AsyncGenerator.prototype["throw"] = function (arg) { + return this._invoke("throw", arg); +}; + +AsyncGenerator.prototype["return"] = function (arg) { + return this._invoke("return", arg); +}; + +module.exports = AsyncGenerator; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/AwaitValue.js b/node_modules/@babel/runtime/helpers/AwaitValue.js new file mode 100644 index 00000000..f9f41841 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/AwaitValue.js @@ -0,0 +1,5 @@ +function _AwaitValue(value) { + this.wrapped = value; +} + +module.exports = _AwaitValue; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js b/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js new file mode 100644 index 00000000..b0b41ddd --- /dev/null +++ b/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js @@ -0,0 +1,30 @@ +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +module.exports = _applyDecoratedDescriptor; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/arrayWithHoles.js b/node_modules/@babel/runtime/helpers/arrayWithHoles.js new file mode 100644 index 00000000..5a62a8ce --- /dev/null +++ b/node_modules/@babel/runtime/helpers/arrayWithHoles.js @@ -0,0 +1,5 @@ +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +module.exports = _arrayWithHoles; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js b/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js new file mode 100644 index 00000000..3234017e --- /dev/null +++ b/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js @@ -0,0 +1,11 @@ +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + + return arr2; + } +} + +module.exports = _arrayWithoutHoles; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/assertThisInitialized.js b/node_modules/@babel/runtime/helpers/assertThisInitialized.js new file mode 100644 index 00000000..98d29498 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/assertThisInitialized.js @@ -0,0 +1,9 @@ +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +module.exports = _assertThisInitialized; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js b/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js new file mode 100644 index 00000000..3fb99659 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js @@ -0,0 +1,53 @@ +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner["throw"] === "function") { + iter["throw"] = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner["return"] === "function") { + iter["return"] = function (value) { + return pump("return", value); + }; + } + + return iter; +} + +module.exports = _asyncGeneratorDelegate; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/asyncIterator.js b/node_modules/@babel/runtime/helpers/asyncIterator.js new file mode 100644 index 00000000..ef5db274 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/asyncIterator.js @@ -0,0 +1,19 @@ +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +module.exports = _asyncIterator; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/asyncToGenerator.js b/node_modules/@babel/runtime/helpers/asyncToGenerator.js new file mode 100644 index 00000000..f5db93df --- /dev/null +++ b/node_modules/@babel/runtime/helpers/asyncToGenerator.js @@ -0,0 +1,37 @@ +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +module.exports = _asyncToGenerator; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js b/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js new file mode 100644 index 00000000..59f797af --- /dev/null +++ b/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js @@ -0,0 +1,7 @@ +var AwaitValue = require("./AwaitValue"); + +function _awaitAsyncGenerator(value) { + return new AwaitValue(value); +} + +module.exports = _awaitAsyncGenerator; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classCallCheck.js b/node_modules/@babel/runtime/helpers/classCallCheck.js new file mode 100644 index 00000000..f389f2e8 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classCallCheck.js @@ -0,0 +1,7 @@ +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +module.exports = _classCallCheck; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classNameTDZError.js b/node_modules/@babel/runtime/helpers/classNameTDZError.js new file mode 100644 index 00000000..8c1bdf55 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classNameTDZError.js @@ -0,0 +1,5 @@ +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +module.exports = _classNameTDZError; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js b/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js new file mode 100644 index 00000000..fab91057 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js @@ -0,0 +1,28 @@ +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +module.exports = _classPrivateFieldDestructureSet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js b/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js new file mode 100644 index 00000000..106c3cd9 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js @@ -0,0 +1,15 @@ +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +module.exports = _classPrivateFieldGet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js b/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js new file mode 100644 index 00000000..64ed79df --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js @@ -0,0 +1,9 @@ +function _classPrivateFieldBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +module.exports = _classPrivateFieldBase; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js b/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js new file mode 100644 index 00000000..a1a6417a --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js @@ -0,0 +1,7 @@ +var id = 0; + +function _classPrivateFieldKey(name) { + return "__private_" + id++ + "_" + name; +} + +module.exports = _classPrivateFieldKey; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js b/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js new file mode 100644 index 00000000..c92f97a8 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js @@ -0,0 +1,21 @@ +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +module.exports = _classPrivateFieldSet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js b/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js new file mode 100644 index 00000000..a3432b9a --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js @@ -0,0 +1,9 @@ +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +module.exports = _classPrivateMethodGet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js b/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js new file mode 100644 index 00000000..38472848 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js @@ -0,0 +1,5 @@ +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +module.exports = _classPrivateMethodSet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js b/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js new file mode 100644 index 00000000..cb751096 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js @@ -0,0 +1,9 @@ +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return descriptor.value; +} + +module.exports = _classStaticPrivateFieldSpecGet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js b/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js new file mode 100644 index 00000000..d758fcfa --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js @@ -0,0 +1,14 @@ +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + return value; +} + +module.exports = _classStaticPrivateFieldSpecSet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js b/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js new file mode 100644 index 00000000..f9b0d003 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js @@ -0,0 +1,9 @@ +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +module.exports = _classStaticPrivateMethodGet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js b/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js new file mode 100644 index 00000000..89042da5 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js @@ -0,0 +1,5 @@ +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +module.exports = _classStaticPrivateMethodSet; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/construct.js b/node_modules/@babel/runtime/helpers/construct.js new file mode 100644 index 00000000..723a7eaa --- /dev/null +++ b/node_modules/@babel/runtime/helpers/construct.js @@ -0,0 +1,33 @@ +var setPrototypeOf = require("./setPrototypeOf"); + +function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (isNativeReflectConstruct()) { + module.exports = _construct = Reflect.construct; + } else { + module.exports = _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +module.exports = _construct; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/createClass.js b/node_modules/@babel/runtime/helpers/createClass.js new file mode 100644 index 00000000..f9d48410 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/createClass.js @@ -0,0 +1,17 @@ +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +module.exports = _createClass; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/decorate.js b/node_modules/@babel/runtime/helpers/decorate.js new file mode 100644 index 00000000..77c0b980 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/decorate.js @@ -0,0 +1,400 @@ +var toArray = require("./toArray"); + +var toPropertyKey = require("./toPropertyKey"); + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function _getDecoratorsApi() { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function initializeInstanceElements(O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function initializeClassElements(F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function defineClassElement(receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function decorateClass(elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + "static": [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function addElementPlacement(element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function decorateElement(element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function decorateConstructor(elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function fromElementDescriptor(element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function toElementDescriptors(elementObjects) { + if (elementObjects === undefined) return; + return toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function toElementDescriptor(elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = toPropertyKey(elementObject.key); + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function toElementFinisherExtras(elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function fromClassDescriptor(elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function toClassDescriptor(obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function runClassFinishers(constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function disallowProperty(obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = toPropertyKey(def.key); + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function isSameElement(other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +module.exports = _decorate; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/defaults.js b/node_modules/@babel/runtime/helpers/defaults.js new file mode 100644 index 00000000..55ba1feb --- /dev/null +++ b/node_modules/@babel/runtime/helpers/defaults.js @@ -0,0 +1,16 @@ +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +module.exports = _defaults; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js b/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js new file mode 100644 index 00000000..5d80ea1e --- /dev/null +++ b/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js @@ -0,0 +1,24 @@ +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +module.exports = _defineEnumerableProperties; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/defineProperty.js b/node_modules/@babel/runtime/helpers/defineProperty.js new file mode 100644 index 00000000..32a8d73f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/defineProperty.js @@ -0,0 +1,16 @@ +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +module.exports = _defineProperty; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js b/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js new file mode 100644 index 00000000..a4e24029 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js @@ -0,0 +1,97 @@ +import AwaitValue from "./AwaitValue"; +export default function AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume("next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen["return"] !== "function") { + this["return"] = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +AsyncGenerator.prototype["throw"] = function (arg) { + return this._invoke("throw", arg); +}; + +AsyncGenerator.prototype["return"] = function (arg) { + return this._invoke("return", arg); +}; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/AwaitValue.js b/node_modules/@babel/runtime/helpers/esm/AwaitValue.js new file mode 100644 index 00000000..5237e18f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/AwaitValue.js @@ -0,0 +1,3 @@ +export default function _AwaitValue(value) { + this.wrapped = value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js b/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js new file mode 100644 index 00000000..84b59617 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js @@ -0,0 +1,28 @@ +export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js b/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js new file mode 100644 index 00000000..be734fc3 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js @@ -0,0 +1,3 @@ +export default function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js b/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js new file mode 100644 index 00000000..cbcffa15 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js @@ -0,0 +1,9 @@ +export default function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + + return arr2; + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js b/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js new file mode 100644 index 00000000..bbf849ca --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js @@ -0,0 +1,7 @@ +export default function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js b/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js new file mode 100644 index 00000000..c3f586f0 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js @@ -0,0 +1,51 @@ +export default function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner["throw"] === "function") { + iter["throw"] = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner["return"] === "function") { + iter["return"] = function (value) { + return pump("return", value); + }; + } + + return iter; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/asyncIterator.js b/node_modules/@babel/runtime/helpers/esm/asyncIterator.js new file mode 100644 index 00000000..e03fa978 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/asyncIterator.js @@ -0,0 +1,17 @@ +export default function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js b/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js new file mode 100644 index 00000000..2a25f543 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js @@ -0,0 +1,35 @@ +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +export default function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js b/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js new file mode 100644 index 00000000..462f99cd --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js @@ -0,0 +1,4 @@ +import AwaitValue from "./AwaitValue"; +export default function _awaitAsyncGenerator(value) { + return new AwaitValue(value); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classCallCheck.js b/node_modules/@babel/runtime/helpers/esm/classCallCheck.js new file mode 100644 index 00000000..2f1738a3 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classCallCheck.js @@ -0,0 +1,5 @@ +export default function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js b/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js new file mode 100644 index 00000000..f7b6dd57 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js @@ -0,0 +1,3 @@ +export default function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js new file mode 100644 index 00000000..1f265bc8 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js @@ -0,0 +1,26 @@ +export default function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js new file mode 100644 index 00000000..f8287f11 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js @@ -0,0 +1,13 @@ +export default function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js new file mode 100644 index 00000000..5b10916f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js @@ -0,0 +1,7 @@ +export default function _classPrivateFieldBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js new file mode 100644 index 00000000..5b7e5ac0 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js @@ -0,0 +1,4 @@ +var id = 0; +export default function _classPrivateFieldKey(name) { + return "__private_" + id++ + "_" + name; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js new file mode 100644 index 00000000..fb4e5d2b --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js @@ -0,0 +1,19 @@ +export default function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js b/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js new file mode 100644 index 00000000..38b9d584 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js @@ -0,0 +1,7 @@ +export default function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js b/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js new file mode 100644 index 00000000..2bbaf3a7 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js @@ -0,0 +1,3 @@ +export default function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js new file mode 100644 index 00000000..29ae49bb --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js @@ -0,0 +1,7 @@ +export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return descriptor.value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js new file mode 100644 index 00000000..15013f5f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js @@ -0,0 +1,12 @@ +export default function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + return value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js new file mode 100644 index 00000000..da9b1e57 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js @@ -0,0 +1,7 @@ +export default function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js new file mode 100644 index 00000000..d5ab60a9 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js @@ -0,0 +1,3 @@ +export default function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/construct.js b/node_modules/@babel/runtime/helpers/esm/construct.js new file mode 100644 index 00000000..82f20fae --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/construct.js @@ -0,0 +1,31 @@ +import setPrototypeOf from "./setPrototypeOf"; + +function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +export default function _construct(Parent, args, Class) { + if (isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/createClass.js b/node_modules/@babel/runtime/helpers/esm/createClass.js new file mode 100644 index 00000000..d6cf4122 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/createClass.js @@ -0,0 +1,15 @@ +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +export default function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/decorate.js b/node_modules/@babel/runtime/helpers/esm/decorate.js new file mode 100644 index 00000000..b6acd1ff --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/decorate.js @@ -0,0 +1,396 @@ +import toArray from "./toArray"; +import toPropertyKey from "./toPropertyKey"; +export default function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function _getDecoratorsApi() { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function initializeInstanceElements(O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function initializeClassElements(F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function defineClassElement(receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function decorateClass(elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + "static": [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function addElementPlacement(element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function decorateElement(element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function decorateConstructor(elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function fromElementDescriptor(element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function toElementDescriptors(elementObjects) { + if (elementObjects === undefined) return; + return toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function toElementDescriptor(elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = toPropertyKey(elementObject.key); + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function toElementFinisherExtras(elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function fromClassDescriptor(elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function toClassDescriptor(obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function runClassFinishers(constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function disallowProperty(obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = toPropertyKey(def.key); + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function isSameElement(other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/defaults.js b/node_modules/@babel/runtime/helpers/esm/defaults.js new file mode 100644 index 00000000..3de1d8ec --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/defaults.js @@ -0,0 +1,14 @@ +export default function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js b/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js new file mode 100644 index 00000000..7981acd4 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js @@ -0,0 +1,22 @@ +export default function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/defineProperty.js b/node_modules/@babel/runtime/helpers/esm/defineProperty.js new file mode 100644 index 00000000..7cf6e59f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/defineProperty.js @@ -0,0 +1,14 @@ +export default function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/extends.js b/node_modules/@babel/runtime/helpers/esm/extends.js new file mode 100644 index 00000000..b9b138d8 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/extends.js @@ -0,0 +1,17 @@ +export default function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/get.js b/node_modules/@babel/runtime/helpers/esm/get.js new file mode 100644 index 00000000..a369d4d1 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/get.js @@ -0,0 +1,20 @@ +import superPropBase from "./superPropBase"; +export default function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = superPropBase(target, property); + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js b/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js new file mode 100644 index 00000000..5abafe38 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js @@ -0,0 +1,6 @@ +export default function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/inherits.js b/node_modules/@babel/runtime/helpers/esm/inherits.js new file mode 100644 index 00000000..035648d0 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/inherits.js @@ -0,0 +1,15 @@ +import setPrototypeOf from "./setPrototypeOf"; +export default function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) setPrototypeOf(subClass, superClass); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js b/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js new file mode 100644 index 00000000..32017e66 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js @@ -0,0 +1,5 @@ +export default function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js b/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js new file mode 100644 index 00000000..26fdea08 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js @@ -0,0 +1,9 @@ +export default function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js b/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js new file mode 100644 index 00000000..d40ca01c --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js @@ -0,0 +1,3 @@ +export default function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/instanceof.js b/node_modules/@babel/runtime/helpers/esm/instanceof.js new file mode 100644 index 00000000..8c43b717 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/instanceof.js @@ -0,0 +1,7 @@ +export default function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js b/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js new file mode 100644 index 00000000..c2df7b64 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js @@ -0,0 +1,5 @@ +export default function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js b/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js new file mode 100644 index 00000000..b28510ee --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js @@ -0,0 +1,24 @@ +export default function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; + + if (desc.get || desc.set) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + } + + newObj["default"] = obj; + return newObj; + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js b/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js new file mode 100644 index 00000000..7b1bc821 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js @@ -0,0 +1,3 @@ +export default function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/iterableToArray.js b/node_modules/@babel/runtime/helpers/esm/iterableToArray.js new file mode 100644 index 00000000..671e400d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/iterableToArray.js @@ -0,0 +1,3 @@ +export default function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js b/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js new file mode 100644 index 00000000..7234d8e6 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js @@ -0,0 +1,25 @@ +export default function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js b/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js new file mode 100644 index 00000000..4261e294 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js @@ -0,0 +1,11 @@ +export default function _iterableToArrayLimitLoose(arr, i) { + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/jsx.js b/node_modules/@babel/runtime/helpers/esm/jsx.js new file mode 100644 index 00000000..0866a55f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/jsx.js @@ -0,0 +1,46 @@ +var REACT_ELEMENT_TYPE; +export default function _createRawReactElement(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js b/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js new file mode 100644 index 00000000..d6cd8643 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js @@ -0,0 +1,5 @@ +export default function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js b/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js new file mode 100644 index 00000000..f94186da --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js @@ -0,0 +1,3 @@ +export default function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js b/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js new file mode 100644 index 00000000..d6bc738a --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js @@ -0,0 +1,3 @@ +export default function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js b/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js new file mode 100644 index 00000000..82b67d2c --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js @@ -0,0 +1,3 @@ +export default function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/objectSpread.js b/node_modules/@babel/runtime/helpers/esm/objectSpread.js new file mode 100644 index 00000000..918bc8e9 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/objectSpread.js @@ -0,0 +1,19 @@ +import defineProperty from "./defineProperty"; +export default function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + defineProperty(target, key, source[key]); + }); + } + + return target; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/objectSpread2.js b/node_modules/@babel/runtime/helpers/esm/objectSpread2.js new file mode 100644 index 00000000..1d3d67f8 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/objectSpread2.js @@ -0,0 +1,35 @@ +import defineProperty from "./defineProperty"; + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +export default function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(source, true).forEach(function (key) { + defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(source).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js b/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js new file mode 100644 index 00000000..2af6091d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js @@ -0,0 +1,19 @@ +import objectWithoutPropertiesLoose from "./objectWithoutPropertiesLoose"; +export default function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + var target = objectWithoutPropertiesLoose(source, excluded); + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js b/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js new file mode 100644 index 00000000..c36815ce --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js @@ -0,0 +1,14 @@ +export default function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js b/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js new file mode 100644 index 00000000..be7b7a44 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js @@ -0,0 +1,9 @@ +import _typeof from "../../helpers/esm/typeof"; +import assertThisInitialized from "./assertThisInitialized"; +export default function _possibleConstructorReturn(self, call) { + if (call && (_typeof(call) === "object" || typeof call === "function")) { + return call; + } + + return assertThisInitialized(self); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/readOnlyError.js b/node_modules/@babel/runtime/helpers/esm/readOnlyError.js new file mode 100644 index 00000000..45d01d72 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/readOnlyError.js @@ -0,0 +1,3 @@ +export default function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/set.js b/node_modules/@babel/runtime/helpers/esm/set.js new file mode 100644 index 00000000..fb20af78 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/set.js @@ -0,0 +1,51 @@ +import superPropBase from "./superPropBase"; +import defineProperty from "./defineProperty"; + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = superPropBase(target, property); + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +export default function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js b/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js new file mode 100644 index 00000000..e6ef03e5 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js @@ -0,0 +1,8 @@ +export default function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js b/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js new file mode 100644 index 00000000..cadd9bb5 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js @@ -0,0 +1,7 @@ +export default function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/slicedToArray.js b/node_modules/@babel/runtime/helpers/esm/slicedToArray.js new file mode 100644 index 00000000..f6f10816 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/slicedToArray.js @@ -0,0 +1,6 @@ +import arrayWithHoles from "./arrayWithHoles"; +import iterableToArrayLimit from "./iterableToArrayLimit"; +import nonIterableRest from "./nonIterableRest"; +export default function _slicedToArray(arr, i) { + return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest(); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/slicedToArrayLoose.js b/node_modules/@babel/runtime/helpers/esm/slicedToArrayLoose.js new file mode 100644 index 00000000..e6757890 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/slicedToArrayLoose.js @@ -0,0 +1,6 @@ +import arrayWithHoles from "./arrayWithHoles"; +import iterableToArrayLimitLoose from "./iterableToArrayLimitLoose"; +import nonIterableRest from "./nonIterableRest"; +export default function _slicedToArrayLoose(arr, i) { + return arrayWithHoles(arr) || iterableToArrayLimitLoose(arr, i) || nonIterableRest(); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/superPropBase.js b/node_modules/@babel/runtime/helpers/esm/superPropBase.js new file mode 100644 index 00000000..eace947c --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/superPropBase.js @@ -0,0 +1,9 @@ +import getPrototypeOf from "./getPrototypeOf"; +export default function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = getPrototypeOf(object); + if (object === null) break; + } + + return object; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js b/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js new file mode 100644 index 00000000..421f18ab --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js @@ -0,0 +1,11 @@ +export default function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js b/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js new file mode 100644 index 00000000..c8f081e9 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js @@ -0,0 +1,8 @@ +export default function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/temporalRef.js b/node_modules/@babel/runtime/helpers/esm/temporalRef.js new file mode 100644 index 00000000..4b0679c6 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/temporalRef.js @@ -0,0 +1,8 @@ +import undef from "./temporalUndefined"; +export default function _temporalRef(val, name) { + if (val === undef) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } else { + return val; + } +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js b/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js new file mode 100644 index 00000000..7c645e42 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js @@ -0,0 +1 @@ +export default {}; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/toArray.js b/node_modules/@babel/runtime/helpers/esm/toArray.js new file mode 100644 index 00000000..5acb22b3 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/toArray.js @@ -0,0 +1,6 @@ +import arrayWithHoles from "./arrayWithHoles"; +import iterableToArray from "./iterableToArray"; +import nonIterableRest from "./nonIterableRest"; +export default function _toArray(arr) { + return arrayWithHoles(arr) || iterableToArray(arr) || nonIterableRest(); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js b/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js new file mode 100644 index 00000000..7e480b9d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js @@ -0,0 +1,6 @@ +import arrayWithoutHoles from "./arrayWithoutHoles"; +import iterableToArray from "./iterableToArray"; +import nonIterableSpread from "./nonIterableSpread"; +export default function _toConsumableArray(arr) { + return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread(); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/toPrimitive.js b/node_modules/@babel/runtime/helpers/esm/toPrimitive.js new file mode 100644 index 00000000..72a4a097 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/toPrimitive.js @@ -0,0 +1,13 @@ +import _typeof from "../../helpers/esm/typeof"; +export default function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js b/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js new file mode 100644 index 00000000..7b53a4de --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js @@ -0,0 +1,6 @@ +import _typeof from "../../helpers/esm/typeof"; +import toPrimitive from "./toPrimitive"; +export default function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/typeof.js b/node_modules/@babel/runtime/helpers/esm/typeof.js new file mode 100644 index 00000000..7825537f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/typeof.js @@ -0,0 +1,15 @@ +function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } + +export default function _typeof(obj) { + if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { + _typeof = function _typeof(obj) { + return _typeof2(obj); + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); + }; + } + + return _typeof(obj); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js b/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js new file mode 100644 index 00000000..6d6d9811 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js @@ -0,0 +1,6 @@ +import AsyncGenerator from "./AsyncGenerator"; +export default function _wrapAsyncGenerator(fn) { + return function () { + return new AsyncGenerator(fn.apply(this, arguments)); + }; +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js b/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js new file mode 100644 index 00000000..5c55d058 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js @@ -0,0 +1,37 @@ +import getPrototypeOf from "./getPrototypeOf"; +import setPrototypeOf from "./setPrototypeOf"; +import isNativeFunction from "./isNativeFunction"; +import construct from "./construct"; +export default function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return construct(Class, arguments, getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js b/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js new file mode 100644 index 00000000..4aa1af06 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js @@ -0,0 +1,69 @@ +import _typeof from "../../helpers/esm/typeof"; +import wrapNativeSuper from "./wrapNativeSuper"; +import getPrototypeOf from "./getPrototypeOf"; +import possibleConstructorReturn from "./possibleConstructorReturn"; +import inherits from "./inherits"; +export default function _wrapRegExp(re, groups) { + _wrapRegExp = function _wrapRegExp(re, groups) { + return new BabelRegExp(re, groups); + }; + + var _RegExp = wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, groups) { + var _this = _RegExp.call(this, re); + + _groups.set(_this, groups); + + return _this; + } + + inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (_typeof(args[args.length - 1]) !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/extends.js b/node_modules/@babel/runtime/helpers/extends.js new file mode 100644 index 00000000..1816877e --- /dev/null +++ b/node_modules/@babel/runtime/helpers/extends.js @@ -0,0 +1,19 @@ +function _extends() { + module.exports = _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +module.exports = _extends; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/get.js b/node_modules/@babel/runtime/helpers/get.js new file mode 100644 index 00000000..31ffc656 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/get.js @@ -0,0 +1,23 @@ +var superPropBase = require("./superPropBase"); + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + module.exports = _get = Reflect.get; + } else { + module.exports = _get = function _get(target, property, receiver) { + var base = superPropBase(target, property); + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +module.exports = _get; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/getPrototypeOf.js b/node_modules/@babel/runtime/helpers/getPrototypeOf.js new file mode 100644 index 00000000..5fc9a169 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/getPrototypeOf.js @@ -0,0 +1,8 @@ +function _getPrototypeOf(o) { + module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +module.exports = _getPrototypeOf; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/inherits.js b/node_modules/@babel/runtime/helpers/inherits.js new file mode 100644 index 00000000..6b4f286d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/inherits.js @@ -0,0 +1,18 @@ +var setPrototypeOf = require("./setPrototypeOf"); + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) setPrototypeOf(subClass, superClass); +} + +module.exports = _inherits; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/inheritsLoose.js b/node_modules/@babel/runtime/helpers/inheritsLoose.js new file mode 100644 index 00000000..c3f7cdb4 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/inheritsLoose.js @@ -0,0 +1,7 @@ +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +module.exports = _inheritsLoose; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/initializerDefineProperty.js b/node_modules/@babel/runtime/helpers/initializerDefineProperty.js new file mode 100644 index 00000000..4caa5ca6 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/initializerDefineProperty.js @@ -0,0 +1,11 @@ +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +module.exports = _initializerDefineProperty; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/initializerWarningHelper.js b/node_modules/@babel/runtime/helpers/initializerWarningHelper.js new file mode 100644 index 00000000..56e0c173 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/initializerWarningHelper.js @@ -0,0 +1,5 @@ +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); +} + +module.exports = _initializerWarningHelper; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/instanceof.js b/node_modules/@babel/runtime/helpers/instanceof.js new file mode 100644 index 00000000..efe134c1 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/instanceof.js @@ -0,0 +1,9 @@ +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +module.exports = _instanceof; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/interopRequireDefault.js b/node_modules/@babel/runtime/helpers/interopRequireDefault.js new file mode 100644 index 00000000..f713d130 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/interopRequireDefault.js @@ -0,0 +1,7 @@ +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; +} + +module.exports = _interopRequireDefault; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/interopRequireWildcard.js b/node_modules/@babel/runtime/helpers/interopRequireWildcard.js new file mode 100644 index 00000000..dd9c045a --- /dev/null +++ b/node_modules/@babel/runtime/helpers/interopRequireWildcard.js @@ -0,0 +1,26 @@ +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; + + if (desc.get || desc.set) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + } + + newObj["default"] = obj; + return newObj; + } +} + +module.exports = _interopRequireWildcard; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/isNativeFunction.js b/node_modules/@babel/runtime/helpers/isNativeFunction.js new file mode 100644 index 00000000..e2dc3ed7 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/isNativeFunction.js @@ -0,0 +1,5 @@ +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +module.exports = _isNativeFunction; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/iterableToArray.js b/node_modules/@babel/runtime/helpers/iterableToArray.js new file mode 100644 index 00000000..e917e579 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/iterableToArray.js @@ -0,0 +1,5 @@ +function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} + +module.exports = _iterableToArray; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js b/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js new file mode 100644 index 00000000..14c1daa6 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js @@ -0,0 +1,27 @@ +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +module.exports = _iterableToArrayLimit; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js b/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js new file mode 100644 index 00000000..c7dfeb30 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js @@ -0,0 +1,13 @@ +function _iterableToArrayLimitLoose(arr, i) { + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +module.exports = _iterableToArrayLimitLoose; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/jsx.js b/node_modules/@babel/runtime/helpers/jsx.js new file mode 100644 index 00000000..000fd617 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/jsx.js @@ -0,0 +1,49 @@ +var REACT_ELEMENT_TYPE; + +function _createRawReactElement(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +module.exports = _createRawReactElement; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/newArrowCheck.js b/node_modules/@babel/runtime/helpers/newArrowCheck.js new file mode 100644 index 00000000..9b59f58c --- /dev/null +++ b/node_modules/@babel/runtime/helpers/newArrowCheck.js @@ -0,0 +1,7 @@ +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +module.exports = _newArrowCheck; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/nonIterableRest.js b/node_modules/@babel/runtime/helpers/nonIterableRest.js new file mode 100644 index 00000000..eb447dd7 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/nonIterableRest.js @@ -0,0 +1,5 @@ +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} + +module.exports = _nonIterableRest; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/nonIterableSpread.js b/node_modules/@babel/runtime/helpers/nonIterableSpread.js new file mode 100644 index 00000000..7d7ca436 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/nonIterableSpread.js @@ -0,0 +1,5 @@ +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); +} + +module.exports = _nonIterableSpread; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js b/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js new file mode 100644 index 00000000..1d5c04a7 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js @@ -0,0 +1,5 @@ +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +module.exports = _objectDestructuringEmpty; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/objectSpread.js b/node_modules/@babel/runtime/helpers/objectSpread.js new file mode 100644 index 00000000..b9234007 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/objectSpread.js @@ -0,0 +1,22 @@ +var defineProperty = require("./defineProperty"); + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + defineProperty(target, key, source[key]); + }); + } + + return target; +} + +module.exports = _objectSpread; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/objectSpread2.js b/node_modules/@babel/runtime/helpers/objectSpread2.js new file mode 100644 index 00000000..6ad76216 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/objectSpread2.js @@ -0,0 +1,37 @@ +var defineProperty = require("./defineProperty"); + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(source, true).forEach(function (key) { + defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(source).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +module.exports = _objectSpread2; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/objectWithoutProperties.js b/node_modules/@babel/runtime/helpers/objectWithoutProperties.js new file mode 100644 index 00000000..253d33c9 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/objectWithoutProperties.js @@ -0,0 +1,22 @@ +var objectWithoutPropertiesLoose = require("./objectWithoutPropertiesLoose"); + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + var target = objectWithoutPropertiesLoose(source, excluded); + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +module.exports = _objectWithoutProperties; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js b/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js new file mode 100644 index 00000000..a58c56b0 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js @@ -0,0 +1,16 @@ +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +module.exports = _objectWithoutPropertiesLoose; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js b/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js new file mode 100644 index 00000000..84f7bf63 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js @@ -0,0 +1,13 @@ +var _typeof = require("../helpers/typeof"); + +var assertThisInitialized = require("./assertThisInitialized"); + +function _possibleConstructorReturn(self, call) { + if (call && (_typeof(call) === "object" || typeof call === "function")) { + return call; + } + + return assertThisInitialized(self); +} + +module.exports = _possibleConstructorReturn; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/readOnlyError.js b/node_modules/@babel/runtime/helpers/readOnlyError.js new file mode 100644 index 00000000..4e61e3fd --- /dev/null +++ b/node_modules/@babel/runtime/helpers/readOnlyError.js @@ -0,0 +1,5 @@ +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +module.exports = _readOnlyError; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/set.js b/node_modules/@babel/runtime/helpers/set.js new file mode 100644 index 00000000..97fa8c35 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/set.js @@ -0,0 +1,54 @@ +var superPropBase = require("./superPropBase"); + +var defineProperty = require("./defineProperty"); + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = superPropBase(target, property); + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +module.exports = _set; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/setPrototypeOf.js b/node_modules/@babel/runtime/helpers/setPrototypeOf.js new file mode 100644 index 00000000..d86e2fc3 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/setPrototypeOf.js @@ -0,0 +1,10 @@ +function _setPrototypeOf(o, p) { + module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +module.exports = _setPrototypeOf; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js b/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js new file mode 100644 index 00000000..e1d6c86b --- /dev/null +++ b/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js @@ -0,0 +1,9 @@ +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +module.exports = _skipFirstGeneratorNext; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/slicedToArray.js b/node_modules/@babel/runtime/helpers/slicedToArray.js new file mode 100644 index 00000000..243ea9e2 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/slicedToArray.js @@ -0,0 +1,11 @@ +var arrayWithHoles = require("./arrayWithHoles"); + +var iterableToArrayLimit = require("./iterableToArrayLimit"); + +var nonIterableRest = require("./nonIterableRest"); + +function _slicedToArray(arr, i) { + return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest(); +} + +module.exports = _slicedToArray; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/slicedToArrayLoose.js b/node_modules/@babel/runtime/helpers/slicedToArrayLoose.js new file mode 100644 index 00000000..c7e4313b --- /dev/null +++ b/node_modules/@babel/runtime/helpers/slicedToArrayLoose.js @@ -0,0 +1,11 @@ +var arrayWithHoles = require("./arrayWithHoles"); + +var iterableToArrayLimitLoose = require("./iterableToArrayLimitLoose"); + +var nonIterableRest = require("./nonIterableRest"); + +function _slicedToArrayLoose(arr, i) { + return arrayWithHoles(arr) || iterableToArrayLimitLoose(arr, i) || nonIterableRest(); +} + +module.exports = _slicedToArrayLoose; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/superPropBase.js b/node_modules/@babel/runtime/helpers/superPropBase.js new file mode 100644 index 00000000..bbb34a2d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/superPropBase.js @@ -0,0 +1,12 @@ +var getPrototypeOf = require("./getPrototypeOf"); + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +module.exports = _superPropBase; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js b/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js new file mode 100644 index 00000000..bdcc1e9d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js @@ -0,0 +1,13 @@ +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +module.exports = _taggedTemplateLiteral; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js b/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js new file mode 100644 index 00000000..beced541 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js @@ -0,0 +1,10 @@ +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +module.exports = _taggedTemplateLiteralLoose; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/temporalRef.js b/node_modules/@babel/runtime/helpers/temporalRef.js new file mode 100644 index 00000000..20b2652a --- /dev/null +++ b/node_modules/@babel/runtime/helpers/temporalRef.js @@ -0,0 +1,11 @@ +var temporalUndefined = require("./temporalUndefined"); + +function _temporalRef(val, name) { + if (val === temporalUndefined) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } else { + return val; + } +} + +module.exports = _temporalRef; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/temporalUndefined.js b/node_modules/@babel/runtime/helpers/temporalUndefined.js new file mode 100644 index 00000000..a0995453 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/temporalUndefined.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/toArray.js b/node_modules/@babel/runtime/helpers/toArray.js new file mode 100644 index 00000000..c28fd9e4 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/toArray.js @@ -0,0 +1,11 @@ +var arrayWithHoles = require("./arrayWithHoles"); + +var iterableToArray = require("./iterableToArray"); + +var nonIterableRest = require("./nonIterableRest"); + +function _toArray(arr) { + return arrayWithHoles(arr) || iterableToArray(arr) || nonIterableRest(); +} + +module.exports = _toArray; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/toConsumableArray.js b/node_modules/@babel/runtime/helpers/toConsumableArray.js new file mode 100644 index 00000000..4cd54a33 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/toConsumableArray.js @@ -0,0 +1,11 @@ +var arrayWithoutHoles = require("./arrayWithoutHoles"); + +var iterableToArray = require("./iterableToArray"); + +var nonIterableSpread = require("./nonIterableSpread"); + +function _toConsumableArray(arr) { + return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread(); +} + +module.exports = _toConsumableArray; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/toPrimitive.js b/node_modules/@babel/runtime/helpers/toPrimitive.js new file mode 100644 index 00000000..cd1d383f --- /dev/null +++ b/node_modules/@babel/runtime/helpers/toPrimitive.js @@ -0,0 +1,16 @@ +var _typeof = require("../helpers/typeof"); + +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +module.exports = _toPrimitive; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/toPropertyKey.js b/node_modules/@babel/runtime/helpers/toPropertyKey.js new file mode 100644 index 00000000..108b083e --- /dev/null +++ b/node_modules/@babel/runtime/helpers/toPropertyKey.js @@ -0,0 +1,10 @@ +var _typeof = require("../helpers/typeof"); + +var toPrimitive = require("./toPrimitive"); + +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} + +module.exports = _toPropertyKey; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/typeof.js b/node_modules/@babel/runtime/helpers/typeof.js new file mode 100644 index 00000000..fd7d3edf --- /dev/null +++ b/node_modules/@babel/runtime/helpers/typeof.js @@ -0,0 +1,17 @@ +function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } + +function _typeof(obj) { + if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { + module.exports = _typeof = function _typeof(obj) { + return _typeof2(obj); + }; + } else { + module.exports = _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); + }; + } + + return _typeof(obj); +} + +module.exports = _typeof; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js b/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js new file mode 100644 index 00000000..11554f3d --- /dev/null +++ b/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js @@ -0,0 +1,9 @@ +var AsyncGenerator = require("./AsyncGenerator"); + +function _wrapAsyncGenerator(fn) { + return function () { + return new AsyncGenerator(fn.apply(this, arguments)); + }; +} + +module.exports = _wrapAsyncGenerator; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/wrapNativeSuper.js b/node_modules/@babel/runtime/helpers/wrapNativeSuper.js new file mode 100644 index 00000000..3d4bd7a0 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/wrapNativeSuper.js @@ -0,0 +1,43 @@ +var getPrototypeOf = require("./getPrototypeOf"); + +var setPrototypeOf = require("./setPrototypeOf"); + +var isNativeFunction = require("./isNativeFunction"); + +var construct = require("./construct"); + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return construct(Class, arguments, getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +module.exports = _wrapNativeSuper; \ No newline at end of file diff --git a/node_modules/@babel/runtime/helpers/wrapRegExp.js b/node_modules/@babel/runtime/helpers/wrapRegExp.js new file mode 100644 index 00000000..08bcb542 --- /dev/null +++ b/node_modules/@babel/runtime/helpers/wrapRegExp.js @@ -0,0 +1,76 @@ +var _typeof = require("../helpers/typeof"); + +var wrapNativeSuper = require("./wrapNativeSuper"); + +var getPrototypeOf = require("./getPrototypeOf"); + +var possibleConstructorReturn = require("./possibleConstructorReturn"); + +var inherits = require("./inherits"); + +function _wrapRegExp(re, groups) { + module.exports = _wrapRegExp = function _wrapRegExp(re, groups) { + return new BabelRegExp(re, groups); + }; + + var _RegExp = wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, groups) { + var _this = _RegExp.call(this, re); + + _groups.set(_this, groups); + + return _this; + } + + inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (_typeof(args[args.length - 1]) !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +module.exports = _wrapRegExp; \ No newline at end of file diff --git a/node_modules/@babel/runtime/package.json b/node_modules/@babel/runtime/package.json new file mode 100644 index 00000000..b463272a --- /dev/null +++ b/node_modules/@babel/runtime/package.json @@ -0,0 +1,18 @@ +{ + "name": "@babel/runtime", + "version": "7.5.5", + "description": "babel's modular runtime helpers", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "repository": "https://github.com/babel/babel/tree/master/packages/babel-runtime", + "author": "Sebastian McKenzie ", + "dependencies": { + "regenerator-runtime": "^0.13.2" + }, + "devDependencies": { + "@babel/helpers": "^7.5.5" + }, + "gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43" +} diff --git a/node_modules/@babel/runtime/regenerator/index.js b/node_modules/@babel/runtime/regenerator/index.js new file mode 100644 index 00000000..9fd4158a --- /dev/null +++ b/node_modules/@babel/runtime/regenerator/index.js @@ -0,0 +1 @@ +module.exports = require("regenerator-runtime"); diff --git a/node_modules/babel-runtime/node_modules/regenerator-runtime/README.md b/node_modules/babel-runtime/node_modules/regenerator-runtime/README.md new file mode 100644 index 00000000..d93386a3 --- /dev/null +++ b/node_modules/babel-runtime/node_modules/regenerator-runtime/README.md @@ -0,0 +1,31 @@ +# regenerator-runtime + +Standalone runtime for +[Regenerator](https://github.com/facebook/regenerator)-compiled generator +and `async` functions. + +To import the runtime as a module (recommended), either of the following +import styles will work: +```js +// CommonJS +const regeneratorRuntime = require("regenerator-runtime"); + +// ECMAScript 2015 +import regeneratorRuntime from "regenerator-runtime"; +``` + +To ensure that `regeneratorRuntime` is defined globally, either of the +following styles will work: +```js +// CommonJS +require("regenerator-runtime/runtime"); + +// ECMAScript 2015 +import "regenerator-runtime/runtime"; +``` + +To get the absolute file system path of `runtime.js`, evaluate the +following expression: +```js +require("regenerator-runtime/path").path +``` diff --git a/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json b/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json new file mode 100644 index 00000000..db053987 --- /dev/null +++ b/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json @@ -0,0 +1,18 @@ +{ + "name": "regenerator-runtime", + "author": "Ben Newman ", + "description": "Runtime for Regenerator-compiled generator and async functions.", + "version": "0.11.1", + "main": "runtime-module.js", + "keywords": [ + "regenerator", + "runtime", + "generator", + "async" + ], + "repository": { + "type": "git", + "url": "https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime" + }, + "license": "MIT" +} diff --git a/node_modules/babel-runtime/node_modules/regenerator-runtime/path.js b/node_modules/babel-runtime/node_modules/regenerator-runtime/path.js new file mode 100644 index 00000000..ced878b8 --- /dev/null +++ b/node_modules/babel-runtime/node_modules/regenerator-runtime/path.js @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +exports.path = require("path").join( + __dirname, + "runtime.js" +); diff --git a/node_modules/regenerator-runtime/runtime-module.js b/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime-module.js similarity index 100% rename from node_modules/regenerator-runtime/runtime-module.js rename to node_modules/babel-runtime/node_modules/regenerator-runtime/runtime-module.js diff --git a/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js b/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js new file mode 100644 index 00000000..22e7b005 --- /dev/null +++ b/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js @@ -0,0 +1,727 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +!(function(global) { + "use strict"; + + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; + + var inModule = typeof module === "object"; + var runtime = global.regeneratorRuntime; + if (runtime) { + if (inModule) { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; + } + // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. + return; + } + + // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. + runtime = global.regeneratorRuntime = inModule ? module.exports : {}; + + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); + + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); + + return generator; + } + runtime.wrap = wrap; + + // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + function tryCatch(fn, obj, arg) { + try { + return { type: "normal", arg: fn.call(obj, arg) }; + } catch (err) { + return { type: "throw", arg: err }; + } + } + + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; + + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; + + // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; + + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; + } + + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; + + // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function(method) { + prototype[method] = function(arg) { + return this._invoke(method, arg); + }; + }); + } + + runtime.isGeneratorFunction = function(genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor + ? ctor === GeneratorFunction || + // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" + : false; + }; + + runtime.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } + } + genFun.prototype = Object.create(Gp); + return genFun; + }; + + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. + runtime.awrap = function(arg) { + return { __await: arg }; + }; + + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); + }); + } + + return Promise.resolve(value).then(function(unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. If the Promise is rejected, however, the + // result for this iteration will be rejected with the same + // reason. Note that rejections of yielded Promises are not + // thrown back into the generator function, as is the case + // when an awaited Promise is rejected. This difference in + // behavior between yield and await is important, because it + // allows the consumer to decide what to do with the yielded + // rejection (swallow it and continue, manually .throw it back + // into the generator, abandon iteration, whatever). With + // await, by contrast, there is no opportunity to examine the + // rejection reason outside the generator function, so the + // only option is to throw it from the await expression, and + // let the generator function handle the exception. + result.value = unwrapped; + resolve(result); + }, reject); + } + } + + var previousPromise; + + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } + + return previousPromise = + // If enqueue has been called before, then we want to wait until + // all previous Promises have been resolved before calling invoke, + // so that results are always delivered in the correct order. If + // enqueue has not been called before, then it is important to + // call invoke immediately, without waiting on a callback to fire, + // so that the async generator function has the opportunity to do + // any necessary setup in a predictable way. This predictability + // is why the Promise constructor synchronously invokes its + // executor callback, and why async functions synchronously + // execute code before the first await. Since we implement simple + // async functions in terms of async generators, it is especially + // important to get this right, even though it requires care. + previousPromise ? previousPromise.then( + callInvokeWithMethodAndArg, + // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg + ) : callInvokeWithMethodAndArg(); + } + + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } + + defineIteratorMethods(AsyncIterator.prototype); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; + runtime.AsyncIterator = AsyncIterator; + + // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + runtime.async = function(innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList) + ); + + return runtime.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; + + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; + + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } + + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; + } + + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } + + context.method = method; + context.arg = arg; + + while (true) { + var delegate = context.delegate; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; + } + } + + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; + + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; + } + + context.dispatchException(context.arg); + + } else if (context.method === "return") { + context.abrupt("return", context.arg); + } + + state = GenStateExecuting; + + var record = tryCatch(innerFn, self, context); + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done + ? GenStateCompleted + : GenStateSuspendedYield; + + if (record.arg === ContinueSentinel) { + continue; + } + + return { + value: record.arg, + done: context.done + }; + + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. + context.method = "throw"; + context.arg = record.arg; + } + } + }; + } + + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; + + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); + + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } + } + + context.method = "throw"; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); + } + + return ContinueSentinel; + } + + var record = tryCatch(method, delegate.iterator, context.arg); + + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } + + var info = record.arg; + + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; + } + + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; + + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; + + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } + + } else { + // Re-yield the result returned by the delegate method. + return info; + } + + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } + + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); + + Gp[toStringTagSymbol] = "Generator"; + + // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. + Gp[iteratorSymbol] = function() { + return this; + }; + + Gp.toString = function() { + return "[object Generator]"; + }; + + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; + + if (1 in locs) { + entry.catchLoc = locs[1]; + } + + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; + } + + this.tryEntries.push(entry); + } + + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } + + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ tryLoc: "root" }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); + } + + runtime.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); + } + keys.reverse(); + + // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. + return function next() { + while (keys.length) { + var key = keys.pop(); + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } + + // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. + next.done = true; + return next; + }; + }; + + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } + + if (typeof iterable.next === "function") { + return iterable; + } + + if (!isNaN(iterable.length)) { + var i = -1, next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; + } + } + + next.value = undefined; + next.done = true; + + return next; + }; + + return next.next = next; + } + } + + // Return an iterator with no values. + return { next: doneResult }; + } + runtime.values = values; + + function doneResult() { + return { value: undefined, done: true }; + } + + Context.prototype = { + constructor: Context, + + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; + + this.method = "next"; + this.arg = undefined; + + this.tryEntries.forEach(resetTryEntry); + + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && + hasOwn.call(this, name) && + !isNaN(+name.slice(1))) { + this[name] = undefined; + } + } + } + }, + + stop: function() { + this.done = true; + + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } + + return this.rval; + }, + + dispatchException: function(exception) { + if (this.done) { + throw exception; + } + + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; + + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } + + return !! caught; + } + + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; + + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); + } + + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); + + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } + + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, + + abrupt: function(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc <= this.prev && + hasOwn.call(entry, "finallyLoc") && + this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; + } + } + + if (finallyEntry && + (type === "break" || + type === "continue") && + finallyEntry.tryLoc <= arg && + arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } + + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; + + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; + return ContinueSentinel; + } + + return this.complete(record); + }, + + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } + + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + + return ContinueSentinel; + }, + + finish: function(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); + resetTryEntry(entry); + return ContinueSentinel; + } + } + }, + + "catch": function(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc === tryLoc) { + var record = entry.completion; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } + return thrown; + } + } + + // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. + throw new Error("illegal catch attempt"); + }, + + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; + + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; + } + + return ContinueSentinel; + } + }; +})( + // In sloppy mode, unbound `this` refers to the global object, fallback to + // Function constructor if we're in global strict mode. That is sadly a form + // of indirect eval which violates Content Security Policy. + (function() { return this })() || Function("return this")() +); diff --git a/node_modules/fn-name/index.js b/node_modules/fn-name/index.js new file mode 100644 index 00000000..c8933518 --- /dev/null +++ b/node_modules/fn-name/index.js @@ -0,0 +1,8 @@ +'use strict'; +module.exports = function (fn) { + if (typeof fn !== 'function') { + throw new TypeError('Expected a function'); + } + + return fn.displayName || fn.name || (/function ([^\(]+)?\(/.exec(fn.toString()) || [])[1] || null; +}; diff --git a/node_modules/fn-name/license b/node_modules/fn-name/license new file mode 100644 index 00000000..654d0bfe --- /dev/null +++ b/node_modules/fn-name/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/fn-name/package.json b/node_modules/fn-name/package.json new file mode 100644 index 00000000..b123584c --- /dev/null +++ b/node_modules/fn-name/package.json @@ -0,0 +1,30 @@ +{ + "name": "fn-name", + "version": "2.0.1", + "description": "Get the name of a named function", + "repository": "sindresorhus/fn-name", + "keywords": [ + "function", + "func", + "fn", + "name" + ], + "license": "MIT", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "files": [ + "index.js" + ], + "scripts": { + "test": "mocha" + }, + "devDependencies": { + "mocha": "*" + }, + "engines": { + "node": ">=0.10.0" + } +} diff --git a/node_modules/fn-name/readme.md b/node_modules/fn-name/readme.md new file mode 100644 index 00000000..6c51f88e --- /dev/null +++ b/node_modules/fn-name/readme.md @@ -0,0 +1,26 @@ +# fn-name [![Build Status](https://travis-ci.org/sindresorhus/fn-name.svg?branch=master)](https://travis-ci.org/sindresorhus/fn-name) + +> Get the name of a named function + +There is a non-standard [name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name) property on functions, but it's not supported in all browsers. +This module tries that property then falls back to extracting the name from the function source. + + +## Install + +```sh +$ npm install --save fn-name +``` + + +## Usage + +```js +fnName(function foo() {}); +//=> foo +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/property-expr/.gitattributes b/node_modules/property-expr/.gitattributes new file mode 100644 index 00000000..412eeda7 --- /dev/null +++ b/node_modules/property-expr/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/node_modules/property-expr/.vscode/launch.json b/node_modules/property-expr/.vscode/launch.json new file mode 100644 index 00000000..c6a24fc1 --- /dev/null +++ b/node_modules/property-expr/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch test via NPM", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run-script", + "debug" + ], + "port": 9229 + }, + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}\\index.js" + } + ] +} \ No newline at end of file diff --git a/node_modules/property-expr/LICENSE.txt b/node_modules/property-expr/LICENSE.txt new file mode 100644 index 00000000..397b66c3 --- /dev/null +++ b/node_modules/property-expr/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Jason Quense + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/node_modules/property-expr/README.md b/node_modules/property-expr/README.md new file mode 100644 index 00000000..dd6dcee6 --- /dev/null +++ b/node_modules/property-expr/README.md @@ -0,0 +1,85 @@ +expr +======= + +Tiny expression helper for creating compiled accessors; handles most stuff, including ["bracket notation"] for property access. Originally based off of Kendo UI Core expression code + + npm install property-expr + +## Use + +Setters and getters are compiled to functions and cached for Performance™ + + var expr = require('property-expr') + , obj = { + foo: { + bar: [ "hi", { buz: { baz: 'found me!' } }] + } + }; + + var getBaz = expr.getter('foo.bar[1]["buz"].baz') + , setBaz = expr.setter('foo.bar[1]["buz"].baz') + + console.log(getBaz(obj)) // => 'found me!' + setBaz(obj, 'set me!') + console.log(obj.foo.bar[1].buz.baz) // => 'set me!' + +### `getter(expression, [ safeAccess ])` + +Returns a function that accepts an obj and returns the value at the supplied expression. You can create a "safe" getter, which won't error out when accessing properties that don't exist, reducing existance checks befroe property access: + + expr.getter('foo.bar.baz', true)({ foo: {} }) // => undefined + //instead of val = foo.bar && foo.bar.baz + +### `setter(expression)` + +Returns a function that accepts an obj and a value and sets the property pointed to by the expression to the supplied value. + + +### `expr(expression, [ safeAccess], [ paramName = 'data'])` + +Returns a normalized expression string pointing to a property on root object +`paramName`. + + expr.expr("foo['bar'][0].baz", true, 'obj') // => "(((obj.foo || {})['bar'] || {})[0])" + +### `split(path) -> Array` + +Returns an array of each path segment. + +```js +expr.split("foo['bar'][0].baz") // [ "foo", "'bar'", "0", "baz"] +``` + +### `forEach(path, iterator[, thisArg])` + +Iterate through a path but segment, with some additional helpful metadata about the segment. The iterator function is called with: `pathSegment`, `isBracket`, `isArray`, `idx`, `segments` + +```js +expr.forEach('foo["bar"][1]', function(pathSegment, isBracket, isArray, idx, segments) { + // 'foo' -> isBracket = false, isArray = false, idx = 0 + // '"bar"' -> isBracket = true, isArray = false, idx = 1 + // '0' -> isBracket = false, isArray = true, idx = 2 +}) +``` + +### `normalizePath(path)` + +Returns an array of path segments without quotes and spaces. +```js +expr.normalizePath('foo["bar"][ "1" ][2][ " sss " ]') +// ['foo', 'bar', '1', '2', ' sss '] +``` + +### `new Cache(maxSize)` + +Just an utility class, returns an instance of cache. When the max size is exceeded, cache clears its storage. +```js +var cache = new Cache(2) +cache.set('a', 123) // returns 123 +cache.get('a') // returns 123 +cache.clear() + +cache.set('a', 1) +cache.set('b', 2) // cache contains 2 values +cache.set('c', 3) // cache was cleaned automatically and contains 1 value +``` diff --git a/node_modules/property-expr/index.js b/node_modules/property-expr/index.js new file mode 100644 index 00000000..b4b0718f --- /dev/null +++ b/node_modules/property-expr/index.js @@ -0,0 +1,205 @@ +/** + * Based on Kendo UI Core expression code + */ +'use strict' + +function Cache(maxSize) { + this._maxSize = maxSize + this.clear() +} +Cache.prototype.clear = function() { + this._size = 0 + this._values = {} +} +Cache.prototype.get = function(key) { + return this._values[key] +} +Cache.prototype.set = function(key, value) { + this._size >= this._maxSize && this.clear() + if (!this._values.hasOwnProperty(key)) { + this._size++ + } + return this._values[key] = value +} + +var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g, + DIGIT_REGEX = /^\d+$/, + LEAD_DIGIT_REGEX = /^\d/, + SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, + CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/, + MAX_CACHE_SIZE = 512 + +var contentSecurityPolicy = false, + pathCache = new Cache(MAX_CACHE_SIZE), + setCache = new Cache(MAX_CACHE_SIZE), + getCache = new Cache(MAX_CACHE_SIZE) + +try { + new Function('') +} catch (error) { + contentSecurityPolicy = true +} + +module.exports = { + Cache: Cache, + + expr: expr, + + split: split, + + normalizePath: normalizePath, + + setter: contentSecurityPolicy + ? function(path) { + var parts = normalizePath(path) + return function(data, value) { + return setterFallback(parts, data, value) + } + } + : function(path) { + return setCache.get(path) || setCache.set( + path, + new Function( + 'data, value', + expr(path, 'data') + ' = value' + ) + ) + }, + + getter: contentSecurityPolicy + ? function(path, safe) { + var parts = normalizePath(path) + return function(data) { + return getterFallback(parts, safe, data) + } + } + : function(path, safe) { + var key = path + '_' + safe + return getCache.get(key) || getCache.set( + key, + new Function('data', 'return ' + expr(path, safe, 'data')) + ) + }, + + join: function(segments) { + return segments.reduce(function(path, part) { + return ( + path + + (isQuoted(part) || DIGIT_REGEX.test(part) + ? '[' + part + ']' + : (path ? '.' : '') + part) + ) + }, '') + }, + + forEach: function(path, cb, thisArg) { + forEach(split(path), cb, thisArg) + } +} + +function setterFallback(parts, data, value) { + var index = 0, + len = parts.length + while (index < len - 1) { + data = data[parts[index++]] + } + data[parts[index]] = value +} + +function getterFallback(parts, safe, data) { + var index = 0, + len = parts.length + while (index < len) { + if (data != null || !safe) { + data = data[parts[index++]] + } else { + return + } + } + return data +} + +function normalizePath(path) { + return pathCache.get(path) || pathCache.set( + path, + split(path).map(function(part) { + return part.replace(CLEAN_QUOTES_REGEX, '$2') + }) + ) +} + +function split(path) { + return path.match(SPLIT_REGEX) +} + +function expr(expression, safe, param) { + expression = expression || '' + + if (typeof safe === 'string') { + param = safe + safe = false + } + + param = param || 'data' + + if (expression && expression.charAt(0) !== '[') expression = '.' + expression + + return safe ? makeSafe(expression, param) : param + expression +} + +function forEach(parts, iter, thisArg) { + var len = parts.length, + part, + idx, + isArray, + isBracket + + for (idx = 0; idx < len; idx++) { + part = parts[idx] + + if (part) { + if (shouldBeQuoted(part)) { + part = '"' + part + '"' + } + + isBracket = isQuoted(part) + isArray = !isBracket && /^\d+$/.test(part) + + iter.call(thisArg, part, isBracket, isArray, idx, parts) + } + } +} + +function isQuoted(str) { + return ( + typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1 + ) +} + +function makeSafe(path, param) { + var result = param, + parts = split(path), + isLast + + forEach(parts, function(part, isBracket, isArray, idx, parts) { + isLast = idx === parts.length - 1 + + part = isBracket || isArray ? '[' + part + ']' : '.' + part + + result += part + (!isLast ? ' || {})' : ')') + }) + + return new Array(parts.length + 1).join('(') + result +} + +function hasLeadingNumber(part) { + return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX) +} + +function hasSpecialChars(part) { + return SPEC_CHAR_REGEX.test(part) +} + +function shouldBeQuoted(part) { + return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part)) +} diff --git a/node_modules/property-expr/package.json b/node_modules/property-expr/package.json new file mode 100644 index 00000000..ce3bd058 --- /dev/null +++ b/node_modules/property-expr/package.json @@ -0,0 +1,30 @@ +{ + "name": "property-expr", + "version": "1.5.1", + "description": "tiny util for getting and setting deep object props safely", + "main": "index.js", + "scripts": { + "test": "node ./test.js", + "debug": "node --inspect-brk ./test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/jquense/expr/" + }, + "keywords": [ + "expr", + "expression", + "setter", + "getter", + "deep", + "property", + "Justin-Beiber", + "accessor" + ], + "author": "@monasticpanic Jason Quense", + "license": "MIT", + "prettier": { + "singleQuote": true, + "semi": false + } +} diff --git a/node_modules/property-expr/test.js b/node_modules/property-expr/test.js new file mode 100644 index 00000000..899b2e7a --- /dev/null +++ b/node_modules/property-expr/test.js @@ -0,0 +1,131 @@ +var a = require('assert'), + expression = require('./index.js'), + getter = expression.getter, + setter = expression.setter, + obj = {}; + +obj = { + foo: { + bar: ['baz', 'bux'], + fux: 5, + '00N40000002S5U0': 1, + N40000002S5U0: 2, + 'FE43-D880-21AE': 3 + } +}; + +// -- Getters -- +a.strictEqual(getter('foo.fux')(obj), 5); +a.deepEqual(getter('foo.bar')(obj), ['baz', 'bux']); + +a.strictEqual(getter('foo.bar[1]')(obj), 'bux'); +a.strictEqual(getter('["foo"]["bar"][1]')(obj), 'bux'); +a.strictEqual(getter('[1]')([1, 'bux']), 'bux'); + +// safe access +a.strictEqual(getter('foo.fux', true)(obj), 5); +a.deepEqual(getter('foo.bar', true)(obj), ['baz', 'bux']); + +a.strictEqual(getter('foo.bar[1]', true)(obj), 'bux'); +a.strictEqual(getter('["foo"]["bar"][1]', true)(obj), 'bux'); +a.strictEqual(getter('[1]', true)([1, 'bux']), 'bux'); + +a.strictEqual(getter('foo.gih.df[0]', true)(obj), undefined); +a.strictEqual(getter('["fr"]["bzr"][1]', true)(obj), undefined); + +a.strictEqual(getter('foo["00N40000002S5U0"]', true)(obj), 1); +a.strictEqual(getter('foo.00N40000002S5U0', true)(obj), 1); +a.strictEqual(getter('foo["N40000002S5U0"]', true)(obj), 2); +a.strictEqual(getter('foo.N40000002S5U0', true)(obj), 2); +a.strictEqual(getter('foo["FE43-D880-21AE"]', true)(obj), 3); +a.strictEqual(getter('foo.FE43-D880-21AE', true)(obj), 3); + +// -- Setters -- +setter('foo.fux')(obj, 10); +a.strictEqual(obj.foo.fux, 10); + +setter('foo.bar[1]')(obj, 'bot'); +a.strictEqual(obj.foo.bar[1], 'bot'); + +setter('[\'foo\']["bar"][1]')(obj, 'baz'); +a.strictEqual(obj.foo.bar[1], 'baz'); + +// -- Cache -- +var cache = new expression.Cache(3) +a.strictEqual(cache._size, 0) +a.strictEqual(cache.set('a', a), a) +a.strictEqual(cache.get('a'), a) +a.strictEqual(cache._size, 1) +a.strictEqual(cache.set('b', 123), 123) +a.strictEqual(cache.get('b'), 123) +a.strictEqual(cache.set('b', 321), 321) +a.strictEqual(cache.get('b'), 321) +a.strictEqual(cache.set('c', null), null) +a.strictEqual(cache.get('c'), null) +a.strictEqual(cache._size, 3) +a.strictEqual(cache.set('d', 444), 444) +a.strictEqual(cache._size, 1) +cache.clear() +a.strictEqual(cache._size, 0) +a.strictEqual(cache.get('a'), undefined) + +// -- split -- + +var parts = expression.split('foo.baz["bar"][1]'); + +a.strictEqual(parts.length, 4); + +// -- join -- + +var parts = expression.split('foo.baz["bar"][1]'); + +a.strictEqual(expression.join(['0', 'baz', '"bar"', 1]), '[0].baz["bar"][1]'); + +a.strictEqual(expression.join(parts), 'foo.baz["bar"][1]'); + +// -- forEach -- + +var count = 0; + +expression.forEach('foo.baz["bar"][1]', function( + part, + isBracket, + isArray, + idx +) { + count = idx; + + switch (idx) { + case 0: + a.strictEqual(part, 'foo'); + a.strictEqual(isBracket, false); + a.strictEqual(isArray, false); + break; + case 1: + a.strictEqual(part, 'baz'); + a.strictEqual(isBracket, false); + a.strictEqual(isArray, false); + break; + case 2: + a.strictEqual(part, '"bar"'); + a.strictEqual(isBracket, true); + a.strictEqual(isArray, false); + break; + case 3: + a.strictEqual(part, '1'); + a.strictEqual(isBracket, false); + a.strictEqual(isArray, true); + break; + } +}); + +a.strictEqual(count, 3); + +// -- normalizePath -- + +a.deepEqual( + expression.normalizePath('foo[ " bux\'s " ].bar["baz"][ 9 ][ \' s \' ]'), + ['foo', ' bux\'s ', 'bar', 'baz', '9', ' s '] +) + +console.log('--- Tests Passed ---'); diff --git a/node_modules/regenerator-runtime/LICENSE b/node_modules/regenerator-runtime/LICENSE new file mode 100644 index 00000000..cde61b6c --- /dev/null +++ b/node_modules/regenerator-runtime/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2014-present, Facebook, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/regenerator-runtime/package.json b/node_modules/regenerator-runtime/package.json index db053987..f6d369d5 100644 --- a/node_modules/regenerator-runtime/package.json +++ b/node_modules/regenerator-runtime/package.json @@ -2,14 +2,15 @@ "name": "regenerator-runtime", "author": "Ben Newman ", "description": "Runtime for Regenerator-compiled generator and async functions.", - "version": "0.11.1", - "main": "runtime-module.js", + "version": "0.13.3", + "main": "runtime.js", "keywords": [ "regenerator", "runtime", "generator", "async" ], + "sideEffects": true, "repository": { "type": "git", "url": "https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime" diff --git a/node_modules/regenerator-runtime/runtime.js b/node_modules/regenerator-runtime/runtime.js index 22e7b005..92d18150 100644 --- a/node_modules/regenerator-runtime/runtime.js +++ b/node_modules/regenerator-runtime/runtime.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -!(function(global) { +var runtime = (function (exports) { "use strict"; var Op = Object.prototype; @@ -16,23 +16,6 @@ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - var inModule = typeof module === "object"; - var runtime = global.regeneratorRuntime; - if (runtime) { - if (inModule) { - // If regeneratorRuntime is defined globally and we're in a module, - // make the exports object identical to regeneratorRuntime. - module.exports = runtime; - } - // Don't bother evaluating the rest of this file if the runtime was - // already defined globally. - return; - } - - // Define the runtime globally (as expected by generated code) as either - // module.exports (if we're in a module) or a new, empty object. - runtime = global.regeneratorRuntime = inModule ? module.exports : {}; - function wrap(innerFn, outerFn, self, tryLocsList) { // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; @@ -45,7 +28,7 @@ return generator; } - runtime.wrap = wrap; + exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion // record like context.tryEntries[i].completion. This interface could @@ -116,7 +99,7 @@ }); } - runtime.isGeneratorFunction = function(genFun) { + exports.isGeneratorFunction = function(genFun) { var ctor = typeof genFun === "function" && genFun.constructor; return ctor ? ctor === GeneratorFunction || @@ -126,7 +109,7 @@ : false; }; - runtime.mark = function(genFun) { + exports.mark = function(genFun) { if (Object.setPrototypeOf) { Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); } else { @@ -143,7 +126,7 @@ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test // `hasOwn.call(value, "__await")` to determine if the yielded value is // meant to be awaited. - runtime.awrap = function(arg) { + exports.awrap = function(arg) { return { __await: arg }; }; @@ -168,22 +151,14 @@ return Promise.resolve(value).then(function(unwrapped) { // When a yielded Promise is resolved, its final value becomes // the .value of the Promise<{value,done}> result for the - // current iteration. If the Promise is rejected, however, the - // result for this iteration will be rejected with the same - // reason. Note that rejections of yielded Promises are not - // thrown back into the generator function, as is the case - // when an awaited Promise is rejected. This difference in - // behavior between yield and await is important, because it - // allows the consumer to decide what to do with the yielded - // rejection (swallow it and continue, manually .throw it back - // into the generator, abandon iteration, whatever). With - // await, by contrast, there is no opportunity to examine the - // rejection reason outside the generator function, so the - // only option is to throw it from the await expression, and - // let the generator function handle the exception. + // current iteration. result.value = unwrapped; resolve(result); - }, reject); + }, function(error) { + // If a rejected Promise was yielded, throw the rejection back + // into the async generator function so it can be handled there. + return invoke("throw", error, resolve, reject); + }); } } @@ -226,17 +201,17 @@ AsyncIterator.prototype[asyncIteratorSymbol] = function () { return this; }; - runtime.AsyncIterator = AsyncIterator; + exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of // AsyncIterator objects; they just return a Promise for the value of // the final result produced by the iterator. - runtime.async = function(innerFn, outerFn, self, tryLocsList) { + exports.async = function(innerFn, outerFn, self, tryLocsList) { var iter = new AsyncIterator( wrap(innerFn, outerFn, self, tryLocsList) ); - return runtime.isGeneratorFunction(outerFn) + return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. : iter.next().then(function(result) { return result.done ? result.value : iter.next(); @@ -333,7 +308,8 @@ context.delegate = null; if (context.method === "throw") { - if (delegate.iterator.return) { + // Note: ["return"] must be used for ES3 parsing compatibility. + if (delegate.iterator["return"]) { // If the delegate iterator has a return method, give it a // chance to clean up. context.method = "return"; @@ -453,7 +429,7 @@ this.reset(true); } - runtime.keys = function(object) { + exports.keys = function(object) { var keys = []; for (var key in object) { keys.push(key); @@ -514,7 +490,7 @@ // Return an iterator with no values. return { next: doneResult }; } - runtime.values = values; + exports.values = values; function doneResult() { return { value: undefined, done: true }; @@ -719,9 +695,32 @@ return ContinueSentinel; } }; -})( - // In sloppy mode, unbound `this` refers to the global object, fallback to - // Function constructor if we're in global strict mode. That is sadly a form - // of indirect eval which violates Content Security Policy. - (function() { return this })() || Function("return this")() -); + + // Regardless of whether this script is executing as a CommonJS module + // or not, return the runtime object so that we can declare the variable + // regeneratorRuntime in the outer scope, which allows this module to be + // injected easily by `bin/regenerator --include-runtime script.js`. + return exports; + +}( + // If this script is executing as a CommonJS module, use module.exports + // as the regeneratorRuntime namespace. Otherwise create a new empty + // object. Either way, the resulting object will be used to initialize + // the regeneratorRuntime variable at the top of this file. + typeof module === "object" ? module.exports : {} +)); + +try { + regeneratorRuntime = runtime; +} catch (accidentalStrictMode) { + // This module should not be running in strict mode, so the above + // assignment should always work unless something is misconfigured. Just + // in case runtime.js accidentally runs in strict mode, we can escape + // strict mode using a global Function call. This could conceivably fail + // if a Content Security Policy forbids using Function, but in that case + // the proper solution is to fix the accidental strict mode problem. If + // you've misconfigured your bundler to force strict mode and applied a + // CSP to forbid Function, and you're not willing to fix either of those + // problems, please detail your unique predicament in a GitHub issue. + Function("r", "regeneratorRuntime = r")(runtime); +} diff --git a/node_modules/synchronous-promise/LICENSE b/node_modules/synchronous-promise/LICENSE new file mode 100644 index 00000000..fc08f059 --- /dev/null +++ b/node_modules/synchronous-promise/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2016, Davyd McColl +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of synchronous-promise nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/synchronous-promise/README.md b/node_modules/synchronous-promise/README.md new file mode 100644 index 00000000..106ff51a --- /dev/null +++ b/node_modules/synchronous-promise/README.md @@ -0,0 +1,293 @@ +# synchronous-promise +TL;DR: A prototypical animal which looks like an A+ Promise but doesn't defer +immediately, so can run synchronously, for testing. Technically, this makes it +*not* A+ compliant, since part of the A+ spec is that resolution be asynchronous. + +This means that I unfortunately can't run the official tests at [https://github.com/promises-aplus/promises-tests](https://github.com/promises-aplus/promises-tests). As such, I rely on issue reports from users and welcome contributions. + +### Why? +The standard ES6 Promise (and any others which *are* A+ compliant) push the promise logic to the background +immediately, departing from the mechanisms employed in years past by promise +implementations in libraries such as jQuery and Q. + +This is a good thing -- for production code. But it can make testing more +convoluted than it really needs to be. + +Often, in a test, we're stubbing out a function which would return a promise +(eg http call, show a modal dialog requiring user interaction) with a promise +that resolves immediately, eg (using, mocha/sinon/chai): + +```javascript +describe('the thing', () => { + it('will do some stuff', () => { + // Arrange + const asyncLibraryFake = { + someMethod: sinon.stub().returns(Promise.resolve('happy value!')) + }, + sut = createSystemUnderTestWith(asyncLibraryFake); + // Act + sut.doSomethingInteresting(); + // Assert + // [*] + }) +}); +``` + +[*] Ideally, we'd just have assertions here, but the code above has backgrounded, +so we're not going to get our expected results unless we employ async testing +strategies ourselves. + +One strategy would be to return the promise from + asyncLibraryFake.someMethod +from the + doSomethingInteresting +function and perform our asserts in there: + +```javascript +describe('the thing', () => { + it('will do some stuff', done => { + // Arrange + const asyncLibraryFake = { + someMethod: sinon.stub().returns(Promise.resolve('happy value!')) + }, + sut = createSystemUnderTestWith(asyncLibraryFake); + // Act + sut.doSomethingInteresting().then(() => { + // Assert + done() + }); + }) +}); +``` +***And there's nothing wrong with this strategy.*** + +I need to put that out there before anyone takes offense or thinks that I'm suggesting +that they're "doing it wrong". +If you're doing this (or something very similar), great; `async/await`, if available, +can make this code quite clean and linear too. + +However, when we're working on more complex interactions, eg when we're not +testing the final result of a promise chain, but rather testing a side-effect +at some step during that promise chain, this can become more effort to test +(and, imo, make your testing more unclear). + +Many moons ago, using, for example, Q, we could create a deferred object with +`Q.defer()` and then resolve or reject ith with `deferred.resolve()` and +`deferred.reject()`. Since there was no initial backgrounding, we could set +up a test with an unresolved promise, make some pre-assertions, then resolve +and make assertions about "after resolution" state, without making our tests +async at all. It made testing a little easier (imo) and the idea has been +propagated into frameworks like `angular-mocks` + +### Usage + +SynchronousPromise looks (from the outside) a lot like an ES6 promise. We construct +the same: + +```javascript +var promise = new SynchronousPromise((resolve, reject) => { + if (Math.random() < 0.1) { + reject('unlucky!'); + } else { + resolve('lucky!'); + } +}); +``` + +They can, of course, be chained: + +```javascript +var initial = new SynchronousPromise((resolve, reject) => { + resolve('happy!'); +}); +initial.then(message => { + console.log(message); +}) +``` + +And have error handling, either from the basic A+ spec: + +```javascript +initial.then(message => { + console.log(message); +}, error => { + console.error(error); +}); +``` + +Or using the more familiar `catch()`: + +```javascript +initial.then(message => { + console.log(message); +}).catch(error => { + console.error(error); +}) +``` + +`.catch()` starts a new promise chain, so you can pick up with new logic +if you want to. `.then()` can deal with returning raw values or promises +(as per A+) + +`SynchronousPromise` also supports `.finally()` as of version 2.0.8. + +### Statics +`.all()`, `.resolve()` and `.reject()` are available on the `SynchronousPromise` +object itself: + +```javascript +SynchronousPromise.all([p1, p2]).then(results => { + // results is an array of results from all promises +}).catch(err => { + // err is any single error thrown by a promise in the array +}); + +SynchronousPromise.resolve('foo'); // creates an already-resolved promise + +SynchronousPromise.reject('bar'); // creats an already-rejected promise +``` + +(`race()` isn't because I haven't determined a good strategy for that yet, +considering the synchronous design goal -- but it's +unlikely you'll need `race()` from a test). + +### Extras +`SynchronousPromise` also provides two extra functions to make testing a little +easier: + +#### Static methods +The `unresolved()` method returns a new, unresolved `SynchronousPromise` with +the constructor-function-provided `resolve` and `reject` functions attached as properties. +Use this when you have no intention of resolving or rejecting the promise or when you +want to resolve or reject at some later date. + +```javascript +var + resolvedValue, + rejectedValue, + promise = SynchronousPromise.unresolved().then(function(data) { + resolved = data; + }).catch(function(data) { + rejected = data; + }); + // at this point, resolved and rejected are both undefined + + // ... some time later ... + if (Math.random() > 0.5) { + promise.resolve("yay"); + // now resolvedValue is "yay" and rejectedValue is still undefined + } else { + promise.reject("boo"); + // now rejectedValue is "boo" and resolvedValue is still undefined + } +``` + +#### Instance methods + +`pause()` pauses the promise chain at the point at which it is called: + +```javascript +SynchronousPromise.resolve('abc').then(data => { + // this will be run + return '123'; +}).pause().then(data2 => { + // we don't get here without resuming +}); +``` + +and `resume()` resumes operations: + +```javascript +var + promise = SynchronousPromise.resolve('123').pause(), + captured = null; +promise.then(data => { + captured = data; +}); + +expect(captured).to.be.null; // because we paused... +promise.resume(); +expect(captured).to.equal('123'); // because we resumed... +``` + +You can use `pause()` and `resume()` to test the state of your system under +test at defined points in a series of promise chains + +### ES5 +SynchronousPromise is purposefully written with prototypical, ES5 syntax so you +can use it from ES5 if you like. Use the `synchronous-promise.js` file from the +`dist` folder if you'd like to include it in a browser environment (eg karma). + +## Typescript +The `synchronous-promise` package includes an `index.d.ts`. To install, run: +``` +typings install npm:synchronous-promise --save +``` +*On any modern TypeScript (v2+), you shouldn't need to do this.* + +Also note that TypeScript does async/await cleverly, treating all promises +equally, such that `await` will work just fine against a SynchronousPromise -- it just won't be backgrounded. + +**HOWEVER:** there is a _very specific_ way that SynchronousPromise +can interfere with TypeScript: if +- SynchronousPromise is installed globally (ie, overriding the + native `Promise` implementation) and +- You create a SynchronousPromise which is resolved asynchronously, + eg: + +```js +global.Promise = SynchronousPromise; +await new SynchronousPromise((resolve, reject) => { + setTimeout(() => resolve(), 0); +}); // this will hang +``` + +This is due to how TypeScript generates the `__awaiter` function +which is `yielded` to provide `async`/`await` functionality, in +particular that the emitted code assumes that the global `Promise` +will _always be asynchronous_, which is normally a reasonable assumption. + +Installing SynchronousPromise globally may be a useful testing tactic, +which I've used in the past, but I've seen this exact issue crop up +in production code. `SynchronousPromise` therefor also provides two methods: + +- `installGlobally` +- `uninstallGlobally` + +which can be used if your testing would be suited to having `Promise` globally +overridden by `SynchronousPromise`. This needs to get the locally-available `__awaiter` and the result (enclosed with a reference to the real `Promise`) +must override that `__awaiter`, eg: + +```ts +declare var __awaiter: Function; +beforeEach(() => { + __awaiter = SynchronousPromise.installGlobally(__awaiter); +}); +afterEach(() => { + SynchronousPromise.uninstallGlobally(); +}); +``` + +It's not elegant that client code needs to know about the transpiled +code, but this works. + +I have an issue open on GitHub +[https://github.com/Microsoft/TypeScript/issues/19909](https://github.com/Microsoft/TypeScript/issues/19909) +but discussion so far has not beein particularly convincing that +TypeScript emission will be altered to (imo) a more robust +implementation which wraps the emitted `__awaiter` in a closure. + + +### Production code +The main aim of SynchronousPromise is to facilitate easier testing. That being +said, it appears to conform to expected `Promise` behaviour, barring the +always-backgrounded behaviour. One might be tempted to just use it everywhere. + +**However**: I'd highly recommend using *any* of the more venerable promise implementations +instead of SynchronousPromise in your production code -- preferably the vanilla +ES6 Promise, where possible (or the shim, where you're in ES5). Or Q. +Or jQUery.Deferred(), Bluebird or any of the implementations at [https://promisesaplus.com/implementations](https://promisesaplus.com/implementations). + +Basically, this seems to work quite well for testing and +I've tried to implement every behaviour I'd expect from a promise -- but I'm +pretty sure that a native `Promise` will be better for production code any day. diff --git a/node_modules/synchronous-promise/browser.js b/node_modules/synchronous-promise/browser.js new file mode 100644 index 00000000..17983be6 --- /dev/null +++ b/node_modules/synchronous-promise/browser.js @@ -0,0 +1 @@ +window.SynchronousPromise = require('./index').SynchronousPromise; \ No newline at end of file diff --git a/node_modules/synchronous-promise/dist/synchronous-promise.js b/node_modules/synchronous-promise/dist/synchronous-promise.js new file mode 100644 index 00000000..c5849a58 --- /dev/null +++ b/node_modules/synchronous-promise/dist/synchronous-promise.js @@ -0,0 +1,364 @@ +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i +import { SynchronousPromise } from "./index"; +import { expect } from 'chai'; + +declare var __awaiter: Function; +beforeEach(() => { + __awaiter = SynchronousPromise.installGlobally(__awaiter); +}); +afterEach(() => { + SynchronousPromise.uninstallGlobally(); +}); + +describe("typescript async/await", () => { + it("should not hang", async function() { + // Arrange + // Act + await new SynchronousPromise(function(resolve, reject) { + setTimeout(() => { + resolve("whee!"); + }, 0); + }); + }) +}); \ No newline at end of file diff --git a/node_modules/synchronous-promise/index.d.ts b/node_modules/synchronous-promise/index.d.ts new file mode 100644 index 00000000..c8e05d00 --- /dev/null +++ b/node_modules/synchronous-promise/index.d.ts @@ -0,0 +1,103 @@ +export interface SynchronousPromise extends Promise { + pause: () => SynchronousPromise + resume: () => SynchronousPromise +} + +export type ValueOrPromiseOfValue = T | PromiseLike +export interface SynchronousPromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: SynchronousPromise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): SynchronousPromise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(v1: ValueOrPromiseOfValue[]): SynchronousPromise; + all(...values: ValueOrPromiseOfValue[]): SynchronousPromise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + // race(values: IterableShim>): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): SynchronousPromise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): SynchronousPromise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): SynchronousPromise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): SynchronousPromise; + + /** + * Creates a new unresolved promise with the `resolve` and `reject` methods exposed + * @returns An unresolved promise with the `resolve` and `reject` methods exposed + */ + unresolved(): UnresolvedSynchronousPromise; + + + /** + * Installs SynchronousPromise as the global Promise implementation. + * When running from within typescript, you will need to use this to + * patch the generated __awaiter to ensure it gets a _real_ Promise implementation + * (see https://github.com/Microsoft/TypeScript/issues/19909). + * + * Use the following code: + * declare var __awaiter: Function; + * __awaiter = SynchronousPromise.installGlobally(); + * + * This is non-destructive to the __awaiter: it simply wraps it in a closure + * where the real implementation of Promise has already been captured. + */ + installGlobally(__awaiter: Function): Function; + + /* + * Uninstalls SynchronousPromise as the global Promise implementation, + * if it is already installed. + */ + uninstallGlobally(): void; +} + +/** + * Interface type only exposed when using the static unresolved() convenience method + */ +interface UnresolvedSynchronousPromise extends SynchronousPromise { + resolve(data: T): void; + resolve(): void; + reject(data: T): void; +} + +export var SynchronousPromise: SynchronousPromiseConstructor; diff --git a/node_modules/synchronous-promise/index.js b/node_modules/synchronous-promise/index.js new file mode 100644 index 00000000..bf6c0920 --- /dev/null +++ b/node_modules/synchronous-promise/index.js @@ -0,0 +1,360 @@ +/* jshint node: true */ +"use strict"; +function makeArrayFrom(obj) { + return Array.prototype.slice.apply(obj); +} +var + PENDING = "pending", + RESOLVED = "resolved", + REJECTED = "rejected"; + +function SynchronousPromise(handler) { + this.status = PENDING; + this._continuations = []; + this._parent = null; + this._paused = false; + if (handler) { + handler.call( + this, + this._continueWith.bind(this), + this._failWith.bind(this) + ); + } +} + +function looksLikeAPromise(obj) { + return obj && typeof (obj.then) === "function"; +} + +SynchronousPromise.prototype = { + then: function (nextFn, catchFn) { + var next = SynchronousPromise.unresolved()._setParent(this); + if (this._isRejected()) { + if (this._paused) { + this._continuations.push({ + promise: next, + nextFn: nextFn, + catchFn: catchFn + }); + return next; + } + if (catchFn) { + try { + var catchResult = catchFn(this._error); + if (looksLikeAPromise(catchResult)) { + this._chainPromiseData(catchResult, next); + return next; + } else { + return SynchronousPromise.resolve(catchResult)._setParent(this); + } + } catch (e) { + return SynchronousPromise.reject(e)._setParent(this); + } + } + return SynchronousPromise.reject(this._error)._setParent(this); + } + this._continuations.push({ + promise: next, + nextFn: nextFn, + catchFn: catchFn + }); + this._runResolutions(); + return next; + }, + catch: function (handler) { + if (this._isResolved()) { + return SynchronousPromise.resolve(this._data)._setParent(this); + } + var next = SynchronousPromise.unresolved()._setParent(this); + this._continuations.push({ + promise: next, + catchFn: handler + }); + this._runRejections(); + return next; + }, + finally: function(callback) { + return (this._finally = SynchronousPromise.resolve() + ._setParent(this) + .then(function() { + return callback(); + })); + }, + pause: function () { + this._paused = true; + return this; + }, + resume: function () { + var firstPaused = this._findFirstPaused(); + if (firstPaused) { + firstPaused._paused = false; + firstPaused._runResolutions(); + firstPaused._runRejections(); + } + return this; + }, + _findAncestry: function () { + return this._continuations.reduce(function (acc, cur) { + if (cur.promise) { + var node = { + promise: cur.promise, + children: cur.promise._findAncestry() + }; + acc.push(node); + } + return acc; + }, []); + }, + _setParent: function (parent) { + if (this._parent) { + throw new Error("parent already set"); + } + this._parent = parent; + return this; + }, + _continueWith: function (data) { + var firstPending = this._findFirstPending(); + if (firstPending) { + firstPending._data = data; + firstPending._setResolved(); + } + }, + _findFirstPending: function () { + return this._findFirstAncestor(function (test) { + return test._isPending && test._isPending(); + }); + }, + _findFirstPaused: function () { + return this._findFirstAncestor(function (test) { + return test._paused; + }); + }, + _findFirstAncestor: function (matching) { + var test = this; + var result; + while (test) { + if (matching(test)) { + result = test; + } + test = test._parent; + } + return result; + }, + _failWith: function (error) { + var firstRejected = this._findFirstPending(); + if (firstRejected) { + firstRejected._error = error; + firstRejected._setRejected(); + } + }, + _takeContinuations: function () { + return this._continuations.splice(0, this._continuations.length); + }, + _runRejections: function () { + if (this._paused || !this._isRejected()) { + return; + } + var + error = this._error, + continuations = this._takeContinuations(), + self = this; + continuations.forEach(function (cont) { + if (cont.catchFn) { + try { + var catchResult = cont.catchFn(error); + self._handleUserFunctionResult(catchResult, cont.promise); + } catch (e) { + var message = e.message; + cont.promise.reject(e); + } + } else { + cont.promise.reject(error); + } + }); + }, + _runResolutions: function () { + if (this._paused || !this._isResolved()) { + return; + } + var continuations = this._takeContinuations(); + if (looksLikeAPromise(this._data)) { + return this._handleWhenResolvedDataIsPromise(this._data); + } + var data = this._data; + var self = this; + continuations.forEach(function (cont) { + if (cont.nextFn) { + try { + var result = cont.nextFn(data); + self._handleUserFunctionResult(result, cont.promise); + } catch (e) { + self._handleResolutionError(e, cont); + } + } else if (cont.promise) { + cont.promise.resolve(data); + } + }); + }, + _handleResolutionError: function (e, continuation) { + this._setRejected(); + if (continuation.catchFn) { + try { + continuation.catchFn(e); + return; + } catch (e2) { + e = e2; + } + } + if (continuation.promise) { + continuation.promise.reject(e); + } + }, + _handleWhenResolvedDataIsPromise: function (data) { + var self = this; + return data.then(function (result) { + self._data = result; + self._runResolutions(); + }).catch(function (error) { + self._error = error; + self._setRejected(); + self._runRejections(); + }); + }, + _handleUserFunctionResult: function (data, nextSynchronousPromise) { + if (looksLikeAPromise(data)) { + this._chainPromiseData(data, nextSynchronousPromise); + } else { + nextSynchronousPromise.resolve(data); + } + }, + _chainPromiseData: function (promiseData, nextSynchronousPromise) { + promiseData.then(function (newData) { + nextSynchronousPromise.resolve(newData); + }).catch(function (newError) { + nextSynchronousPromise.reject(newError); + }); + }, + _setResolved: function () { + this.status = RESOLVED; + if (!this._paused) { + this._runResolutions(); + } + }, + _setRejected: function () { + this.status = REJECTED; + if (!this._paused) { + this._runRejections(); + } + }, + _isPending: function () { + return this.status === PENDING; + }, + _isResolved: function () { + return this.status === RESOLVED; + }, + _isRejected: function () { + return this.status === REJECTED; + } +}; + +SynchronousPromise.resolve = function (result) { + return new SynchronousPromise(function (resolve, reject) { + if (looksLikeAPromise(result)) { + result.then(function (newResult) { + resolve(newResult); + }).catch(function (error) { + reject(error); + }); + } else { + resolve(result); + } + }); +}; + +SynchronousPromise.reject = function (result) { + return new SynchronousPromise(function (resolve, reject) { + reject(result); + }); +}; + +SynchronousPromise.unresolved = function () { + return new SynchronousPromise(function (resolve, reject) { + this.resolve = resolve; + this.reject = reject; + }); +}; + +SynchronousPromise.all = function () { + var args = makeArrayFrom(arguments); + if (Array.isArray(args[0])) { + args = args[0]; + } + if (!args.length) { + return SynchronousPromise.resolve([]); + } + return new SynchronousPromise(function (resolve, reject) { + var + allData = [], + numResolved = 0, + doResolve = function () { + if (numResolved === args.length) { + resolve(allData); + } + }, + rejected = false, + doReject = function (err) { + if (rejected) { + return; + } + rejected = true; + reject(err); + }; + args.forEach(function (arg, idx) { + SynchronousPromise.resolve(arg).then(function (thisResult) { + allData[idx] = thisResult; + numResolved += 1; + doResolve(); + }).catch(function (err) { + doReject(err); + }); + }); + }); +}; + +/* jshint ignore:start */ +if (Promise === SynchronousPromise) { + throw new Error("Please use SynchronousPromise.installGlobally() to install globally"); +} +var RealPromise = Promise; +SynchronousPromise.installGlobally = function(__awaiter) { + if (Promise === SynchronousPromise) { + return __awaiter; + } + var result = patchAwaiterIfRequired(__awaiter); + Promise = SynchronousPromise; + return result; +}; + +SynchronousPromise.uninstallGlobally = function() { + if (Promise === SynchronousPromise) { + Promise = RealPromise; + } +}; + +function patchAwaiterIfRequired(__awaiter) { + if (typeof(__awaiter) === "undefined" || __awaiter.__patched) { + return __awaiter; + } + var originalAwaiter = __awaiter; + __awaiter = function() { + var Promise = RealPromise; + originalAwaiter.apply(this, makeArrayFrom(arguments)); + }; + __awaiter.__patched = true; + return __awaiter; +} +/* jshint ignore:end */ + +module.exports = { + SynchronousPromise: SynchronousPromise +}; \ No newline at end of file diff --git a/node_modules/synchronous-promise/index.spec.js b/node_modules/synchronous-promise/index.spec.js new file mode 100644 index 00000000..077d549a --- /dev/null +++ b/node_modules/synchronous-promise/index.spec.js @@ -0,0 +1,1016 @@ +/* +* linting omitted on spec mainly because jslint doesn"t seem to allow the +* mocha expression-like syntax +*/ +"use strict"; +var + expect = require("chai").expect, + sut = require("./index"), + SynchronousPromise = sut.SynchronousPromise, + _argumentsToArray = sut._argumentsToArray; +describe("synchronous-promise", function () { + it("should be constructable", function () { + expect(SynchronousPromise).to.exist; + expect(new SynchronousPromise(function () { })).to.exist; + }); + it("should have a then function", function () { + expect(SynchronousPromise.prototype.then).to.be.a("function"); + }); + it("should have a catch function", function () { + expect(SynchronousPromise.prototype.catch).to.be.a("function"); + }); + function create(ctor) { + return new SynchronousPromise(ctor); + } + function createResolved(data) { + return SynchronousPromise.resolve(data); + } + function createRejected(data) { + return SynchronousPromise.reject(data); + } + describe("then", function () { + it("when resolved, should return a new resolved promise", function () { + var sut = createResolved(); + expect(sut.then(null, function () { })).to.be.instanceOf(SynchronousPromise); + }); + it("should return the new resolved promise v2", function () { + var + result = createResolved().then(function () { + /* purposely don't return anything */ + }); + expect(result).to.be.instanceOf(SynchronousPromise); + }); + it("should return a new rejected promise", function () { + var sut = createRejected(); + expect(sut.then(function () { })).to.be.instanceOf(SynchronousPromise); + }); + it("should return a new rejected promise v2", function () { + var result = createRejected().then(function () { + /* purposely don't return anything */ + }); + expect(result).to.be.instanceOf(SynchronousPromise) + }); + it("should bring the first resolve value into the first then", function () { + var + initial = "123", + captured = null; + createResolved(initial).then(function (data) { + captured = data; + }); + expect(captured).to.equal(initial); + }); + + it("should call into the immediate catch function when the function given to then throws", function () { + var + sut = createResolved(), + expected = "the error", + received = null; + sut.then(function () { + throw new Error(expected); + }).catch(function (err) { + received = err; + }); + expect(received.message).to.equal(expected); + }); + + it(`should allow re-throwing in a .catch and re-catching later`, () => { + // Arrange + var + sut = createResolved(), + error1 = "moo", + received = null, + expected = "moo-cow"; + // Act + sut.then(function () { + throw new Error(error1); + }).catch(function (err) { + debugger; + throw new Error(err.message + "-cow"); + }).catch(function (err) { + received = err.message; + }); + // Assert + expect(received).to.equal(expected); + }); + + it("should call the catch from a rejection invoke", () => { + // Arrange + var + expected = "moo", + sut = new SynchronousPromise(function (resolve, reject) { + reject(expected); + }), + captured; + // Act + sut.catch(function (e) { captured = e; }); + // Assert + expect(captured).to.equal(expected); + }); + + it("should call into the later catch function when the function given to then throws", function () { + var + sut = createResolved(), + expected = "the error", + received = null; + sut.then(function () { + throw new Error(expected); + }).then(function () { + return 42; // not a thrower + }).catch(function (err) { + received = err; + }); + + expect(received.message).to.equal(expected); + }); + + it("should prefer to call into onRejected over the .catch handler on failure", function () { + var + sut = createResolved(), + expected = "the error", + captured = null, + catchCaptured = null; + sut.then(function () { + throw expected; + }, function (e) { + captured = e; + }).catch(function (e) { + console.log(".catch handler"); + catchCaptured = e; + }); + + expect(captured).to.equal(expected); + expect(catchCaptured).to.be.null; + }); + + it("should bring the first rejected value into the first onRejected then handler", function () { + var + initial = new Error("123"), + captured = null; + createRejected(initial).then(function () { + }, function (e) { + captured = e + }); + expect(captured).to.equal(initial); + }); + + it("should resolve when the first resolution is a resolved promise", function () { + var + initial = createResolved("123"), + captured = null; + createResolved(initial).then(function (data) { + captured = data; + }); + expect(captured).to.equal("123"); + }); + it("should catch when the first resolution is a rejected promise", function () { + var + initial = createRejected("123"), + captured = null; + createResolved(initial).catch(function (data) { + captured = data; + }); + expect(captured).to.equal("123"); + }) + it("should catch when a subsequent resolution returns a rejected promise", function () { + var + initial = createResolved("123"), + captured = null, + expected = "le error"; + initial.then(function () { + return createRejected(expected); + }).catch(function (e) { + captured = e; + }) + + expect(captured).to.equal(expected); + }); + it("should run a simple chain", function () { + var + initial = "123", + second = "abc", + captured = null; + createResolved(initial).then(function (data) { + return createResolved(second); + }).then(function (data) { + captured = data; + }); + expect(captured).to.equal(second); + }); + it("should run a longer chain", function () { + var + initial = "123", + second = "abc", + third = "---", + expected = second + third, + captured = null; + createResolved(initial).then(function (data) { + return createResolved(second); + }).then(function (data) { + return second; + }).then(function (data) { + captured = data + third; + }); + expect(captured).to.equal(expected); + }); + it("should run a longer chain v2", function () { + var + initial = "123", + second = "abc", + third = "---", + expected = second + third, + captured = null; + createResolved(initial).then(function (data) { + return createResolved(second); + }).then(function (data) { + return createResolved(second); + }).then(function (data) { + captured = data + third; + }); + expect(captured).to.equal(expected); + }); + it("should run a longer chain v3", function () { + var + initial = "123", + second = "abc", + third = "---", + expected = second + third, + captured = null; + createResolved(initial).then(function (data) { + return second; + }).then(function (data) { + return createResolved(second); + }).then(function (data) { + captured = data + third; + }); + expect(captured).to.equal(expected); + }); + it("should resolve when the ctor function resolves", function () { + var + providedResolve = null, + captured = null, + expected = "xyz", + promise = create(function (resolve, reject) { + providedResolve = resolve; + }).then(function (data) { + captured = data; + }); + + expect(captured).to.be.null; + expect(providedResolve).to.be.a("function"); + providedResolve(expected) + expect(captured).to.equal(expected); + }); + + it("should resolve the same value from the same promise multiple times", () => { + // Arrange + var + expected = "multi-pass", + sut = SynchronousPromise.resolve(expected), + captured1, + captured2; + // Act + sut.then(result => captured1 = result); + sut.then(result => captured2 = result); + // Assert + expect(captured1).to.equal(expected); + expect(captured2).to.equal(expected); + }); + }); + describe("catch", function () { + it("should be called if the initial reject is called", function () { + var + expected = "123", + captured = null; + createRejected(expected).catch(function (e) { + captured = e; + }) + expect(captured).to.equal(expected); + }); + it("should call handler if the promise resolves", function () { + // Arrange + var + sut = SynchronousPromise.unresolved(), + resolved = false, + caught = false; + // Act + sut.then(() => resolved = true).catch(() => caught = true); + sut.resolve(); + // Assert + expect(resolved).to.be.true; + expect(caught).to.be.false; + }); + it("should be called on a delayed rejection", function () { + var + providedReject = null, + captured = null, + expected = "123", + promise = create(function (resolve, reject) { + providedReject = reject; + }).catch(function (e) { + captured = e; + }); + + expect(captured).to.be.null; + expect(providedReject).to.be.a("function"); + providedReject(expected); + expect(captured).to.equal(expected); + }); + it("should return a resolved promise if doesn't throw an error", function () { + var + promise = createRejected("123"), + result = promise.catch(function (data) { + expect(data).to.equal("123"); + }); + + expect(result).to.exist; + expect(result).to.be.instanceOf(SynchronousPromise); + expect(result.status).to.be.equal("resolved"); + }); + it("should not interfere with a later then if there is no error", function () { + var + captured = null, + expected = "123", + capturedError = null; + createResolved(expected).catch(function (e) { + capturedError = e; + }).then(function (data) { + captured = data; + }) + + expect(capturedError).to.be.null; + expect(captured).to.equal(expected); + }); + it("should not be called if the promise is handled successful by a previous onRejected handler", function () { + var + expected = new Error("123"), + notExpected = new Error("Not expected"), + capturedError = null; + createRejected(expected).then( + function () { }, + function (e) { + capturedError = e + }) + .catch(function () { + /* purposely don't return anything */ + capturedError = notExpected; + }) + + expect(capturedError).to.equal(expected); + }); + it("should prevent the handlers after the error from being called", function () { + var + captured = null; + createResolved("123").catch(function (e) { + }).then(function (data) { + throw "foo"; + }).then(function (data) { + captured = "abc"; + }) + + expect(captured).to.be.null; + }); + + it("should re-catch if a catch handler returns a rejected promise", function (done) { + // Arrange + var + expected = "123", + pausedRejectedPromise = SynchronousPromise.reject(expected).pause(), + capturedA = null, + capturedB = null; + + pausedRejectedPromise.catch(function (e) { + capturedA = e; + // prove that this works even from an async promise + return Promise.reject(e); + }).catch(function (e) { + capturedB = e; + }) + + // Act + pausedRejectedPromise.resume(); + + // Assert + setTimeout(function () { + try { + expect(capturedA).to.equal(expected); + expect(capturedB).to.equal(expected); + done(); + } catch (e) { + done(e); + } + }, 100); + }); + + it("should re-catch if a then onRejected handler returns a rejected promise", function (done) { + // Arrange + var + expected = "123", + pausedRejectedPromise = SynchronousPromise.reject(expected).pause(), + capturedA = null, + capturedB = null; + + pausedRejectedPromise.then(function () { + /* purposely don't return anything */ + }, function (e) { + capturedA = e; + // prove that this works even from an async promise + return Promise.reject(e); + }).catch(function (e) { + capturedB = e; + }) + + // Act + pausedRejectedPromise.resume(); + + // Assert + setTimeout(function () { + expect(capturedA).to.equal(expected); + expect(capturedB).to.equal(expected); + done(); + }, 100); + }); + + it("should continue if a catch handler returns a resolved promise", function (done) { + // Arrange + var + expected = "123", + pausedRejectedPromise = SynchronousPromise.reject(expected).pause(), + capturedA = null, + capturedB = null, + secondResolve; + + pausedRejectedPromise.catch(function (e) { + capturedA = e; + // prove that this works even from an async promise + return Promise.resolve("456"); + }).catch(function (e) { + capturedB = e; + }).then(function (data) { + secondResolve = data; + }); + + // Act + pausedRejectedPromise.resume(); + + // Assert + setTimeout(function () { + try { + expect(capturedA).to.equal(expected); + expect(capturedB).to.be.null; + expect(secondResolve).to.equal("456"); + done(); + } catch (e) { + done(e); + } + }, 100); + }); + }); + describe("prototype pause", function () { + it("should exist as a function on the prototype", function () { + expect(SynchronousPromise.prototype.pause).to.be.a("function"); + }); + it("should return the promise", function () { + const + promise = createResolved("123"), + result = promise.pause(); + expect(result).to.equal(promise); + }); + it("should prevent resolution from continuing at that point", function () { + var calls = 0; + createResolved("123").then(function () { + return calls++; + }).pause().then(function () { + return calls++; + }); + expect(calls).to.equal(1); + }); + it("should prevent rejection from being caught at that point", function () { + var calls = 0; + createRejected("123").pause().catch(function (e) { + calls++; + }) + expect(calls).to.equal(0); + }); + it("should prevent rejection from continuing past at that point", function () { + var + calls = 0, + captured = null; + + createRejected("123").then(function () { + // should not be called + calls++; + }).catch(function (e) { + captured = e; + }).pause().then(function () { + calls++; + }); + + expect(captured).to.equal("123"); + expect(calls).to.equal(0); + }) + describe("starting paused", function () { + it("should return a promise in paused state with no initial data and being resolved on resume", function () { + var + captured, + promise = SynchronousPromise.resolve().pause().then(function () { + return "moo"; + }).then(function (data) { + captured = data; + }); + expect(captured).to.be.undefined; + promise.resume(); + expect(captured).to.equal("moo"); + }); + it("should return a promise in paused state with no initial data and being rejected on resume", function () { + var + captured, + expected = new Error("moon"), + promise = SynchronousPromise.resolve().pause().then(function () { + throw expected + }).catch(function (e) { + captured = e; + }); + expect(captured).to.be.undefined; + promise.resume(); + expect(captured).to.equal(expected); + }); + it("should return a promise in paused state with no initial data and being resolved after a catch on resume", function () { + var + captured, + error = new Error("moon"), + promise = SynchronousPromise.resolve().pause().then(function () { + throw error + }).catch(function (e) { + return e.message; + }).then(function (m) { + captured = m; + }); + expect(captured).to.be.undefined; + promise.resume(); + expect(captured).to.equal("moon"); + }); + }); + }); + describe("resume", function () { + it("should exist as a function on the prototype", function () { + expect(SynchronousPromise.prototype.resume).to.be.a("function"); + }); + it("should return the promise", function () { + var + promise = createResolved("123").pause(), + result = promise.resume(); + expect(result).to.equal(promise); + }); + it("should not barf if the promise is not already paused", function () { + var promise = createResolved("123"); + expect(function () { + promise.resume(); + }).not.to.throw; + }) + it("should resume resolution operations after the last pause", function () { + var + calls = 0, + promise = createResolved("123").then(function () { + return calls++; + }).pause().then(function () { + return calls++; + }); + expect(calls).to.equal(1); + promise.resume(); + expect(calls).to.equal(2); + }); + it("should resume rejection operations after the last pause", function () { + var + calls = 0, + captured = null, + expected = "die, scum!", + promise = createResolved("123").then(function () { + throw expected; + }).pause().then(function () { + return calls++; + }).catch(function (e) { + captured = e; + }); + expect(calls).to.equal(0); + expect(captured).to.be.null; + promise.resume(); + expect(calls).to.equal(0); + expect(captured).to.equal(expected); + }); + it("should resume a promise which was started rejected as rejected", function () { + var + calls = 0, + captured = null, + expected = "it\"s the end of the world!", + promise = SynchronousPromise.reject(expected).pause().then(function () { + calls++; + }).catch(function (e) { + captured = e; + }); + expect(calls).to.equal(0); + expect(captured).to.be.null; + promise.resume(); + expect(calls).to.equal(0); + expect(captured).to.equal(expected); + }) + }) + describe("static resolve", function () { + it("should be a function", function () { + expect(SynchronousPromise.resolve).to.be.a("function"); + }); + it("should return a resolved promise", function () { + var + expected = "foo", + result = SynchronousPromise.resolve(expected); + expect(result.status).to.equal("resolved"); + var captured = null; + result.then(function (data) { + captured = data; + }); + expect(captured).to.equal(expected); + }) + }); + describe("static reject", function () { + it("should be a function", function () { + expect(SynchronousPromise.reject).to.be.a("function"); + }); + it("should return a rejected promise", function () { + var + expected = "moo", + result = SynchronousPromise.reject(expected); + expect(result.status).to.equal("rejected"); + var captured = null; + result.catch(function (err) { + captured = err; + }); + expect(captured).to.equal(expected); + }); + }); + describe("static all", function () { + it("should be a function", function () { + expect(SynchronousPromise.all).to.be.a("function") + }) + it("should resolve with all values from given resolved promises as variable args", function () { + var + p1 = createResolved("abc"), + p2 = createResolved("123"), + all = SynchronousPromise.all(p1, p2), + captured = null; + + all.then(function (data) { + captured = data; + }); + + expect(captured).to.have.length(2); + expect(captured).to.contain("abc"); + expect(captured).to.contain("123"); + }); + + it("should resolve with all values from given promise or none promise variable args", function () { + var + all = SynchronousPromise.all(["123", createResolved("abc")]), + captured = null; + + all.then(function (data) { + captured = data; + }); + + expect(captured).to.have.length(2); + expect(captured).to.contain("abc"); + expect(captured).to.contain("123"); + }); + it("should resolve with all values from given resolved promises as an array", function () { + var + p1 = createResolved("abc"), + p2 = createResolved("123"), + all = SynchronousPromise.all([p1, p2]), + captured = null; + + all.then(function (data) { + captured = data; + }); + + expect(captured).to.have.length(2); + expect(captured).to.contain("abc"); + expect(captured).to.contain("123"); + }); + it("should resolve empty promise array", function () { + var + all = SynchronousPromise.all([]), + captured = null; + + all.then(function (data) { + captured = data; + }); + + expect(captured).to.have.length(0); + }); + it("should resolve with values in the correct order", function () { + var + resolve1, + resolve2, + captured; + + var p1 = create(function (resolve) { + resolve1 = resolve; + }); + + var p2 = create(function (resolve) { + resolve2 = resolve; + }); + + SynchronousPromise.all([p1, p2]).then(function (data) { + captured = data; + }); + + resolve2("a"); + resolve1("b"); + + expect(captured).to.deep.equal(["b", "a"]); + }); + it("should reject if any promise rejects", function () { + var + p1 = createResolved("abc"), + p2 = createRejected("123"), + all = SynchronousPromise.all(p1, p2), + capturedData = null, + capturedError = null; + all.then(function (data) { + capturedData = data; + }).catch(function (err) { + capturedError = err; + }); + expect(capturedData).to.be.null; + expect(capturedError).to.equal("123"); + }); + }); + describe("static unresolved", function () { + it("should exist as a function", function () { + // Arrange + // Act + // Assert + expect(SynchronousPromise.unresolved).to.exist; + expect(SynchronousPromise.unresolved).to.be.a("function"); + }); + it("should return a new SynchronousPromise", function () { + // Arrange + // Act + var result1 = SynchronousPromise.unresolved(), + result2 = SynchronousPromise.unresolved(); + // Assert + expect(result1).to.exist; + expect(result2).to.exist; + expect(Object.getPrototypeOf(result1)).to.equal(SynchronousPromise.prototype); + expect(Object.getPrototypeOf(result2)).to.equal(SynchronousPromise.prototype); + expect(result1).not.to.equal(result2); + }); + describe("result", function () { + it("should not be resolved or rejected", function () { + // Arrange + var resolved = false, + rejected = false; + // Act + SynchronousPromise.unresolved().then(function () { + resolved = true; + }).catch(function () { + rejected = true; + }); + // Assert + expect(resolved).to.be.false; + expect(rejected).to.be.false; + }); + describe("resolve", function () { + it("should be a function", function () { + // Arrange + // Act + var sut = SynchronousPromise.unresolved(); + // Assert + expect(sut.resolve).to.exist; + expect(sut.resolve).to.be.a("function"); + }); + it("should resolve the promise when invoked", function () { + // Arrange + var + resolved = undefined, + error = undefined, + sut = SynchronousPromise.unresolved().then(function (result) { + resolved = result; + }).catch(function (err) { + error = err; + }), + expected = { key: "value" }; + // Act + debugger; + sut.resolve(expected); + // Assert + expect(resolved).to.equal(expected); + expect(error).not.to.exist; + }); + it("should resolve all thens when invoked", () => { + // Arrange + var + sut = SynchronousPromise.unresolved(), + captured1, + captured2, + next1 = sut.then(result => captured1 = result), + next2 = sut.then(result => captured2 = result), + expected = "cake-moo"; + // Act + sut.resolve(expected); + // Assert + expect(captured1).to.equal(expected); + expect(captured2).to.equal(expected); + }); + }); + describe("reject property", function () { + it("should be a function", function () { + // Arrange + // Act + var sut = SynchronousPromise.unresolved(); + // Assert + expect(sut.reject).to.exist; + expect(sut.reject).to.be.a("function"); + }); + it("should reject the promise when invoked", function () { + // Arrange + var + resolved = undefined, + error = undefined, + sut = SynchronousPromise.unresolved().then(function (result) { + resolved = result; + }).catch(function (err) { + error = err; + }), + expected = { key: "value" }; + // Act + sut.reject(expected); + // Assert + expect(error).to.equal(expected); + expect(resolved).not.to.exist; + }); + }); + + describe("with timeout in ctor", () => { + it("should complete when the timeout does", (done) => { + // Arrange + var + captured, + sut = new SynchronousPromise(function(resolve, reject) { + setTimeout(function() { + resolve("moo"); + }, 0); + }).then(function(result) { + captured = result; + }); + // Act + // Assert + setTimeout(function() { + expect(captured).to.equal("moo"); + done(); + }, 500); + }); + }); + }); + }); + describe(`finally`, () => { + it(`should call the provided function when the promise resolves`, async () => { + // Arrange + var called = false; + // Act + SynchronousPromise.resolve("foo").finally(function() { + called = true; + }); + // Assert + expect(called).to.be.true; + }); + it(`should call the provided function when the promise rejects`, async () => { + // Arrange + var called = false; + // Act + SynchronousPromise.reject("foo").finally(function() { + called = true; + }); + // Assert + }); + it(`should call the provided function when the promise is rejected then caught`, async () => { + // Arrange + var + catchCalled = false, + finallyCalled = false; + // Act + SynchronousPromise.reject("error") + .catch(function(e) { + catchCalled = true; + }).finally(function() { + finallyCalled = true; + }); + // Assert + expect(catchCalled).to.be.true; + expect(finallyCalled).to.be.true; + }); + it(`should start a new promise chain after resolution, with non-throwing finally`, async () => { + // Arrange + var captured = null; + // Act + SynchronousPromise.resolve("first value") + .finally(function() { + return "second value"; + }).then(function(data) { + captured = data; + }); + // Assert + expect(captured).to.equal("second value"); + }); + it(`should start a new promise chain after resolution, with resolving finally`, async () => { + // Arrange + var captured = null; + // Act + SynchronousPromise.resolve("first value") + .finally(function() { + return SynchronousPromise.resolve("second value"); + }).then(function(data) { + captured = data; + }); + // Assert + expect(captured).to.equal("second value"); + }); + it(`should start a new promise chain after resolution, with throwing finally`, async () => { + // Arrange + var captured = null; + // Act + SynchronousPromise.reject("first error") + .finally(function() { + throw "finally data"; + }).catch(function(data) { + captured = data; + }); + // Assert + expect(captured).to.equal("finally data"); + }); + it(`should start a new promise chain after resolution, with rejecting finally`, async () => { + // Arrange + var captured = null; + // Act + SynchronousPromise.reject("first error") + .finally(function() { + return SynchronousPromise.reject("finally data"); + }).catch(function(data) { + captured = data; + }); + // Assert + expect(captured).to.equal("finally data"); + }); + it(`should start a new promise chain after rejection, with non-throwing finally`, async () => { + // Arrange + var + called = false; + // Act + SynchronousPromise.reject("le error") + .finally(function() { + }).then(function() { + called = true; + }); + // Assert + expect(called).to.be.true; + }); + it(`should start a new promise chain after rejection, with resolving finally`, async () => { + // Arrange + var captured = null; + // Act + SynchronousPromise.reject("le error") + .finally(function() { + return SynchronousPromise.resolve("le data"); + }).then(function(data) { + captured = data; + }); + // Assert + expect(captured).to.equal("le data"); + }); + it(`should start a new promise chain after rejection, with throwing finally`, async () => { + // Arrange + var finallyError = null; + // Act + SynchronousPromise.reject("another error") + .finally(function() { + throw "moo cakes"; + }).catch(function(err) { + finallyError = err; + }); + // Assert + expect(finallyError).to.equal("moo cakes"); + }); + it(`should start a new promise chain after rejection, with rejecting finally`, async () => { + // Arrange + var finallyError = null; + // Act + SynchronousPromise.reject("another error") + .finally(function() { + return SynchronousPromise.reject("moo cakes"); + }).catch(function(err) { + finallyError = err; + }); + // Assert + expect(finallyError).to.equal("moo cakes"); + }); + }); +}); diff --git a/node_modules/synchronous-promise/jslint.conf b/node_modules/synchronous-promise/jslint.conf new file mode 100644 index 00000000..0ceeca62 --- /dev/null +++ b/node_modules/synchronous-promise/jslint.conf @@ -0,0 +1,11 @@ +{ + "evil":false, + "indent":2, + "vars":true, + "passfail":false, + "plusplus":false, + "predef": "module,require", + "nomen": true, + "unparam": true, + "laxbreak": true +} diff --git a/node_modules/synchronous-promise/package.json b/node_modules/synchronous-promise/package.json new file mode 100644 index 00000000..457fd8a5 --- /dev/null +++ b/node_modules/synchronous-promise/package.json @@ -0,0 +1,52 @@ +{ + "name": "synchronous-promise", + "version": "2.0.9", + "description": "Synchronous Promise-like prototype to use in testing where you would have used an ES6 Promise", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/fluffynuts/synchronous-promise.git" + }, + "scripts": { + "preautotest-once": "node -e \"console.log('Tests started: ', new Date());\"", + "autotest-once": "mocha index.spec.js --reporter mocha-yar", + "autotest": "nodemon -q -x \"run-s -s autotest-once\"", + "autolint": "nodemon -q -x \"run-s -s lint\"", + "prelint": "node -e \"console.log('Linting started: ', new Date());\"", + "lint": "jshint index.js", + "postlint": "node -e \"console.log('Linting completed: ', new Date());\"", + "pretest": "run-s lint", + "test-js": "mocha index.spec.js", + "test": "run-s test-js test-ts", + "predist": "mkdirp dist", + "dist": "browserify browser.js -o dist/synchronous-promise.js", + "prepublish": "run-s -s test dist", + "debug": "mocha -w *.spec.js --reporter mocha-yar --debug-brk --inspect", + "debug-ts": "mocha -r ts-node/register *.spec.ts --debug-brk --inspect", + "preautotest-ts-once": "node -e \"console.log('TS Tests started: ', new Date());\"", + "autotest-ts": "nodemon -q -e ts -x \"run-s -s test-ts\"", + "test-ts": "mocha -r ts-node/register *.spec.ts --reporter mocha-yar", + "tsc": "tsc", + "test-emitted": "mocha index-ts.spec.js", + "debug-emitted": "mocha index-ts.spec.js --debug-brk --inspect" + }, + "author": "Davyd McColl (https://github.com/fluffynuts)", + "license": "BSD-3-Clause", + "devDependencies": { + "@types/chai": "^4.1.5", + "@types/mocha": "^2.2.44", + "@types/node": "^8.10.30", + "browserify": "^14.5.0", + "chai": "^4.1.2", + "jshint": "^2.9.6", + "mkdirp": "^0.5.1", + "mocha": "^4.0.1", + "mocha-yar": "^1.0.13", + "node-ts": "^2.1.2", + "nodemon": "^1.18.4", + "npm-run-all": "^4.1.2", + "run-sequence": "^2.2.0", + "ts-node": "^3.3.0", + "typescript": "^2.9.2" + } +} diff --git a/node_modules/synchronous-promise/tsconfig.json b/node_modules/synchronous-promise/tsconfig.json new file mode 100644 index 00000000..eb3b65af --- /dev/null +++ b/node_modules/synchronous-promise/tsconfig.json @@ -0,0 +1,55 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": ["es2015"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + "noImplicitThis": false /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/node_modules/toposort/.npmignore b/node_modules/toposort/.npmignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/node_modules/toposort/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/toposort/.travis.yml b/node_modules/toposort/.travis.yml new file mode 100644 index 00000000..de50a1f7 --- /dev/null +++ b/node_modules/toposort/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 4 + - 6 + - 8 diff --git a/node_modules/toposort/License b/node_modules/toposort/License new file mode 100644 index 00000000..7975a823 --- /dev/null +++ b/node_modules/toposort/License @@ -0,0 +1,21 @@ + +Toposort - Topological sorting for node.js +Copyright (c) 2012 by Marcel Klehr +MIT LICENSE +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/toposort/Makefile b/node_modules/toposort/Makefile new file mode 100644 index 00000000..0f14dac3 --- /dev/null +++ b/node_modules/toposort/Makefile @@ -0,0 +1,11 @@ + +build: components index.js + @component build --dev + +components: component.json + @component install --dev + +clean: + rm -fr build components template.js + +.PHONY: clean diff --git a/node_modules/toposort/README.md b/node_modules/toposort/README.md new file mode 100644 index 00000000..58d4ab3e --- /dev/null +++ b/node_modules/toposort/README.md @@ -0,0 +1,98 @@ +# Toposort + +Sort directed acyclic graphs + +[![Build Status](https://travis-ci.org/marcelklehr/toposort.png)](https://travis-ci.org/marcelklehr/toposort) + +## Installation + +`npm install toposort` or `component install marcelklehr/toposort` + +then in your code: + +```js +toposort = require('toposort') +``` + +## Usage +We want to sort the following graph. + +![graph](https://cdn.rawgit.com/marcelklehr/toposort/8b14e9fd/graph.svg) + +```js +// First, we define our edges. +var graph = [ + ['put on your shoes', 'tie your shoes'] +, ['put on your shirt', 'put on your jacket'] +, ['put on your shorts', 'put on your jacket'] +, ['put on your shorts', 'put on your shoes'] +] + + +// Now, sort the vertices topologically, to reveal a legal execution order. +toposort(graph) +// [ 'put on your shirt' +// , 'put on your shorts' +// , 'put on your jacket' +// , 'put on your shoes' +// , 'tie your shoes' ] +``` + +(Note that there is no defined order for graph parts that are not connected + -- you could also put on your jacket after having tied your shoes...) + +### Sorting dependencies +It is usually more convenient to specify *dependencies* instead of "sequences". +```js +// This time, edges represent dependencies. +var graph = [ + ['tie your shoes', 'put on your shoes'] +, ['put on your jacket', 'put on your shirt'] +, ['put on your shoes', 'put on your shorts'] +, ['put on your jacket', 'put on your shorts'] +] + +toposort(graph) +// [ 'tie your shoes' +// , 'put on your shoes' +// , 'put on your jacket' +// , 'put on your shirt' +// , 'put on your shorts' ] + +// Now, reversing the list will reveal a legal execution order. +toposort(graph).reverse() +// [ 'put on your shorts' +// , 'put on your shirt' +// , 'put on your jacket' +// , 'put on your shoes' +// , 'tie your shoes' ] +``` + +## API + +### toposort(edges) + ++ edges {Array} An array of directed edges describing a graph. An edge looks like this: `[node1, node2]` (vertices needn't be strings but can be of any type). + +Returns: {Array} a list of vertices, sorted from "start" to "end" + +Throws an error if there are any cycles in the graph. + +### toposort.array(nodes, edges) + ++ nodes {Array} An array of nodes ++ edges {Array} An array of directed edges. You don't need to mention all `nodes` here. + +This is a convenience method that allows you to define nodes that may or may not be connected to any other nodes. The ordering of unconnected nodes is not defined. + +Returns: {Array} a list of vertices, sorted from "start" to "end" + +Throws an error if there are any cycles in the graph. + +## Tests + +Run the tests with `node test.js`. + +## Legal + +MIT License diff --git a/node_modules/toposort/component.json b/node_modules/toposort/component.json new file mode 100644 index 00000000..fe12ae20 --- /dev/null +++ b/node_modules/toposort/component.json @@ -0,0 +1,24 @@ +{ + "name": "toposort", + "author": "Marcel Klehr ", + "repo": "marcelklehr/toposort", + "description": "Topological sort of directed acyclic graphs (like dependency lists)", + "version": "0.2.10", + "keywords": [ + "topological", + "sort", + "sorting", + "graphs", + "graph", + "dependency", + "list", + "dependencies", + "acyclic" + ], + "dependencies": {}, + "development": {}, + "license": "MIT", + "scripts": [ + "index.js" + ] +} diff --git a/node_modules/toposort/graph.svg b/node_modules/toposort/graph.svg new file mode 100644 index 00000000..e14b0d93 --- /dev/null +++ b/node_modules/toposort/graph.svg @@ -0,0 +1 @@ +image/svg+xmlput on your shortsput on your shirtput on your shoesput on your jackettie your shoes diff --git a/node_modules/toposort/index.js b/node_modules/toposort/index.js new file mode 100644 index 00000000..826f9591 --- /dev/null +++ b/node_modules/toposort/index.js @@ -0,0 +1,98 @@ + +/** + * Topological sorting function + * + * @param {Array} edges + * @returns {Array} + */ + +module.exports = function(edges) { + return toposort(uniqueNodes(edges), edges) +} + +module.exports.array = toposort + +function toposort(nodes, edges) { + var cursor = nodes.length + , sorted = new Array(cursor) + , visited = {} + , i = cursor + // Better data structures make algorithm much faster. + , outgoingEdges = makeOutgoingEdges(edges) + , nodesHash = makeNodesHash(nodes) + + // check for unknown nodes + edges.forEach(function(edge) { + if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) { + throw new Error('Unknown node. There is an unknown node in the supplied edges.') + } + }) + + while (i--) { + if (!visited[i]) visit(nodes[i], i, new Set()) + } + + return sorted + + function visit(node, i, predecessors) { + if(predecessors.has(node)) { + var nodeRep + try { + nodeRep = ", node was:" + JSON.stringify(node) + } catch(e) { + nodeRep = "" + } + throw new Error('Cyclic dependency' + nodeRep) + } + + if (!nodesHash.has(node)) { + throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node)) + } + + if (visited[i]) return; + visited[i] = true + + var outgoing = outgoingEdges.get(node) || new Set() + outgoing = Array.from(outgoing) + + if (i = outgoing.length) { + predecessors.add(node) + do { + var child = outgoing[--i] + visit(child, nodesHash.get(child), predecessors) + } while (i) + predecessors.delete(node) + } + + sorted[--cursor] = node + } +} + +function uniqueNodes(arr){ + var res = new Set() + for (var i = 0, len = arr.length; i < len; i++) { + var edge = arr[i] + res.add(edge[0]) + res.add(edge[1]) + } + return Array.from(res) +} + +function makeOutgoingEdges(arr){ + var edges = new Map() + for (var i = 0, len = arr.length; i < len; i++) { + var edge = arr[i] + if (!edges.has(edge[0])) edges.set(edge[0], new Set()) + if (!edges.has(edge[1])) edges.set(edge[1], new Set()) + edges.get(edge[0]).add(edge[1]) + } + return edges +} + +function makeNodesHash(arr){ + var res = new Map() + for (var i = 0, len = arr.length; i < len; i++) { + res.set(arr[i], i) + } + return res +} diff --git a/node_modules/toposort/package.json b/node_modules/toposort/package.json new file mode 100644 index 00000000..0d737aad --- /dev/null +++ b/node_modules/toposort/package.json @@ -0,0 +1,29 @@ +{ + "name": "toposort", + "version": "2.0.2", + "description": "Topological sort of directed ascyclic graphs (like dependecy lists)", + "main": "index.js", + "scripts": { + "test": "node test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/marcelklehr/toposort.git" + }, + "devDependencies": { + "vows": "0.7.x" + }, + "keywords": [ + "topological", + "sort", + "sorting", + "graphs", + "graph", + "dependency", + "list", + "dependencies", + "acyclic" + ], + "author": "Marcel Klehr ", + "license": "MIT" +} diff --git a/node_modules/toposort/test.js b/node_modules/toposort/test.js new file mode 100644 index 00000000..2de9d8f0 --- /dev/null +++ b/node_modules/toposort/test.js @@ -0,0 +1,171 @@ +var vows = require('vows') + , toposort = require('./index') + , assert = require('assert') + +var suite = vows.describe('toposort') +suite.addBatch( +{ 'acyclic graphs': + { topic: function() { + /*(read downwards) + 6 3 + | | + 5->2 + | | + 4 1 + */ + return toposort( + [ ["3", '2'] + , ["2", "1"] + , ["6", "5"] + , ["5", "2"] + , ["5", "4"] + ]) + } + , 'should be sorted correctly': function(er, result) { + assert.instanceOf(result, Array) + var failed = [], passed + // valid permutations + ;[ [ '3','6','5','2','1','4' ] + , [ '3','6','5','2','4','1' ] + , [ '6','3','5','2','1','4' ] + , [ '6','5','3','2','1','4' ] + , [ '6','5','3','2','4','1' ] + , [ '6','5', '4','3','2','1' ] + ].forEach(function(solution) { + try { + assert.deepEqual(result, solution) + passed = true + }catch (e) { + failed.push(e) + } + }) + if (!passed) { + console.log(failed) + throw failed[0]; + } + } + } +, 'simple cyclic graphs': + { topic: function() { + /* + foo<->bar + */ + return toposort( + [ ["foo", 'bar'] + , ["bar", "foo"]// cyclic dependecy + ]) + } + , 'should throw an exception': function(_, val) { + assert.instanceOf(val, Error) + } + } +, 'complex cyclic graphs': + { topic: function() { + /* + foo + | + bar<-john + | ^ + ron->tom + */ + return toposort( + [ ["foo", 'bar'] + , ["bar", "ron"] + , ["john", "bar"] + , ["tom", "john"] + , ["ron", "tom"]// cyclic dependecy + ]) + } + , 'should throw an exception': function(_, val) { + assert.instanceOf(val, Error) + } + } +, 'unknown nodes in edges': + { topic: function() { + return toposort.array(['bla'], + [ ["foo", 'bar'] + , ["bar", "ron"] + , ["john", "bar"] + , ["tom", "john"] + , ["ron", "tom"] + ]) + } + , 'should throw an exception': function(_, val) { + assert.instanceOf(val, Error) + } + } +, 'triangular dependency': + { topic: function() { + /* + a-> b + | / + c<- + */ + return toposort([ + ['a', 'b'] + , ['a', 'c'] + , ['b', 'c'] + ]); + } + , 'shouldn\'t throw an error': function(er, result) { + assert.deepEqual(result, ['a', 'b', 'c']) + } + } +, 'toposort.array': + { topic: function() { + return toposort.array(['d', 'c', 'a', 'b'], [['a','b'],['b','c']]) + } + , 'should include unconnected nodes': function(er, result){ + var i = result.indexOf('d') + assert(i >= 0) + result.splice(i, 1) + assert.deepEqual(result, ['a', 'b', 'c']) + } + } +, 'toposort.array mutation': + { topic: function() { + var array = ['d', 'c', 'a', 'b'] + toposort.array(array, [['a','b'],['b','c']]) + return array + } + , 'should not mutate its arguments': function(er, result){ + assert.deepEqual(result, ['d', 'c', 'a', 'b']) + } + } +, 'giant graphs': + { + topic: function() { + var graph = [] + , nodeCount = 100000 + for (var i = 0; i < nodeCount; i++) { + graph.push([i, i + 1]) + } + return graph + } + , 'should sort quickly': function(er, result){ + var start = (new Date).getTime() + var sorted = toposort(result) + var end = (new Date).getTime() + var elapsedSeconds = (end - start) / 1000 + assert(elapsedSeconds < 1) + } + } +, 'object keys': + { + topic: function() { + var o1 = {k1: 'v1', nested: {k2: 'v2'}} + var o2 = {k2: 'v2'} + var o3 = {k3: 'v3'} + var graph = [[o1, o2], [o2, o3]] + return graph + } + , 'should handle object nodes': function(er, result){ + var sorted = toposort(result) + assert.deepEqual(sorted, [{k1: 'v1', nested: {k2: 'v2'}}, {k2: 'v2'}, {k3: 'v3'}]) + } + } +}) +.run(null, function() { + (suite.results.broken+suite.results.errored) > 0 && process.exit(1) + process.exit(0) +}) diff --git a/node_modules/yup/CHANGELOG.md b/node_modules/yup/CHANGELOG.md new file mode 100644 index 00000000..cd5de62e --- /dev/null +++ b/node_modules/yup/CHANGELOG.md @@ -0,0 +1,284 @@ +# [0.27.0](https://github.com/jquense/yup/compare/v0.26.10...v0.27.0) (2019-03-14) + + +### Bug Fixes + +* change @babel/runtime version to be a range ([#488](https://github.com/jquense/yup/issues/488)) ([1c9b362](https://github.com/jquense/yup/commit/1c9b362)), closes [#486](https://github.com/jquense/yup/issues/486) +* concat of mixed and subtype ([#444](https://github.com/jquense/yup/issues/444)) ([7705972](https://github.com/jquense/yup/commit/7705972)) +* default message for test with object ([#453](https://github.com/jquense/yup/issues/453)) ([f1be37f](https://github.com/jquense/yup/commit/f1be37f)) +* noUnknown() overriding ([#452](https://github.com/jquense/yup/issues/452)) ([3047b33](https://github.com/jquense/yup/commit/3047b33)) +* typo README (about excludeEmptyString) ([#441](https://github.com/jquense/yup/issues/441)) ([d02ff5e](https://github.com/jquense/yup/commit/d02ff5e)) + + +### Features + +* add _isFilled as overrideable `mixed` method to control required behavior ([#459](https://github.com/jquense/yup/issues/459)) ([5b01f18](https://github.com/jquense/yup/commit/5b01f18)) +* aliases `optional()` and `unknown()` ([#460](https://github.com/jquense/yup/issues/460)) ([51e8661](https://github.com/jquense/yup/commit/51e8661)) +* allow toggling strict() ([#457](https://github.com/jquense/yup/issues/457)) ([851d421](https://github.com/jquense/yup/commit/851d421)) +* allow withMutation() nesting ([#456](https://github.com/jquense/yup/issues/456)) ([e53ea8c](https://github.com/jquense/yup/commit/e53ea8c)) +* do concat in mutation mode ([#461](https://github.com/jquense/yup/issues/461)) ([02be4ca](https://github.com/jquense/yup/commit/02be4ca)) +* finalize resolve() ([#447](https://github.com/jquense/yup/issues/447)) ([afc5119](https://github.com/jquense/yup/commit/afc5119)) +* support self references ([#443](https://github.com/jquense/yup/issues/443)) ([1cac515](https://github.com/jquense/yup/commit/1cac515)), closes [/github.com/jquense/yup/blob/d02ff5e59e004b4c5189d1b9fc0055cff45c61df/src/Reference.js#L3](https://github.com//github.com/jquense/yup/blob/d02ff5e59e004b4c5189d1b9fc0055cff45c61df/src/Reference.js/issues/L3) + + +### BREAKING CHANGES + +* reach() no longer resolves the returned schema meaning it's conditions have not been processed yet; prefer validateAt/castAt where it makes sense +* required no longer shows up twice in describe() output for array and strings, which also no longer override required + + + + + +## v0.26.3 - Tue, 28 Aug 2018 15:00:04 GMT + +## v0.26.0 - Fri, 20 Jul 2018 15:39:03 GMT + +## v0.25.1 - Wed, 16 May 2018 23:59:14 GMT + +## v0.25.0 - Tue, 15 May 2018 21:43:54 GMT + +- remove default export, there are only named exports now! +- fix message defaults for built-in tests, default is only used for `undefined` messages +- fix the `describe()` method so it works with nested schemas + +## v0.24.1 - Fri, 09 Feb 2018 19:09:02 GMT + +## v0.24.0 - Tue, 16 Jan 2018 14:44:32 GMT + +- [f2a0b75](../../commit/f2a0b75), [061e590](../../commit/061e590) [added] number methods lessThan, moreThan + +## v0.23.0 - Thu, 12 Oct 2017 17:08:47 GMT + +** Probably not breaking but we are being safe about it ** + +- 🎉 Add Synchronous validation! [#94](https://github.com/jquense/yup/pull/94) + +** Features ** + +- Custom locales without import order [#125](https://github.com/jquense/yup/pull/125) + +## v0.22.1 - Thu, 12 Oct 2017 14:49:16 GMT + +- Fix bug in browsers without symbol [#132](https://github.com/jquense/yup/pull/132) + +## v0.22.0 - Sat, 26 Aug 2017 14:48:57 GMT + +** Breaking ** + +- Use native Set and lodash CloneDeep: [#109](https://github.com/jquense/yup/pull/109) + +\*\* Fixes and Features + +- Better custom locale support: [#105](https://github.com/jquense/yup/pull/105) +- fix some messages: [#112](https://github.com/jquense/yup/pull/112) +- Clearer errors for common mistakes: [#108](https://github.com/jquense/yup/pull/108) +- New string validation length: [#67](https://github.com/jquense/yup/pull/67) + +## v0.21.3 - Wed, 18 Jan 2017 15:39:25 GMT + +- [7bc01e0](../../commit/7bc01e0) [added] deep path support for `from` + +## v0.21.2 - Fri, 09 Sep 2016 16:52:44 GMT + +- [be80413](../../commit/be80413) [fixed] default in concat() + +## v0.21.1 - Mon, 29 Aug 2016 18:39:29 GMT + +## v0.21.0 - Mon, 29 Aug 2016 18:29:31 GMT + +- [8a8cc5b](../../commit/8a8cc5b) [changed] remove case aliases and simplify camelCase + +## v0.20.0 - Wed, 20 Jul 2016 02:02:08 GMT + +- [f7446d2](../../commit/f7446d2) [fixed] pass path correctly to cast() +- [9b5232a](../../commit/9b5232a) [added] allow function then/otherwise bodies +- [73858fe](../../commit/73858fe) [changed] Don't throw on undefined values in cast() + +## v0.19.1 - Mon, 18 Jul 2016 21:53:05 GMT + +- [69c0ad4](../../commit/69c0ad4) [fixed] array().concat() incorrectly cleared the sub-schema + +## v0.19.0 - Fri, 24 Jun 2016 15:19:48 GMT + +- [b0dd021](../../commit/b0dd021) [changed] Split integer(), remove transform +- [758ac51](../../commit/758ac51) [added] string.ensure +- [f2b0078](../../commit/f2b0078) [changed] Less aggressive type coercions +- [ab94510](../../commit/ab94510) [fixed] boxed number allowed NaN + +## v0.18.3 - Mon, 09 May 2016 15:50:47 GMT + +## v0.18.2 - Mon, 25 Apr 2016 18:23:13 GMT + +## v0.18.1 - Mon, 25 Apr 2016 15:01:16 GMT + +- [816e607](../../commit/816e607) [added] validation params to ValidationError + +## v0.18.0 - Sat, 23 Apr 2016 01:20:27 GMT + +- [f827822](../../commit/f827822) [changed] validate() on objects won't cast nested schema with strict() + +## v0.17.6 - Thu, 21 Apr 2016 14:59:59 GMT + +- [139dd24](../../commit/139dd24) [changed] lazy qualifies as a yup schema + +## v0.17.5 - Thu, 21 Apr 2016 11:20:16 GMT + +- [c553cc0](../../commit/c553cc0) [added] options to lazy resolve + +## v0.17.4 - Wed, 20 Apr 2016 14:15:39 GMT + +## v0.17.3 - Tue, 19 Apr 2016 20:24:09 GMT + +- [6c309e4](../../commit/6c309e4) [fixed] array.ensure() + +## v0.17.2 - Tue, 19 Apr 2016 16:46:54 GMT + +## v0.17.1 - Thu, 14 Apr 2016 19:12:22 GMT + +- [ab78f54](../../commit/ab78f54) [fixed] reach with lazy() + +## v0.17.0 - Thu, 14 Apr 2016 17:13:50 GMT + +- [6e9046b](../../commit/6e9046b) [changed] clean up interface, added lazy(), and fixed object strict semantics + +## v0.16.5 - Tue, 12 Apr 2016 13:36:38 GMT + +- [c3b613b](../../commit/c3b613b) [added] strip() method for objects +- [68fc010](../../commit/68fc010) [added] array.of shorthand + +## v0.16.4 - Sat, 09 Apr 2016 20:13:13 GMT + +- [f30d1e3](../../commit/f30d1e3) [fixed] bug in date min/max with ref + +## v0.16.3 - Thu, 07 Apr 2016 19:13:23 GMT + +## v0.16.2 - Thu, 07 Apr 2016 17:57:44 GMT + +- [83c0656](../../commit/83c0656) [added] meta() and describe() + +## v0.16.1 - Tue, 05 Apr 2016 20:56:45 GMT + +- [9d70a7b](../../commit/9d70a7b) [changed] doesn't throw when context is missing. +- [594fa53](../../commit/594fa53) [changed] added reach error + +## v0.16.0 - Tue, 05 Apr 2016 20:17:40 GMT + +- [75739b8](../../commit/75739b8) [added] context sensitive reach() + +## v0.15.0 - Tue, 29 Mar 2016 14:56:15 GMT + +- [3ae5fdc](../../commit/3ae5fdc) [changed] `null` is not considered an empty value for isValid +- [9eb42c6](../../commit/9eb42c6) [added] refs! + +## v0.14.2 - Tue, 29 Mar 2016 14:48:37 GMT + +## v0.14.1 - Tue, 16 Feb 2016 19:51:25 GMT + +- [ff19720](../../commit/ff19720) [fixed] noUnknown and stripUnknown work and propagate to children + +## v0.14.0 - Mon, 08 Feb 2016 16:17:40 GMT + +- [86b6446](../../commit/86b6446) [fixed] camelCase should maintain leading underscores + +## v0.13.0 - Mon, 01 Feb 2016 20:49:40 GMT + +- [335eb18](../../commit/335eb18) [fixed] pass options to array sub schema +- [f7f631d](../../commit/f7f631d) [changed] oneOf doesn't include empty values +- [0a7b2d4](../../commit/0a7b2d4) [fixed] type and whitelist/blacklist checks threw inconsistent errors +- [1274a45](../../commit/1274a45) [changed] required() to non-exclusive + +## v0.12.0 - Tue, 12 Jan 2016 19:12:18 GMT + +- [5bc250f](../../commit/5bc250f) [changed] don't clone unspecified object keys +- [069c6fd](../../commit/069c6fd) [added] withMutation() method +- [e1d4891](../../commit/e1d4891) [fixed] don't alias non existent fields + +## v0.11.0 - Sun, 08 Nov 2015 17:17:09 GMT + +- [686f6b1](../../commit/686f6b1) [changed] concat() allows mixing "mixed" and other type + +## 0.9.0 + +**breaking** + +- `test` functions are no longer passed `path` and `context` as arguments, Instead they are now values on `this` inside the test function. +- test functions are longer called with the schema as their `this` value, use `this.schema` instead. + +**other changes** + +- test functions are call with with a new context object, including, options, parent and `createError` for dynamically altering validation errors. + +## 0.8.3 + +- document `stripUnknown` +- add `recursive` option +- add `noUnknown()` test to objects + +## 0.8.2 + +- default for objects now adds keys for all fields, not just fields with non empty defaults + +## 0.8.1 + +- bug fix + +## 0.8.0 + +**breaking** + +- `test` functions are now passed `path` and `context` values along with the field value. Only breaks if using the callback style of defining custom validations + +## 0.7.0 + +**breaking** + +- the `validation()` method has been renamed to `test()` and has a new signature requiring a `name` argument +- exclusive validations now trump the previous one instead of defering to it e.g: `string().max(10).max(15)` has a max of `15` instead of `10` + +**other changes** + +- expose advanced signature for custom validation tests, gives finer grained control over how tests are added +- added the `abortEarly` (default: `true`) option +- transforms are passed an addition parameter: 'originalValue' you allow recovering from a bad transform further up the chain (provided no one mutated the value) + +## 0.6.3 + +- fix `concat()` method and add tests + +## 0.6.2 + +- fix validations where nullable fields were failing due to `null` values e.g `string.max()` + +## 0.6.1 + +- fix export error + +## 0.6.0 + +**breaking** + +- Removed the `extend` and `create` methods. Use whatever javascript inheritance patterns you want instead. +- the resolution order of defaults and coercions has changed. as well as the general handling of `null` values. + - Number: `null` will coerce to `false` when `nullable()` is not specified. `NaN` values will now fail `isType()` checks + - String: `null` will coerce to `''` when `nullable()` is not specified + - Date: Invalid dates will not be coerced to `null`, but left as invalid date, This is probably not a problem for anyone as invalid dates will also fail `isType()` checks +- default values are cloned everytime they are returned, so it is impossible to share references to defaults across schemas. No one should be doing that anyway +- stopped pretending that using schemas as conditions in `when()` actually worked (it didn't) + +**other changes** + +- `transform()` now passes the original value to each transformer. Allowing you to recover from a bad transform. +- added the `equals()` alias for `oneOf` +- + +## 0.5.0 + +**breaking** + +- isValid is now async, provide a node style callback, or use the promise the method returns to read the validity. This change allows for more robust validations, specifically remote ones for client code (or db queries for server code). The cast method is still, and will remain, synchronous. +- + +**other changes** + +- added validate method (also async) which resolves to the value, and rejects with a new ValidationError diff --git a/node_modules/yup/LICENSE.md b/node_modules/yup/LICENSE.md new file mode 100644 index 00000000..397b66c3 --- /dev/null +++ b/node_modules/yup/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Jason Quense + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/node_modules/yup/README.md b/node_modules/yup/README.md new file mode 100644 index 00000000..0e96b6a4 --- /dev/null +++ b/node_modules/yup/README.md @@ -0,0 +1,1202 @@ +# Yup + +Yup is a JavaScript object schema validator and object parser. The API and style is ~~stolen~~ heavily inspired +by [Joi](https://github.com/hapijs/joi), which is an amazing library but is generally too large and difficult +to package for use in a browser. Yup is leaner: in the same spirit, without some of the fancy features. +You can use it on the server as well, but in that case you might as well just use Joi. + +Yup is also a good bit less opinionated than joi, allowing for custom transformations and async validation. +It also allows "stacking" conditions via `when` for properties that depend on more than one other sibling or +child property. Yup separates the parsing and validating functions into separate steps so it can be used to parse +json separate from validating it, via the `cast` method. + +**Try it out:** https://runkit.com/jquense/yup# + + + + + +- [Install](#install) +- [Usage](#usage) + - [Using a custom locale dictionary](#using-a-custom-locale-dictionary) +- [API](#api) + - [`yup`](#yup) + - [`yup.reach(schema: Schema, path: string, value?: object, context?: object): Schema`](#yupreachschema-schema-path-string-value-object-context-object-schema) + - [`yup.addMethod(schemaType: Schema, name: string, method: ()=> Schema): void`](#yupaddmethodschematype-schema-name-string-method--schema-void) + - [`yup.ref(path: string, options: { contextPrefix: string }): Ref`](#yuprefpath-string-options--contextprefix-string--ref) + - [`yup.lazy((value: any) => Schema): Lazy`](#yuplazyvalue-any--schema-lazy) + - [`ValidationError(errors: string | Array, value: any, path: string)`](#validationerrorerrors-string--arraystring-value-any-path-string) + - [mixed](#mixed) + - [`mixed.clone(): Schema`](#mixedclone-schema) + - [`mixed.label(label: string): Schema`](#mixedlabellabel-string-schema) + - [`mixed.meta(metadata: object): Schema`](#mixedmetametadata-object-schema) + - [`mixed.describe(): SchemaDescription`](#mixeddescribe-schemadescription) + - [`mixed.concat(schema: Schema)`](#mixedconcatschema-schema) + - [`mixed.validate(value: any, options?: object): Promise`](#mixedvalidatevalue-any-options-object-promiseany-validationerror) + - [`mixed.validateSync(value: any, options?: object): any`](#mixedvalidatesyncvalue-any-options-object-any) + - [`mixed.validateAt(path: string, value: any, options?: object): Promise`](#mixedvalidateatpath-string-value-any-options-object-promiseany-validationerror) + - [`mixed.validateSyncAt(path: string, value: any, options?: object): any`](#mixedvalidatesyncatpath-string-value-any-options-object-any) + - [`mixed.isValid(value: any, options?: object): Promise`](#mixedisvalidvalue-any-options-object-promiseboolean) + - [`mixed.isValidSync(value: any, options?: object): boolean`](#mixedisvalidsyncvalue-any-options-object-boolean) + - [`mixed.cast(value: any, options = {}): any`](#mixedcastvalue-any-options---any) + - [`mixed.isType(value: any): boolean`](#mixedistypevalue-any-boolean) + - [`mixed.strict(isStrict: boolean = false): Schema`](#mixedstrictisstrict-boolean--false-schema) + - [`mixed.strip(stripField: boolean = true): Schema`](#mixedstripstripfield-boolean--true-schema) + - [`mixed.withMutation(builder: (current: Schema) => void): void`](#mixedwithmutationbuilder-current-schema--void-void) + - [`mixed.default(value: any): Schema`](#mixeddefaultvalue-any-schema) + - [`mixed.default(): Any`](#mixeddefault-any) + - [`mixed.nullable(isNullable: boolean = true): Schema`](#mixednullableisnullable-boolean--true-schema) + - [`mixed.required(message?: string | function): Schema`](#mixedrequiredmessage-string--function-schema) + - [`mixed.notRequired(): Schema`](#mixednotrequired-schema) + - [`mixed.typeError(message: string): Schema`](#mixedtypeerrormessage-string-schema) + - [`mixed.oneOf(arrayOfValues: Array, message?: string | function): Schema` Alias: `equals`](#mixedoneofarrayofvalues-arrayany-message-string--function-schema-alias-equals) + - [`mixed.notOneOf(arrayOfValues: Array, message?: string | function)`](#mixednotoneofarrayofvalues-arrayany-message-string--function) + - [`mixed.when(keys: string | Array, builder: object | (value, schema)=> Schema): Schema`](#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema) + - [`mixed.test(name: string, message: string | function, test: function): Schema`](#mixedtestname-string-message-string--function-test-function-schema) + - [`mixed.test(options: object): Schema`](#mixedtestoptions-object-schema) + - [`mixed.transform((currentValue: any, originalValue: any) => any): Schema`](#mixedtransformcurrentvalue-any-originalvalue-any--any-schema) + - [string](#string) + - [`string.required(message?: string | function): Schema`](#stringrequiredmessage-string--function-schema) + - [`string.length(limit: number | Ref, message?: string | function): Schema`](#stringlengthlimit-number--ref-message-string--function-schema) + - [`string.min(limit: number | Ref, message?: string | function): Schema`](#stringminlimit-number--ref-message-string--function-schema) + - [`string.max(limit: number | Ref, message?: string | function): Schema`](#stringmaxlimit-number--ref-message-string--function-schema) + - [`string.matches(regex: Regex, message?: string | function): Schema`](#stringmatchesregex-regex-message-string--function-schema) + - [`string.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schema`](#stringmatchesregex-regex-options--message-string-excludeemptystring-bool--schema) + - [`string.email(message?: string | function): Schema`](#stringemailmessage-string--function-schema) + - [`string.url(message?: string | function): Schema`](#stringurlmessage-string--function-schema) + - [`string.ensure(): Schema`](#stringensure-schema) + - [`string.trim(message?: string | function): Schema`](#stringtrimmessage-string--function-schema) + - [`string.lowercase(message?: string | function): Schema`](#stringlowercasemessage-string--function-schema) + - [`string.uppercase(message?: string | function): Schema`](#stringuppercasemessage-string--function-schema) + - [number](#number) + - [`number.min(limit: number | Ref, message?: string | function): Schema`](#numberminlimit-number--ref-message-string--function-schema) + - [`number.max(limit: number | Ref, message?: string | function): Schema`](#numbermaxlimit-number--ref-message-string--function-schema) + - [`number.lessThan(max: number | Ref, message?: string | function): Schema`](#numberlessthanmax-number--ref-message-string--function-schema) + - [`number.moreThan(min: number | Ref, message?: string | function): Schema`](#numbermorethanmin-number--ref-message-string--function-schema) + - [`number.positive(message?: string | function): Schema`](#numberpositivemessage-string--function-schema) + - [`number.negative(message?: string | function): Schema`](#numbernegativemessage-string--function-schema) + - [`number.integer(message?: string | function): Schema`](#numberintegermessage-string--function-schema) + - [`number.truncate(): Schema`](#numbertruncate-schema) + - [`number.round(type: 'floor' | 'ceil' | 'trunc' | 'round' = 'round'): Schema`](#numberroundtype-floor--ceil--trunc--round--round-schema) + - [boolean](#boolean) + - [date](#date) + - [`date.min(limit: Date | string | Ref, message?: string | function): Schema`](#dateminlimit-date--string--ref-message-string--function-schema) + - [`date.max(limit: Date | string | Ref, message?: string | function): Schema`](#datemaxlimit-date--string--ref-message-string--function-schema) + - [array](#array) + - [`array.of(type: Schema): Schema`](#arrayoftype-schema-schema) + - [`array.required(message?: string | function): Schema`](#arrayrequiredmessage-string--function-schema) + - [`array.min(limit: number | Ref, message?: string | function): Schema`](#arrayminlimit-number--ref-message-string--function-schema) + - [`array.max(limit: number | Ref, message?: string | function): Schema`](#arraymaxlimit-number--ref-message-string--function-schema) + - [`array.ensure(): Schema`](#arrayensure-schema) + - [`array.compact(rejector: (value) => boolean): Schema`](#arraycompactrejector-value--boolean-schema) + - [object](#object) + - [`object.shape(fields: object, noSortEdges?: Array<[string, string]>): Schema`](#objectshapefields-object-nosortedges-arraystring-string-schema) + - [`object.from(fromKey: string, toKey: string, alias: boolean = false): Schema`](#objectfromfromkey-string-tokey-string-alias-boolean--false-schema) + - [`object.noUnknown(onlyKnownKeys: boolean = true, message?: string | function): Schema`](#objectnounknownonlyknownkeys-boolean--true-message-string--function-schema) + - [`object.camelCase(): Schema`](#objectcamelcase-schema) + - [`object.constantCase(): Schema`](#objectconstantcase-schema) +- [Extending Schema Types](#extending-schema-types) + + + +## Install + +```sh +npm install -S yup +``` + +Yup always relies on the `Promise` global object to handle asynchronous values as well as `Set` and `Map`. +For browsers that do not support these, you'll need to include a polyfill, such as core-js: + +```js +import 'core-js/es6/promise'; +import 'core-js/es6/set'; +import 'core-js/es6/map'; +``` + +## Usage + +You define and create schema objects. Schema objects are immutable, so each call of a method returns a _new_ schema object. + +**try it out using tonicdev! https://tonicdev.com/570c52590a85f71200eb09ba/yup** + +When using es module syntax, yup exports everything as a named export + +```js +import * as yup from 'yup'; // for everything +// or +import { string, object } from 'yup'; // for only what you need +``` + +```js +let yup = require('yup'); + +let schema = yup.object().shape({ + name: yup.string().required(), + age: yup + .number() + .required() + .positive() + .integer(), + email: yup.string().email(), + website: yup.string().url(), + createdOn: yup.date().default(function() { + return new Date(); + }), +}); + +// check validity +schema + .isValid({ + name: 'jimmy', + age: 24, + }) + .then(function(valid) { + valid; // => true + }); + +// you can try and type cast objects to the defined schema +schema.cast({ + name: 'jimmy', + age: '24', + createdOn: '2014-09-23T19:25:25Z', +}); +// => { name: 'jimmy', age: 24, createdOn: Date } +``` + +> If you're looking for an easily serializable DSL for yup schema, check out [yup-ast](https://github.com/WASD-Team/yup-ast) + +### Using a custom locale dictionary + +Allows you to customize the default messages used by Yup, when no message is provided with a validation test. +If any message is missing in the custom dictionary the error message will default to Yup's one. + +```js +import { setLocale } from 'yup'; + +setLocale({ + mixed: { + default: 'Não é válido', + }, + number: { + min: 'Deve ser maior que ${min}', + }, +}); + +// now use Yup schemas AFTER you defined your custom dictionary +let schema = yup.object().shape({ + name: yup.string(), + age: yup.number().min(18), +}); + +schema.validate({ name: 'jimmy', age: 11 }).catch(function(err) { + err.name; // => 'ValidationError' + err.errors; // => ['Deve ser maior que 18'] +}); +``` + +## API + +### `yup` + +The module export. + +```js +let yup = require('yup'); + +yup.mixed; +yup.string; +yup.number; +yup.boolean; // also aliased as yup.bool +yup.date; +yup.object; +yup.array; + +yup.reach; +yup.addMethod; +yup.ref; +yup.lazy; +yup.setLocale; +yup.ValidationError; +``` + +#### `yup.reach(schema: Schema, path: string, value?: object, context?: object): Schema` + +For nested schema's `yup.reach` will retrieve a nested schema based on the provided path. + +For nested schema that need to resolve dynamically, you can provide a `value` and optionally +a `context` object. + +```js +let schema = object().shape({ + nested: object().shape({ + arr: array().of(object().shape({ num: number().max(4) })), + }), +}); + +reach(schema, 'nested.arr.num'); +reach(schema, 'nested.arr[].num'); +reach(schema, 'nested.arr[1].num'); +reach(schema, 'nested["arr"][1].num'); +``` + +#### `yup.addMethod(schemaType: Schema, name: string, method: ()=> Schema): void` + +Adds a new method to the core schema types. A friendlier convenience method for `schemaType.prototype[name] = method`. + +```js +yup.addMethod(yup.date, 'format', function(formats, parseStrict) { + return this.transform(function(value, originalValue) { + if (this.isType(value)) return value; + + value = Moment(originalValue, formats, parseStrict); + + return date.isValid() ? date.toDate() : invalidDate; + }); +}); +``` + +#### `yup.ref(path: string, options: { contextPrefix: string }): Ref` + +Creates a reference to another sibling or sibling descendant field. Ref's are resolved +at _validation/cast time_ and supported where specified. Ref's are evaluated in in the proper order so that +the ref value is resolved before the field using the ref (be careful of circular dependencies!). + +```js +let schema = object({ + baz: ref('foo.bar'), + foo: object({ + bar: string(), + }), + x: ref('$x'), +}); + +schema.cast({ foo: { bar: 'boom' } }, { context: { x: 5 } }); +// => { baz: 'boom', x: 5, foo: { bar: 'boom' } } +``` + +#### `yup.lazy((value: any) => Schema): Lazy` + +Creates a schema that is evaluated at validation/cast time. Useful for creating +recursive schema like Trees, for polymophic fields and arrays. + +**CAUTION!** When defining parent-child recursive object schema, you want to reset the `default()` +to `undefined` on the child otherwise the object will infinitely nest itself when you cast it!. + +```js +let node = object({ + id: number(), + child: yup.lazy(() => node.default(undefined)), +}); + +let renderable = yup.lazy(value => { + switch (typeof value) { + case 'number': + return number(); + case 'string': + return string(); + default: + return mixed(); + } +}); + +let renderables = array().of(renderable); +``` + +#### `ValidationError(errors: string | Array, value: any, path: string)` + +Thrown on failed validations, with the following properties + +- `name`: "ValidationError" +- `path`: a string, indicating where there error was thrown. `path` is empty at the root level. +- `errors`: array of error messages +- `inner`: in the case of aggregate errors, inner is an array of `ValidationErrors` throw earlier in the + validation chain. When the `abortEarly` option is `false` this is where you can inspect each error thrown, + alternatively `errors` will have all the of the messages from each inner error. + +### mixed + +Creates a schema that matches all types. All types inherit from this base type + +```js +let schema = yup.mixed(); + +schema.isValid(undefined, function(valid) { + valid; // => true +}); +``` + +#### `mixed.clone(): Schema` + +Creates a deep copy of the schema. Clone is used internally to return a new schema with every schema state change. + +#### `mixed.label(label: string): Schema` + +Overrides the key name which is used in error messages. + +#### `mixed.meta(metadata: object): Schema` + +Adds to a metadata object, useful for storing data with a schema, that doesn't belong +the cast object itself. + +#### `mixed.describe(): SchemaDescription` + +Collects schema details (like meta, labels, and active tests) into a serializable +description object. + +``` +SchemaDescription { + type: string, + label: string, + meta: object, + tests: Array<{ name: string, params: object }> +} +``` + +#### `mixed.concat(schema: Schema)` + +Creates a new instance of the schema by combining two schemas. Only schemas of the same type can be concatenated. + +#### `mixed.validate(value: any, options?: object): Promise` + +Returns the value (a cast value if `isStrict` is `false`) if the value is valid, and returns the errors otherwise. +This method is **asynchronous** and returns a Promise object, that is fulfilled with the value, or rejected +with a `ValidationError`. + +The `options` argument is an object hash containing any schema options you may want to override +(or specify for the first time). + +```js +Options = { + strict: boolean = false; + abortEarly: boolean = true; + stripUnknown: boolean = false; + recursive: boolean = true; + context?: object; +} +``` + +- `strict`: only validate the input, and skip and coercion or transformation +- `abortEarly`: return from validation methods on the first error rather + than after all validations run. +- `stripUnknown`: remove unspecified keys from objects. +- `recursive`: when `false` validations will not descend into nested schema + (relevant for objects or arrays). +- `context`: any context needed for validating schema conditions (see: `when()`) + +```js +schema.validate({ name: 'jimmy', age: 24 }).then(function(value) { + value; // => { name: 'jimmy',age: 24 } +}); + +schema.validate({ name: 'jimmy', age: 'hi' }).catch(function(err) { + err.name; // => 'ValidationError' + err.errors; // => ['age must be a number'] +}); +``` + +#### `mixed.validateSync(value: any, options?: object): any` + +Runs validatations synchronously _if possible_ and returns the resulting value, +or throws a ValidationError. Accepts all the same options as `validate`. + +Synchronous validation only works if there are no configured async tests, e.g tests that return a Promise. +For instance this will work: + +```js +let schema = number().test( + 'is-42', + "this isn't the number i want", + value => value != 42, +); + +schema.validateSync(23); // throws ValidationError +``` + +however this will not: + +```js +let schema = number().test('is-42', "this isn't the number i want", value => + Promise.resolve(value != 42), +); + +schema.validateSync(42); // throws Error +``` + +#### `mixed.validateAt(path: string, value: any, options?: object): Promise` + +Validate a deeply nested path within the schema. Similar to how `reach` works, +but uses the resulting schema as the subject for validation. + +> Note! The `value` here is the _root_ value relative to the starting schema, not the value at the nested path. + +```js +let schema = object({ + foo: array().of( + object({ + loose: boolean(), + bar: string().when('loose', { + is: true, + otherwise: s => s.strict(), + }), + }), + ), +}); + +let rootValue = { + foo: [{ bar: 1 }, { bar: 1, loose: true }], +}; + +await schema.validateAt('foo[0].bar', rootValue); // => ValidationError: must be a string + +await schema.validateAt('foo[1].bar', rootValue); // => '1' +``` + +#### `mixed.validateSyncAt(path: string, value: any, options?: object): any` + +Same as `validateAt` but synchronous. + +#### `mixed.isValid(value: any, options?: object): Promise` + +Returns `true` when the passed in value matches the schema. `isValid` +is **asynchronous** and returns a Promise object. + +Takes the same options as `validate()`. + +#### `mixed.isValidSync(value: any, options?: object): boolean` + +Synchronously returns `true` when the passed in value matches the schema. + +Takes the same options as `validateSync()` and has the same caveats around async tests. + +#### `mixed.cast(value: any, options = {}): any` + +Attempts to coerce the passed in value to a value that matches the schema. For example: `'5'` will +cast to `5` when using the `number()` type. Failed casts generally return `null`, but may also +return results like `NaN` and unexpected strings. + +`options` parameter can be an object containing `context`. (For more info on `context` see `mixed.validate`) + +#### `mixed.isType(value: any): boolean` + +Runs a type check against the passed in `value`. It returns true if it matches, +it does not cast the value. When `nullable()` is set `null` is considered a valid value of the type. +You should use `isType` for all Schema type checks. + +#### `mixed.strict(isStrict: boolean = false): Schema` + +Sets the `strict` option to `true`. Strict schemas skip coercion and transformation attempts, +validating the value "as is". + +#### `mixed.strip(stripField: boolean = true): Schema` + +Marks a schema to be removed from an output object. Only works as a nested schema. + +```js +let schema = object({ + useThis: number(), + notThis: string().strip(), +}); + +schema.cast({ notThis: 'foo', useThis: 4 }); // => { useThis: 4 } +``` + +#### `mixed.withMutation(builder: (current: Schema) => void): void` + +First the legally required Rich Hickey quote: + +> If a tree falls in the woods, does it make a sound? +> +> If a pure function mutates some local data in order to produce an immutable return value, is that ok? + +`withMutation` allows you to mutate the schema in place, instead of the default behavior which clones before each change. +Generally this isn't necessary since the vast majority of schema changes happen during the initial +declaration, and only happen once over the lifetime of the schema, so performance isn't an issue. +However certain mutations _do_ occur at cast/validation time, (such as conditional schema using `when()`), or +when instantiating a schema object. + +```js +object() + .shape({ key: string() }) + .withMutation(schema => { + return arrayOfObjectTests.forEach(test => { + schema.test(test); + }); + }); +``` + +#### `mixed.default(value: any): Schema` + +Sets a default value to use when the value is `undefined`. +Defaults are created after transformations are executed, but before validations, to help ensure that safe +defaults are specified. The default value will be cloned on each use, which can incur performance penalty +for objects and arrays. To avoid this overhead you can also pass a function that returns a new default. +Note that `null` is considered a separate non-empty value. + +```js +yup.string.default('nothing'); + +yup.object.default({ number: 5 }); // object will be cloned every time a default is needed + +yup.object.default(() => ({ number: 5 })); // this is cheaper + +yup.date.default(() => new Date()); // also helpful for defaults that change over time +``` + +#### `mixed.default(): Any` + +Calling `default` with no arguments will return the current default value + +#### `mixed.nullable(isNullable: boolean = true): Schema` + +Indicates that `null` is a valid value for the schema. Without `nullable()` +`null` is treated as a different type and will fail `isType()` checks. + +#### `mixed.required(message?: string | function): Schema` + +Mark the schema as required. All field values apart from `undefined` and `null` meet this requirement. + +#### `mixed.notRequired(): Schema` + +Mark the schema as not required. Passing `undefined` as value will not fail validation. + +#### `mixed.typeError(message: string): Schema` + +Define an error message for failed type checks. The `${value}` and `${type}` interpolation can +be used in the `message` argument. + +#### `mixed.oneOf(arrayOfValues: Array, message?: string | function): Schema` Alias: `equals` + +Whitelist a set of values. Values added are automatically removed from any blacklist if they are in it. +The `${values}` interpolation can be used in the `message` argument. + +```js +let schema = yup.mixed().oneOf(['jimmy', 42]); + +await schema.isValid(42); // => true +await schema.isValid('jimmy'); // => true +await schema.isValid(new Date()); // => false +``` + +#### `mixed.notOneOf(arrayOfValues: Array, message?: string | function)` + +Blacklist a set of values. Values added are automatically removed from any whitelist if they are in it. +The `${values}` interpolation can be used in the `message` argument. + +```js +let schema = yup.mixed().notOneOf(['jimmy', 42]); + +await schema.isValid(42); // => false +await schema.isValid(new Date()); // => true +``` + +#### `mixed.when(keys: string | Array, builder: object | (value, schema)=> Schema): Schema` + +Adjust the schema based on a sibling or sibling children fields. You can provide an object +literal where the key `is` is value or a matcher function, `then` provides the true schema and/or +`otherwise` for the failure condition. + +`is` conditions are strictly compared (`===`) if you want to use a different form of equality you +can provide a function like: `is: (value) => value == true`. + +Like joi you can also prefix properties with `$` to specify a property that is dependent +on `context` passed in by `validate()` or `isValid`. `when` conditions are additive. + +```js +let schema = object({ + isBig: boolean(), + count: number() + .when('isBig', { + is: true, // alternatively: (val) => val == true + then: yup.number().min(5), + otherwise: yup.number().min(0), + }) + .when('$other', (other, schema) => (other === 4 ? schema.max(6) : schema)), +}); + +await schema.validate(value, { context: { other: 4 } }); +``` + +You can also specify more than one dependent key, in which case each value will be spread as an argument. + +```js +let schema = object({ + isSpecial: boolean(), + isBig: boolean(), + count: number().when(['isBig', 'isSpecial'], { + is: true, // alternatively: (isBig, isSpecial) => isBig && isSpecial + then: yup.number().min(5), + otherwise: yup.number().min(0), + }), +}); + +await schema.validate({ + isBig: true, + isSpecial: true, + count: 10, +}); +``` + +Alternatively you can provide a function that returns a schema +(called with the value of the key and the current schema). + +```js +let schema = yup.object({ + isBig: yup.boolean(), + count: yup.number().when('isBig', (isBig, schema) => { + return isBig ? schema.min(5) : schema.min(0); + }), +}); + +await schema.validate({ isBig: false, count: 4 }); +``` + +#### `mixed.test(name: string, message: string | function, test: function): Schema` + +Adds a test function to the validation chain. Tests are run after any object is cast. +Many types have some tests built in, but you can create custom ones easily. +In order to allow asynchronous custom validations _all_ (or no) tests are run asynchronously. +A consequence of this is that test execution order cannot be guaranteed. + +All tests must provide a `name`, an error `message` and a validation function that must return +`true` or `false` or a `ValidationError`. To make a test async return a promise that resolves `true` +or `false` or a `ValidationError`. + +for the `message` argument you can provide a string which is will interpolate certain values +if specified using the `${param}` syntax. By default all test messages are passed a `path` value +which is valuable in nested schemas. + +the `test` function is called with the current `value`. For more advanced validations you can +use the alternate signature to provide more options (see below): + +```js +let jimmySchema = string().test( + 'is-jimmy', + '${path} is not Jimmy', + value => value === 'jimmy', +); + +// or make it async by returning a promise +let asyncJimmySchema = string().test( + 'is-jimmy', + '${path} is not Jimmy', + async (value) => (await fetch('/is-jimmy/' + value)).responseText === 'true', +}); + +await schema.isValid('jimmy'); // => true +await schema.isValid('john'); // => false +``` + +test functions are called with a special context, or `this` value, that exposes some useful metadata and functions. Note that to use the `this` context the test function must be a function expression (`function test(value) {}`), not an arrow function, since arrow functions have lexical context. + +- `this.path`: the string path of the current validation +- `this.schema`: the resolved schema object that the test is running against. +- `this.options`: the `options` object that validate() or isValid() was called with +- `this.parent`: in the case of nested schema, this is the value of the parent object +- `this.createError(Object: { path: String, message: String })`: create and return a + validation error. Useful for dynamically setting the `path`, or more likely, the error `message`. + If either option is omitted it will use the current path, or default message. + +#### `mixed.test(options: object): Schema` + +Alternative `test(..)` signature. `options` is an object containing some of the following options: + +```js +Options = { + // unique name identifying the test + name: string; + // test function, determines schema validity + test: (value: any) => boolean; + // the validation error message + message: string; + // values passed to message for interpolation + params: ?object; + // mark the test as exclusive, meaning only one of the same can be active at once + exclusive: boolean = false; +} +``` + +In the case of mixing exclusive and non-exclusive tests the following logic is used. +If a non-exclusive test is added to a schema with an exclusive test of the same name +the exclusive test is removed and further tests of the same name will be stacked. + +If an exclusive test is added to a schema with non-exclusive tests of the same name +the previous tests are removed and further tests of the same name will replace each other. + +```js +let max = 64; +let schema = yup.mixed().test({ + name: 'max', + exclusive: true, + params: { max }, + message: '${path} must be less than ${max} characters', + test: value => value == null || value.length <= max, +}); +``` + +#### `mixed.transform((currentValue: any, originalValue: any) => any): Schema` + +Adds a transformation to the transform chain. Transformations are central to the casting process, +default transforms for each type coerce values to the specific type (as verified by [`isType()`](mixedistypevalue)). +transforms are run before validations and only applied when `strict` is `true`. Some types have built in transformations. + +Transformations are useful for arbitrarily altering how the object is cast, **however, you should take care +not to mutate the passed in value.** Transforms are run sequentially so each `value` represents the +current state of the cast, you can use the `originalValue` param if you need to work on the raw initial value. + +```js +let schema = string().transform(function(value, originalvalue) { + return this.isType(value) && value !== null ? value.toUpperCase() : value; +}); + +schema.cast('jimmy'); // => 'JIMMY' +``` + +Each types will handle basic coercion of values to the proper type for you, but occasionally +you may want to adjust or refine the default behavior. For example, if you wanted to use a different +date parsing strategy than the default one you could do that with a transform. + +```js +module.exports = function(formats = 'MMM dd, yyyy') { + return date().transform(function(value, originalvalue) { + // check to see if the previous transform already parsed the date + if (this.isType(value)) return value; + + // the default coercion failed so lets try it with Moment.js instead + value = Moment(originalValue, formats); + + // if its valid return the date object, otherwise return an `InvalidDate` + return value.isValid() ? value.toDate() : new Date(''); + }); +}; +``` + +### string + +Define a string schema. Supports all the same methods as [`mixed`](#mixed). + +```js +let schema = yup.string(); + +await schema.isValid('hello'); // => true +``` + +By default, the `cast` logic of `string` is to call `toString` on the value if it exists. +empty values are not coerced (use `ensure()` to coerce empty values to empty strings). + +Failed casts return the input value. + +#### `string.required(message?: string | function): Schema` + +The same as the `mixed()` schema required, except that empty strings are also considered 'missing' values. + +#### `string.length(limit: number | Ref, message?: string | function): Schema` + +Set a required length for the string value. The `${length}` interpolation can be used in the `message` argument + +#### `string.min(limit: number | Ref, message?: string | function): Schema` + +Set a minimum length limit for the string value. The `${min}` interpolation can be used in the `message` argument + +#### `string.max(limit: number | Ref, message?: string | function): Schema` + +Set a maximum length limit for the string value. The `${max}` interpolation can be used in the `message` argument + +#### `string.matches(regex: Regex, message?: string | function): Schema` + +Provide an arbitrary `regex` to match the value against. + +```js +let schema = string().matches(/(hi|bye)/); + +await schema.isValid('hi'); // => true +await schema.isValid('nope'); // => false +``` + +#### `string.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schema` + +An alternate signature for `string.matches` with an options object. `excludeEmptyString`, when true, +short circuits the regex test when the value is an empty string + +```js +let schema = string().matches(/(hi|bye)/, { excludeEmptyString: true }); + +await schema.isValid(''); // => true +``` + +#### `string.email(message?: string | function): Schema` + +Validates the value as an email address via a regex. + +#### `string.url(message?: string | function): Schema` + +Validates the value as a valid URL via a regex. + +#### `string.ensure(): Schema` + +Transforms `undefined` and `null` values to an empty string along with +setting the `default` to an empty string. + +#### `string.trim(message?: string | function): Schema` + +Transforms string values by removing leading and trailing whitespace. If +`strict()` is set it will only validate that the value is trimmed. + +#### `string.lowercase(message?: string | function): Schema` + +Transforms the string value to lowercase. If `strict()` is set it +will only validate that the value is lowercase. + +#### `string.uppercase(message?: string | function): Schema` + +Transforms the string value to uppercase. If `strict()` is set it +will only validate that the value is uppercase. + +### number + +Define a number schema. Supports all the same methods as [`mixed`](#mixed). + +```js +let schema = yup.number(); + +await schema.isValid(10); // => true +``` + +The default `cast` logic of `number` is: [`parseFloat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat). + +Failed casts return `NaN`. + +#### `number.min(limit: number | Ref, message?: string | function): Schema` + +Set the minimum value allowed. The `${min}` interpolation can be used in the +`message` argument. + +#### `number.max(limit: number | Ref, message?: string | function): Schema` + +Set the maximum value allowed. The `${max}` interpolation can be used in the +`message` argument. + +#### `number.lessThan(max: number | Ref, message?: string | function): Schema` + +Value must be less than `max`. The `${less}` interpolation can be used in the +`message` argument. + +#### `number.moreThan(min: number | Ref, message?: string | function): Schema` + +Value must be strictly greater than `min`. The `${more}` interpolation can be used in the +`message` argument. + +#### `number.positive(message?: string | function): Schema` + +Value must be a positive number. + +#### `number.negative(message?: string | function): Schema` + +Value must be a negative number. + +#### `number.integer(message?: string | function): Schema` + +Validates that a number is an integer. + +#### `number.truncate(): Schema` + +Transformation that coerces the value to an integer by stripping off the digits +to the right of the decimal point. + +#### `number.round(type: 'floor' | 'ceil' | 'trunc' | 'round' = 'round'): Schema` + +Adjusts the value via the specified method of `Math` (defaults to 'round'). + +### boolean + +Define a boolean schema. Supports all the same methods as [`mixed`](#mixed). + +```js +let schema = yup.boolean(); + +await schema.isValid(true); // => true +``` + +### date + +Define a Date schema. By default ISO date strings will parse correctly, +for more robust parsing options see the extending schema types at the end of the readme. +Supports all the same methods as [`mixed`](#mixed). + +```js +let schema = yup.date(); + +await schema.isValid(new Date()); // => true +``` + +The default `cast` logic of `date` is pass the value to the `Date` constructor, failing that, it will attempt +to parse the date as an ISO date string. + +Failed casts return an invalid Date. + +#### `date.min(limit: Date | string | Ref, message?: string | function): Schema` + +Set the minimum date allowed. When a string is provided it will attempt to cast to a date first +and use the result as the limit. + +#### `date.max(limit: Date | string | Ref, message?: string | function): Schema` + +Set the maximum date allowed, When a string is provided it will attempt to cast to a date first +and use the result as the limit. + +### array + +Define an array schema. Arrays can be typed or not, When specifying the element type, `cast` and `isValid` +will apply to the elements as well. Options passed into `isValid` are passed also passed to child schemas. +Supports all the same methods as [`mixed`](#mixed). + +```js +let schema = yup.array().of(yup.number().min(2)); + +await schema.isValid([2, 3]); // => true +await schema.isValid([1, -24]); // => false + +schema.cast(['2', '3']); // => [2, 3] +``` + +You can also pass a subtype schema to the array constructor as a convenience. + +```js +array().of(yup.number()); +// or +array(yup.number()); +``` + +The default `cast` behavior for `array` is: [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) + +Failed casts return: `null`; + +#### `array.of(type: Schema): Schema` + +Specify the schema of array elements. `of()` is optional and when omitted the array schema will +not validate its contents. + +#### `array.required(message?: string | function): Schema` + +The same as the `mixed()` schema required, except that empty arrays are also considered 'missing' values. + +#### `array.min(limit: number | Ref, message?: string | function): Schema` + +Set a minimum length limit for the array. The `${min}` interpolation can be used in the `message` argument. + +#### `array.max(limit: number | Ref, message?: string | function): Schema` + +Set a maximum length limit for the array. The `${max}` interpolation can be used in the `message` argument. + +#### `array.ensure(): Schema` + +Ensures that the value is an array, by setting the default to `[]` and transforming `null` and `undefined` +values to an empty array as well. Any non-empty, non-array value will be wrapped in an array. + +```js +array() + .ensure() + .cast(null); // => [] +array() + .ensure() + .cast(1); // => [1] +array() + .ensure() + .cast([1]); // => [1] +``` + +#### `array.compact(rejector: (value) => boolean): Schema` + +Removes falsey values from the array. Providing a rejecter function lets you specify the rejection criteria yourself. + +```js +array() + .compact() + .cast(['', 1, 0, 4, false, null]); // => [1, 4] + +array() + .compact(function(v) { + return v == null; + }) + .cast(['', 1, 0, 4, false, null]); // => ['', 1, 0, 4, false] +``` + +### object + +Define an object schema. Options passed into `isValid` are also passed to child schemas. +Supports all the same methods as [`mixed`](#mixed). + +```js +yup.object().shape({ + name: string().required(), + age: number() + .required() + .positive() + .integer(), + email: string().email(), + website: string().url(), +}); +``` + +You can also pass a shape to the object constructor as a convenience. + +```js +object().shape({ + num: number(), +}); +// or +object({ + num: number(), +}); +``` + +The default `cast` behavior for `object` is: [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) + +Failed casts return: `null`; + +#### `object.shape(fields: object, noSortEdges?: Array<[string, string]>): Schema` + +Define the keys of the object and the schemas for said keys. + +Note that you can chain `shape` method, which acts like object extends, for example: + +```js +object({ + a: string(), + b: number(), +}).shape({ + b: string(), + c: number(), +}); +``` + +would be exactly the same as: + +```js +object({ + a: string(), + b: string(), + c: number(), +}); +``` + +#### `object.from(fromKey: string, toKey: string, alias: boolean = false): Schema` + +Transforms the specified key to a new key. If `alias` is `true` then the old key will be left. + +```js +let schema = object({ + myProp: mixed(), + Other: mixed(), +}) + .from('prop', 'myProp') + .from('other', 'Other', true); + +schema.cast({ prop: 5, other: 6 }); // => { myProp: 5, other: 6, Other: 6 } +``` + +#### `object.noUnknown(onlyKnownKeys: boolean = true, message?: string | function): Schema` + +Validate that the object value only contains keys specified in `shape`, pass `false` as the first +argument to disable the check. Restricting keys to known, also enables `stripUnknown` option, when not in strict mode. + +#### `object.camelCase(): Schema` + +Transforms all object keys to camelCase + +#### `object.constantCase(): Schema` + +Transforms all object keys to CONSTANT_CASE. + +## Extending Schema Types + +The simplest way to extend an existing type is just to cache a configured schema and use that through your application. + +```js +let yup = require('yup'); +let parseFormats = ['MMM dd, yyy']; +let invalidDate = new Date(''); + +module.exports = yup.date().transform(function(value, originalValue) { + if (this.isType(value)) return value; + // the default coercion transform failed so lets try it with Moment instead + value = Moment(originalValue, parseFormats); + return value.isValid() ? value.toDate() : invalidDate; +}); +``` + +Alternatively, each schema is a normal JavaScript constructor function that you can mutate or delegate to +using the normal patterns. Generally you should not inherit from `mixed` unless you know what you are doing, +better to think of it as an abstract class. The other types are fair game though. + +You should keep in mind some basic guidelines when extending schemas + +- never mutate an existing schema, always `clone()` and then mutate the new one before returning it. + Built-in methods like `test` and `transform` take care of this for you, so you can safely use them (see below) without worrying +- transforms should never mutate the `value` passed in, and should return an invalid object when one exists + (`NaN`, `InvalidDate`, etc) instead of `null` for bad values. +- by the time validations run the `value` is guaranteed to be the correct type, however if `nullable` is + set then `null` is a valid value for that type, so don't assume that a property or method exists on the value. + +**Adjust core Types** + +```js +let invalidDate = new Date(''); + +function parseDateFromFormats(formats, parseStrict) { + return this.transform(function(value, originalValue) { + if (this.isType(value)) return value; + + value = Moment(originalValue, formats, parseStrict); + + return value.isValid() ? value.toDate() : invalidDate; + }); +} + +// `addMethod` doesn't do anything special it's +// equivalent to: yup.date.prototype.format = parseDateFromFormats +yup.addMethod(yup.date, 'format', parseDateFromFormats); +``` + +**Creating new Types** + +Yup schema use the common constructor pattern for modeling inheritance. You can use any +utility or pattern that works with that pattern. The below demonstrates using the es6 class +syntax since its less verbose, but you absolutely aren't required to use it. + +```js +let DateSchema = yup.date; +let invalidDate = new Date(''); // our failed to coerce value + +class MomentDateSchemaType extends DateSchema { + constructor() { + super(); + this._validFormats = []; + + this.withMutation(() => { + this.transform(function(value, originalvalue) { + if (this.isType(value)) + // we have a valid value + return value; + return Moment(originalValue, this._validFormats, true); + }); + }); + } + + _typeCheck(value) { + return ( + super._typeCheck(value) || (moment.isMoment(value) && value.isValid()) + ); + } + + format(formats) { + if (!formats) throw new Error('must enter a valid format'); + let next = this.clone(); + next._validFormats = {}.concat(formats); + } +} + +let schema = new MomentDateSchemaType(); + +schema.format('YYYY-MM-DD').cast('It is 2012-05-25'); // => Fri May 25 2012 00:00:00 GMT-0400 (Eastern Daylight Time) +``` diff --git a/node_modules/yup/lib/Condition.js b/node_modules/yup/lib/Condition.js new file mode 100644 index 00000000..395700db --- /dev/null +++ b/node_modules/yup/lib/Condition.js @@ -0,0 +1,69 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _has = _interopRequireDefault(require("lodash/has")); + +var _isSchema = _interopRequireDefault(require("./util/isSchema")); + +var Condition = +/*#__PURE__*/ +function () { + function Condition(refs, options) { + this.refs = refs; + + if (typeof options === 'function') { + this.fn = options; + return; + } + + if (!(0, _has.default)(options, 'is')) throw new TypeError('`is:` is required for `when()` conditions'); + if (!options.then && !options.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions'); + var is = options.is, + then = options.then, + otherwise = options.otherwise; + var check = typeof is === 'function' ? is : function () { + for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + return values.every(function (value) { + return value === is; + }); + }; + + this.fn = function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var options = args.pop(); + var schema = args.pop(); + var branch = check.apply(void 0, args) ? then : otherwise; + if (!branch) return undefined; + if (typeof branch === 'function') return branch(schema); + return schema.concat(branch.resolve(options)); + }; + } + + var _proto = Condition.prototype; + + _proto.resolve = function resolve(base, options) { + var values = this.refs.map(function (ref) { + return ref.getValue(options); + }); + var schema = this.fn.apply(base, values.concat(base, options)); + if (schema === undefined || schema === base) return base; + if (!(0, _isSchema.default)(schema)) throw new TypeError('conditions must return a schema object'); + return schema.resolve(options); + }; + + return Condition; +}(); + +var _default = Condition; +exports.default = _default; +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/Lazy.js b/node_modules/yup/lib/Lazy.js new file mode 100644 index 00000000..155a78bc --- /dev/null +++ b/node_modules/yup/lib/Lazy.js @@ -0,0 +1,53 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _isSchema = _interopRequireDefault(require("./util/isSchema")); + +var Lazy = +/*#__PURE__*/ +function () { + function Lazy(mapFn) { + this._resolve = function (value, options) { + var schema = mapFn(value, options); + if (!(0, _isSchema.default)(schema)) throw new TypeError('lazy() functions must return a valid schema'); + return schema.resolve(options); + }; + } + + var _proto = Lazy.prototype; + + _proto.resolve = function resolve(options) { + return this._resolve(options.value, options); + }; + + _proto.cast = function cast(value, options) { + return this._resolve(value, options).cast(value, options); + }; + + _proto.validate = function validate(value, options) { + return this._resolve(value, options).validate(value, options); + }; + + _proto.validateSync = function validateSync(value, options) { + return this._resolve(value, options).validateSync(value, options); + }; + + _proto.validateAt = function validateAt(path, value, options) { + return this._resolve(value, options).validateAt(path, value, options); + }; + + _proto.validateSyncAt = function validateSyncAt(path, value, options) { + return this._resolve(value, options).validateSyncAt(path, value, options); + }; + + return Lazy; +}(); + +Lazy.prototype.__isYupSchema__ = true; +var _default = Lazy; +exports.default = _default; +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/Reference.js b/node_modules/yup/lib/Reference.js new file mode 100644 index 00000000..5be513a0 --- /dev/null +++ b/node_modules/yup/lib/Reference.js @@ -0,0 +1,76 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +var _propertyExpr = require("property-expr"); + +var prefixes = { + context: '$', + value: '.' +}; + +var Reference = +/*#__PURE__*/ +function () { + function Reference(key, options) { + if (options === void 0) { + options = {}; + } + + if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key); + this.key = key.trim(); + if (key === '') throw new TypeError('ref must be a non-empty string'); + this.isContext = this.key[0] === prefixes.context; + this.isValue = this.key[0] === prefixes.value; + this.isSibling = !this.isContext && !this.isValue; + var prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : ''; + this.path = this.key.slice(prefix.length); + this.getter = this.path && (0, _propertyExpr.getter)(this.path, true); + this.map = options.map; + } + + var _proto = Reference.prototype; + + _proto.getValue = function getValue(options) { + var result = this.isContext ? options.context : this.isValue ? options.value : options.parent; + if (this.getter) result = this.getter(result || {}); + if (this.map) result = this.map(result); + return result; + }; + + _proto.cast = function cast(value, options) { + return this.getValue((0, _extends2.default)({}, options, { + value: value + })); + }; + + _proto.resolve = function resolve() { + return this; + }; + + _proto.describe = function describe() { + return { + type: 'ref', + key: this.key + }; + }; + + _proto.toString = function toString() { + return "Ref(" + this.key + ")"; + }; + + Reference.isRef = function isRef(value) { + return value && value.__isYupRef; + }; + + return Reference; +}(); + +exports.default = Reference; +Reference.prototype.__isYupRef = true; +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/ValidationError.js b/node_modules/yup/lib/ValidationError.js new file mode 100644 index 00000000..03e73235 --- /dev/null +++ b/node_modules/yup/lib/ValidationError.js @@ -0,0 +1,55 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = ValidationError; + +var _printValue = _interopRequireDefault(require("./util/printValue")); + +var strReg = /\$\{\s*(\w+)\s*\}/g; + +var replace = function replace(str) { + return function (params) { + return str.replace(strReg, function (_, key) { + return (0, _printValue.default)(params[key]); + }); + }; +}; + +function ValidationError(errors, value, field, type) { + var _this = this; + + this.name = 'ValidationError'; + this.value = value; + this.path = field; + this.type = type; + this.errors = []; + this.inner = []; + if (errors) [].concat(errors).forEach(function (err) { + _this.errors = _this.errors.concat(err.errors || err); + if (err.inner) _this.inner = _this.inner.concat(err.inner.length ? err.inner : err); + }); + this.message = this.errors.length > 1 ? this.errors.length + " errors occurred" : this.errors[0]; + if (Error.captureStackTrace) Error.captureStackTrace(this, ValidationError); +} + +ValidationError.prototype = Object.create(Error.prototype); +ValidationError.prototype.constructor = ValidationError; + +ValidationError.isError = function (err) { + return err && err.name === 'ValidationError'; +}; + +ValidationError.formatError = function (message, params) { + if (typeof message === 'string') message = replace(message); + + var fn = function fn(params) { + params.path = params.label || params.path || 'this'; + return typeof message === 'function' ? message(params) : message; + }; + + return arguments.length === 1 ? fn : fn(params); +}; + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/array.js b/node_modules/yup/lib/array.js new file mode 100644 index 00000000..3608ae79 --- /dev/null +++ b/node_modules/yup/lib/array.js @@ -0,0 +1,202 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose")); + +var _inherits = _interopRequireDefault(require("./util/inherits")); + +var _isAbsent = _interopRequireDefault(require("./util/isAbsent")); + +var _isSchema = _interopRequireDefault(require("./util/isSchema")); + +var _makePath = _interopRequireDefault(require("./util/makePath")); + +var _printValue = _interopRequireDefault(require("./util/printValue")); + +var _mixed = _interopRequireDefault(require("./mixed")); + +var _locale = require("./locale"); + +var _runValidations = _interopRequireWildcard(require("./util/runValidations")); + +function _templateObject() { + var data = (0, _taggedTemplateLiteralLoose2.default)(["", "[", "]"]); + + _templateObject = function _templateObject() { + return data; + }; + + return data; +} + +var _default = ArraySchema; +exports.default = _default; + +function ArraySchema(type) { + var _this = this; + + if (!(this instanceof ArraySchema)) return new ArraySchema(type); + + _mixed.default.call(this, { + type: 'array' + }); // `undefined` specifically means uninitialized, as opposed to + // "no subtype" + + + this._subType = undefined; + this.withMutation(function () { + _this.transform(function (values) { + if (typeof values === 'string') try { + values = JSON.parse(values); + } catch (err) { + values = null; + } + return this.isType(values) ? values : null; + }); + + if (type) _this.of(type); + }); +} + +(0, _inherits.default)(ArraySchema, _mixed.default, { + _typeCheck: function _typeCheck(v) { + return Array.isArray(v); + }, + _cast: function _cast(_value, _opts) { + var _this2 = this; + + var value = _mixed.default.prototype._cast.call(this, _value, _opts); //should ignore nulls here + + + if (!this._typeCheck(value) || !this._subType) return value; + var isChanged = false; + var castArray = value.map(function (v) { + var castElement = _this2._subType.cast(v, _opts); + + if (castElement !== v) { + isChanged = true; + } + + return castElement; + }); + return isChanged ? castArray : value; + }, + _validate: function _validate(_value, options) { + var _this3 = this; + + if (options === void 0) { + options = {}; + } + + var errors = []; + var sync = options.sync; + var path = options.path; + var subType = this._subType; + + var endEarly = this._option('abortEarly', options); + + var recursive = this._option('recursive', options); + + var originalValue = options.originalValue != null ? options.originalValue : _value; + return _mixed.default.prototype._validate.call(this, _value, options).catch((0, _runValidations.propagateErrors)(endEarly, errors)).then(function (value) { + if (!recursive || !subType || !_this3._typeCheck(value)) { + if (errors.length) throw errors[0]; + return value; + } + + originalValue = originalValue || value; + var validations = value.map(function (item, idx) { + var path = (0, _makePath.default)(_templateObject(), options.path, idx); // object._validate note for isStrict explanation + + var innerOptions = (0, _extends2.default)({}, options, { + path: path, + strict: true, + parent: value, + originalValue: originalValue[idx] + }); + if (subType.validate) return subType.validate(item, innerOptions); + return true; + }); + return (0, _runValidations.default)({ + sync: sync, + path: path, + value: value, + errors: errors, + endEarly: endEarly, + validations: validations + }); + }); + }, + _isPresent: function _isPresent(value) { + return _mixed.default.prototype._cast.call(this, value) && value.length > 0; + }, + of: function of(schema) { + var next = this.clone(); + if (schema !== false && !(0, _isSchema.default)(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema, or `false` to negate a current sub-schema. ' + 'not: ' + (0, _printValue.default)(schema)); + next._subType = schema; + return next; + }, + min: function min(_min, message) { + message = message || _locale.array.min; + return this.test({ + message: message, + name: 'min', + exclusive: true, + params: { + min: _min + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value.length >= this.resolve(_min); + } + }); + }, + max: function max(_max, message) { + message = message || _locale.array.max; + return this.test({ + message: message, + name: 'max', + exclusive: true, + params: { + max: _max + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value.length <= this.resolve(_max); + } + }); + }, + ensure: function ensure() { + var _this4 = this; + + return this.default(function () { + return []; + }).transform(function (val) { + if (_this4.isType(val)) return val; + return val === null ? [] : [].concat(val); + }); + }, + compact: function compact(rejector) { + var reject = !rejector ? function (v) { + return !!v; + } : function (v, i, a) { + return !rejector(v, i, a); + }; + return this.transform(function (values) { + return values != null ? values.filter(reject) : values; + }); + }, + describe: function describe() { + var base = _mixed.default.prototype.describe.call(this); + + if (this._subType) base.innerType = this._subType.describe(); + return base; + } +}); +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/boolean.js b/node_modules/yup/lib/boolean.js new file mode 100644 index 00000000..9315e350 --- /dev/null +++ b/node_modules/yup/lib/boolean.js @@ -0,0 +1,42 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _inherits = _interopRequireDefault(require("./util/inherits")); + +var _mixed = _interopRequireDefault(require("./mixed")); + +var _default = BooleanSchema; +exports.default = _default; + +function BooleanSchema() { + var _this = this; + + if (!(this instanceof BooleanSchema)) return new BooleanSchema(); + + _mixed.default.call(this, { + type: 'boolean' + }); + + this.withMutation(function () { + _this.transform(function (value) { + if (!this.isType(value)) { + if (/^(true|1)$/i.test(value)) return true; + if (/^(false|0)$/i.test(value)) return false; + } + + return value; + }); + }); +} + +(0, _inherits.default)(BooleanSchema, _mixed.default, { + _typeCheck: function _typeCheck(v) { + if (v instanceof Boolean) v = v.valueOf(); + return typeof v === 'boolean'; + } +}); +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/date.js b/node_modules/yup/lib/date.js new file mode 100644 index 00000000..9a303280 --- /dev/null +++ b/node_modules/yup/lib/date.js @@ -0,0 +1,100 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _mixed = _interopRequireDefault(require("./mixed")); + +var _inherits = _interopRequireDefault(require("./util/inherits")); + +var _isodate = _interopRequireDefault(require("./util/isodate")); + +var _locale = require("./locale"); + +var _isAbsent = _interopRequireDefault(require("./util/isAbsent")); + +var _Reference = _interopRequireDefault(require("./Reference")); + +var invalidDate = new Date(''); + +var isDate = function isDate(obj) { + return Object.prototype.toString.call(obj) === '[object Date]'; +}; + +var _default = DateSchema; +exports.default = _default; + +function DateSchema() { + var _this = this; + + if (!(this instanceof DateSchema)) return new DateSchema(); + + _mixed.default.call(this, { + type: 'date' + }); + + this.withMutation(function () { + _this.transform(function (value) { + if (this.isType(value)) return value; + value = (0, _isodate.default)(value); + return value ? new Date(value) : invalidDate; + }); + }); +} + +(0, _inherits.default)(DateSchema, _mixed.default, { + _typeCheck: function _typeCheck(v) { + return isDate(v) && !isNaN(v.getTime()); + }, + min: function min(_min, message) { + if (message === void 0) { + message = _locale.date.min; + } + + var limit = _min; + + if (!_Reference.default.isRef(limit)) { + limit = this.cast(_min); + if (!this._typeCheck(limit)) throw new TypeError('`min` must be a Date or a value that can be `cast()` to a Date'); + } + + return this.test({ + message: message, + name: 'min', + exclusive: true, + params: { + min: _min + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value >= this.resolve(limit); + } + }); + }, + max: function max(_max, message) { + if (message === void 0) { + message = _locale.date.max; + } + + var limit = _max; + + if (!_Reference.default.isRef(limit)) { + limit = this.cast(_max); + if (!this._typeCheck(limit)) throw new TypeError('`max` must be a Date or a value that can be `cast()` to a Date'); + } + + return this.test({ + message: message, + name: 'max', + exclusive: true, + params: { + max: _max + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value <= this.resolve(limit); + } + }); + } +}); +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/index.js b/node_modules/yup/lib/index.js new file mode 100644 index 00000000..018d1442 --- /dev/null +++ b/node_modules/yup/lib/index.js @@ -0,0 +1,76 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.addMethod = addMethod; +exports.lazy = exports.ref = exports.boolean = void 0; + +var _mixed = _interopRequireDefault(require("./mixed")); + +exports.mixed = _mixed.default; + +var _boolean = _interopRequireDefault(require("./boolean")); + +exports.bool = _boolean.default; + +var _string = _interopRequireDefault(require("./string")); + +exports.string = _string.default; + +var _number = _interopRequireDefault(require("./number")); + +exports.number = _number.default; + +var _date = _interopRequireDefault(require("./date")); + +exports.date = _date.default; + +var _object = _interopRequireDefault(require("./object")); + +exports.object = _object.default; + +var _array = _interopRequireDefault(require("./array")); + +exports.array = _array.default; + +var _Reference = _interopRequireDefault(require("./Reference")); + +var _Lazy = _interopRequireDefault(require("./Lazy")); + +var _ValidationError = _interopRequireDefault(require("./ValidationError")); + +exports.ValidationError = _ValidationError.default; + +var _reach = _interopRequireDefault(require("./util/reach")); + +exports.reach = _reach.default; + +var _isSchema = _interopRequireDefault(require("./util/isSchema")); + +exports.isSchema = _isSchema.default; + +var _setLocale = _interopRequireDefault(require("./setLocale")); + +exports.setLocale = _setLocale.default; +var boolean = _boolean.default; +exports.boolean = boolean; + +var ref = function ref(key, options) { + return new _Reference.default(key, options); +}; + +exports.ref = ref; + +var lazy = function lazy(fn) { + return new _Lazy.default(fn); +}; + +exports.lazy = lazy; + +function addMethod(schemaType, name, fn) { + if (!schemaType || !(0, _isSchema.default)(schemaType.prototype)) throw new TypeError('You must provide a yup schema constructor function'); + if (typeof name !== 'string') throw new TypeError('A Method name must be provided'); + if (typeof fn !== 'function') throw new TypeError('Method function must be provided'); + schemaType.prototype[name] = fn; +} \ No newline at end of file diff --git a/node_modules/yup/lib/locale.js b/node_modules/yup/lib/locale.js new file mode 100644 index 00000000..deff7415 --- /dev/null +++ b/node_modules/yup/lib/locale.js @@ -0,0 +1,79 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = exports.array = exports.object = exports.boolean = exports.date = exports.number = exports.string = exports.mixed = void 0; + +var _printValue = _interopRequireDefault(require("./util/printValue")); + +var mixed = { + default: '${path} is invalid', + required: '${path} is a required field', + oneOf: '${path} must be one of the following values: ${values}', + notOneOf: '${path} must not be one of the following values: ${values}', + notType: function notType(_ref) { + var path = _ref.path, + type = _ref.type, + value = _ref.value, + originalValue = _ref.originalValue; + var isCast = originalValue != null && originalValue !== value; + var msg = path + " must be a `" + type + "` type, " + ("but the final value was: `" + (0, _printValue.default)(value, true) + "`") + (isCast ? " (cast from the value `" + (0, _printValue.default)(originalValue, true) + "`)." : '.'); + + if (value === null) { + msg += "\n If \"null\" is intended as an empty value be sure to mark the schema as `.nullable()`"; + } + + return msg; + } +}; +exports.mixed = mixed; +var string = { + length: '${path} must be exactly ${length} characters', + min: '${path} must be at least ${min} characters', + max: '${path} must be at most ${max} characters', + matches: '${path} must match the following: "${regex}"', + email: '${path} must be a valid email', + url: '${path} must be a valid URL', + trim: '${path} must be a trimmed string', + lowercase: '${path} must be a lowercase string', + uppercase: '${path} must be a upper case string' +}; +exports.string = string; +var number = { + min: '${path} must be greater than or equal to ${min}', + max: '${path} must be less than or equal to ${max}', + lessThan: '${path} must be less than ${less}', + moreThan: '${path} must be greater than ${more}', + notEqual: '${path} must be not equal to ${notEqual}', + positive: '${path} must be a positive number', + negative: '${path} must be a negative number', + integer: '${path} must be an integer' +}; +exports.number = number; +var date = { + min: '${path} field must be later than ${min}', + max: '${path} field must be at earlier than ${max}' +}; +exports.date = date; +var boolean = {}; +exports.boolean = boolean; +var object = { + noUnknown: '${path} field cannot have keys not specified in the object shape' +}; +exports.object = object; +var array = { + min: '${path} field must have at least ${min} items', + max: '${path} field must have less than or equal to ${max} items' +}; +exports.array = array; +var _default = { + mixed: mixed, + string: string, + number: number, + date: date, + object: object, + array: array, + boolean: boolean +}; +exports.default = _default; \ No newline at end of file diff --git a/node_modules/yup/lib/mixed.js b/node_modules/yup/lib/mixed.js new file mode 100644 index 00000000..6bc94e5e --- /dev/null +++ b/node_modules/yup/lib/mixed.js @@ -0,0 +1,583 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = SchemaType; + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +var _has = _interopRequireDefault(require("lodash/has")); + +var _cloneDeepWith = _interopRequireDefault(require("lodash/cloneDeepWith")); + +var _toArray2 = _interopRequireDefault(require("lodash/toArray")); + +var _locale = require("./locale"); + +var _Condition = _interopRequireDefault(require("./Condition")); + +var _runValidations = _interopRequireDefault(require("./util/runValidations")); + +var _prependDeep = _interopRequireDefault(require("./util/prependDeep")); + +var _isSchema = _interopRequireDefault(require("./util/isSchema")); + +var _createValidation = _interopRequireDefault(require("./util/createValidation")); + +var _printValue = _interopRequireDefault(require("./util/printValue")); + +var _Reference = _interopRequireDefault(require("./Reference")); + +var _reach = require("./util/reach"); + +var RefSet = +/*#__PURE__*/ +function () { + function RefSet() { + this.list = new Set(); + this.refs = new Map(); + } + + var _proto = RefSet.prototype; + + _proto.toArray = function toArray() { + return (0, _toArray2.default)(this.list).concat((0, _toArray2.default)(this.refs.values())); + }; + + _proto.add = function add(value) { + _Reference.default.isRef(value) ? this.refs.set(value.key, value) : this.list.add(value); + }; + + _proto.delete = function _delete(value) { + _Reference.default.isRef(value) ? this.refs.delete(value.key, value) : this.list.delete(value); + }; + + _proto.has = function has(value, resolve) { + if (this.list.has(value)) return true; + var item, + values = this.refs.values(); + + while (item = values.next(), !item.done) { + if (resolve(item.value) === value) return true; + } + + return false; + }; + + return RefSet; +}(); + +function SchemaType(options) { + var _this = this; + + if (options === void 0) { + options = {}; + } + + if (!(this instanceof SchemaType)) return new SchemaType(); + this._deps = []; + this._conditions = []; + this._options = { + abortEarly: true, + recursive: true + }; + this._exclusive = Object.create(null); + this._whitelist = new RefSet(); + this._blacklist = new RefSet(); + this.tests = []; + this.transforms = []; + this.withMutation(function () { + _this.typeError(_locale.mixed.notType); + }); + if ((0, _has.default)(options, 'default')) this._defaultDefault = options.default; + this._type = options.type || 'mixed'; +} + +var proto = SchemaType.prototype = { + __isYupSchema__: true, + constructor: SchemaType, + clone: function clone() { + var _this2 = this; + + if (this._mutate) return this; // if the nested value is a schema we can skip cloning, since + // they are already immutable + + return (0, _cloneDeepWith.default)(this, function (value) { + if ((0, _isSchema.default)(value) && value !== _this2) return value; + }); + }, + label: function label(_label) { + var next = this.clone(); + next._label = _label; + return next; + }, + meta: function meta(obj) { + if (arguments.length === 0) return this._meta; + var next = this.clone(); + next._meta = (0, _extends2.default)(next._meta || {}, obj); + return next; + }, + withMutation: function withMutation(fn) { + var before = this._mutate; + this._mutate = true; + var result = fn(this); + this._mutate = before; + return result; + }, + concat: function concat(schema) { + if (!schema || schema === this) return this; + if (schema._type !== this._type && this._type !== 'mixed') throw new TypeError("You cannot `concat()` schema's of different types: " + this._type + " and " + schema._type); + var next = (0, _prependDeep.default)(schema.clone(), this); // new undefined default is overriden by old non-undefined one, revert + + if ((0, _has.default)(schema, '_default')) next._default = schema._default; + next.tests = this.tests; + next._exclusive = this._exclusive; // manually add the new tests to ensure + // the deduping logic is consistent + + next.withMutation(function (next) { + schema.tests.forEach(function (fn) { + next.test(fn.OPTIONS); + }); + }); + return next; + }, + isType: function isType(v) { + if (this._nullable && v === null) return true; + return !this._typeCheck || this._typeCheck(v); + }, + resolve: function resolve(options) { + var schema = this; + + if (schema._conditions.length) { + var conditions = schema._conditions; + schema = schema.clone(); + schema._conditions = []; + schema = conditions.reduce(function (schema, condition) { + return condition.resolve(schema, options); + }, schema); + schema = schema.resolve(options); + } + + return schema; + }, + cast: function cast(value, options) { + if (options === void 0) { + options = {}; + } + + var resolvedSchema = this.resolve((0, _extends2.default)({}, options, { + value: value + })); + + var result = resolvedSchema._cast(value, options); + + if (value !== undefined && options.assert !== false && resolvedSchema.isType(result) !== true) { + var formattedValue = (0, _printValue.default)(value); + var formattedResult = (0, _printValue.default)(result); + throw new TypeError("The value of " + (options.path || 'field') + " could not be cast to a value " + ("that satisfies the schema type: \"" + resolvedSchema._type + "\". \n\n") + ("attempted value: " + formattedValue + " \n") + (formattedResult !== formattedValue ? "result of cast: " + formattedResult : '')); + } + + return result; + }, + _cast: function _cast(rawValue) { + var _this3 = this; + + var value = rawValue === undefined ? rawValue : this.transforms.reduce(function (value, fn) { + return fn.call(_this3, value, rawValue); + }, rawValue); + + if (value === undefined && (0, _has.default)(this, '_default')) { + value = this.default(); + } + + return value; + }, + _validate: function _validate(_value, options) { + var _this4 = this; + + if (options === void 0) { + options = {}; + } + + var value = _value; + var originalValue = options.originalValue != null ? options.originalValue : _value; + + var isStrict = this._option('strict', options); + + var endEarly = this._option('abortEarly', options); + + var sync = options.sync; + var path = options.path; + var label = this._label; + + if (!isStrict) { + value = this._cast(value, (0, _extends2.default)({ + assert: false + }, options)); + } // value is cast, we can check if it meets type requirements + + + var validationParams = { + value: value, + path: path, + schema: this, + options: options, + label: label, + originalValue: originalValue, + sync: sync + }; + var initialTests = []; + if (this._typeError) initialTests.push(this._typeError(validationParams)); + if (this._whitelistError) initialTests.push(this._whitelistError(validationParams)); + if (this._blacklistError) initialTests.push(this._blacklistError(validationParams)); + return (0, _runValidations.default)({ + validations: initialTests, + endEarly: endEarly, + value: value, + path: path, + sync: sync + }).then(function (value) { + return (0, _runValidations.default)({ + path: path, + sync: sync, + value: value, + endEarly: endEarly, + validations: _this4.tests.map(function (fn) { + return fn(validationParams); + }) + }); + }); + }, + validate: function validate(value, options) { + if (options === void 0) { + options = {}; + } + + var schema = this.resolve((0, _extends2.default)({}, options, { + value: value + })); + return schema._validate(value, options); + }, + validateSync: function validateSync(value, options) { + if (options === void 0) { + options = {}; + } + + var schema = this.resolve((0, _extends2.default)({}, options, { + value: value + })); + var result, err; + + schema._validate(value, (0, _extends2.default)({}, options, { + sync: true + })).then(function (r) { + return result = r; + }).catch(function (e) { + return err = e; + }); + + if (err) throw err; + return result; + }, + isValid: function isValid(value, options) { + return this.validate(value, options).then(function () { + return true; + }).catch(function (err) { + if (err.name === 'ValidationError') return false; + throw err; + }); + }, + isValidSync: function isValidSync(value, options) { + try { + this.validateSync(value, options); + return true; + } catch (err) { + if (err.name === 'ValidationError') return false; + throw err; + } + }, + getDefault: function getDefault(options) { + if (options === void 0) { + options = {}; + } + + var schema = this.resolve(options); + return schema.default(); + }, + default: function _default(def) { + if (arguments.length === 0) { + var defaultValue = (0, _has.default)(this, '_default') ? this._default : this._defaultDefault; + return typeof defaultValue === 'function' ? defaultValue.call(this) : (0, _cloneDeepWith.default)(defaultValue); + } + + var next = this.clone(); + next._default = def; + return next; + }, + strict: function strict(isStrict) { + if (isStrict === void 0) { + isStrict = true; + } + + var next = this.clone(); + next._options.strict = isStrict; + return next; + }, + _isPresent: function _isPresent(value) { + return value != null; + }, + required: function required(message) { + if (message === void 0) { + message = _locale.mixed.required; + } + + return this.test({ + message: message, + name: 'required', + exclusive: true, + test: function test(value) { + return this.schema._isPresent(value); + } + }); + }, + notRequired: function notRequired() { + var next = this.clone(); + next.tests = next.tests.filter(function (test) { + return test.OPTIONS.name !== 'required'; + }); + return next; + }, + nullable: function nullable(isNullable) { + if (isNullable === void 0) { + isNullable = true; + } + + var next = this.clone(); + next._nullable = isNullable; + return next; + }, + transform: function transform(fn) { + var next = this.clone(); + next.transforms.push(fn); + return next; + }, + + /** + * Adds a test function to the schema's queue of tests. + * tests can be exclusive or non-exclusive. + * + * - exclusive tests, will replace any existing tests of the same name. + * - non-exclusive: can be stacked + * + * If a non-exclusive test is added to a schema with an exclusive test of the same name + * the exclusive test is removed and further tests of the same name will be stacked. + * + * If an exclusive test is added to a schema with non-exclusive tests of the same name + * the previous tests are removed and further tests of the same name will replace each other. + */ + test: function test() { + var opts; + + if (arguments.length === 1) { + if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'function') { + opts = { + test: arguments.length <= 0 ? undefined : arguments[0] + }; + } else { + opts = arguments.length <= 0 ? undefined : arguments[0]; + } + } else if (arguments.length === 2) { + opts = { + name: arguments.length <= 0 ? undefined : arguments[0], + test: arguments.length <= 1 ? undefined : arguments[1] + }; + } else { + opts = { + name: arguments.length <= 0 ? undefined : arguments[0], + message: arguments.length <= 1 ? undefined : arguments[1], + test: arguments.length <= 2 ? undefined : arguments[2] + }; + } + + if (opts.message === undefined) opts.message = _locale.mixed.default; + if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters'); + var next = this.clone(); + var validate = (0, _createValidation.default)(opts); + var isExclusive = opts.exclusive || opts.name && next._exclusive[opts.name] === true; + + if (opts.exclusive && !opts.name) { + throw new TypeError('Exclusive tests must provide a unique `name` identifying the test'); + } + + next._exclusive[opts.name] = !!opts.exclusive; + next.tests = next.tests.filter(function (fn) { + if (fn.OPTIONS.name === opts.name) { + if (isExclusive) return false; + if (fn.OPTIONS.test === validate.OPTIONS.test) return false; + } + + return true; + }); + next.tests.push(validate); + return next; + }, + when: function when(keys, options) { + if (arguments.length === 1) { + options = keys; + keys = '.'; + } + + var next = this.clone(), + deps = [].concat(keys).map(function (key) { + return new _Reference.default(key); + }); + deps.forEach(function (dep) { + if (dep.isSibling) next._deps.push(dep.key); + }); + + next._conditions.push(new _Condition.default(deps, options)); + + return next; + }, + typeError: function typeError(message) { + var next = this.clone(); + next._typeError = (0, _createValidation.default)({ + message: message, + name: 'typeError', + test: function test(value) { + if (value !== undefined && !this.schema.isType(value)) return this.createError({ + params: { + type: this.schema._type + } + }); + return true; + } + }); + return next; + }, + oneOf: function oneOf(enums, message) { + if (message === void 0) { + message = _locale.mixed.oneOf; + } + + var next = this.clone(); + enums.forEach(function (val) { + next._whitelist.add(val); + + next._blacklist.delete(val); + }); + next._whitelistError = (0, _createValidation.default)({ + message: message, + name: 'oneOf', + test: function test(value) { + if (value === undefined) return true; + var valids = this.schema._whitelist; + return valids.has(value, this.resolve) ? true : this.createError({ + params: { + values: valids.toArray().join(', ') + } + }); + } + }); + return next; + }, + notOneOf: function notOneOf(enums, message) { + if (message === void 0) { + message = _locale.mixed.notOneOf; + } + + var next = this.clone(); + enums.forEach(function (val) { + next._blacklist.add(val); + + next._whitelist.delete(val); + }); + next._blacklistError = (0, _createValidation.default)({ + message: message, + name: 'notOneOf', + test: function test(value) { + var invalids = this.schema._blacklist; + if (invalids.has(value, this.resolve)) return this.createError({ + params: { + values: invalids.toArray().join(', ') + } + }); + return true; + } + }); + return next; + }, + strip: function strip(_strip) { + if (_strip === void 0) { + _strip = true; + } + + var next = this.clone(); + next._strip = _strip; + return next; + }, + _option: function _option(key, overrides) { + return (0, _has.default)(overrides, key) ? overrides[key] : this._options[key]; + }, + describe: function describe() { + var next = this.clone(); + return { + type: next._type, + meta: next._meta, + label: next._label, + tests: next.tests.map(function (fn) { + return { + name: fn.OPTIONS.name, + params: fn.OPTIONS.params + }; + }).filter(function (n, idx, list) { + return list.findIndex(function (c) { + return c.name === n.name; + }) === idx; + }) + }; + } +}; +var _arr = ['validate', 'validateSync']; + +var _loop = function _loop() { + var method = _arr[_i]; + + proto[method + "At"] = function (path, value, options) { + if (options === void 0) { + options = {}; + } + + var _getIn = (0, _reach.getIn)(this, path, value, options.context), + parent = _getIn.parent, + parentPath = _getIn.parentPath, + schema = _getIn.schema; + + return schema[method](parent && parent[parentPath], (0, _extends2.default)({}, options, { + parent: parent, + path: path + })); + }; +}; + +for (var _i = 0; _i < _arr.length; _i++) { + _loop(); +} + +var _arr2 = ['equals', 'is']; + +for (var _i2 = 0; _i2 < _arr2.length; _i2++) { + var alias = _arr2[_i2]; + proto[alias] = proto.oneOf; +} + +var _arr3 = ['not', 'nope']; + +for (var _i3 = 0; _i3 < _arr3.length; _i3++) { + var _alias = _arr3[_i3]; + proto[_alias] = proto.notOneOf; +} + +proto.optional = proto.notRequired; +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/number.js b/node_modules/yup/lib/number.js new file mode 100644 index 00000000..a5204c94 --- /dev/null +++ b/node_modules/yup/lib/number.js @@ -0,0 +1,164 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = NumberSchema; + +var _inherits = _interopRequireDefault(require("./util/inherits")); + +var _mixed = _interopRequireDefault(require("./mixed")); + +var _locale = require("./locale"); + +var _isAbsent = _interopRequireDefault(require("./util/isAbsent")); + +var isNaN = function isNaN(value) { + return value != +value; +}; + +var isInteger = function isInteger(val) { + return (0, _isAbsent.default)(val) || val === (val | 0); +}; + +function NumberSchema() { + var _this = this; + + if (!(this instanceof NumberSchema)) return new NumberSchema(); + + _mixed.default.call(this, { + type: 'number' + }); + + this.withMutation(function () { + _this.transform(function (value) { + var parsed = value; + + if (typeof parsed === 'string') { + parsed = parsed.replace(/\s/g, ''); + if (parsed === '') return NaN; // don't use parseFloat to avoid positives on alpha-numeric strings + + parsed = +parsed; + } + + if (this.isType(parsed)) return parsed; + return parseFloat(parsed); + }); + }); +} + +(0, _inherits.default)(NumberSchema, _mixed.default, { + _typeCheck: function _typeCheck(value) { + if (value instanceof Number) value = value.valueOf(); + return typeof value === 'number' && !isNaN(value); + }, + min: function min(_min, message) { + if (message === void 0) { + message = _locale.number.min; + } + + return this.test({ + message: message, + name: 'min', + exclusive: true, + params: { + min: _min + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value >= this.resolve(_min); + } + }); + }, + max: function max(_max, message) { + if (message === void 0) { + message = _locale.number.max; + } + + return this.test({ + message: message, + name: 'max', + exclusive: true, + params: { + max: _max + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value <= this.resolve(_max); + } + }); + }, + lessThan: function lessThan(less, message) { + if (message === void 0) { + message = _locale.number.lessThan; + } + + return this.test({ + message: message, + name: 'max', + exclusive: true, + params: { + less: less + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value < this.resolve(less); + } + }); + }, + moreThan: function moreThan(more, message) { + if (message === void 0) { + message = _locale.number.moreThan; + } + + return this.test({ + message: message, + name: 'min', + exclusive: true, + params: { + more: more + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value > this.resolve(more); + } + }); + }, + positive: function positive(msg) { + if (msg === void 0) { + msg = _locale.number.positive; + } + + return this.moreThan(0, msg); + }, + negative: function negative(msg) { + if (msg === void 0) { + msg = _locale.number.negative; + } + + return this.lessThan(0, msg); + }, + integer: function integer(message) { + if (message === void 0) { + message = _locale.number.integer; + } + + return this.test({ + name: 'integer', + message: message, + test: isInteger + }); + }, + truncate: function truncate() { + return this.transform(function (value) { + return !(0, _isAbsent.default)(value) ? value | 0 : value; + }); + }, + round: function round(method) { + var avail = ['ceil', 'floor', 'round', 'trunc']; + method = method && method.toLowerCase() || 'round'; // this exists for symemtry with the new Math.trunc + + if (method === 'trunc') return this.truncate(); + if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', ')); + return this.transform(function (value) { + return !(0, _isAbsent.default)(value) ? Math[method](value) : value; + }); + } +}); +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/object.js b/node_modules/yup/lib/object.js new file mode 100644 index 00000000..2071e93c --- /dev/null +++ b/node_modules/yup/lib/object.js @@ -0,0 +1,333 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = ObjectSchema; + +var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose")); + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +var _has = _interopRequireDefault(require("lodash/has")); + +var _snakeCase2 = _interopRequireDefault(require("lodash/snakeCase")); + +var _camelCase2 = _interopRequireDefault(require("lodash/camelCase")); + +var _mapKeys = _interopRequireDefault(require("lodash/mapKeys")); + +var _mapValues = _interopRequireDefault(require("lodash/mapValues")); + +var _propertyExpr = require("property-expr"); + +var _mixed = _interopRequireDefault(require("./mixed")); + +var _locale = require("./locale.js"); + +var _sortFields = _interopRequireDefault(require("./util/sortFields")); + +var _sortByKeyOrder = _interopRequireDefault(require("./util/sortByKeyOrder")); + +var _inherits = _interopRequireDefault(require("./util/inherits")); + +var _makePath = _interopRequireDefault(require("./util/makePath")); + +var _runValidations = _interopRequireWildcard(require("./util/runValidations")); + +function _templateObject2() { + var data = (0, _taggedTemplateLiteralLoose2.default)(["", ".", ""]); + + _templateObject2 = function _templateObject2() { + return data; + }; + + return data; +} + +function _templateObject() { + var data = (0, _taggedTemplateLiteralLoose2.default)(["", ".", ""]); + + _templateObject = function _templateObject() { + return data; + }; + + return data; +} + +var isObject = function isObject(obj) { + return Object.prototype.toString.call(obj) === '[object Object]'; +}; + +function unknown(ctx, value) { + var known = Object.keys(ctx.fields); + return Object.keys(value).filter(function (key) { + return known.indexOf(key) === -1; + }); +} + +function ObjectSchema(spec) { + var _this2 = this; + + if (!(this instanceof ObjectSchema)) return new ObjectSchema(spec); + + _mixed.default.call(this, { + type: 'object', + default: function _default() { + var _this = this; + + if (!this._nodes.length) return undefined; + var dft = {}; + + this._nodes.forEach(function (key) { + dft[key] = _this.fields[key].default ? _this.fields[key].default() : undefined; + }); + + return dft; + } + }); + + this.fields = Object.create(null); + this._nodes = []; + this._excludedEdges = []; + this.withMutation(function () { + _this2.transform(function coerce(value) { + if (typeof value === 'string') { + try { + value = JSON.parse(value); + } catch (err) { + value = null; + } + } + + if (this.isType(value)) return value; + return null; + }); + + if (spec) { + _this2.shape(spec); + } + }); +} + +(0, _inherits.default)(ObjectSchema, _mixed.default, { + _typeCheck: function _typeCheck(value) { + return isObject(value) || typeof value === 'function'; + }, + _cast: function _cast(_value, options) { + var _this3 = this; + + if (options === void 0) { + options = {}; + } + + var value = _mixed.default.prototype._cast.call(this, _value, options); //should ignore nulls here + + + if (value === undefined) return this.default(); + if (!this._typeCheck(value)) return value; + var fields = this.fields; + var strip = this._option('stripUnknown', options) === true; + + var props = this._nodes.concat(Object.keys(value).filter(function (v) { + return _this3._nodes.indexOf(v) === -1; + })); + + var intermediateValue = {}; // is filled during the transform below + + var innerOptions = (0, _extends2.default)({}, options, { + parent: intermediateValue, + __validating: false + }); + var isChanged = false; + props.forEach(function (prop) { + var field = fields[prop]; + var exists = (0, _has.default)(value, prop); + + if (field) { + var fieldValue; + var strict = field._options && field._options.strict; // safe to mutate since this is fired in sequence + + innerOptions.path = (0, _makePath.default)(_templateObject(), options.path, prop); + innerOptions.value = value[prop]; + field = field.resolve(innerOptions); + + if (field._strip === true) { + isChanged = isChanged || prop in value; + return; + } + + fieldValue = !options.__validating || !strict ? field.cast(value[prop], innerOptions) : value[prop]; + if (fieldValue !== undefined) intermediateValue[prop] = fieldValue; + } else if (exists && !strip) intermediateValue[prop] = value[prop]; + + if (intermediateValue[prop] !== value[prop]) isChanged = true; + }); + return isChanged ? intermediateValue : value; + }, + _validate: function _validate(_value, opts) { + var _this4 = this; + + if (opts === void 0) { + opts = {}; + } + + var endEarly, recursive; + var sync = opts.sync; + var errors = []; + var originalValue = opts.originalValue != null ? opts.originalValue : _value; + endEarly = this._option('abortEarly', opts); + recursive = this._option('recursive', opts); + opts = (0, _extends2.default)({}, opts, { + __validating: true, + originalValue: originalValue + }); + return _mixed.default.prototype._validate.call(this, _value, opts).catch((0, _runValidations.propagateErrors)(endEarly, errors)).then(function (value) { + if (!recursive || !isObject(value)) { + // only iterate though actual objects + if (errors.length) throw errors[0]; + return value; + } + + originalValue = originalValue || value; + + var validations = _this4._nodes.map(function (key) { + var path = (0, _makePath.default)(_templateObject2(), opts.path, key); + var field = _this4.fields[key]; + var innerOptions = (0, _extends2.default)({}, opts, { + path: path, + parent: value, + originalValue: originalValue[key] + }); + + if (field && field.validate) { + // inner fields are always strict: + // 1. this isn't strict so the casting will also have cast inner values + // 2. this is strict in which case the nested values weren't cast either + innerOptions.strict = true; + return field.validate(value[key], innerOptions); + } + + return Promise.resolve(true); + }); + + return (0, _runValidations.default)({ + sync: sync, + validations: validations, + value: value, + errors: errors, + endEarly: endEarly, + path: opts.path, + sort: (0, _sortByKeyOrder.default)(_this4.fields) + }); + }); + }, + concat: function concat(schema) { + var next = _mixed.default.prototype.concat.call(this, schema); + + next._nodes = (0, _sortFields.default)(next.fields, next._excludedEdges); + return next; + }, + shape: function shape(schema, excludes) { + if (excludes === void 0) { + excludes = []; + } + + var next = this.clone(); + var fields = (0, _extends2.default)(next.fields, schema); + next.fields = fields; + + if (excludes.length) { + if (!Array.isArray(excludes[0])) excludes = [excludes]; + var keys = excludes.map(function (_ref) { + var first = _ref[0], + second = _ref[1]; + return first + "-" + second; + }); + next._excludedEdges = next._excludedEdges.concat(keys); + } + + next._nodes = (0, _sortFields.default)(fields, next._excludedEdges); + return next; + }, + from: function from(_from, to, alias) { + var fromGetter = (0, _propertyExpr.getter)(_from, true); + return this.transform(function (obj) { + if (obj == null) return obj; + var newObj = obj; + + if ((0, _has.default)(obj, _from)) { + newObj = (0, _extends2.default)({}, obj); + if (!alias) delete newObj[_from]; + newObj[to] = fromGetter(obj); + } + + return newObj; + }); + }, + noUnknown: function noUnknown(noAllow, message) { + if (noAllow === void 0) { + noAllow = true; + } + + if (message === void 0) { + message = _locale.object.noUnknown; + } + + if (typeof noAllow === 'string') { + message = noAllow; + noAllow = true; + } + + var next = this.test({ + name: 'noUnknown', + exclusive: true, + message: message, + test: function test(value) { + return value == null || !noAllow || unknown(this.schema, value).length === 0; + } + }); + next._options.stripUnknown = noAllow; + return next; + }, + unknown: function unknown(allow, message) { + if (allow === void 0) { + allow = true; + } + + if (message === void 0) { + message = _locale.object.noUnknown; + } + + return this.noUnknown(!allow, message); + }, + transformKeys: function transformKeys(fn) { + return this.transform(function (obj) { + return obj && (0, _mapKeys.default)(obj, function (_, key) { + return fn(key); + }); + }); + }, + camelCase: function camelCase() { + return this.transformKeys(_camelCase2.default); + }, + snakeCase: function snakeCase() { + return this.transformKeys(_snakeCase2.default); + }, + constantCase: function constantCase() { + return this.transformKeys(function (key) { + return (0, _snakeCase2.default)(key).toUpperCase(); + }); + }, + describe: function describe() { + var base = _mixed.default.prototype.describe.call(this); + + base.fields = (0, _mapValues.default)(this.fields, function (value) { + return value.describe(); + }); + return base; + } +}); +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/setLocale.js b/node_modules/yup/lib/setLocale.js new file mode 100644 index 00000000..2b6054f6 --- /dev/null +++ b/node_modules/yup/lib/setLocale.js @@ -0,0 +1,18 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = setLocale; + +var _locale = _interopRequireDefault(require("./locale")); + +function setLocale(custom) { + Object.keys(custom).forEach(function (type) { + Object.keys(custom[type]).forEach(function (method) { + _locale.default[type][method] = custom[type][method]; + }); + }); +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/string.js b/node_modules/yup/lib/string.js new file mode 100644 index 00000000..27fb9014 --- /dev/null +++ b/node_modules/yup/lib/string.js @@ -0,0 +1,194 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = StringSchema; + +var _inherits = _interopRequireDefault(require("./util/inherits")); + +var _mixed = _interopRequireDefault(require("./mixed")); + +var _locale = require("./locale"); + +var _isAbsent = _interopRequireDefault(require("./util/isAbsent")); + +// eslint-disable-next-line +var rEmail = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-next-line + +var rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; + +var isTrimmed = function isTrimmed(value) { + return (0, _isAbsent.default)(value) || value === value.trim(); +}; + +function StringSchema() { + var _this = this; + + if (!(this instanceof StringSchema)) return new StringSchema(); + + _mixed.default.call(this, { + type: 'string' + }); + + this.withMutation(function () { + _this.transform(function (value) { + if (this.isType(value)) return value; + return value != null && value.toString ? value.toString() : value; + }); + }); +} + +(0, _inherits.default)(StringSchema, _mixed.default, { + _typeCheck: function _typeCheck(value) { + if (value instanceof String) value = value.valueOf(); + return typeof value === 'string'; + }, + _isPresent: function _isPresent(value) { + return _mixed.default.prototype._cast.call(this, value) && value.length > 0; + }, + length: function length(_length, message) { + if (message === void 0) { + message = _locale.string.length; + } + + return this.test({ + message: message, + name: 'length', + exclusive: true, + params: { + length: _length + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value.length === this.resolve(_length); + } + }); + }, + min: function min(_min, message) { + if (message === void 0) { + message = _locale.string.min; + } + + return this.test({ + message: message, + name: 'min', + exclusive: true, + params: { + min: _min + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value.length >= this.resolve(_min); + } + }); + }, + max: function max(_max, message) { + if (message === void 0) { + message = _locale.string.max; + } + + return this.test({ + name: 'max', + exclusive: true, + message: message, + params: { + max: _max + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value.length <= this.resolve(_max); + } + }); + }, + matches: function matches(regex, options) { + var excludeEmptyString = false; + var message; + + if (options) { + if (options.message || options.hasOwnProperty('excludeEmptyString')) { + excludeEmptyString = options.excludeEmptyString; + message = options.message; + } else message = options; + } + + return this.test({ + message: message || _locale.string.matches, + params: { + regex: regex + }, + test: function test(value) { + return (0, _isAbsent.default)(value) || value === '' && excludeEmptyString || regex.test(value); + } + }); + }, + email: function email(message) { + if (message === void 0) { + message = _locale.string.email; + } + + return this.matches(rEmail, { + message: message, + excludeEmptyString: true + }); + }, + url: function url(message) { + if (message === void 0) { + message = _locale.string.url; + } + + return this.matches(rUrl, { + message: message, + excludeEmptyString: true + }); + }, + //-- transforms -- + ensure: function ensure() { + return this.default('').transform(function (val) { + return val === null ? '' : val; + }); + }, + trim: function trim(message) { + if (message === void 0) { + message = _locale.string.trim; + } + + return this.transform(function (val) { + return val != null ? val.trim() : val; + }).test({ + message: message, + name: 'trim', + test: isTrimmed + }); + }, + lowercase: function lowercase(message) { + if (message === void 0) { + message = _locale.string.lowercase; + } + + return this.transform(function (value) { + return !(0, _isAbsent.default)(value) ? value.toLowerCase() : value; + }).test({ + message: message, + name: 'string_case', + exclusive: true, + test: function test(value) { + return (0, _isAbsent.default)(value) || value === value.toLowerCase(); + } + }); + }, + uppercase: function uppercase(message) { + if (message === void 0) { + message = _locale.string.uppercase; + } + + return this.transform(function (value) { + return !(0, _isAbsent.default)(value) ? value.toUpperCase() : value; + }).test({ + message: message, + name: 'string_case', + exclusive: true, + test: function test(value) { + return (0, _isAbsent.default)(value) || value === value.toUpperCase(); + } + }); + } +}); +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/createValidation.js b/node_modules/yup/lib/util/createValidation.js new file mode 100644 index 00000000..168cd616 --- /dev/null +++ b/node_modules/yup/lib/util/createValidation.js @@ -0,0 +1,119 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.createErrorFactory = createErrorFactory; +exports.default = createValidation; + +var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +var _mapValues = _interopRequireDefault(require("lodash/mapValues")); + +var _ValidationError = _interopRequireDefault(require("../ValidationError")); + +var _Reference = _interopRequireDefault(require("../Reference")); + +var _synchronousPromise = require("synchronous-promise"); + +var formatError = _ValidationError.default.formatError; + +var thenable = function thenable(p) { + return p && typeof p.then === 'function' && typeof p.catch === 'function'; +}; + +function runTest(testFn, ctx, value, sync) { + var result = testFn.call(ctx, value); + if (!sync) return Promise.resolve(result); + + if (thenable(result)) { + throw new Error("Validation test of type: \"" + ctx.type + "\" returned a Promise during a synchronous validate. " + "This test will finish after the validate call has returned"); + } + + return _synchronousPromise.SynchronousPromise.resolve(result); +} + +function resolveParams(oldParams, newParams, resolve) { + return (0, _mapValues.default)((0, _extends2.default)({}, oldParams, newParams), resolve); +} + +function createErrorFactory(_ref) { + var value = _ref.value, + label = _ref.label, + resolve = _ref.resolve, + originalValue = _ref.originalValue, + opts = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["value", "label", "resolve", "originalValue"]); + return function createError(_temp) { + var _ref2 = _temp === void 0 ? {} : _temp, + _ref2$path = _ref2.path, + path = _ref2$path === void 0 ? opts.path : _ref2$path, + _ref2$message = _ref2.message, + message = _ref2$message === void 0 ? opts.message : _ref2$message, + _ref2$type = _ref2.type, + type = _ref2$type === void 0 ? opts.name : _ref2$type, + params = _ref2.params; + + params = (0, _extends2.default)({ + path: path, + value: value, + originalValue: originalValue, + label: label + }, resolveParams(opts.params, params, resolve)); + return (0, _extends2.default)(new _ValidationError.default(formatError(message, params), value, path, type), { + params: params + }); + }; +} + +function createValidation(options) { + var name = options.name, + message = options.message, + test = options.test, + params = options.params; + + function validate(_ref3) { + var value = _ref3.value, + path = _ref3.path, + label = _ref3.label, + options = _ref3.options, + originalValue = _ref3.originalValue, + sync = _ref3.sync, + rest = (0, _objectWithoutPropertiesLoose2.default)(_ref3, ["value", "path", "label", "options", "originalValue", "sync"]); + var parent = options.parent; + + var resolve = function resolve(item) { + return _Reference.default.isRef(item) ? item.getValue({ + value: value, + parent: parent, + context: options.context + }) : item; + }; + + var createError = createErrorFactory({ + message: message, + path: path, + value: value, + originalValue: originalValue, + params: params, + label: label, + resolve: resolve, + name: name + }); + var ctx = (0, _extends2.default)({ + path: path, + parent: parent, + type: name, + createError: createError, + resolve: resolve, + options: options + }, rest); + return runTest(test, ctx, value, sync).then(function (validOrError) { + if (_ValidationError.default.isError(validOrError)) throw validOrError;else if (!validOrError) throw createError(); + }); + } + + validate.OPTIONS = options; + return validate; +} \ No newline at end of file diff --git a/node_modules/yup/lib/util/inherits.js b/node_modules/yup/lib/util/inherits.js new file mode 100644 index 00000000..8929fa75 --- /dev/null +++ b/node_modules/yup/lib/util/inherits.js @@ -0,0 +1,22 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = inherits; + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +function inherits(ctor, superCtor, spec) { + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + (0, _extends2.default)(ctor.prototype, spec); +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/isAbsent.js b/node_modules/yup/lib/util/isAbsent.js new file mode 100644 index 00000000..0bf84e64 --- /dev/null +++ b/node_modules/yup/lib/util/isAbsent.js @@ -0,0 +1,11 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _default = function _default(value) { + return value == null; +}; + +exports.default = _default; +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/isSchema.js b/node_modules/yup/lib/util/isSchema.js new file mode 100644 index 00000000..797eb4bd --- /dev/null +++ b/node_modules/yup/lib/util/isSchema.js @@ -0,0 +1,11 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _default = function _default(obj) { + return obj && obj.__isYupSchema__; +}; + +exports.default = _default; +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/isodate.js b/node_modules/yup/lib/util/isodate.js new file mode 100644 index 00000000..3e710937 --- /dev/null +++ b/node_modules/yup/lib/util/isodate.js @@ -0,0 +1,49 @@ +"use strict"; + +exports.__esModule = true; +exports.default = parseIsoDate; + +/* eslint-disable */ + +/** + * + * Date.parse with progressive enhancement for ISO 8601 + * NON-CONFORMANT EDITION. + * © 2011 Colin Snover + * Released under MIT license. + */ +// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm +var isoReg = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/; + +function parseIsoDate(date) { + var numericKeys = [1, 4, 5, 6, 7, 10, 11], + minutesOffset = 0, + timestamp, + struct; + + if (struct = isoReg.exec(date)) { + // avoid NaN timestamps caused by “undefined” values being passed to Date.UTC + for (var i = 0, k; k = numericKeys[i]; ++i) { + struct[k] = +struct[k] || 0; + } // allow undefined days and months + + + struct[2] = (+struct[2] || 1) - 1; + struct[3] = +struct[3] || 1; // allow arbitrary sub-second precision beyond milliseconds + + struct[7] = struct[7] ? String(struct[7]).substr(0, 3) : 0; // timestamps without timezone identifiers should be considered local time + + if ((struct[8] === undefined || struct[8] === '') && (struct[9] === undefined || struct[9] === '')) timestamp = +new Date(struct[1], struct[2], struct[3], struct[4], struct[5], struct[6], struct[7]);else { + if (struct[8] !== 'Z' && struct[9] !== undefined) { + minutesOffset = struct[10] * 60 + struct[11]; + if (struct[9] === '+') minutesOffset = 0 - minutesOffset; + } + + timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]); + } + } else timestamp = Date.parse ? Date.parse(date) : NaN; + + return timestamp; +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/makePath.js b/node_modules/yup/lib/util/makePath.js new file mode 100644 index 00000000..cb0f6afc --- /dev/null +++ b/node_modules/yup/lib/util/makePath.js @@ -0,0 +1,18 @@ +"use strict"; + +exports.__esModule = true; +exports.default = makePath; + +function makePath(strings) { + for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + values[_key - 1] = arguments[_key]; + } + + var path = strings.reduce(function (str, next) { + var value = values.shift(); + return str + (value == null ? '' : value) + next; + }); + return path.replace(/^\./, ''); +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/prependDeep.js b/node_modules/yup/lib/util/prependDeep.js new file mode 100644 index 00000000..069ed370 --- /dev/null +++ b/node_modules/yup/lib/util/prependDeep.js @@ -0,0 +1,39 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = prependDeep; + +var _has = _interopRequireDefault(require("lodash/has")); + +var _isSchema = _interopRequireDefault(require("./isSchema")); + +var isObject = function isObject(obj) { + return Object.prototype.toString.call(obj) === '[object Object]'; +}; + +function prependDeep(target, source) { + for (var key in source) { + if ((0, _has.default)(source, key)) { + var sourceVal = source[key], + targetVal = target[key]; + + if (targetVal === undefined) { + target[key] = sourceVal; + } else if (targetVal === sourceVal) { + continue; + } else if ((0, _isSchema.default)(targetVal)) { + if ((0, _isSchema.default)(sourceVal)) target[key] = sourceVal.concat(targetVal); + } else if (isObject(targetVal)) { + if (isObject(sourceVal)) target[key] = prependDeep(targetVal, sourceVal); + } else if (Array.isArray(targetVal)) { + if (Array.isArray(sourceVal)) target[key] = sourceVal.concat(targetVal); + } + } + } + + return target; +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/printValue.js b/node_modules/yup/lib/util/printValue.js new file mode 100644 index 00000000..d9cf5a9d --- /dev/null +++ b/node_modules/yup/lib/util/printValue.js @@ -0,0 +1,47 @@ +"use strict"; + +exports.__esModule = true; +exports.default = printValue; +var toString = Object.prototype.toString; +var errorToString = Error.prototype.toString; +var regExpToString = RegExp.prototype.toString; +var symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : function () { + return ''; +}; +var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/; + +function printNumber(val) { + if (val != +val) return 'NaN'; + var isNegativeZero = val === 0 && 1 / val < 0; + return isNegativeZero ? '-0' : '' + val; +} + +function printSimpleValue(val, quoteStrings) { + if (quoteStrings === void 0) { + quoteStrings = false; + } + + if (val == null || val === true || val === false) return '' + val; + var typeOf = typeof val; + if (typeOf === 'number') return printNumber(val); + if (typeOf === 'string') return quoteStrings ? "\"" + val + "\"" : val; + if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']'; + if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)'); + var tag = toString.call(val).slice(8, -1); + if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val); + if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']'; + if (tag === 'RegExp') return regExpToString.call(val); + return null; +} + +function printValue(value, quoteStrings) { + var result = printSimpleValue(value, quoteStrings); + if (result !== null) return result; + return JSON.stringify(value, function (key, value) { + var result = printSimpleValue(this[key], quoteStrings); + if (result !== null) return result; + return value; + }, 2); +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/reach.js b/node_modules/yup/lib/util/reach.js new file mode 100644 index 00000000..ea2dd6b0 --- /dev/null +++ b/node_modules/yup/lib/util/reach.js @@ -0,0 +1,73 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.getIn = getIn; +exports.default = void 0; + +var _propertyExpr = require("property-expr"); + +var _has = _interopRequireDefault(require("lodash/has")); + +var trim = function trim(part) { + return part.substr(0, part.length - 1).substr(1); +}; + +function getIn(schema, path, value, context) { + var parent, lastPart, lastPartDebug; // if only one "value" arg then use it for both + + context = context || value; + if (!path) return { + parent: parent, + parentPath: path, + schema: schema + }; + (0, _propertyExpr.forEach)(path, function (_part, isBracket, isArray) { + var part = isBracket ? trim(_part) : _part; + + if (isArray || (0, _has.default)(schema, '_subType')) { + // we skipped an array: foo[].bar + var idx = isArray ? parseInt(part, 10) : 0; + schema = schema.resolve({ + context: context, + parent: parent, + value: value + })._subType; + + if (value) { + if (isArray && idx >= value.length) { + throw new Error("Yup.reach cannot resolve an array item at index: " + _part + ", in the path: " + path + ". " + "because there is no value at that index. "); + } + + value = value[idx]; + } + } + + if (!isArray) { + schema = schema.resolve({ + context: context, + parent: parent, + value: value + }); + if (!(0, _has.default)(schema, 'fields') || !(0, _has.default)(schema.fields, part)) throw new Error("The schema does not contain the path: " + path + ". " + ("(failed at: " + lastPartDebug + " which is a type: \"" + schema._type + "\") ")); + schema = schema.fields[part]; + parent = value; + value = value && value[part]; + lastPart = part; + lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part; + } + }); + return { + schema: schema, + parent: parent, + parentPath: lastPart + }; +} + +var reach = function reach(obj, path, value, context) { + return getIn(obj, path, value, context).schema; +}; + +var _default = reach; +exports.default = _default; \ No newline at end of file diff --git a/node_modules/yup/lib/util/runValidations.js b/node_modules/yup/lib/util/runValidations.js new file mode 100644 index 00000000..0c266f1d --- /dev/null +++ b/node_modules/yup/lib/util/runValidations.js @@ -0,0 +1,108 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.propagateErrors = propagateErrors; +exports.settled = settled; +exports.collectErrors = collectErrors; +exports.default = runValidations; + +var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); + +var _synchronousPromise = require("synchronous-promise"); + +var _ValidationError = _interopRequireDefault(require("../ValidationError")); + +var promise = function promise(sync) { + return sync ? _synchronousPromise.SynchronousPromise : Promise; +}; + +var unwrapError = function unwrapError(errors) { + if (errors === void 0) { + errors = []; + } + + return errors.inner && errors.inner.length ? errors.inner : [].concat(errors); +}; + +function scopeToValue(promises, value, sync) { + //console.log('scopeToValue', promises, value) + var p = promise(sync).all(promises); //console.log('scopeToValue B', p) + + var b = p.catch(function (err) { + if (err.name === 'ValidationError') err.value = value; + throw err; + }); //console.log('scopeToValue c', b) + + var c = b.then(function () { + return value; + }); //console.log('scopeToValue d', c) + + return c; +} +/** + * If not failing on the first error, catch the errors + * and collect them in an array + */ + + +function propagateErrors(endEarly, errors) { + return endEarly ? null : function (err) { + errors.push(err); + return err.value; + }; +} + +function settled(promises, sync) { + var Promise = promise(sync); + return Promise.all(promises.map(function (p) { + return Promise.resolve(p).then(function (value) { + return { + fulfilled: true, + value: value + }; + }, function (value) { + return { + fulfilled: false, + value: value + }; + }); + })); +} + +function collectErrors(_ref) { + var validations = _ref.validations, + value = _ref.value, + path = _ref.path, + sync = _ref.sync, + errors = _ref.errors, + sort = _ref.sort; + errors = unwrapError(errors); + return settled(validations, sync).then(function (results) { + var nestedErrors = results.filter(function (r) { + return !r.fulfilled; + }).reduce(function (arr, _ref2) { + var error = _ref2.value; + + // we are only collecting validation errors + if (!_ValidationError.default.isError(error)) { + throw error; + } + + return arr.concat(error); + }, []); + if (sort) nestedErrors.sort(sort); //show parent errors after the nested ones: name.first, name + + errors = nestedErrors.concat(errors); + if (errors.length) throw new _ValidationError.default(errors, value, path); + return value; + }); +} + +function runValidations(_ref3) { + var endEarly = _ref3.endEarly, + options = (0, _objectWithoutPropertiesLoose2.default)(_ref3, ["endEarly"]); + if (endEarly) return scopeToValue(options.validations, options.value, options.sync); + return collectErrors(options); +} \ No newline at end of file diff --git a/node_modules/yup/lib/util/sortByKeyOrder.js b/node_modules/yup/lib/util/sortByKeyOrder.js new file mode 100644 index 00000000..58388551 --- /dev/null +++ b/node_modules/yup/lib/util/sortByKeyOrder.js @@ -0,0 +1,24 @@ +"use strict"; + +exports.__esModule = true; +exports.default = sortByKeyOrder; + +function findIndex(arr, err) { + var idx = Infinity; + arr.some(function (key, ii) { + if (err.path.indexOf(key) !== -1) { + idx = ii; + return true; + } + }); + return idx; +} + +function sortByKeyOrder(fields) { + var keys = Object.keys(fields); + return function (a, b) { + return findIndex(keys, a) - findIndex(keys, b); + }; +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/lib/util/sortFields.js b/node_modules/yup/lib/util/sortFields.js new file mode 100644 index 00000000..d38c8f5e --- /dev/null +++ b/node_modules/yup/lib/util/sortFields.js @@ -0,0 +1,45 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = sortFields; + +var _has = _interopRequireDefault(require("lodash/has")); + +var _toposort = _interopRequireDefault(require("toposort")); + +var _propertyExpr = require("property-expr"); + +var _Reference = _interopRequireDefault(require("../Reference")); + +var _isSchema = _interopRequireDefault(require("./isSchema")); + +function sortFields(fields, excludes) { + if (excludes === void 0) { + excludes = []; + } + + var edges = [], + nodes = []; + + function addNode(depPath, key) { + var node = (0, _propertyExpr.split)(depPath)[0]; + if (!~nodes.indexOf(node)) nodes.push(node); + if (!~excludes.indexOf(key + "-" + node)) edges.push([key, node]); + } + + for (var key in fields) { + if ((0, _has.default)(fields, key)) { + var value = fields[key]; + if (!~nodes.indexOf(key)) nodes.push(key); + if (_Reference.default.isRef(value) && value.isSibling) addNode(value.path, key);else if ((0, _isSchema.default)(value) && value._deps) value._deps.forEach(function (path) { + return addNode(path, key); + }); + } + } + + return _toposort.default.array(nodes, edges).reverse(); +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/node_modules/yup/package.json b/node_modules/yup/package.json new file mode 100644 index 00000000..a63c1188 --- /dev/null +++ b/node_modules/yup/package.json @@ -0,0 +1,98 @@ +{ + "name": "yup", + "version": "0.27.0", + "description": "Dead simple Object schema validation", + "main": "lib/index.js", + "runkitExampleFilename": "./runkit-example.js", + "scripts": { + "test": "npm run lint && npm run test-all -- --runInBand", + "testonly": "jest", + "test-all": "npm run testonly -- --projects ./jest-sync.config.json --projects ./package.json", + "tdd": "jest --watch", + "lint": "eslint src test", + "precommit": "lint-staged", + "toc": "doctoc README.md --github", + "release": "rollout", + "build": "babel src --out-dir lib --delete-dir-on-start && npm run toc", + "prepublishOnly": "npm run build" + }, + "files": [ + "lib" + ], + "repository": { + "type": "git", + "url": "https://github.com/jquense/yup.git" + }, + "author": "@monasticpanic Jason Quense", + "license": "MIT", + "bugs": { + "url": "https://github.com/jquense/yup/issues" + }, + "homepage": "https://github.com/jquense/yup", + "release": { + "conventional-commits": true + }, + "prettier": { + "singleQuote": true, + "trailingComma": "all" + }, + "lint-staged": { + "*.{js,json,css,md}": [ + "prettier --write", + "git add" + ] + }, + "jest": { + "globals": { + "YUP_USE_SYNC": true + }, + "testEnvironment": "node", + "setupTestFrameworkScriptFile": "./test-setup.js", + "roots": [ + "test" + ], + "testRegex": "\\.js", + "testPathIgnorePatterns": [ + "helpers\\.js" + ] + }, + "devDependencies": { + "@4c/rollout": "^1.3.3", + "@babel/cli": "7.2.3", + "@babel/core": "7.3.4", + "babel-core": "^7.0.0-bridge.0", + "babel-eslint": "^9.0.0", + "babel-jest": "^22.4.3", + "babel-preset-jason": "^6.0.1", + "benchmark": "^2.0.0", + "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", + "dirty-chai": "^2.0.1", + "doctoc": "^1.4.0", + "eslint": "^4.19.1", + "eslint-config-jason": "^4.0.1", + "eslint-config-prettier": "^3.0.1", + "eslint-plugin-import": "^2.16.0", + "eslint-plugin-jest": "^21.22.0", + "eslint-plugin-react": "^7.12.4", + "husky": "^0.14.3", + "jest": "^22.4.3", + "lint-staged": "^7.2.2", + "prettier": "^1.13.7", + "rollup": "^0.65.0", + "rollup-plugin-babel": "^4.0.2", + "rollup-plugin-filesize": "^4.0.1", + "rollup-plugin-node-resolve": "^3.3.0", + "rollup-plugin-size-snapshot": "^0.6.1", + "sinon": "^6.1.5", + "sinon-chai": "^3.3.0" + }, + "dependencies": { + "@babel/runtime": "^7.0.0", + "fn-name": "~2.0.1", + "lodash": "^4.17.11", + "property-expr": "^1.5.0", + "synchronous-promise": "^2.0.6", + "toposort": "^2.0.2" + } +} diff --git a/package.json b/package.json index 0bd6b719..00e97990 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "jsonwebtoken": "^8.5.1", "pg": "^7.11.0", "pg-hstore": "^2.3.3", - "sequelize": "^5.10.1" + "sequelize": "^5.10.1", + "yup": "^0.27.0" }, "devDependencies": { "eslint": "^5.16.0", diff --git a/src/app/controllers/SessionController.js b/src/app/controllers/SessionController.js index 452ecae1..7fe6e305 100644 --- a/src/app/controllers/SessionController.js +++ b/src/app/controllers/SessionController.js @@ -1,9 +1,18 @@ import jwt from 'jsonwebtoken'; +import * as Yup from 'yup'; import authConfig from '../../config/auth'; import User from '../models/User'; class SessionController { async store(req, res) { + const schema = Yup.object().shape({ + email: Yup.string() + .email() + .required(), + + password: Yup.string().required(), + }); + const { email, password } = req.body; const user = await User.findOne({ where: { email } }); diff --git a/src/app/controllers/UserController.js b/src/app/controllers/UserController.js index 25b87bc9..b83e9e8a 100644 --- a/src/app/controllers/UserController.js +++ b/src/app/controllers/UserController.js @@ -1,7 +1,28 @@ +import * as Yup from 'yup'; import User from '../models/User'; class UserController { async store(req, res) { + const schema = Yup.object().shape({ + name: Yup.string().required(), + email: Yup.string() + .email() + .required(), + oldPassword: Yup.string().min(6), + password: Yup.string() + .min(6) + .when('oldPassword', (oldPassword, field) => + oldPassword ? field.required() : field + ), + confirmPassword: Yup.string().when('password', (password, field) => + password ? field.required().oneOf([Yup.ref('password')]) : field + ), + }); + + if (!(await schema.isValid(req.body))) { + return res.status(400).json({ error: 'Validations fails' }); + } + const userExists = await User.findOne({ where: { email: req.body.email } }); if (userExists) { return res.status(400).json({ error: 'User already exists' }); diff --git a/yarn.lock b/yarn.lock index 6956601d..77435c22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18,6 +18,13 @@ esutils "^2.0.2" js-tokens "^4.0.0" +"@babel/runtime@^7.0.0": + version "7.5.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132" + integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ== + dependencies: + regenerator-runtime "^0.13.2" + "@types/node@*": version "12.6.8" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.8.tgz#e469b4bf9d1c9832aee4907ba8a051494357c12c" @@ -1153,6 +1160,11 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== +fn-name@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7" + integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc= + for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -2619,6 +2631,11 @@ progress@^2.0.0: resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== +property-expr@^1.5.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-1.5.1.tgz#22e8706894a0c8e28d58735804f6ba3a3673314f" + integrity sha512-CGuc0VUTGthpJXL36ydB6jnbyOf/rAHFvmVrJlH+Rg0DqqLFQGAP6hIaxD/G0OAmBJPhXDHuEJigrp0e0wFV6g== + proto-list@~1.2.1: version "1.2.4" resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" @@ -2721,6 +2738,11 @@ regenerator-runtime@^0.11.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== +regenerator-runtime@^0.13.2: + version "0.13.3" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" + integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw== + regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" @@ -3201,6 +3223,11 @@ supports-color@^5.2.0, supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +synchronous-promise@^2.0.6: + version "2.0.9" + resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.9.tgz#b83db98e9e7ae826bf9c8261fd8ac859126c780a" + integrity sha512-LO95GIW16x69LuND1nuuwM4pjgFGupg7pZ/4lU86AmchPKrhk0o2tpMU2unXRrqo81iAFe1YJ0nAGEVwsrZAgg== + table@^5.2.3: version "5.4.4" resolved "https://registry.yarnpkg.com/table/-/table-5.4.4.tgz#6e0f88fdae3692793d1077fd172a4667afe986a6" @@ -3310,6 +3337,11 @@ toposort-class@^1.0.1: resolved "https://registry.yarnpkg.com/toposort-class/-/toposort-class-1.0.1.tgz#7ffd1f78c8be28c3ba45cd4e1a3f5ee193bd9988" integrity sha1-f/0feMi+KMO6Rc1OGj9e4ZO9mYg= +toposort@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" + integrity sha1-riF2gXXRVZ1IvvNUILL0li8JwzA= + touch@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b" @@ -3596,3 +3628,15 @@ yargs@^13.1.0: which-module "^2.0.0" y18n "^4.0.0" yargs-parser "^13.1.1" + +yup@^0.27.0: + version "0.27.0" + resolved "https://registry.yarnpkg.com/yup/-/yup-0.27.0.tgz#f8cb198c8e7dd2124beddc2457571329096b06e7" + integrity sha512-v1yFnE4+u9za42gG/b/081E7uNW9mUj3qtkmelLbW5YPROZzSH/KUUyJu9Wt8vxFJcT9otL/eZopS0YK1L5yPQ== + dependencies: + "@babel/runtime" "^7.0.0" + fn-name "~2.0.1" + lodash "^4.17.11" + property-expr "^1.5.0" + synchronous-promise "^2.0.6" + toposort "^2.0.2"