diff options
author | Minteck <contact@minteck.org> | 2022-06-04 08:51:19 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-06-04 08:51:19 +0200 |
commit | b22f6770c8bd084d66950655203c61dd701b3d90 (patch) | |
tree | 873d7fb19584ec2709b95cc1ca05a1fc7cfd0fc4 /node_modules/got/source/create.js | |
parent | 383285ecd5292bf9a825e05904955b937de84cc9 (diff) | |
download | equestriadb-b22f6770c8bd084d66950655203c61dd701b3d90.tar.gz equestriadb-b22f6770c8bd084d66950655203c61dd701b3d90.tar.bz2 equestriadb-b22f6770c8bd084d66950655203c61dd701b3d90.zip |
Remove node_modules
Diffstat (limited to 'node_modules/got/source/create.js')
-rw-r--r-- | node_modules/got/source/create.js | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/node_modules/got/source/create.js b/node_modules/got/source/create.js deleted file mode 100644 index b78c51f..0000000 --- a/node_modules/got/source/create.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; -const errors = require('./errors'); -const asStream = require('./as-stream'); -const asPromise = require('./as-promise'); -const normalizeArguments = require('./normalize-arguments'); -const merge = require('./merge'); -const deepFreeze = require('./utils/deep-freeze'); - -const getPromiseOrStream = options => options.stream ? asStream(options) : asPromise(options); - -const aliases = [ - 'get', - 'post', - 'put', - 'patch', - 'head', - 'delete' -]; - -const create = defaults => { - defaults = merge({}, defaults); - normalizeArguments.preNormalize(defaults.options); - - if (!defaults.handler) { - // This can't be getPromiseOrStream, because when merging - // the chain would stop at this point and no further handlers would be called. - defaults.handler = (options, next) => next(options); - } - - function got(url, options) { - try { - return defaults.handler(normalizeArguments(url, options, defaults), getPromiseOrStream); - } catch (error) { - if (options && options.stream) { - throw error; - } else { - return Promise.reject(error); - } - } - } - - got.create = create; - got.extend = options => { - let mutableDefaults; - if (options && Reflect.has(options, 'mutableDefaults')) { - mutableDefaults = options.mutableDefaults; - delete options.mutableDefaults; - } else { - mutableDefaults = defaults.mutableDefaults; - } - - return create({ - options: merge.options(defaults.options, options), - handler: defaults.handler, - mutableDefaults - }); - }; - - got.mergeInstances = (...args) => create(merge.instances(args)); - - got.stream = (url, options) => got(url, {...options, stream: true}); - - for (const method of aliases) { - got[method] = (url, options) => got(url, {...options, method}); - got.stream[method] = (url, options) => got.stream(url, {...options, method}); - } - - Object.assign(got, {...errors, mergeOptions: merge.options}); - Object.defineProperty(got, 'defaults', { - value: defaults.mutableDefaults ? defaults : deepFreeze(defaults), - writable: defaults.mutableDefaults, - configurable: defaults.mutableDefaults, - enumerable: true - }); - - return got; -}; - -module.exports = create; |