vue-resource
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -5,3 +5,3 @@ { | ||
"description": "A web request service for Vue.js", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/vuejs/vue-resource", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
@@ -1,7 +0,35 @@ | ||
module.exports = { | ||
entry: "./src/index", | ||
output: { | ||
path: "./dist", | ||
filename: "vue-resource.js" | ||
var webpack = require("webpack"); | ||
var version = require("../package.json").version; | ||
var banner = | ||
"/**\n" + | ||
" * vue-resource v" + version + "\n" + | ||
" * https://github.com/vuejs/vue-resource\n" + | ||
" * Released under the MIT License.\n" + | ||
" */\n"; | ||
module.exports = [ | ||
{ | ||
entry: "./src/index", | ||
output: { | ||
path: "./dist", | ||
filename: "vue-resource.js" | ||
}, | ||
plugins: [ | ||
new webpack.BannerPlugin(banner, {raw: true}) | ||
] | ||
}, | ||
{ | ||
entry: "./src/index", | ||
output: { | ||
path: "./dist", | ||
filename: "vue-resource.min.js" | ||
}, | ||
plugins: [ | ||
new webpack.optimize.UglifyJsPlugin, | ||
new webpack.BannerPlugin(banner, {raw: true}) | ||
] | ||
} | ||
}; | ||
]; |
@@ -0,1 +1,7 @@ | ||
/** | ||
* vue-resource v0.1.4 | ||
* https://github.com/vuejs/vue-resource | ||
* Released under the MIT License. | ||
*/ | ||
/******/ (function(modules) { // webpackBootstrap | ||
@@ -99,3 +105,3 @@ /******/ // The module cache | ||
if (!url.match(/^(https?:)?\//) && options.root) { | ||
if (options.root !== false && !url.match(/^(https?:)?\//)) { | ||
url = options.root + '/' + url; | ||
@@ -128,3 +134,3 @@ } | ||
url: '', | ||
root: '', | ||
root: false, | ||
params: {} | ||
@@ -236,3 +242,3 @@ }; | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ function(module, exports) { | ||
@@ -563,3 +569,3 @@ /** | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ function(module, exports) { | ||
@@ -566,0 +572,0 @@ /** |
@@ -1,1 +0,7 @@ | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(e){e.url=n(5)(e),e.http=n(2)(e),e.resource=n(4)(e)}window.Vue&&Vue.use(r),e.exports=r},function(e,t,n){e.exports=function(e){function t(e,r,o){for(var s in r)o&&(n.isPlainObject(r[s])||n.isArray(r[s]))?(n.isPlainObject(r[s])&&!n.isPlainObject(e[s])&&(e[s]={}),n.isArray(r[s])&&!n.isArray(e[s])&&(e[s]=[]),t(e[s],r[s],o)):void 0!==r[s]&&(e[s]=r[s])}var n=e.util.extend({},e.util);return n.options=function(e,t,r){var o=t.$options||{};return n.extend({},o[e],r)},n.each=function(e,t){var r,o;if("number"==typeof e.length)for(r=0;r<e.length;r++)t.call(e[r],e[r],r);else if(n.isObject(e))for(o in e)e.hasOwnProperty(o)&&t.call(e[o],e[o],o);return e},n.extend=function(e){var n,r=[],o=r.slice.call(arguments,1);return"boolean"==typeof e&&(n=e,e=o.shift()),o.forEach(function(r){t(e,r,n)}),e},n.isFunction=function(e){return e&&"function"==typeof e},n}},function(e,t,n){e.exports=function(e){function t(n,i){var c,u,p=this;return i=i||{},a.isPlainObject(n)&&(i=n,n=""),c=a.extend({},t.headers.common,t.headers[i.method.toLowerCase()]),i=a.extend(!0,{url:n,headers:c},t.options,a.options("http",this,i)),u=("jsonp"==i.method.toLowerCase()?o:r).call(this,this.$url||e.url,i),a.extend(u,{success:function(e){return this.then(function(t){e.apply(p,s(t))},function(){}),this},error:function(e){return this["catch"](function(t){e.apply(p,s(t))}),this},always:function(e){var t=function(t){e.apply(p,s(t))};return this.then(t,t),this}}),i.success&&u.success(i.success),i.error&&u.error(i.error),u}function r(e,t){var n=new XMLHttpRequest;a.isFunction(t.beforeSend)&&t.beforeSend(n,t),t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers["X-HTTP-Method-Override"]=t.method,t.method="POST"),t.emulateJSON&&a.isPlainObject(t.data)&&(t.headers["Content-Type"]="application/x-www-form-urlencoded",t.data=e.params(t.data)),a.isObject(t.data)&&/FormData/i.test(t.data.toString())&&delete t.headers["Content-Type"],a.isPlainObject(t.data)&&(t.data=JSON.stringify(t.data));var r=new i(function(r,o){n.open(t.method,e(t),!0),a.each(t.headers,function(e,t){n.setRequestHeader(t,e)}),n.onreadystatechange=function(){4===this.readyState&&(this.status>=200&&this.status<300?r(this):o(this))},n.send(t.data)});return a.extend(r,{abort:function(){n.abort()}}),r}function o(e,t){var n,r,o="_jsonp"+Math.random().toString(36).substr(2);a.extend(t.params,t.data),t.params[t.jsonp]=o,a.isFunction(t.beforeSend)&&t.beforeSend({},t);var s=new i(function(s,a){n=document.createElement("script"),n.src=e(t.url,t.params),n.type="text/javascript",n.async=!0,window[o]=function(e){r=e};var i=function(e){delete window[o],document.body.removeChild(n),"load"!==e.type||r||(e.type="error");var t=r?r:e.type,i="error"===e.type?404:200;(200===i?s:a)({responseText:t,status:i})};n.onload=i,n.onerror=i,document.body.appendChild(n)});return s}function s(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e.status,e]}var a=n(1)(e),i=n(3),c={"Content-Type":"application/json;charset=utf-8"};return t.options={method:"GET",params:{},data:"",jsonp:"callback",beforeSend:null,emulateHTTP:!1,emulateJSON:!1},t.headers={put:c,post:c,patch:c,"delete":c,common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"}},["get","put","post","patch","delete","jsonp"].forEach(function(e){t[e]=function(t,n,r,o){return a.isFunction(n)&&(o=r,r=n,n=void 0),this(t,a.extend({method:e,data:n,success:r},o))}}),Object.defineProperty(e.prototype,"$http",{get:function(){return a.extend(t.bind(this),t)}}),t}},function(e,t,n){function r(e){e(this.resolve.bind(this),this.reject.bind(this)),this._thens=[]}r.prototype={then:function(e,t,n){this._thens.push({resolve:e,reject:t,progress:n})},"catch":function(e){this._thens.push({reject:e})},resolve:function(e){this._complete("resolve",e)},reject:function(e){this._complete("reject",e)},progress:function(e){for(var t,n=0;t=this._thens[n++];)t.progress&&t.progress(e)},_complete:function(e,t){this.then="resolve"===e?function(e,n){e&&e(t)}:function(e,n){n&&n(t)},this.resolve=this.reject=this.progress=function(){throw new Error("Promise already completed.")};for(var n,r=0;n=this._thens[r++];)n[e]&&n[e](t);delete this._thens}},e.exports=window.Promise?window.Promise:r},function(e,t,n){e.exports=function(e){function t(n,s,a){var i=this,c={};return a=o.extend({},t.actions,a),o.each(a,function(t,a){t=o.extend(!0,{url:n,params:s||{}},t),c[a]=function(){return(i.$http||e.http)(r(t,arguments))}}),c}function r(e,t){var n,r,s,a=o.extend({},e),i={};switch(t.length){case 4:s=t[3],r=t[2];case 3:case 2:if(!o.isFunction(t[1])){i=t[0],n=t[1],r=t[2];break}if(o.isFunction(t[0])){r=t[0],s=t[1];break}r=t[1],s=t[2];case 1:o.isFunction(t[0])?r=t[0]:/^(POST|PUT|PATCH)$/i.test(a.method)?n=t[0]:i=t[0];break;case 0:break;default:throw"Expected up to 4 arguments [params, data, success, error], got "+t.length+" arguments"}return a.url=e.url,a.data=n,a.params=o.extend({},e.params,i),r&&(a.success=r),s&&(a.error=s),a}var o=n(1)(e);return t.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},remove:{method:"DELETE"},"delete":{method:"DELETE"}},Object.defineProperty(e.prototype,"$resource",{get:function(){return t.bind(this)}}),t}},function(e,t,n){e.exports=function(e){function t(e,n){var r,s={},i={},c=e;return a.isPlainObject(c)||(c={url:e,params:n}),c=a.extend({},t.options,a.options("url",this,c)),e=c.url.replace(/:([a-z]\w*)/gi,function(e,t){return c.params[t]?(s[t]=!0,o(c.params[t])):""}),!e.match(/^(https?:)?\//)&&c.root&&(e=c.root+"/"+e),e=e.replace(/([^:])[\/]{2,}/g,"$1/"),e=e.replace(/(\w+)\/+$/,"$1"),a.each(c.params,function(e,t){s[t]||(i[t]=e)}),r=t.params(i),r&&(e+=(-1==e.indexOf("?")?"?":"&")+r),e}function r(e,t,n){var o,s=a.isArray(t),i=a.isPlainObject(t);a.each(t,function(t,c){o=a.isObject(t)||a.isArray(t),n&&(c=n+"["+(i||o?c:"")+"]"),!n&&s?e.add(t.name,t.value):o?r(e,t,c):e.add(c,t)})}function o(e){return s(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function s(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,t?"%20":"+")}var a=n(1)(e);return t.options={url:"",root:"",params:{}},t.params=function(e){var t=[];return t.add=function(e,t){a.isFunction(t)&&(t=t()),null===t&&(t=""),this.push(o(e)+"="+o(t))},r(t,e),t.join("&")},t.parse=function(e){var t=new RegExp("^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?"),n=e.match(t);return{url:e,scheme:n[1]||"",host:n[2]||"",path:n[3]||"",query:n[4]||"",fragment:n[5]||""}},Object.defineProperty(e.prototype,"$url",{get:function(){return a.extend(t.bind(this),t)}}),t}}]); | ||
/** | ||
* vue-resource v0.1.4 | ||
* https://github.com/vuejs/vue-resource | ||
* Released under the MIT License. | ||
*/ | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(e){e.url=n(1)(e),e.http=n(3)(e),e.resource=n(5)(e)}window.Vue&&Vue.use(r),e.exports=r},function(e,t,n){e.exports=function(e){function t(e,n){var r,s={},i={},c=e;return a.isPlainObject(c)||(c={url:e,params:n}),c=a.extend({},t.options,a.options("url",this,c)),e=c.url.replace(/:([a-z]\w*)/gi,function(e,t){return c.params[t]?(s[t]=!0,o(c.params[t])):""}),c.root===!1||e.match(/^(https?:)?\//)||(e=c.root+"/"+e),e=e.replace(/([^:])[\/]{2,}/g,"$1/"),e=e.replace(/(\w+)\/+$/,"$1"),a.each(c.params,function(e,t){s[t]||(i[t]=e)}),r=t.params(i),r&&(e+=(-1==e.indexOf("?")?"?":"&")+r),e}function r(e,t,n){var o,s=a.isArray(t),i=a.isPlainObject(t);a.each(t,function(t,c){o=a.isObject(t)||a.isArray(t),n&&(c=n+"["+(i||o?c:"")+"]"),!n&&s?e.add(t.name,t.value):o?r(e,t,c):e.add(c,t)})}function o(e){return s(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function s(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,t?"%20":"+")}var a=n(2)(e);return t.options={url:"",root:!1,params:{}},t.params=function(e){var t=[];return t.add=function(e,t){a.isFunction(t)&&(t=t()),null===t&&(t=""),this.push(o(e)+"="+o(t))},r(t,e),t.join("&")},t.parse=function(e){var t=new RegExp("^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?"),n=e.match(t);return{url:e,scheme:n[1]||"",host:n[2]||"",path:n[3]||"",query:n[4]||"",fragment:n[5]||""}},Object.defineProperty(e.prototype,"$url",{get:function(){return a.extend(t.bind(this),t)}}),t}},function(e,t){e.exports=function(e){function t(e,r,o){for(var s in r)o&&(n.isPlainObject(r[s])||n.isArray(r[s]))?(n.isPlainObject(r[s])&&!n.isPlainObject(e[s])&&(e[s]={}),n.isArray(r[s])&&!n.isArray(e[s])&&(e[s]=[]),t(e[s],r[s],o)):void 0!==r[s]&&(e[s]=r[s])}var n=e.util.extend({},e.util);return n.options=function(e,t,r){var o=t.$options||{};return n.extend({},o[e],r)},n.each=function(e,t){var r,o;if("number"==typeof e.length)for(r=0;r<e.length;r++)t.call(e[r],e[r],r);else if(n.isObject(e))for(o in e)e.hasOwnProperty(o)&&t.call(e[o],e[o],o);return e},n.extend=function(e){var n,r=[],o=r.slice.call(arguments,1);return"boolean"==typeof e&&(n=e,e=o.shift()),o.forEach(function(r){t(e,r,n)}),e},n.isFunction=function(e){return e&&"function"==typeof e},n}},function(e,t,n){e.exports=function(e){function t(n,i){var c,u,p=this;return i=i||{},a.isPlainObject(n)&&(i=n,n=""),c=a.extend({},t.headers.common,t.headers[i.method.toLowerCase()]),i=a.extend(!0,{url:n,headers:c},t.options,a.options("http",this,i)),u=("jsonp"==i.method.toLowerCase()?o:r).call(this,this.$url||e.url,i),a.extend(u,{success:function(e){return this.then(function(t){e.apply(p,s(t))},function(){}),this},error:function(e){return this["catch"](function(t){e.apply(p,s(t))}),this},always:function(e){var t=function(t){e.apply(p,s(t))};return this.then(t,t),this}}),i.success&&u.success(i.success),i.error&&u.error(i.error),u}function r(e,t){var n=new XMLHttpRequest;a.isFunction(t.beforeSend)&&t.beforeSend(n,t),t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers["X-HTTP-Method-Override"]=t.method,t.method="POST"),t.emulateJSON&&a.isPlainObject(t.data)&&(t.headers["Content-Type"]="application/x-www-form-urlencoded",t.data=e.params(t.data)),a.isObject(t.data)&&/FormData/i.test(t.data.toString())&&delete t.headers["Content-Type"],a.isPlainObject(t.data)&&(t.data=JSON.stringify(t.data));var r=new i(function(r,o){n.open(t.method,e(t),!0),a.each(t.headers,function(e,t){n.setRequestHeader(t,e)}),n.onreadystatechange=function(){4===this.readyState&&(this.status>=200&&this.status<300?r(this):o(this))},n.send(t.data)});return a.extend(r,{abort:function(){n.abort()}}),r}function o(e,t){var n,r,o="_jsonp"+Math.random().toString(36).substr(2);a.extend(t.params,t.data),t.params[t.jsonp]=o,a.isFunction(t.beforeSend)&&t.beforeSend({},t);var s=new i(function(s,a){n=document.createElement("script"),n.src=e(t.url,t.params),n.type="text/javascript",n.async=!0,window[o]=function(e){r=e};var i=function(e){delete window[o],document.body.removeChild(n),"load"!==e.type||r||(e.type="error");var t=r?r:e.type,i="error"===e.type?404:200;(200===i?s:a)({responseText:t,status:i})};n.onload=i,n.onerror=i,document.body.appendChild(n)});return s}function s(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e.status,e]}var a=n(2)(e),i=n(4),c={"Content-Type":"application/json;charset=utf-8"};return t.options={method:"GET",params:{},data:"",jsonp:"callback",beforeSend:null,emulateHTTP:!1,emulateJSON:!1},t.headers={put:c,post:c,patch:c,"delete":c,common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"}},["get","put","post","patch","delete","jsonp"].forEach(function(e){t[e]=function(t,n,r,o){return a.isFunction(n)&&(o=r,r=n,n=void 0),this(t,a.extend({method:e,data:n,success:r},o))}}),Object.defineProperty(e.prototype,"$http",{get:function(){return a.extend(t.bind(this),t)}}),t}},function(e,t){function n(e){e(this.resolve.bind(this),this.reject.bind(this)),this._thens=[]}n.prototype={then:function(e,t,n){this._thens.push({resolve:e,reject:t,progress:n})},"catch":function(e){this._thens.push({reject:e})},resolve:function(e){this._complete("resolve",e)},reject:function(e){this._complete("reject",e)},progress:function(e){for(var t,n=0;t=this._thens[n++];)t.progress&&t.progress(e)},_complete:function(e,t){this.then="resolve"===e?function(e,n){e&&e(t)}:function(e,n){n&&n(t)},this.resolve=this.reject=this.progress=function(){throw new Error("Promise already completed.")};for(var n,r=0;n=this._thens[r++];)n[e]&&n[e](t);delete this._thens}},e.exports=window.Promise?window.Promise:n},function(e,t,n){e.exports=function(e){function t(n,s,a){var i=this,c={};return a=o.extend({},t.actions,a),o.each(a,function(t,a){t=o.extend(!0,{url:n,params:s||{}},t),c[a]=function(){return(i.$http||e.http)(r(t,arguments))}}),c}function r(e,t){var n,r,s,a=o.extend({},e),i={};switch(t.length){case 4:s=t[3],r=t[2];case 3:case 2:if(!o.isFunction(t[1])){i=t[0],n=t[1],r=t[2];break}if(o.isFunction(t[0])){r=t[0],s=t[1];break}r=t[1],s=t[2];case 1:o.isFunction(t[0])?r=t[0]:/^(POST|PUT|PATCH)$/i.test(a.method)?n=t[0]:i=t[0];break;case 0:break;default:throw"Expected up to 4 arguments [params, data, success, error], got "+t.length+" arguments"}return a.url=e.url,a.data=n,a.params=o.extend({},e.params,i),r&&(a.success=r),s&&(a.error=s),a}var o=n(2)(e);return t.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},remove:{method:"DELETE"},"delete":{method:"DELETE"}},Object.defineProperty(e.prototype,"$resource",{get:function(){return t.bind(this)}}),t}}]); |
{ | ||
"name": "vue-resource", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A web request service for Vue.js", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "webpack --config build/webpack.build.config.js && webpack --config build/webpack.build.config.js --output-file vue-resource.min.js -p" | ||
"build": "webpack --config build/webpack.build.config.js" | ||
}, | ||
@@ -25,4 +25,4 @@ "repository": { | ||
"devDependencies": { | ||
"webpack": "^1.8.11" | ||
"webpack": "^1.10.0" | ||
} | ||
} |
# vue-resource | ||
Resource plugin for Vue.js (v0.11). | ||
Resource plugin for Vue.js. | ||
@@ -11,3 +11,3 @@ The plugin provides services for making web requests and handle responses using a XMLHttpRequest or JSONP. | ||
List of methods: | ||
### Methods | ||
@@ -21,2 +21,16 @@ * `Vue.http.get(url, [data], [success], [options])` | ||
### Options | ||
* **url** - `string` - URL to which the request is sent | ||
* **data** - `Object|string` - Data to be sent as the request message data | ||
* **method** - `string` - HTTP method (e.g. GET, POST, ...) | ||
* **params** - `Object` - Parameters object to be appended as GET parameters | ||
* **headers** - `Object` - Headers object to be sent as HTTP request headers | ||
* **success** - `function(data, status, request)` - Callback function to be called when the request finishes | ||
* **error** - `function(data, status, request)` - Callback function to be called when the request fails | ||
* **beforeSend** - `function(request, options)` - Callback function to modify the request object before it is sent | ||
* **emulateHTTP** - `boolean` - Send PUT, PATCH and DELETE requests with a HTTP POST and set the `X-HTTP-Method-Override` header | ||
* **emulateJSON** - `boolean` - Send request data as `application/x-www-form-urlencoded` content type | ||
* **jsonp** - `string` - Callback function name in a JSONP request | ||
### Usage | ||
@@ -48,7 +62,7 @@ | ||
List of methods: | ||
### Methods | ||
* `Vue.resource(url, [params], [actions])` | ||
List of default actions: | ||
### Default Actions | ||
@@ -55,0 +69,0 @@ ```javascript |
@@ -32,3 +32,3 @@ module.exports = function (Vue) { | ||
if (!url.match(/^(https?:)?\//) && options.root) { | ||
if (options.root !== false && !url.match(/^(https?:)?\//)) { | ||
url = options.root + '/' + url; | ||
@@ -61,3 +61,3 @@ } | ||
url: '', | ||
root: '', | ||
root: false, | ||
params: {} | ||
@@ -64,0 +64,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
45673
1056
105
0