diff --git a/bower.json b/bower.json index fa8370acee..4e46dc79b2 100644 --- a/bower.json +++ b/bower.json @@ -21,7 +21,6 @@ "license": "MIT", "ignore": [ "**/.*", - "*.iml", "examples", "lib", "node_modules", diff --git a/lib/helpers/buildURL.js b/lib/helpers/buildURL.js index 8c40e4096a..7a7d7a6199 100644 --- a/lib/helpers/buildURL.js +++ b/lib/helpers/buildURL.js @@ -39,7 +39,7 @@ module.exports = function buildURL(url, params, paramsSerializer) { return; } - if (utils.isArray(val)) { + if (Array.isArray(val)) { key = key + '[]'; } else { val = [val]; diff --git a/lib/helpers/parseHeaders.js b/lib/helpers/parseHeaders.js index 8af2cc7f1b..5747a1bd7a 100644 --- a/lib/helpers/parseHeaders.js +++ b/lib/helpers/parseHeaders.js @@ -34,8 +34,8 @@ module.exports = function parseHeaders(headers) { utils.forEach(headers.split('\n'), function parser(line) { i = line.indexOf(':'); - key = utils.trim(line.substr(0, i)).toLowerCase(); - val = utils.trim(line.substr(i + 1)); + key = line.substr(0, i).trim().toLowerCase(); + val = line.substr(i + 1).trim(); if (key) { if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { diff --git a/lib/utils.js b/lib/utils.js index e028c6763e..125f2be2a5 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -2,22 +2,10 @@ var bind = require('./helpers/bind'); -/*global toString:true*/ - // utils is a library of generic helper functions non-specific to axios var toString = Object.prototype.toString; -/** - * Determine if a value is an Array - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an Array, otherwise false - */ -function isArray(val) { - return toString.call(val) === '[object Array]'; -} - /** * Determine if a value is undefined * @@ -165,16 +153,6 @@ function isURLSearchParams(val) { return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; } -/** - * Trim excess whitespace off the beginning and end of a string - * - * @param {String} str The String to trim - * @returns {String} The String freed of excess whitespace - */ -function trim(str) { - return str.replace(/^\s*/, '').replace(/\s*$/, ''); -} - /** * Determine if we're running in a standard browser environment * @@ -226,7 +204,7 @@ function forEach(obj, fn) { obj = [obj]; } - if (isArray(obj)) { + if (Array.isArray(obj)) { // Iterate over array values for (var i = 0, l = obj.length; i < l; i++) { fn.call(null, obj[i], i, obj); @@ -320,7 +298,6 @@ function extend(a, b, thisArg) { } module.exports = { - isArray: isArray, isArrayBuffer: isArrayBuffer, isBuffer: isBuffer, isFormData: isFormData, @@ -339,6 +316,5 @@ module.exports = { forEach: forEach, merge: merge, deepMerge: deepMerge, - extend: extend, - trim: trim + extend: extend }; diff --git a/package.json b/package.json index cabd9e42b3..f1c73cc2a9 100644 --- a/package.json +++ b/package.json @@ -32,41 +32,39 @@ }, "homepage": "https://github.com/axios/axios", "devDependencies": { - "bundlesize": "^0.17.0", - "coveralls": "^3.0.0", - "es6-promise": "^4.2.4", + "bundlesize": "^0.18.0", + "coveralls": "^3.0.9", "grunt": "^1.0.2", "grunt-banner": "^0.6.0", "grunt-cli": "^1.2.0", - "grunt-contrib-clean": "^1.1.0", + "grunt-contrib-clean": "^2.0.0", "grunt-contrib-watch": "^1.0.0", - "grunt-eslint": "^20.1.0", - "grunt-karma": "^2.0.0", + "grunt-eslint": "^22.0.0", + "grunt-karma": "^3.0.2", "grunt-mocha-test": "^0.13.3", "grunt-ts": "^6.0.0-beta.19", - "grunt-webpack": "^1.0.18", - "istanbul-instrumenter-loader": "^1.0.0", - "jasmine-core": "^2.4.1", - "karma": "^1.3.0", - "karma-chrome-launcher": "^2.2.0", - "karma-coverage": "^1.1.1", - "karma-firefox-launcher": "^1.1.0", - "karma-jasmine": "^1.1.1", + "grunt-webpack": "^3.1.3", + "istanbul-instrumenter-loader": "^3.0.1", + "jasmine-core": "^3.5.0", + "karma": "^4.3.0", + "karma-chrome-launcher": "^3.1.0", + "karma-coverage": "^2.0.1", + "karma-firefox-launcher": "^1.3.0", + "karma-jasmine": "^3.1.0", "karma-jasmine-ajax": "^0.1.13", "karma-opera-launcher": "^1.0.0", "karma-safari-launcher": "^1.0.0", - "karma-sauce-launcher": "^1.2.0", + "karma-sauce-launcher": "^2.0.2", "karma-sinon": "^1.0.5", "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^1.7.0", - "load-grunt-tasks": "^3.5.2", + "karma-webpack": "^4.0.2", + "load-grunt-tasks": "^5.1.0", "minimist": "^1.2.0", - "mocha": "^5.2.0", - "sinon": "^4.5.0", + "mocha": "^7.0.1", + "sinon": "^8.1.1", "typescript": "^2.8.1", "url-search-params": "^0.10.0", - "webpack": "^1.13.1", - "webpack-dev-server": "^1.14.1" + "webpack": "^4.40.2" }, "browser": { "./lib/adapters/http.js": "./lib/adapters/xhr.js" diff --git a/test/manual/basic.html b/test/manual/basic.html index 35fa6490d8..978e0c5cf6 100644 --- a/test/manual/basic.html +++ b/test/manual/basic.html @@ -7,7 +7,10 @@ An alert should be shown with the {"name":"axios"} - + - \ No newline at end of file + diff --git a/test/manual/cors.html b/test/manual/cors.html index da6e946fee..fb4519846e 100644 --- a/test/manual/cors.html +++ b/test/manual/cors.html @@ -7,7 +7,10 @@ An alert should be shown with {"status":"ok"} - + - \ No newline at end of file + diff --git a/test/manual/promise.js b/test/manual/promise.js deleted file mode 100644 index 2d48351584..0000000000 --- a/test/manual/promise.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * @overview es6-promise - a tiny implementation of Promises/A+. - * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE - * @version 3.0.2 - */ - -(function(){"use strict";function lib$es6$promise$utils$$objectOrFunction(x){return typeof x==="function"||typeof x==="object"&&x!==null}function lib$es6$promise$utils$$isFunction(x){return typeof x==="function"}function lib$es6$promise$utils$$isMaybeThenable(x){return typeof x==="object"&&x!==null}var lib$es6$promise$utils$$_isArray;if(!Array.isArray){lib$es6$promise$utils$$_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}else{lib$es6$promise$utils$$_isArray=Array.isArray}var lib$es6$promise$utils$$isArray=lib$es6$promise$utils$$_isArray;var lib$es6$promise$asap$$len=0;var lib$es6$promise$asap$$toString={}.toString;var lib$es6$promise$asap$$vertxNext;var lib$es6$promise$asap$$customSchedulerFn;var lib$es6$promise$asap$$asap=function asap(callback,arg){lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len]=callback;lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len+1]=arg;lib$es6$promise$asap$$len+=2;if(lib$es6$promise$asap$$len===2){if(lib$es6$promise$asap$$customSchedulerFn){lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush)}else{lib$es6$promise$asap$$scheduleFlush()}}};function lib$es6$promise$asap$$setScheduler(scheduleFn){lib$es6$promise$asap$$customSchedulerFn=scheduleFn}function lib$es6$promise$asap$$setAsap(asapFn){lib$es6$promise$asap$$asap=asapFn}var lib$es6$promise$asap$$browserWindow=typeof window!=="undefined"?window:undefined;var lib$es6$promise$asap$$browserGlobal=lib$es6$promise$asap$$browserWindow||{};var lib$es6$promise$asap$$BrowserMutationObserver=lib$es6$promise$asap$$browserGlobal.MutationObserver||lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;var lib$es6$promise$asap$$isNode=typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var lib$es6$promise$asap$$isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function lib$es6$promise$asap$$useNextTick(){return function(){process.nextTick(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useVertxTimer(){return function(){lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useMutationObserver(){var iterations=0;var observer=new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){node.data=iterations=++iterations%2}}function lib$es6$promise$asap$$useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=lib$es6$promise$asap$$flush;return function(){channel.port2.postMessage(0)}}function lib$es6$promise$asap$$useSetTimeout(){return function(){setTimeout(lib$es6$promise$asap$$flush,1)}}var lib$es6$promise$asap$$queue=new Array(1e3);function lib$es6$promise$asap$$flush(){for(var i=0;i -1; - var config = { + return { + mode: 'production', entry: './index.js', output: { - path: 'dist/', + path: `${__dirname}/dist`, filename: name + '.js', sourceMapFilename: name + '.map', library: 'axios', @@ -15,30 +16,21 @@ function generateConfig(name) { node: { process: false }, - devtool: 'source-map' + devtool: 'source-map', + optimization: { + minimize: name.includes('min'), + minimizer: [ + // config options documented at https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions + new TerserPlugin({ + sourceMap: true, + }), + ], + }, }; - - config.plugins = [ - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) - }) - ]; - - if (uglify) { - config.plugins.push( - new webpack.optimize.UglifyJsPlugin({ - compressor: { - warnings: false - } - }) - ); - } - - return config; } -['axios', 'axios.min'].forEach(function (key) { - config[key] = generateConfig(key); +['axios', 'axios.min'].forEach(outputScript => { + config[outputScript] = generateConfig(outputScript); }); module.exports = config;