ng-base-service
Version:
BaseService is a service for angular API CRUD
2 lines • 3.21 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("ng-base-service",["exports"],e):e(t["ng-base-service"]={})}(this,function(t){"use strict";var e=function(){function t(t,e){this._http=t,this.url=e}return t.prototype.getById=function(t){return this._http.get(this.url+"/"+t)},t.prototype.getAll=function(){return this._http.get(this.url)},t.prototype.add=function(t){return this._http.post(this.url,t)},t.prototype.update=function(t,e){return this._http.put(this.url+"/"+t,e)},t.prototype["delete"]=function(t){return this._http["delete"](this.url+"/"+t)},t}();function r(e,u,s,c){return new(s||(s=Promise))(function(t,n){function r(t){try{o(c.next(t))}catch(e){n(e)}}function i(t){try{o(c["throw"](t))}catch(e){n(e)}}function o(e){e.done?t(e.value):new s(function(t){t(e.value)}).then(r,i)}o((c=c.apply(e,u||[])).next())})}function i(r,i){var o,u,s,t,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),"throw":e(1),"return":e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function n(t){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,u&&(s=2&t[0]?u["return"]:t[0]?u["throw"]||((s=u["return"])&&s.call(u),0):u.next)&&!(s=s.call(u,t[1])).done)return s;switch(u=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,u=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(s=0<(s=c.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){c.label=t[1];break}if(6===t[0]&&c.label<s[1]){c.label=s[1],s=t;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(t);break}s[2]&&c.ops.pop(),c.trys.pop();continue}t=i.call(r,c)}catch(e){t=[6,e],u=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([e,t])}}}var n=function(){function t(t,e){this._http=t,this.url=e}return t.prototype.getById=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._http.get(this.url+"/"+e).toPromise()];case 1:return[2,t.sent()]}})})},t.prototype.getAll=function(){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._http.get(this.url).toPromise()];case 1:return[2,t.sent()]}})})},t.prototype.add=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._http.post(this.url,e).toPromise()];case 1:return[2,t.sent()]}})})},t.prototype.update=function(e,n){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._http.put(this.url+"/"+e,n).toPromise()];case 1:return[2,t.sent()]}})})},t.prototype["delete"]=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._http["delete"](this.url+"/"+e).toPromise()];case 1:return[2,t.sent()]}})})},t}();t.BaseService=e,t.BaseAsyncService=n,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-base-service.umd.min.js.map