Skip to content

Commit 297a59d

Browse files
committed
style:
1 parent bb2c9aa commit 297a59d

File tree

5 files changed

+127
-61
lines changed

5 files changed

+127
-61
lines changed

dist/vue-axios.es5.js

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,75 @@ Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66

7+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
8+
79
var _axios = require('axios');
810

911
var _axios2 = _interopRequireDefault(_axios);
1012

11-
var _utils = require('./utils');
12-
1313
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1414

15+
/**
16+
* Copied from vue-resource
17+
*/
18+
19+
function isFunction(val) {
20+
return typeof val === 'function';
21+
}
22+
23+
var isArray = Array.isArray;
24+
25+
function isPlainObject(obj) {
26+
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
27+
}
28+
29+
function isObject(obj) {
30+
return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
31+
}
32+
33+
function _merge(target, source, deep) {
34+
for (var key in source) {
35+
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
36+
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
37+
target[key] = {};
38+
}
39+
if (isArray(source[key]) && !isArray(target[key])) {
40+
target[key] = [];
41+
}
42+
_merge(target[key], source[key], deep);
43+
} else if (source[key] !== undefined) {
44+
target[key] = source[key];
45+
}
46+
}
47+
}
48+
49+
function merge(target) {
50+
51+
var args = slice.call(arguments, 1);
52+
53+
args.forEach(function (source) {
54+
_merge(target, source, true);
55+
});
56+
57+
return target;
58+
}
59+
60+
function options(fn, obj, opts) {
61+
62+
opts = opts || {};
63+
64+
if (isFunction(opts)) {
65+
opts = opts.call(obj);
66+
}
67+
68+
return merge(fn.bind({ $vm: obj, $options: opts }), fn, { $options: opts });
69+
}
70+
71+
/**
72+
* Install plugin
73+
* @param Vue
74+
*/
75+
1576
function plugin(Vue) {
1677

1778
if (plugin.installed) {
@@ -24,7 +85,7 @@ function plugin(Vue) {
2485

2586
axios: {
2687
get: function get() {
27-
return (0, _utils.options)(Vue.axios, this, this.$options.axios);
88+
return options(Vue.axios, this, this.$options.axios);
2889
}
2990
}
3091

dist/vue-axios.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-axios",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A small wrapper for integrating axios to Vuejs",
55
"main": "dist/vue-axios.min.js",
66
"scripts": {

src/index.js

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,65 @@
11
import axios from 'axios';
2-
import { options } from './utils'
2+
3+
/**
4+
* Copied from vue-resource
5+
*/
6+
7+
function isFunction(val) {
8+
return typeof val === 'function';
9+
}
10+
11+
const isArray = Array.isArray;
12+
13+
function isPlainObject(obj) {
14+
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
15+
}
16+
17+
function isObject(obj) {
18+
return obj !== null && typeof obj === 'object';
19+
}
20+
21+
function _merge(target, source, deep) {
22+
for (var key in source) {
23+
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
24+
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
25+
target[key] = {};
26+
}
27+
if (isArray(source[key]) && !isArray(target[key])) {
28+
target[key] = [];
29+
}
30+
_merge(target[key], source[key], deep);
31+
} else if (source[key] !== undefined) {
32+
target[key] = source[key];
33+
}
34+
}
35+
}
36+
37+
function merge(target) {
38+
39+
var args = slice.call(arguments, 1);
40+
41+
args.forEach((source) => {
42+
_merge(target, source, true);
43+
});
44+
45+
return target;
46+
}
47+
48+
function options(fn, obj, opts) {
49+
50+
opts = opts || {};
51+
52+
if (isFunction(opts)) {
53+
opts = opts.call(obj);
54+
}
55+
56+
return merge(fn.bind({$vm: obj, $options: opts}), fn, {$options: opts});
57+
}
58+
59+
/**
60+
* Install plugin
61+
* @param Vue
62+
*/
363

464
function plugin(Vue) {
565

src/utils.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)