aboutsummaryrefslogtreecommitdiff
path: root/includes/fetcher/node_modules/axios/lib/helpers/validator.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-04-14 17:43:06 +0200
committerMinteck <contact@minteck.org>2022-04-14 17:43:06 +0200
commit3071764c42c63f47cd76d80b5b90fe280ac9f0ab (patch)
tree2458441ce5218cc88a8be165b364f174a9ba8e3b /includes/fetcher/node_modules/axios/lib/helpers/validator.js
parentf6e5be4e0ef648d3eb1d8a12edcb48dbb8c31037 (diff)
downloadember-3071764c42c63f47cd76d80b5b90fe280ac9f0ab.tar.gz
ember-3071764c42c63f47cd76d80b5b90fe280ac9f0ab.tar.bz2
ember-3071764c42c63f47cd76d80b5b90fe280ac9f0ab.zip
Fetcher
Diffstat (limited to 'includes/fetcher/node_modules/axios/lib/helpers/validator.js')
-rw-r--r--includes/fetcher/node_modules/axios/lib/helpers/validator.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/includes/fetcher/node_modules/axios/lib/helpers/validator.js b/includes/fetcher/node_modules/axios/lib/helpers/validator.js
new file mode 100644
index 0000000..a4ec413
--- /dev/null
+++ b/includes/fetcher/node_modules/axios/lib/helpers/validator.js
@@ -0,0 +1,82 @@
+'use strict';
+
+var VERSION = require('../env/data').version;
+
+var validators = {};
+
+// eslint-disable-next-line func-names
+['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
+ validators[type] = function validator(thing) {
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
+ };
+});
+
+var deprecatedWarnings = {};
+
+/**
+ * Transitional option validator
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
+ * @param {string?} version - deprecated version / removed since version
+ * @param {string?} message - some message with additional info
+ * @returns {function}
+ */
+validators.transitional = function transitional(validator, version, message) {
+ function formatMessage(opt, desc) {
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
+ }
+
+ // eslint-disable-next-line func-names
+ return function(value, opt, opts) {
+ if (validator === false) {
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
+ }
+
+ if (version && !deprecatedWarnings[opt]) {
+ deprecatedWarnings[opt] = true;
+ // eslint-disable-next-line no-console
+ console.warn(
+ formatMessage(
+ opt,
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
+ )
+ );
+ }
+
+ return validator ? validator(value, opt, opts) : true;
+ };
+};
+
+/**
+ * Assert object's properties type
+ * @param {object} options
+ * @param {object} schema
+ * @param {boolean?} allowUnknown
+ */
+
+function assertOptions(options, schema, allowUnknown) {
+ if (typeof options !== 'object') {
+ throw new TypeError('options must be an object');
+ }
+ var keys = Object.keys(options);
+ var i = keys.length;
+ while (i-- > 0) {
+ var opt = keys[i];
+ var validator = schema[opt];
+ if (validator) {
+ var value = options[opt];
+ var result = value === undefined || validator(value, opt, options);
+ if (result !== true) {
+ throw new TypeError('option ' + opt + ' must be ' + result);
+ }
+ continue;
+ }
+ if (allowUnknown !== true) {
+ throw Error('Unknown option ' + opt);
+ }
+ }
+}
+
+module.exports = {
+ assertOptions: assertOptions,
+ validators: validators
+};