Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xjbieke
axios
提交
60a82ef4
A
axios
项目概览
xjbieke
/
axios
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
axios
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
60a82ef4
编写于
3月 18, 2015
作者:
M
mzabriskie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changing to file level use strict statement
上级
fc12b933
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
31 addition
and
45 deletion
+31
-45
.eslintrc
.eslintrc
+2
-1
lib/adapters/http.js
lib/adapters/http.js
+2
-2
lib/adapters/xhr.js
lib/adapters/xhr.js
+2
-2
lib/axios.js
lib/axios.js
+2
-7
lib/core/InterceptorManager.js
lib/core/InterceptorManager.js
+2
-4
lib/core/dispatchRequest.js
lib/core/dispatchRequest.js
+2
-0
lib/defaults.js
lib/defaults.js
+2
-2
lib/helpers/buildUrl.js
lib/helpers/buildUrl.js
+2
-2
lib/helpers/cookies.js
lib/helpers/cookies.js
+2
-3
lib/helpers/deprecatedMethod.js
lib/helpers/deprecatedMethod.js
+2
-3
lib/helpers/parseHeaders.js
lib/helpers/parseHeaders.js
+2
-1
lib/helpers/spread.js
lib/helpers/spread.js
+2
-1
lib/helpers/transformData.js
lib/helpers/transformData.js
+2
-1
lib/helpers/urlIsSameOrigin.js
lib/helpers/urlIsSameOrigin.js
+2
-2
lib/utils.js
lib/utils.js
+3
-14
未找到文件。
.eslintrc
浏览文件 @
60a82ef4
...
...
@@ -5,7 +5,8 @@
"require": true
},
"env": {
"browser": true
"browser": true,
"node": true
},
"rules": {
"quotes": "single"
...
...
lib/adapters/http.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
defaults
=
require
(
'
./../defaults
'
);
var
utils
=
require
(
'
./../utils
'
);
var
buildUrl
=
require
(
'
./../helpers/buildUrl
'
);
...
...
@@ -9,8 +11,6 @@ var pkg = require('./../../package.json');
var
Buffer
=
require
(
'
buffer
'
).
Buffer
;
module
.
exports
=
function
httpAdapter
(
resolve
,
reject
,
config
)
{
'
use strict
'
;
// Transform request data
var
data
=
transformData
(
config
.
data
,
...
...
lib/adapters/xhr.js
浏览文件 @
60a82ef4
'
use strict
'
;
/*global ActiveXObject:true*/
var
defaults
=
require
(
'
./../defaults
'
);
...
...
@@ -9,8 +11,6 @@ var transformData = require('./../helpers/transformData');
var
urlIsSameOrigin
=
require
(
'
./../helpers/urlIsSameOrigin
'
);
module
.
exports
=
function
xhrAdapter
(
resolve
,
reject
,
config
)
{
'
use strict
'
;
// Transform request data
var
data
=
transformData
(
config
.
data
,
...
...
lib/axios.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
defaults
=
require
(
'
./defaults
'
);
var
utils
=
require
(
'
./utils
'
);
var
deprecatedMethod
=
require
(
'
./helpers/deprecatedMethod
'
);
...
...
@@ -6,8 +8,6 @@ var InterceptorManager = require('./core/InterceptorManager');
// Polyfill ES6 Promise if needed
(
function
()
{
'
use strict
'
;
// webpack is being used to set es6-promise to the native Promise
// for the standalone build. It's necessary to make sure polyfill exists.
var
P
=
require
(
'
es6-promise
'
);
...
...
@@ -17,8 +17,6 @@ var InterceptorManager = require('./core/InterceptorManager');
})();
var
axios
=
module
.
exports
=
function
axios
(
config
)
{
'
use strict
'
;
config
=
utils
.
merge
({
method
:
'
get
'
,
headers
:
{},
...
...
@@ -73,7 +71,6 @@ axios.defaults = defaults;
// Expose all/spread
axios
.
all
=
function
(
promises
)
{
'
use strict
'
;
return
Promise
.
all
(
promises
);
};
axios
.
spread
=
require
(
'
./helpers/spread
'
);
...
...
@@ -86,8 +83,6 @@ axios.interceptors = {
// Provide aliases for supported request methods
(
function
()
{
'
use strict
'
;
function
createShortMethods
()
{
utils
.
forEach
(
arguments
,
function
(
method
)
{
axios
[
method
]
=
function
(
url
,
config
)
{
...
...
lib/core/InterceptorManager.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./../utils
'
);
function
InterceptorManager
()
{
'
use strict
'
;
this
.
handlers
=
[];
}
...
...
@@ -14,7 +15,6 @@ function InterceptorManager() {
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager
.
prototype
.
use
=
function
(
fulfilled
,
rejected
)
{
'
use strict
'
;
this
.
handlers
.
push
({
fulfilled
:
fulfilled
,
rejected
:
rejected
...
...
@@ -28,7 +28,6 @@ InterceptorManager.prototype.use = function (fulfilled, rejected) {
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager
.
prototype
.
eject
=
function
(
id
)
{
'
use strict
'
;
if
(
this
.
handlers
[
id
])
{
this
.
handlers
[
id
]
=
null
;
}
...
...
@@ -43,7 +42,6 @@ InterceptorManager.prototype.eject = function (id) {
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager
.
prototype
.
forEach
=
function
(
fn
)
{
'
use strict
'
;
utils
.
forEach
(
this
.
handlers
,
function
(
h
)
{
if
(
h
!==
null
)
{
fn
(
h
);
...
...
lib/core/dispatchRequest.js
浏览文件 @
60a82ef4
'
use strict
'
;
/**
* Dispatch a request to the server using whichever adapter
* is supported by the current environment.
...
...
lib/defaults.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./utils
'
);
var
JSON_START
=
/^
\s
*
(\[
|
\{[^\{])
/
;
...
...
@@ -9,7 +11,6 @@ var DEFAULT_CONTENT_TYPE = {
module
.
exports
=
{
transformRequest
:
[
function
(
data
,
headers
)
{
'
use strict
'
;
if
(
utils
.
isArrayBuffer
(
data
))
{
return
data
;
}
...
...
@@ -27,7 +28,6 @@ module.exports = {
}],
transformResponse
:
[
function
(
data
)
{
'
use strict
'
;
if
(
typeof
data
===
'
string
'
)
{
data
=
data
.
replace
(
PROTECTION_PREFIX
,
''
);
if
(
JSON_START
.
test
(
data
)
&&
JSON_END
.
test
(
data
))
{
...
...
lib/helpers/buildUrl.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./../utils
'
);
function
encode
(
val
)
{
'
use strict
'
;
return
encodeURIComponent
(
val
).
replace
(
/%40/gi
,
'
@
'
).
replace
(
/%3A/gi
,
'
:
'
).
...
...
@@ -18,7 +19,6 @@ function encode(val) {
* @returns {string} The formatted url
*/
module
.
exports
=
function
buildUrl
(
url
,
params
)
{
'
use strict
'
;
if
(
!
params
)
{
return
url
;
}
...
...
lib/helpers/cookies.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./../utils
'
);
module
.
exports
=
{
write
:
function
write
(
name
,
value
,
expires
,
path
,
domain
,
secure
)
{
'
use strict
'
;
var
cookie
=
[];
cookie
.
push
(
name
+
'
=
'
+
encodeURIComponent
(
value
));
...
...
@@ -26,13 +27,11 @@ module.exports = {
},
read
:
function
read
(
name
)
{
'
use strict
'
;
var
match
=
document
.
cookie
.
match
(
new
RegExp
(
'
(^|;
\\
s*)(
'
+
name
+
'
)=([^;]*)
'
));
return
(
match
?
decodeURIComponent
(
match
[
3
])
:
null
);
},
remove
:
function
remove
(
name
)
{
'
use strict
'
;
this
.
write
(
name
,
''
,
Date
.
now
()
-
86400000
);
}
};
lib/helpers/deprecatedMethod.js
浏览文件 @
60a82ef4
'
use strict
'
;
/**
* Supply a warning to the developer that a method they are using
* has been deprecated.
...
...
@@ -7,9 +9,6 @@
* @param {string} [docs] The documentation URL to get further details
*/
module
.
exports
=
function
deprecatedMethod
(
method
,
instead
,
docs
)
{
/*eslint-env node*/
'
use strict
'
;
try
{
console
.
warn
(
'
DEPRECATED method `
'
+
method
+
'
`.
'
+
...
...
lib/helpers/parseHeaders.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./../utils
'
);
/**
...
...
@@ -14,7 +16,6 @@ var utils = require('./../utils');
* @returns {Object} Headers parsed into an object
*/
module
.
exports
=
function
parseHeaders
(
headers
)
{
'
use strict
'
;
var
parsed
=
{},
key
,
val
,
i
;
if
(
!
headers
)
{
return
parsed
;
}
...
...
lib/helpers/spread.js
浏览文件 @
60a82ef4
'
use strict
'
;
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.
*
...
...
@@ -19,7 +21,6 @@
* @returns {Function}
*/
module
.
exports
=
function
spread
(
callback
)
{
'
use strict
'
;
return
function
(
arr
)
{
callback
.
apply
(
null
,
arr
);
};
...
...
lib/helpers/transformData.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./../utils
'
);
/**
...
...
@@ -9,7 +11,6 @@ var utils = require('./../utils');
* @returns {*} The resulting transformed data
*/
module
.
exports
=
function
transformData
(
data
,
headers
,
fns
)
{
'
use strict
'
;
utils
.
forEach
(
fns
,
function
(
fn
)
{
data
=
fn
(
data
,
headers
);
});
...
...
lib/helpers/urlIsSameOrigin.js
浏览文件 @
60a82ef4
'
use strict
'
;
var
utils
=
require
(
'
./../utils
'
);
var
msie
=
/
(
msie|trident
)
/i
.
test
(
navigator
.
userAgent
);
var
urlParsingNode
=
document
.
createElement
(
'
a
'
);
...
...
@@ -10,7 +12,6 @@ var originUrl;
* @returns {Object}
*/
function
urlResolve
(
url
)
{
'
use strict
'
;
var
href
=
url
;
if
(
msie
)
{
...
...
@@ -45,7 +46,6 @@ originUrl = urlResolve(window.location.href);
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
module
.
exports
=
function
urlIsSameOrigin
(
requestUrl
)
{
'
use strict
'
;
var
parsed
=
(
utils
.
isString
(
requestUrl
))
?
urlResolve
(
requestUrl
)
:
requestUrl
;
return
(
parsed
.
protocol
===
originUrl
.
protocol
&&
parsed
.
host
===
originUrl
.
host
);
...
...
lib/utils.js
浏览文件 @
60a82ef4
'
use strict
'
;
/*global toString:true*/
// utils is a library of generic helper functions non-specific to axios
var
toString
=
Object
.
prototype
.
toString
;
...
...
@@ -10,7 +13,6 @@ var toString = Object.prototype.toString;
* @returns {boolean} True if value is an Array, otherwise false
*/
function
isArray
(
val
)
{
'
use strict
'
;
return
toString
.
call
(
val
)
===
'
[object Array]
'
;
}
...
...
@@ -21,7 +23,6 @@ function isArray(val) {
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
*/
function
isArrayBuffer
(
val
)
{
'
use strict
'
;
return
toString
.
call
(
val
)
===
'
[object ArrayBuffer]
'
;
}
...
...
@@ -32,7 +33,6 @@ function isArrayBuffer(val) {
* @returns {boolean} True if value is an FormData, otherwise false
*/
function
isFormData
(
val
)
{
'
use strict
'
;
return
toString
.
call
(
val
)
===
'
[object FormData]
'
;
}
...
...
@@ -43,7 +43,6 @@ function isFormData(val) {
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
*/
function
isArrayBufferView
(
val
)
{
'
use strict
'
;
if
((
typeof
ArrayBuffer
!==
'
undefined
'
)
&&
(
ArrayBuffer
.
isView
))
{
return
ArrayBuffer
.
isView
(
val
);
}
else
{
...
...
@@ -58,7 +57,6 @@ function isArrayBufferView(val) {
* @returns {boolean} True if value is a String, otherwise false
*/
function
isString
(
val
)
{
'
use strict
'
;
return
typeof
val
===
'
string
'
;
}
...
...
@@ -69,7 +67,6 @@ function isString(val) {
* @returns {boolean} True if value is a Number, otherwise false
*/
function
isNumber
(
val
)
{
'
use strict
'
;
return
typeof
val
===
'
number
'
;
}
...
...
@@ -80,7 +77,6 @@ function isNumber(val) {
* @returns {boolean} True if the value is undefined, otherwise false
*/
function
isUndefined
(
val
)
{
'
use strict
'
;
return
typeof
val
===
'
undefined
'
;
}
...
...
@@ -91,7 +87,6 @@ function isUndefined(val) {
* @returns {boolean} True if value is an Object, otherwise false
*/
function
isObject
(
val
)
{
'
use strict
'
;
return
val
!==
null
&&
typeof
val
===
'
object
'
;
}
...
...
@@ -102,7 +97,6 @@ function isObject(val) {
* @returns {boolean} True if value is a Date, otherwise false
*/
function
isDate
(
val
)
{
'
use strict
'
;
return
toString
.
call
(
val
)
===
'
[object Date]
'
;
}
...
...
@@ -113,7 +107,6 @@ function isDate(val) {
* @returns {boolean} True if value is a File, otherwise false
*/
function
isFile
(
val
)
{
'
use strict
'
;
return
toString
.
call
(
val
)
===
'
[object File]
'
;
}
...
...
@@ -124,7 +117,6 @@ function isFile(val) {
* @returns {boolean} True if value is a Blob, otherwise false
*/
function
isBlob
(
val
)
{
'
use strict
'
;
return
toString
.
call
(
val
)
===
'
[object Blob]
'
;
}
...
...
@@ -135,7 +127,6 @@ function isBlob(val) {
* @returns {String} The String freed of excess whitespace
*/
function
trim
(
str
)
{
'
use strict
'
;
return
str
.
replace
(
/^
\s
*/
,
''
).
replace
(
/
\s
*$/
,
''
);
}
...
...
@@ -152,7 +143,6 @@ function trim(str) {
* @param {Function} fn The callback to invoke for each item
*/
function
forEach
(
obj
,
fn
)
{
'
use strict
'
;
// Don't bother if no value provided
if
(
obj
===
null
||
typeof
obj
===
'
undefined
'
)
{
return
;
...
...
@@ -200,7 +190,6 @@ function forEach(obj, fn) {
* @returns {Object} Result of all merge properties
*/
function
merge
(
/*obj1, obj2, obj3, ...*/
)
{
'
use strict
'
;
var
result
=
{};
forEach
(
arguments
,
function
(
obj
)
{
forEach
(
obj
,
function
(
val
,
key
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录