Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fakerest

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fakerest - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

4

dist/FakeRest.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.FakeRest=t():e.FakeRest=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=n(o),u=r(2),a=n(u),s=r(3),c=n(s),l=r(4),f=n(l);t["default"]={Server:i["default"],FetchServer:a["default"],Collection:c["default"],Single:f["default"]},e.exports=t["default"]},function(e,t,r){"use strict";var n=r(6)["default"],o=r(7)["default"],i=r(8)["default"],u=r(9)["default"],a=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var s=r(13),c=a(s),l=r(3),f=a(l),d=r(4),p=a(d),h=r(10),y=a(h),v=c["default"].getPolyfill(),g=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0];o(this,e),this.baseUrl=t,this.loggingEnabled=!1,this.defaultQuery=function(){},this.batchUrl=null,this.collections={},this.singles={},this.requestInterceptors=[],this.responseInterceptors=[]}return n(e,[{key:"init",value:function(e){for(var t in e)Array.isArray(e[t])?this.addCollection(t,new f["default"](e[t],"id")):this.addSingle(t,new p["default"](e[t]))}},{key:"toggleLogging",value:function(){this.loggingEnabled=!this.loggingEnabled}},{key:"setDefaultQuery",value:function(e){this.defaultQuery=e}},{key:"setBatchUrl",value:function(e){this.batchUrl=e}},{key:"setBatch",value:function(e){console.warn("Server.setBatch() is deprecated, use Server.setBatchUrl() instead"),this.batchUrl=e}},{key:"addCollection",value:function(e,t){this.collections[e]=t,t.setServer(this),t.setName(e)}},{key:"getCollection",value:function(e){return this.collections[e]}},{key:"getCollectionNames",value:function(){return i(this.collections)}},{key:"addSingle",value:function(e,t){this.singles[e]=t,t.setServer(this),t.setName(e)}},{key:"getSingle",value:function(e){return this.singles[e]}},{key:"getSingleNames",value:function(){return i(this.singles)}},{key:"addRequestInterceptor",value:function(e){this.requestInterceptors.push(e)}},{key:"addResponseInterceptor",value:function(e){this.responseInterceptors.push(e)}},{key:"getCount",value:function(e,t){return this.collections[e].getCount(t)}},{key:"getAll",value:function(e,t){return this.collections[e].getAll(t)}},{key:"getOne",value:function(e,t,r){return this.collections[e].getOne(t,r)}},{key:"addOne",value:function(e,t){return this.collections[e].addOne(t)}},{key:"updateOne",value:function(e,t,r){return this.collections[e].updateOne(t,r)}},{key:"removeOne",value:function(e,t){return this.collections[e].removeOne(t)}},{key:"getOnly",value:function(e){return this.singles[e].getOnly()}},{key:"updateOnly",value:function(e,t){return this.singles[e].updateOnly(t)}},{key:"decode",value:function(e){if(e.queryString=decodeURIComponent(e.url.slice(e.url.indexOf("?")+1)),e.params=y["default"](e.queryString),e.requestBody)try{e.json=JSON.parse(e.requestBody)}catch(t){}return this.requestInterceptors.reduce(function(e,t){return t(e)},e)}},{key:"respond",value:function(e,t,r){var n=arguments.length<=3||void 0===arguments[3]?200:arguments[3];t||(t={}),t["Content-Type"]||(t["Content-Type"]="application/json");var o={status:n,headers:t,body:e};return o=this.responseInterceptors.reduce(function(e,t){return t(e,r)},o),this.log(r,o),r.respond(o.status,o.headers,JSON.stringify(o.body))}},{key:"log",value:function(e,t){this.loggingEnabled&&(console.group?(console.groupCollapsed(e.method,e.url,"(FakeRest)"),console.group("request"),console.log(e.method,e.url),console.log("headers",e.requestHeaders),console.log("body ",e.requestBody),console.groupEnd(),console.group("response",t.status),console.log("headers",t.headers),console.log("body ",t.body),console.groupEnd(),console.groupEnd()):(console.log("FakeRest request ",e.method,e.url,"headers",e.requestHeaders,"body",e.requestBody),console.log("FakeRest response",t.status,"headers",t.headers,"body",t.body)))}},{key:"batch",value:function(e){var t=e.json,r=this.handle.bind(this),n=i(t).reduce(function(e,n){var o,u={url:t[n],method:"GET",params:{},respond:function(e,t,r){o={code:e,headers:i(t||{}).map(function(e){return{name:e,value:t[e]}}),body:r||{}}}};return r(u),e[n]=o||{code:404,headers:[],body:{}},e},{});return this.respond(n,{},e,200)}},{key:"handle",value:function(e){if(e=this.decode(e),this.batchUrl&&this.batchUrl===e.url&&"POST"===e.method)return this.batch(e);var t=!0,r=!1,n=void 0;try{for(var o,i=u(this.getSingleNames());!(t=(o=i.next()).done);t=!0){var a=o.value,s=e.url.match(new RegExp("^"+this.baseUrl+"\\/("+a+")(\\/?.*)?$"));if(s){if("GET"==e.method)try{var c=this.getOnly(a);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PUT"==e.method)try{var c=this.updateOnly(a,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PATCH"==e.method)try{var c=this.updateOnly(a,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}}}}catch(f){r=!0,n=f}finally{try{!t&&i["return"]&&i["return"]()}finally{if(r)throw n}}var d=!0,p=!1,h=void 0;try{for(var y,g=u(this.getCollectionNames());!(d=(y=g.next()).done);d=!0){var b=y.value,s=e.url.match(new RegExp("^"+this.baseUrl+"\\/("+b+")(\\/(\\d+))?(\\?.*)?$"));if(s){var m=v({},this.defaultQuery(b),e.params);if(s[2]){var O=s[3];if("GET"==e.method)try{var c=this.getOne(b,O,m);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PUT"==e.method)try{var c=this.updateOne(b,O,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PATCH"==e.method)try{var c=this.updateOne(b,O,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("DELETE"==e.method)try{var c=this.removeOne(b,O);return this.respond(c,null,e)}catch(l){return e.respond(404)}}else{if("GET"==e.method){var j=this.getCount(b,m.filter?{filter:m.filter}:{}),w=void 0,x=void 0,E=void 0;if(j>0){w=this.getAll(b,m);var S=m.range?m.range[0]:0,k=m.range?Math.min(w.length-1+S,m.range[1]):w.length-1;x="items "+S+"-"+k+"/"+j,E=w.length==j?200:206}else w=[],x="items */0",E=200;return this.respond(w,{"Content-Range":x},e,E)}if("POST"==e.method){var _=this.addOne(b,e.json),P=this.baseUrl+"/"+b+"/"+_[this.getCollection(b).identifierName];return this.respond(_,{Location:P},e,201)}}}}}catch(f){p=!0,h=f}finally{try{!d&&g["return"]&&g["return"]()}finally{if(p)throw h}}}},{key:"getHandler",value:function(){return this.handle.bind(this)}}]),e}();t["default"]=g,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(11)["default"],o=r(12)["default"],i=r(6)["default"],u=r(7)["default"],a=r(9)["default"],s=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var c=r(13),l=s(c),f=r(1),d=s(f),p=r(3),h=(s(p),r(4)),y=(s(h),r(10)),v=s(y),g=l["default"].getPolyfill(),b=function(e){function t(){u(this,t),n(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return o(t,e),i(t,[{key:"decode",value:function(e,t){var r=this,n="string"==typeof e?new Request(e,t):e;return n.queryString=decodeURIComponent(n.url.slice(n.url.indexOf("?")+1)),n.params=v["default"](n.queryString),n.text().then(function(e){n.requestBody=e;try{n.requestJson=JSON.parse(e)}catch(t){}}).then(function(){return r.requestInterceptors.reduce(function(e,t){return t(e)},n)})}},{key:"respond",value:function(e,t){return e=this.responseInterceptors.reduce(function(e,r){return r(e,t)},e),this.log(t,e),e}},{key:"log",value:function(e,t){this.loggingEnabled&&(console.group?(console.groupCollapsed(e.method,e.url,"(FakeRest)"),console.group("request"),console.log(e.method,e.url),console.log("headers",e.requestHeaders),console.log("body ",e.requestBody),console.groupEnd(),console.group("response",t.status),console.log("headers",t.headers),console.log("body ",t.body),console.groupEnd(),console.groupEnd()):(console.log("FakeRest request ",e.method,e.url,"headers",e.requestHeaders,"body",e.requestBody),console.log("FakeRest response",t.status,"headers",t.headers,"body",t.body)))}},{key:"batch",value:function(){throw new Error("not implemented")}},{key:"handle",value:function(e,t){var r=this;return this.decode(e,t).then(function(e){var t={headers:{"Content-Type":"application/json"},status:200};if(r.batchUrl&&r.batchUrl===e.url&&"POST"===e.method)return r.batch(e);var n=!0,o=!1,i=void 0;try{for(var u,s=a(r.getSingleNames());!(n=(u=s.next()).done);n=!0){var c=u.value,l=e.url.match(new RegExp("^"+r.baseUrl+"\\/("+c+")(\\/?.*)?$"));if(l){if("GET"==e.method){try{t.body=r.getOnly(c)}catch(f){reponse.status=404}return r.respond(t,e)}if("PUT"==e.method){try{t.body=r.updateOnly(c,e.requestJson)}catch(f){reponse.status=404}return r.respond(t,e)}if("PATCH"==e.method){try{t.body=r.updateOnly(c,e.requestJson)}catch(f){reponse.status=404}return r.respond(t,e)}}}}catch(d){o=!0,i=d}finally{try{!n&&s["return"]&&s["return"]()}finally{if(o)throw i}}var p=!0,h=!1,y=void 0;try{for(var v,b=a(r.getCollectionNames());!(p=(v=b.next()).done);p=!0){var m=v.value,l=e.url.match(new RegExp("^"+r.baseUrl+"\\/("+m+")(\\/(\\d+))?(\\?.*)?$"));if(l){var O=g({},r.defaultQuery(m),e.params);if(l[2]){var j=l[3];if("GET"==e.method){try{t.body=r.getOne(m,j,O)}catch(f){t.status=404}return r.respond(t,e)}if("PUT"==e.method){try{t.body=r.updateOne(m,j,e.requestJson)}catch(f){t.status=404}return r.respond(t,e)}if("PATCH"==e.method){try{t.body=r.updateOne(m,j,e.requestJson)}catch(f){t.status=404}return r.respond(t,e)}if("DELETE"==e.method){try{t.body=r.removeOne(m,j)}catch(f){t.status=404}return r.respond(t,e)}}else{if("GET"==e.method){var w=r.getCount(m,O.filter?{filter:O.filter}:{});if(w>0){var x=r.getAll(m,O),E=O.range?O.range[0]:0,S=O.range?Math.min(x.length-1+E,O.range[1]):x.length-1;t.body=x,t.headers["Content-Range"]="items "+E+"-"+S+"/"+w,t.status=x.length==w?200:206}else t.body=[],t.headers["Content-Range"]="items */0";return r.respond(t,e)}if("POST"==e.method){var k=r.addOne(m,e.requestJson),_=r.baseUrl+"/"+m+"/"+k[r.getCollection(m).identifierName];return t.body=k,t.headers.Location=_,t.status=201,r.respond(t,e)}}}}}catch(d){h=!0,y=d}finally{try{!p&&b["return"]&&b["return"]()}finally{if(h)throw y}}return r.respond(t,e)})}}]),t}(d["default"]);t["default"]=b,e.exports=t["default"]},function(e,t,r){"use strict";function n(e,t){if("function"==typeof t)return e.filter(t);if(t instanceof Object){var r=s(t).map(function(e){if("q"===e){var r=function(){var e=new RegExp(t.q,"i");return{v:function(t){for(var r in t)if(t[r]&&t[r].match&&null!==t[r].match(e))return!0;return!1}}}();if("object"==typeof r)return r.v}var n=t[e];if(-1!==e.indexOf("_lte")){var o=function(){var t=e.replace(/(_lte)$/,"");return{v:function(e){return e[t]<=n}}}();if("object"==typeof o)return o.v}if(-1!==e.indexOf("_gte")){var i=function(){var t=e.replace(/(_gte)$/,"");return{v:function(e){return e[t]>=n}}}();if("object"==typeof i)return i.v}if(-1!==e.indexOf("_lt")){var u=function(){var t=e.replace(/(_lt)$/,"");return{v:function(e){return e[t]<n}}}();if("object"==typeof u)return u.v}if(-1!==e.indexOf("_gt")){var a=function(){var t=e.replace(/(_gt)$/,"");return{v:function(e){return e[t]>n}}}();if("object"==typeof a)return a.v}return Array.isArray(n)?function(t){return n.filter(function(r){return r==t[e]}).length>0}:function(t){return Array.isArray(t[e])&&"string"==typeof n?-1!==t[e].indexOf(n):"boolean"==typeof t[e]&&"string"==typeof n?t[e]==("true"===n?!0:!1):t[e]==n}});return e.filter(function(e){return r.reduce(function(t,r){return t&&r(e)},!0)})}throw new Error("Unsupported filter type")}function o(e,t){if("function"==typeof t)return e.sort(t);if("string"==typeof t)return e.sort(function(e,r){return e[t]>r[t]?1:e[t]<r[t]?-1:0});if(Array.isArray(t)){var r=function(){var r=t[0],n="asc"==t[1].toLowerCase()?1:-1;return{v:e.sort(function(e,t){return e[r]>t[r]?n:e[r]<t[r]?-1*n:0})}}();if("object"==typeof r)return r.v}throw new Error("Unsupported sort type")}function i(e,t){if(Array.isArray(t))return e.slice(t[0],void 0!==t[1]?t[1]+1:void 0);throw new Error("Unsupported range type")}var u=r(6)["default"],a=r(7)["default"],s=r(8)["default"],c=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var l=r(13),f=c(l);r(14),r(19);var d=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],r=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(a(this,e),!Array.isArray(t))throw new Error("Can't initialize a Collection with anything else than an array of items");this.sequence=0,this.identifierName=r,this.items=[],this.server=null,this.name=null,t.map(this.addOne.bind(this))}return u(e,[{key:"setServer",value:function(e){this.server=e}},{key:"setName",value:function(e){this.name=e}},{key:"_oneToManyEmbedder",value:function(e){var t=this,r=this.name.slice(0,-1),n=r+"_id";return function(r){var o=t.server.collections[e];if(!o)throw new Error("Can't embed a non-existing collection "+e);return r[e]=o.getAll(Array.isArray(r[e])?{filter:function(t){return-1!==r[e].indexOf(t[o.identifierName])}}:{filter:function(e){return e[n]==r[t.identifierName]}}),r}}},{key:"_manyToOneEmbedder",value:function(e){var t=this,r=e+"s",n=e+"_id";return function(o){var i=t.server.collections[r];if(!i)throw new Error("Can't embed a non-existing collection "+e);try{o[e]=i.getOne(o[n])}catch(u){}return o}}},{key:"_itemEmbedder",value:function(e){var t=this,r=Array.isArray(e)?e:[e],n=r.map(function(e){return e.endsWith("s")?t._oneToManyEmbedder(e):t._manyToOneEmbedder(e)});return function(e){return n.reduce(function(e,t){return t(e)},e)}}},{key:"getCount",value:function(e){return this.getAll(e).length}},{key:"getAll",value:function(e){var t=this.items.slice(0);return e&&(e.filter&&(t=n(t,e.filter)),e.sort&&(t=o(t,e.sort)),e.range&&(t=i(t,e.range)),e.embed&&this.server&&(t=t.map(function(e){return f["default"]({},e)}).map(this._itemEmbedder(e.embed)))),t}},{key:"getIndex",value:function(e){var t=this;return this.items.findIndex(function(r){return r[t.identifierName]==e})}},{key:"getOne",value:function(e,t){var r=this.getIndex(e);if(-1===r)throw new Error("No item with identifier "+e);var n=this.items[r];return t&&t.embed&&this.server&&(n=f["default"]({},n),n=this._itemEmbedder(t.embed)(n)),n}},{key:"addOne",value:function(e){var t=e[this.identifierName];if(void 0!==t){if(-1!==this.getIndex(t))throw new Error("An item with the identifier "+t+" already exists");this.sequence=Math.max(this.sequence,t)+1}else e[this.identifierName]=this.sequence++;return this.items.push(e),e}},{key:"updateOne",value:function(e,t){var r=this.getIndex(e);if(-1===r)throw new Error("No item with identifier "+e);for(var n in t)this.items[r][n]=t[n];return this.items[r]}},{key:"removeOne",value:function(e){var t=this.getIndex(e);if(-1===t)throw new Error("No item with identifier "+e);var r=this.items[t];return this.items.splice(t,1),e==this.sequence-1&&this.sequence--,r}}]),e}();t["default"]=d,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(6)["default"],o=r(7)["default"],i=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var u=r(13),a=i(u);r(19);var s=function(){function e(t){if(o(this,e),!(t instanceof Object))throw new Error("Can't initialize a Single with anything except an object");this.obj=t,this.server=null,this.name=null}return n(e,[{key:"setServer",value:function(e){this.server=e}},{key:"setName",value:function(e){this.name=e}},{key:"_oneToManyEmbedder",value:function(e){var t=this;return function(r){var n=t.server.collections[e];if(!n)throw new Error("Can't embed a non-existing collection "+e);return r[e]=n.getAll({filter:function(t){return-1!==r[e].indexOf(t[n.identifierName])}}),r}}},{key:"_manyToOneEmbedder",value:function(e){var t=this,r=e+"s",n=e+"_id";return function(o){var i=t.server.collections[r];if(!i)throw new Error("Can't embed a non-existing collection "+e);try{o[e]=i.getOne(o[n])}catch(u){}return o}}},{key:"_itemEmbedder",value:function(e){var t=this,r=Array.isArray(e)?e:[e],n=r.map(function(e){return e.endsWith("s")?t._oneToManyEmbedder(e):t._manyToOneEmbedder(e)});return function(e){return n.reduce(function(e,t){return t(e)},e)}}},{key:"getOnly",value:function(e){var t=this.obj;return e&&e.embed&&this.server&&(t=a["default"]({},t),t=this._itemEmbedder(e.embed)(t)),t}},{key:"updateOnly",value:function(e){for(var t in e)this.obj[t]=e[t];return this.obj}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t){"use strict";t["default"]=function(e){return e&&e.__esModule?e:{"default":e}},t.__esModule=!0},function(e,t,r){"use strict";var n=r(15)["default"];t["default"]=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),n(e,o.key,o)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),t.__esModule=!0},function(e,t){"use strict";t["default"]=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t.__esModule=!0},function(e,t,r){e.exports={"default":r(25),__esModule:!0}},function(e,t,r){e.exports={"default":r(24),__esModule:!0}},function(e,t,r){"use strict";function n(e){if(!e)return{};var t={},r=e.split("&");return r.map(function(e){if(-1===e.indexOf("="))t[e]=!0;else{var r=e.split("="),n=o(r,2),i=n[0],u=n[1];(0===u.indexOf("[")||0===u.indexOf("{"))&&(u=JSON.parse(u)),t[i.trim()]=u}}),t}var o=r(16)["default"];Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(17)["default"];t["default"]=function(e,t,r){for(var o=!0;o;){var i=e,u=t,a=r;s=l=c=void 0,o=!1,null===i&&(i=Function.prototype);var s=n(i,u);if(void 0!==s){if("value"in s)return s.value;var c=s.get;return void 0===c?void 0:c.call(a)}var l=Object.getPrototypeOf(i);if(null===l)return void 0;e=l,t=u,r=a,o=!0}},t.__esModule=!0},function(e,t,r){"use strict";var n=r(18)["default"];t["default"]=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=n(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},t.__esModule=!0},function(e,t,r){"use strict";var n=r(29),o=r(20),i=r(21),u=r(22);n(o,{implementation:o,getPolyfill:i,shim:u}),e.exports=o},function(){!function(){if(!Array.prototype.findIndex){var e=function(e){var t=Object(this),r=Math.max(0,t.length)>>>0;if(0===r)return-1;if("function"!=typeof e||"[object Function]"!==Object.prototype.toString.call(e))throw new TypeError("Array#findIndex: predicate must be a function");for(var n=arguments.length>1?arguments[1]:void 0,o=0;r>o;o++)if(e.call(n,t[o],o,t))return o;return-1};if(Object.defineProperty)try{Object.defineProperty(Array.prototype,"findIndex",{value:e,configurable:!0,writable:!0})}catch(t){}Array.prototype.findIndex||(Array.prototype.findIndex=e)}}(this)},function(e,t,r){e.exports={"default":r(26),__esModule:!0}},function(e,t,r){"use strict";var n=r(9)["default"],o=r(23)["default"];t["default"]=function(){function e(e,t){var r=[],o=!0,i=!1,u=void 0;try{for(var a,s=n(e);!(o=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);o=!0);}catch(c){i=!0,u=c}finally{try{!o&&s["return"]&&s["return"]()}finally{if(i)throw u}}return r}return function(t,r){if(Array.isArray(t))return t;if(o(Object(t)))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),t.__esModule=!0},function(e,t,r){e.exports={"default":r(27),__esModule:!0}},function(e,t,r){e.exports={"default":r(28),__esModule:!0}},function(){/*! http://mths.be/endswith v0.2.0 by @mathias */
String.prototype.endsWith||!function(){"use strict";var e=function(){try{var e={},t=Object.defineProperty,r=t(e,e,e)&&t}catch(n){}return r}(),t={}.toString,r=function(e){if(null==this)throw TypeError();var r=String(this);if(e&&"[object RegExp]"==t.call(e))throw TypeError();var n=r.length,o=String(e),i=o.length,u=n;if(arguments.length>1){var a=arguments[1];void 0!==a&&(u=a?Number(a):0,u!=u&&(u=0))}var s=Math.min(Math.max(u,0),n),c=s-i;if(0>c)return!1;for(var l=-1;++l<i;)if(r.charCodeAt(c+l)!=o.charCodeAt(l))return!1;return!0};e?e(String.prototype,"endsWith",{value:r,configurable:!0,writable:!0}):String.prototype.endsWith=r}()},function(e,t,r){"use strict";var n=r(32),o=r(33),i=function(e){return"undefined"!=typeof e&&null!==e},u=r(30)(),a=Object,s=o.call(Function.call,Array.prototype.push),c=o.call(Function.call,Object.prototype.propertyIsEnumerable);e.exports=function(e){if(!i(e))throw new TypeError("target must be an object");var t,r,o,l,f,d=a(e);for(t=1;t<arguments.length;++t){if(r=a(arguments[t]),l=n(r),u&&Object.getOwnPropertySymbols)for(f=Object.getOwnPropertySymbols(r),o=0;o<f.length;++o)c(r,f[o])&&s(l,f[o]);for(o=0;o<l.length;++o)d[l[o]]=r[l[o]]}return d}},function(e,t,r){"use strict";var n=r(20),o=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch(t){return"y"===e[1]}};e.exports=function(){return!Object.assign||o()?n:Object.assign}},function(e,t,r){"use strict";var n=r(29),o=r(21);e.exports=function(){var e=o();return Object.assign!==e&&n(Object,{assign:e}),e}},function(e,t,r){e.exports={"default":r(31),__esModule:!0}},function(e,t,r){r(36),r(37),r(38),e.exports=r(35).core.getIterator},function(e,t,r){r(34),e.exports=r(35).core.Object.keys},function(e,t,r){var n=r(35);e.exports=function(e,t,r){return n.setDesc(e,t,r)}},function(e,t,r){var n=r(35);r(34),e.exports=function(e,t){return n.getDesc(e,t)}},function(e,t,r){var n=r(35);e.exports=function(e,t){return n.create(e,t)}},function(e,t,r){"use strict";var n=r(32),o=r(39),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),u=Object.prototype.toString,a=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)},s=function(){var e={};try{Object.defineProperty(e,"x",{value:e,enumerable:!1});for(var t in e)return!1;return e.x===e}catch(r){return!1}},c=Object.defineProperty&&s(),l=function(e,t,r,n){(!(t in e)||a(n)&&n())&&(c?Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:!0,value:r}):e[t]=r)},f=function(e,t){var r=arguments.length>2?arguments[2]:{},u=n(t);i&&(u=u.concat(Object.getOwnPropertySymbols(t))),o(u,function(n){l(e,n,t[n],r[n])})};f.supportsDescriptors=!!c,e.exports=f},function(e,t,r){"use strict";var n=r(32);e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test");if("string"==typeof t)return!1;if(t instanceof Symbol)return!1;e[t]=42;for(t in e)return!1;if(0!==n(e).length)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||o.enumerable!==!0)return!1}return!0}},function(e,t,r){r(36),r(37),r(38),e.exports=r(35).core.isIterable},function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Array.prototype.slice,u=r(40),a=!{toString:null}.propertyIsEnumerable("toString"),s=function(){}.propertyIsEnumerable("prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(e){var t=e.constructor;return t&&t.prototype===e},f={$window:!0,$console:!0,$parent:!0,$self:!0,$frames:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0},d=function(){if("undefined"==typeof window)return!1;for(var e in window)if(!f["$"+e]&&n.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{l(window[e])}catch(t){return!0}return!1}(),p=function(e){if("undefined"==typeof window&&!d)return l(e);try{return l(e)}catch(t){return!1}},h=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===o.call(e),i=u(e),l=t&&"[object String]"===o.call(e),f=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var d=s&&r;if(l&&e.length>0&&!n.call(e,0))for(var h=0;h<e.length;++h)f.push(String(h));if(i&&e.length>0)for(var y=0;y<e.length;++y)f.push(String(y));else for(var v in e)d&&"prototype"===v||!n.call(e,v)||f.push(String(v));if(a)for(var g=p(e),b=0;b<c.length;++b)g&&"constructor"===c[b]||!n.call(e,c[b])||f.push(c[b]);return f};h.shim=function(){if(Object.keys){var e=function(){return 2===(Object.keys(arguments)||"").length}(1,2);if(!e){var t=Object.keys;Object.keys=function(e){return t(u(e)?i.call(e):e)}}}else Object.keys=h;return Object.keys||h},e.exports=h},function(e){var t="Function.prototype.bind called on incompatible ",r=Array.prototype.slice,n=Object.prototype.toString,o="[object Function]";e.exports=function(e){var i=this;if("function"!=typeof i||n.call(i)!==o)throw new TypeError(t+i);for(var u=r.call(arguments,1),a=function(){if(this instanceof f){var t=i.apply(this,u.concat(r.call(arguments)));return Object(t)===t?t:this}return i.apply(e,u.concat(r.call(arguments)))},s=Math.max(0,i.length-u.length),c=[],l=0;s>l;l++)c.push("$"+l);var f=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(a);if(i.prototype){var d=function(){};d.prototype=i.prototype,f.prototype=new d,d.prototype=null}return f}},function(e,t,r){var n=r(35),o=r(41),i=n.isObject,u=n.toObject;n.each.call("freeze,seal,preventExtensions,isFrozen,isSealed,isExtensible,getOwnPropertyDescriptor,getPrototypeOf,keys,getOwnPropertyNames".split(","),function(e,t){var a=(n.core.Object||{})[e]||Object[e],s=0,c={};c[e]=0==t?function(e){return i(e)?a(e):e}:1==t?function(e){return i(e)?a(e):e}:2==t?function(e){return i(e)?a(e):e}:3==t?function(e){return i(e)?a(e):!0}:4==t?function(e){return i(e)?a(e):!0}:5==t?function(e){return i(e)?a(e):!1}:6==t?function(e,t){return a(u(e),t)}:7==t?function(e){return a(Object(n.assertDefined(e)))}:8==t?function(e){return a(u(e))}:r(42).get;try{a("z")}catch(l){s=1}o(o.S+o.F*s,"Object",c)})},function(e,t,r){"use strict";function n(e){return isNaN(e=+e)?0:(e>0?y:h)(e)}function o(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}function i(e,t,r){return e[t]=r,e}function u(e){return b?function(t,r,n){return O.setDesc(t,r,o(e,n))}:i}function a(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function s(e){return"function"==typeof e}function c(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}var l="undefined"!=typeof self?self:Function("return this")(),f={},d=Object.defineProperty,p={}.hasOwnProperty,h=Math.ceil,y=Math.floor,v=Math.max,g=Math.min,b=!!function(){try{return 2==d({},"a",{get:function(){return 2}}).a}catch(e){}}(),m=u(1),O=e.exports=r(49)({g:l,core:f,html:l.document&&document.documentElement,isObject:a,isFunction:s,that:function(){return this},toInteger:n,toLength:function(e){return e>0?g(n(e),9007199254740991):0},toIndex:function(e,t){return e=n(e),0>e?v(e+t,0):g(e,t)},has:function(e,t){return p.call(e,t)},create:Object.create,getProto:Object.getPrototypeOf,DESC:b,desc:o,getDesc:Object.getOwnPropertyDescriptor,setDesc:d,setDescs:Object.defineProperties,getKeys:Object.keys,getNames:Object.getOwnPropertyNames,getSymbols:Object.getOwnPropertySymbols,assertDefined:c,ES5Object:Object,toObject:function(e){return O.ES5Object(c(e))},hide:m,def:u(0),set:l.Symbol?i:m,each:[].forEach});"undefined"!=typeof __e&&(__e=f),"undefined"!=typeof __g&&(__g=l)},function(e,t,r){r(43);var n=r(35),o=r(44).Iterators,i=r(45)("iterator"),u=o.Array,a=n.g.NodeList,s=n.g.HTMLCollection,c=a&&a.prototype,l=s&&s.prototype;n.FW&&(!a||i in c||n.hide(c,i,u),!s||i in l||n.hide(l,i,u)),o.NodeList=o.HTMLCollection=u},function(e,t,r){var n=r(35).set,o=r(46)(!0),i=r(47).safe("iter"),u=r(44),a=u.step;r(48)(String,"String",function(e){n(this,i,{o:String(e),i:0})},function(){var e,t=this[i],r=t.o,n=t.i;return n>=r.length?a(1):(e=o(r,n),t.i+=e.length,a(0,e))})},function(e,t,r){var n=r(35).core,o=r(44);n.isIterable=o.is,n.getIterator=o.get},function(e){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString;e.exports=function(e,n,o){if("[object Function]"!==r.call(n))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var u=0;i>u;u++)n.call(o,e[u],u,e);else for(var a in e)t.call(e,a)&&n.call(o,e[a],a,e)}},function(e){"use strict";var t=Object.prototype.toString;e.exports=function(e){var r=t.call(e),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===t.call(e.callee)),n}},function(e,t,r){function n(e,t){return function(){return e.apply(t,arguments)}}function o(e,t,r){var i,c,l,f,d=e&o.G,p=e&o.P,h=d?u:e&o.S?u[t]:(u[t]||{}).prototype,y=d?a:a[t]||(a[t]={});d&&(r=t);for(i in r)c=!(e&o.F)&&h&&i in h,c&&i in y||(l=c?h[i]:r[i],d&&!s(h[i])?f=r[i]:e&o.B&&c?f=n(l,u):e&o.W&&h[i]==l?!function(e){f=function(t){return this instanceof e?new e(t):e(t)},f.prototype=e.prototype}(l):f=p&&s(l)?n(Function.call,l):l,y[i]=f,p&&((y.prototype||(y.prototype={}))[i]=l))}var i=r(35),u=i.g,a=i.core,s=i.isFunction;o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,e.exports=o},function(e,t,r){function n(e){try{return u(e)}catch(t){return a.slice()}}var o=r(35),i={}.toString,u=o.getNames,a="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.get=function(e){return a&&"[object Window]"==i.call(e)?n(e):u(o.toObject(e))}},function(e,t,r){var n=r(35),o=r(53),i=r(47).safe("iter"),u=r(44),a=u.step,s=u.Iterators;r(48)(Array,"Array",function(e,t){n.set(this,i,{o:n.toObject(e),i:0,k:t})},function(){var e=this[i],t=e.o,r=e.k,n=e.i++;return!t||n>=t.length?(e.o=void 0,a(1)):"keys"==r?a(0,n):"values"==r?a(0,t[n]):a(0,[n,t[n]])},"values"),s.Arguments=s.Array,o("keys"),o("values"),o("entries")},function(e,t,r){"use strict";function n(e,t){o.hide(e,c,t),l in[]&&o.hide(e,l,t)}var o=r(35),i=r(50),u=i.classof,a=r(51),s=a.obj,c=r(45)("iterator"),l="@@iterator",f=r(52)("iterators"),d={};n(d,o.that),e.exports={BUGGY:"keys"in[]&&!("next"in[].keys()),Iterators:f,step:function(e,t){return{value:t,done:!!e}},is:function(e){var t=Object(e),r=o.g.Symbol;return(r&&r.iterator||l)in t||c in t||o.has(f,u(t))},get:function(e){var t,r=o.g.Symbol;return void 0!=e&&(t=e[r&&r.iterator||l]||e[c]||f[u(e)]),a(o.isFunction(t),e," is not iterable!"),s(t.call(e))},set:n,create:function(e,t,r,n){e.prototype=o.create(n||d,{next:o.desc(1,r)}),i.set(e,t+" Iterator")}}},function(e,t,r){var n=r(35).g,o=r(52)("wks");e.exports=function(e){return o[e]||(o[e]=n.Symbol&&n.Symbol[e]||r(47).safe("Symbol."+e))}},function(e,t,r){var n=r(35);e.exports=function(e){return function(t,r){var o,i,u=String(n.assertDefined(t)),a=n.toInteger(r),s=u.length;return 0>a||a>=s?e?"":void 0:(o=u.charCodeAt(a),55296>o||o>56319||a+1===s||(i=u.charCodeAt(a+1))<56320||i>57343?e?u.charAt(a):o:e?u.slice(a,a+2):(o-55296<<10)+(i-56320)+65536)}}},function(e,t,r){function n(e){return"Symbol(".concat(void 0===e?"":e,")_",(++o+Math.random()).toString(36))}var o=0;n.safe=r(35).g.Symbol||n,e.exports=n},function(e,t,r){var n=r(41),o=r(54),i=r(35),u=r(50),a=r(44),s=r(45)("iterator"),c="@@iterator",l="keys",f="values",d=a.Iterators;e.exports=function(e,t,r,p,h,y,v){function g(e){function t(t){return new r(t,e)}switch(e){case l:return function(){return t(this)};case f:return function(){return t(this)}}return function(){return t(this)}}a.create(r,t,p);var b,m,O=t+" Iterator",j=e.prototype,w=j[s]||j[c]||h&&j[h],x=w||g(h);if(w){var E=i.getProto(x.call(new e));u.set(E,O,!0),i.FW&&i.has(j,c)&&a.set(E,i.that)}if((i.FW||v)&&a.set(j,x),d[t]=x,d[O]=i.that,h)if(b={keys:y?x:g(l),values:h==f?x:g(f),entries:h!=f?x:g("entries")},v)for(m in b)m in j||o(j,m,b[m]);else n(n.P+n.F*a.BUGGY,t,b)}},function(e){e.exports=function(e){return e.FW=!1,e.path=e.core,e}},function(e,t,r){function n(e){return u.call(e).slice(8,-1)}var o=r(35),i=r(45)("toStringTag"),u={}.toString;n.classof=function(e){var t,r;return void 0==e?void 0===e?"Undefined":"Null":"string"==typeof(r=(t=Object(e))[i])?r:n(t)},n.set=function(e,t,r){e&&!o.has(e=r?e:e.prototype,i)&&o.hide(e,i,t)},e.exports=n},function(e,t,r){function n(e,t,r){if(!e)throw TypeError(r?t+r:t)}var o=r(35);n.def=o.assertDefined,n.fn=function(e){if(!o.isFunction(e))throw TypeError(e+" is not a function!");return e},n.obj=function(e){if(!o.isObject(e))throw TypeError(e+" is not an object!");return e},n.inst=function(e,t,r){if(!(e instanceof t))throw TypeError(r+": use the 'new' operator!");return e},e.exports=n},function(e,t,r){var n=r(35),o="__core-js_shared__",i=n.g[o]||(n.g[o]={});e.exports=function(e){return i[e]||(i[e]={})}},function(e){e.exports=function(){}},function(e,t,r){e.exports=r(35).hide}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.FakeRest=t():e.FakeRest=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=n(o),u=r(2),a=n(u),s=r(3),c=n(s),l=r(4),f=n(l);t["default"]={Server:i["default"],FetchServer:a["default"],Collection:c["default"],Single:f["default"]},e.exports=t["default"]},function(e,t,r){"use strict";var n=r(8)["default"],o=r(9)["default"],i=r(12)["default"],u=r(10)["default"],a=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var s=r(13),c=a(s),l=r(3),f=a(l),d=r(4),p=a(d),h=r(11),y=a(h),v=c["default"].getPolyfill(),g=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0];o(this,e),this.baseUrl=t,this.loggingEnabled=!1,this.defaultQuery=function(){},this.batchUrl=null,this.collections={},this.singles={},this.requestInterceptors=[],this.responseInterceptors=[]}return n(e,[{key:"init",value:function(e){for(var t in e)Array.isArray(e[t])?this.addCollection(t,new f["default"](e[t],"id")):this.addSingle(t,new p["default"](e[t]))}},{key:"toggleLogging",value:function(){this.loggingEnabled=!this.loggingEnabled}},{key:"setDefaultQuery",value:function(e){this.defaultQuery=e}},{key:"setBatchUrl",value:function(e){this.batchUrl=e}},{key:"setBatch",value:function(e){console.warn("Server.setBatch() is deprecated, use Server.setBatchUrl() instead"),this.batchUrl=e}},{key:"addCollection",value:function(e,t){this.collections[e]=t,t.setServer(this),t.setName(e)}},{key:"getCollection",value:function(e){return this.collections[e]}},{key:"getCollectionNames",value:function(){return i(this.collections)}},{key:"addSingle",value:function(e,t){this.singles[e]=t,t.setServer(this),t.setName(e)}},{key:"getSingle",value:function(e){return this.singles[e]}},{key:"getSingleNames",value:function(){return i(this.singles)}},{key:"addRequestInterceptor",value:function(e){this.requestInterceptors.push(e)}},{key:"addResponseInterceptor",value:function(e){this.responseInterceptors.push(e)}},{key:"getCount",value:function(e,t){return this.collections[e].getCount(t)}},{key:"getAll",value:function(e,t){return this.collections[e].getAll(t)}},{key:"getOne",value:function(e,t,r){return this.collections[e].getOne(t,r)}},{key:"addOne",value:function(e,t){return this.collections[e].addOne(t)}},{key:"updateOne",value:function(e,t,r){return this.collections[e].updateOne(t,r)}},{key:"removeOne",value:function(e,t){return this.collections[e].removeOne(t)}},{key:"getOnly",value:function(e){return this.singles[e].getOnly()}},{key:"updateOnly",value:function(e,t){return this.singles[e].updateOnly(t)}},{key:"decode",value:function(e){if(e.queryString=decodeURIComponent(e.url.slice(e.url.indexOf("?")+1)),e.params=y["default"](e.queryString),e.requestBody)try{e.json=JSON.parse(e.requestBody)}catch(t){}return this.requestInterceptors.reduce(function(e,t){return t(e)},e)}},{key:"respond",value:function(e,t,r){var n=arguments.length<=3||void 0===arguments[3]?200:arguments[3];t||(t={}),t["Content-Type"]||(t["Content-Type"]="application/json");var o={status:n,headers:t,body:e};return o=this.responseInterceptors.reduce(function(e,t){return t(e,r)},o),this.log(r,o),r.respond(o.status,o.headers,JSON.stringify(o.body))}},{key:"log",value:function(e,t){this.loggingEnabled&&(console.group?(console.groupCollapsed(e.method,e.url,"(FakeRest)"),console.group("request"),console.log(e.method,e.url),console.log("headers",e.requestHeaders),console.log("body ",e.requestBody),console.groupEnd(),console.group("response",t.status),console.log("headers",t.headers),console.log("body ",t.body),console.groupEnd(),console.groupEnd()):(console.log("FakeRest request ",e.method,e.url,"headers",e.requestHeaders,"body",e.requestBody),console.log("FakeRest response",t.status,"headers",t.headers,"body",t.body)))}},{key:"batch",value:function(e){var t=e.json,r=this.handle.bind(this),n=i(t).reduce(function(e,n){var o,u={url:t[n],method:"GET",params:{},respond:function(e,t,r){o={code:e,headers:i(t||{}).map(function(e){return{name:e,value:t[e]}}),body:r||{}}}};return r(u),e[n]=o||{code:404,headers:[],body:{}},e},{});return this.respond(n,{},e,200)}},{key:"handle",value:function(e){if(e=this.decode(e),this.batchUrl&&this.batchUrl===e.url&&"POST"===e.method)return this.batch(e);var t=!0,r=!1,n=void 0;try{for(var o,i=u(this.getSingleNames());!(t=(o=i.next()).done);t=!0){var a=o.value,s=e.url.match(new RegExp("^"+this.baseUrl+"\\/("+a+")(\\/?.*)?$"));if(s){if("GET"==e.method)try{var c=this.getOnly(a);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PUT"==e.method)try{var c=this.updateOnly(a,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PATCH"==e.method)try{var c=this.updateOnly(a,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}}}}catch(f){r=!0,n=f}finally{try{!t&&i["return"]&&i["return"]()}finally{if(r)throw n}}var d=!0,p=!1,h=void 0;try{for(var y,g=u(this.getCollectionNames());!(d=(y=g.next()).done);d=!0){var b=y.value,s=e.url.match(new RegExp("^"+this.baseUrl+"\\/("+b+")(\\/(\\d+))?(\\?.*)?$"));if(s){var m=v({},this.defaultQuery(b),e.params);if(s[2]){var O=s[3];if("GET"==e.method)try{var c=this.getOne(b,O,m);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PUT"==e.method)try{var c=this.updateOne(b,O,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("PATCH"==e.method)try{var c=this.updateOne(b,O,e.json);return this.respond(c,null,e)}catch(l){return e.respond(404)}if("DELETE"==e.method)try{var c=this.removeOne(b,O);return this.respond(c,null,e)}catch(l){return e.respond(404)}}else{if("GET"==e.method){var j=this.getCount(b,m.filter?{filter:m.filter}:{}),w=void 0,x=void 0,E=void 0;if(j>0){w=this.getAll(b,m);var S=m.range?m.range[0]:0,k=m.range?Math.min(w.length-1+S,m.range[1]):w.length-1;x="items "+S+"-"+k+"/"+j,E=w.length==j?200:206}else w=[],x="items */0",E=200;return this.respond(w,{"Content-Range":x},e,E)}if("POST"==e.method){var _=this.addOne(b,e.json),P=this.baseUrl+"/"+b+"/"+_[this.getCollection(b).identifierName];return this.respond(_,{Location:P},e,201)}}}}}catch(f){p=!0,h=f}finally{try{!d&&g["return"]&&g["return"]()}finally{if(p)throw h}}}},{key:"getHandler",value:function(){return this.handle.bind(this)}}]),e}();t["default"]=g,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(6)["default"],o=r(7)["default"],i=r(8)["default"],u=r(9)["default"],a=r(10)["default"],s=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var c=r(13),l=s(c),f=r(1),d=s(f),p=r(3),h=(s(p),r(4)),y=(s(h),r(11)),v=s(y),g=l["default"].getPolyfill(),b=function(e){function t(){u(this,t),n(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return o(t,e),i(t,[{key:"decode",value:function(e,t){var r=this,n="string"==typeof e?new Request(e,t):e;return n.queryString=decodeURIComponent(n.url.slice(n.url.indexOf("?")+1)),n.params=v["default"](n.queryString),n.text().then(function(e){n.requestBody=e;try{n.requestJson=JSON.parse(e)}catch(t){}}).then(function(){return r.requestInterceptors.reduce(function(e,t){return t(e)},n)})}},{key:"respond",value:function(e,t){return e=this.responseInterceptors.reduce(function(e,r){return r(e,t)},e),this.log(t,e),e.headers=new Headers(e.headers),e}},{key:"log",value:function(e,t){this.loggingEnabled&&(console.group?(console.groupCollapsed(e.method,e.url,"(FakeRest)"),console.group("request"),console.log(e.method,e.url),console.log("headers",e.headers),console.log("body ",e.requestBody),console.groupEnd(),console.group("response",t.status),console.log("headers",t.headers),console.log("body ",t.body),console.groupEnd(),console.groupEnd()):(console.log("FakeRest request ",e.method,e.url,"headers",e.headers,"body",e.requestBody),console.log("FakeRest response",t.status,"headers",t.headers,"body",t.body)))}},{key:"batch",value:function(){throw new Error("not implemented")}},{key:"handle",value:function(e,t){var r=this;return this.decode(e,t).then(function(e){var t={headers:{"Content-Type":"application/json"},status:200};if(r.batchUrl&&r.batchUrl===e.url&&"POST"===e.method)return r.batch(e);var n=!0,o=!1,i=void 0;try{for(var u,s=a(r.getSingleNames());!(n=(u=s.next()).done);n=!0){var c=u.value,l=e.url.match(new RegExp("^"+r.baseUrl+"\\/("+c+")(\\/?.*)?$"));if(l){if("GET"==e.method){try{t.body=r.getOnly(c)}catch(f){reponse.status=404}return r.respond(t,e)}if("PUT"==e.method){try{t.body=r.updateOnly(c,e.requestJson)}catch(f){reponse.status=404}return r.respond(t,e)}if("PATCH"==e.method){try{t.body=r.updateOnly(c,e.requestJson)}catch(f){reponse.status=404}return r.respond(t,e)}}}}catch(d){o=!0,i=d}finally{try{!n&&s["return"]&&s["return"]()}finally{if(o)throw i}}var p=!0,h=!1,y=void 0;try{for(var v,b=a(r.getCollectionNames());!(p=(v=b.next()).done);p=!0){var m=v.value,l=e.url.match(new RegExp("^"+r.baseUrl+"\\/("+m+")(\\/(\\d+))?(\\?.*)?$"));if(l){var O=g({},r.defaultQuery(m),e.params);if(l[2]){var j=l[3];if("GET"==e.method){try{t.body=r.getOne(m,j,O)}catch(f){t.status=404}return r.respond(t,e)}if("PUT"==e.method){try{t.body=r.updateOne(m,j,e.requestJson)}catch(f){t.status=404}return r.respond(t,e)}if("PATCH"==e.method){try{t.body=r.updateOne(m,j,e.requestJson)}catch(f){t.status=404}return r.respond(t,e)}if("DELETE"==e.method){try{t.body=r.removeOne(m,j)}catch(f){t.status=404}return r.respond(t,e)}}else{if("GET"==e.method){var w=r.getCount(m,O.filter?{filter:O.filter}:{});if(w>0){var x=r.getAll(m,O),E=O.range?O.range[0]:0,S=O.range?Math.min(x.length-1+E,O.range[1]):x.length-1;t.body=x,t.headers["Content-Range"]="items "+E+"-"+S+"/"+w,t.status=x.length==w?200:206}else t.body=[],t.headers["Content-Range"]="items */0";return r.respond(t,e)}if("POST"==e.method){var k=r.addOne(m,e.requestJson),_=r.baseUrl+"/"+m+"/"+k[r.getCollection(m).identifierName];return t.body=k,t.headers.Location=_,t.status=201,r.respond(t,e)}}}}}catch(d){h=!0,y=d}finally{try{!p&&b["return"]&&b["return"]()}finally{if(h)throw y}}return r.respond(t,e)})}}]),t}(d["default"]);t["default"]=b,e.exports=t["default"]},function(e,t,r){"use strict";function n(e,t){if("function"==typeof t)return e.filter(t);if(t instanceof Object){var r=s(t).map(function(e){if("q"===e){var r=function(){var e=new RegExp(t.q,"i");return{v:function(t){for(var r in t)if(t[r]&&t[r].match&&null!==t[r].match(e))return!0;return!1}}}();if("object"==typeof r)return r.v}var n=t[e];if(-1!==e.indexOf("_lte")){var o=function(){var t=e.replace(/(_lte)$/,"");return{v:function(e){return e[t]<=n}}}();if("object"==typeof o)return o.v}if(-1!==e.indexOf("_gte")){var i=function(){var t=e.replace(/(_gte)$/,"");return{v:function(e){return e[t]>=n}}}();if("object"==typeof i)return i.v}if(-1!==e.indexOf("_lt")){var u=function(){var t=e.replace(/(_lt)$/,"");return{v:function(e){return e[t]<n}}}();if("object"==typeof u)return u.v}if(-1!==e.indexOf("_gt")){var a=function(){var t=e.replace(/(_gt)$/,"");return{v:function(e){return e[t]>n}}}();if("object"==typeof a)return a.v}return Array.isArray(n)?function(t){return n.filter(function(r){return r==t[e]}).length>0}:function(t){return Array.isArray(t[e])&&"string"==typeof n?-1!==t[e].indexOf(n):"boolean"==typeof t[e]&&"string"==typeof n?t[e]==("true"===n?!0:!1):t[e]==n}});return e.filter(function(e){return r.reduce(function(t,r){return t&&r(e)},!0)})}throw new Error("Unsupported filter type")}function o(e,t){if("function"==typeof t)return e.sort(t);if("string"==typeof t)return e.sort(function(e,r){return e[t]>r[t]?1:e[t]<r[t]?-1:0});if(Array.isArray(t)){var r=function(){var r=t[0],n="asc"==t[1].toLowerCase()?1:-1;return{v:e.sort(function(e,t){return e[r]>t[r]?n:e[r]<t[r]?-1*n:0})}}();if("object"==typeof r)return r.v}throw new Error("Unsupported sort type")}function i(e,t){if(Array.isArray(t))return e.slice(t[0],void 0!==t[1]?t[1]+1:void 0);throw new Error("Unsupported range type")}var u=r(8)["default"],a=r(9)["default"],s=r(12)["default"],c=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var l=r(13),f=c(l);r(14),r(19);var d=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],r=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(a(this,e),!Array.isArray(t))throw new Error("Can't initialize a Collection with anything else than an array of items");this.sequence=0,this.identifierName=r,this.items=[],this.server=null,this.name=null,t.map(this.addOne.bind(this))}return u(e,[{key:"setServer",value:function(e){this.server=e}},{key:"setName",value:function(e){this.name=e}},{key:"_oneToManyEmbedder",value:function(e){var t=this,r=this.name.slice(0,-1),n=r+"_id";return function(r){var o=t.server.collections[e];if(!o)throw new Error("Can't embed a non-existing collection "+e);return r[e]=o.getAll(Array.isArray(r[e])?{filter:function(t){return-1!==r[e].indexOf(t[o.identifierName])}}:{filter:function(e){return e[n]==r[t.identifierName]}}),r}}},{key:"_manyToOneEmbedder",value:function(e){var t=this,r=e+"s",n=e+"_id";return function(o){var i=t.server.collections[r];if(!i)throw new Error("Can't embed a non-existing collection "+e);try{o[e]=i.getOne(o[n])}catch(u){}return o}}},{key:"_itemEmbedder",value:function(e){var t=this,r=Array.isArray(e)?e:[e],n=r.map(function(e){return e.endsWith("s")?t._oneToManyEmbedder(e):t._manyToOneEmbedder(e)});return function(e){return n.reduce(function(e,t){return t(e)},e)}}},{key:"getCount",value:function(e){return this.getAll(e).length}},{key:"getAll",value:function(e){var t=this.items.slice(0);return e&&(e.filter&&(t=n(t,e.filter)),e.sort&&(t=o(t,e.sort)),e.range&&(t=i(t,e.range)),e.embed&&this.server&&(t=t.map(function(e){return f["default"]({},e)}).map(this._itemEmbedder(e.embed)))),t}},{key:"getIndex",value:function(e){var t=this;return this.items.findIndex(function(r){return r[t.identifierName]==e})}},{key:"getOne",value:function(e,t){var r=this.getIndex(e);if(-1===r)throw new Error("No item with identifier "+e);var n=this.items[r];return t&&t.embed&&this.server&&(n=f["default"]({},n),n=this._itemEmbedder(t.embed)(n)),n}},{key:"addOne",value:function(e){var t=e[this.identifierName];if(void 0!==t){if(-1!==this.getIndex(t))throw new Error("An item with the identifier "+t+" already exists");this.sequence=Math.max(this.sequence,t)+1}else e[this.identifierName]=this.sequence++;return this.items.push(e),e}},{key:"updateOne",value:function(e,t){var r=this.getIndex(e);if(-1===r)throw new Error("No item with identifier "+e);for(var n in t)this.items[r][n]=t[n];return this.items[r]}},{key:"removeOne",value:function(e){var t=this.getIndex(e);if(-1===t)throw new Error("No item with identifier "+e);var r=this.items[t];return this.items.splice(t,1),e==this.sequence-1&&this.sequence--,r}}]),e}();t["default"]=d,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(8)["default"],o=r(9)["default"],i=r(5)["default"];Object.defineProperty(t,"__esModule",{value:!0});var u=r(13),a=i(u);r(19);var s=function(){function e(t){if(o(this,e),!(t instanceof Object))throw new Error("Can't initialize a Single with anything except an object");this.obj=t,this.server=null,this.name=null}return n(e,[{key:"setServer",value:function(e){this.server=e}},{key:"setName",value:function(e){this.name=e}},{key:"_oneToManyEmbedder",value:function(e){var t=this;return function(r){var n=t.server.collections[e];if(!n)throw new Error("Can't embed a non-existing collection "+e);return r[e]=n.getAll({filter:function(t){return-1!==r[e].indexOf(t[n.identifierName])}}),r}}},{key:"_manyToOneEmbedder",value:function(e){var t=this,r=e+"s",n=e+"_id";return function(o){var i=t.server.collections[r];if(!i)throw new Error("Can't embed a non-existing collection "+e);try{o[e]=i.getOne(o[n])}catch(u){}return o}}},{key:"_itemEmbedder",value:function(e){var t=this,r=Array.isArray(e)?e:[e],n=r.map(function(e){return e.endsWith("s")?t._oneToManyEmbedder(e):t._manyToOneEmbedder(e)});return function(e){return n.reduce(function(e,t){return t(e)},e)}}},{key:"getOnly",value:function(e){var t=this.obj;return e&&e.embed&&this.server&&(t=a["default"]({},t),t=this._itemEmbedder(e.embed)(t)),t}},{key:"updateOnly",value:function(e){for(var t in e)this.obj[t]=e[t];return this.obj}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t){"use strict";t["default"]=function(e){return e&&e.__esModule?e:{"default":e}},t.__esModule=!0},function(e,t,r){"use strict";var n=r(15)["default"];t["default"]=function(e,t,r){for(var o=!0;o;){var i=e,u=t,a=r;s=l=c=void 0,o=!1,null===i&&(i=Function.prototype);var s=n(i,u);if(void 0!==s){if("value"in s)return s.value;var c=s.get;return void 0===c?void 0:c.call(a)}var l=Object.getPrototypeOf(i);if(null===l)return void 0;e=l,t=u,r=a,o=!0}},t.__esModule=!0},function(e,t,r){"use strict";var n=r(16)["default"];t["default"]=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=n(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},t.__esModule=!0},function(e,t,r){"use strict";var n=r(17)["default"];t["default"]=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),n(e,o.key,o)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),t.__esModule=!0},function(e,t){"use strict";t["default"]=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t.__esModule=!0},function(e,t,r){e.exports={"default":r(24),__esModule:!0}},function(e,t,r){"use strict";function n(e){if(!e)return{};var t={},r=e.split("&");return r.map(function(e){if(-1===e.indexOf("="))t[e]=!0;else{var r=e.split("="),n=o(r,2),i=n[0],u=n[1];(0===u.indexOf("[")||0===u.indexOf("{"))&&(u=JSON.parse(u)),t[i.trim()]=u}}),t}var o=r(18)["default"];Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n,e.exports=t["default"]},function(e,t,r){e.exports={"default":r(25),__esModule:!0}},function(e,t,r){"use strict";var n=r(29),o=r(20),i=r(21),u=r(22);n(o,{implementation:o,getPolyfill:i,shim:u}),e.exports=o},function(){!function(){if(!Array.prototype.findIndex){var e=function(e){var t=Object(this),r=Math.max(0,t.length)>>>0;if(0===r)return-1;if("function"!=typeof e||"[object Function]"!==Object.prototype.toString.call(e))throw new TypeError("Array#findIndex: predicate must be a function");for(var n=arguments.length>1?arguments[1]:void 0,o=0;r>o;o++)if(e.call(n,t[o],o,t))return o;return-1};if(Object.defineProperty)try{Object.defineProperty(Array.prototype,"findIndex",{value:e,configurable:!0,writable:!0})}catch(t){}Array.prototype.findIndex||(Array.prototype.findIndex=e)}}(this)},function(e,t,r){e.exports={"default":r(26),__esModule:!0}},function(e,t,r){e.exports={"default":r(27),__esModule:!0}},function(e,t,r){e.exports={"default":r(28),__esModule:!0}},function(e,t,r){"use strict";var n=r(10)["default"],o=r(23)["default"];t["default"]=function(){function e(e,t){var r=[],o=!0,i=!1,u=void 0;try{for(var a,s=n(e);!(o=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);o=!0);}catch(c){i=!0,u=c}finally{try{!o&&s["return"]&&s["return"]()}finally{if(i)throw u}}return r}return function(t,r){if(Array.isArray(t))return t;if(o(Object(t)))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),t.__esModule=!0},function(){/*! http://mths.be/endswith v0.2.0 by @mathias */
String.prototype.endsWith||!function(){"use strict";var e=function(){try{var e={},t=Object.defineProperty,r=t(e,e,e)&&t}catch(n){}return r}(),t={}.toString,r=function(e){if(null==this)throw TypeError();var r=String(this);if(e&&"[object RegExp]"==t.call(e))throw TypeError();var n=r.length,o=String(e),i=o.length,u=n;if(arguments.length>1){var a=arguments[1];void 0!==a&&(u=a?Number(a):0,u!=u&&(u=0))}var s=Math.min(Math.max(u,0),n),c=s-i;if(0>c)return!1;for(var l=-1;++l<i;)if(r.charCodeAt(c+l)!=o.charCodeAt(l))return!1;return!0};e?e(String.prototype,"endsWith",{value:r,configurable:!0,writable:!0}):String.prototype.endsWith=r}()},function(e,t,r){"use strict";var n=r(31),o=r(32),i=function(e){return"undefined"!=typeof e&&null!==e},u=r(30)(),a=Object,s=o.call(Function.call,Array.prototype.push),c=o.call(Function.call,Object.prototype.propertyIsEnumerable);e.exports=function(e){if(!i(e))throw new TypeError("target must be an object");var t,r,o,l,f,d=a(e);for(t=1;t<arguments.length;++t){if(r=a(arguments[t]),l=n(r),u&&Object.getOwnPropertySymbols)for(f=Object.getOwnPropertySymbols(r),o=0;o<f.length;++o)c(r,f[o])&&s(l,f[o]);for(o=0;o<l.length;++o)d[l[o]]=r[l[o]]}return d}},function(e,t,r){"use strict";var n=r(20),o=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch(t){return"y"===e[1]}};e.exports=function(){return!Object.assign||o()?n:Object.assign}},function(e,t,r){"use strict";var n=r(29),o=r(21);e.exports=function(){var e=o();return Object.assign!==e&&n(Object,{assign:e}),e}},function(e,t,r){e.exports={"default":r(33),__esModule:!0}},function(e,t,r){r(34),r(35),r(36),e.exports=r(37).core.getIterator},function(e,t,r){r(38),e.exports=r(37).core.Object.keys},function(e,t,r){var n=r(37);r(38),e.exports=function(e,t){return n.getDesc(e,t)}},function(e,t,r){var n=r(37);e.exports=function(e,t){return n.create(e,t)}},function(e,t,r){var n=r(37);e.exports=function(e,t,r){return n.setDesc(e,t,r)}},function(e,t,r){"use strict";var n=r(31),o=r(39),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),u=Object.prototype.toString,a=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)},s=function(){var e={};try{Object.defineProperty(e,"x",{value:e,enumerable:!1});for(var t in e)return!1;return e.x===e}catch(r){return!1}},c=Object.defineProperty&&s(),l=function(e,t,r,n){(!(t in e)||a(n)&&n())&&(c?Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:!0,value:r}):e[t]=r)},f=function(e,t){var r=arguments.length>2?arguments[2]:{},u=n(t);i&&(u=u.concat(Object.getOwnPropertySymbols(t))),o(u,function(n){l(e,n,t[n],r[n])})};f.supportsDescriptors=!!c,e.exports=f},function(e,t,r){"use strict";var n=r(31);e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test");if("string"==typeof t)return!1;if(t instanceof Symbol)return!1;e[t]=42;for(t in e)return!1;if(0!==n(e).length)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||o.enumerable!==!0)return!1}return!0}},function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Array.prototype.slice,u=r(40),a=!{toString:null}.propertyIsEnumerable("toString"),s=function(){}.propertyIsEnumerable("prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(e){var t=e.constructor;return t&&t.prototype===e},f={$window:!0,$console:!0,$parent:!0,$self:!0,$frames:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0},d=function(){if("undefined"==typeof window)return!1;for(var e in window)if(!f["$"+e]&&n.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{l(window[e])}catch(t){return!0}return!1}(),p=function(e){if("undefined"==typeof window&&!d)return l(e);try{return l(e)}catch(t){return!1}},h=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===o.call(e),i=u(e),l=t&&"[object String]"===o.call(e),f=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var d=s&&r;if(l&&e.length>0&&!n.call(e,0))for(var h=0;h<e.length;++h)f.push(String(h));if(i&&e.length>0)for(var y=0;y<e.length;++y)f.push(String(y));else for(var v in e)d&&"prototype"===v||!n.call(e,v)||f.push(String(v));if(a)for(var g=p(e),b=0;b<c.length;++b)g&&"constructor"===c[b]||!n.call(e,c[b])||f.push(c[b]);return f};h.shim=function(){if(Object.keys){var e=function(){return 2===(Object.keys(arguments)||"").length}(1,2);if(!e){var t=Object.keys;Object.keys=function(e){return t(u(e)?i.call(e):e)}}}else Object.keys=h;return Object.keys||h},e.exports=h},function(e){var t="Function.prototype.bind called on incompatible ",r=Array.prototype.slice,n=Object.prototype.toString,o="[object Function]";e.exports=function(e){var i=this;if("function"!=typeof i||n.call(i)!==o)throw new TypeError(t+i);for(var u=r.call(arguments,1),a=function(){if(this instanceof f){var t=i.apply(this,u.concat(r.call(arguments)));return Object(t)===t?t:this}return i.apply(e,u.concat(r.call(arguments)))},s=Math.max(0,i.length-u.length),c=[],l=0;s>l;l++)c.push("$"+l);var f=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(a);if(i.prototype){var d=function(){};d.prototype=i.prototype,f.prototype=new d,d.prototype=null}return f}},function(e,t,r){r(34),r(35),r(36),e.exports=r(37).core.isIterable},function(e,t,r){r(41);var n=r(37),o=r(42).Iterators,i=r(43)("iterator"),u=o.Array,a=n.g.NodeList,s=n.g.HTMLCollection,c=a&&a.prototype,l=s&&s.prototype;n.FW&&(!a||i in c||n.hide(c,i,u),!s||i in l||n.hide(l,i,u)),o.NodeList=o.HTMLCollection=u},function(e,t,r){var n=r(37).set,o=r(44)(!0),i=r(45).safe("iter"),u=r(42),a=u.step;r(46)(String,"String",function(e){n(this,i,{o:String(e),i:0})},function(){var e,t=this[i],r=t.o,n=t.i;return n>=r.length?a(1):(e=o(r,n),t.i+=e.length,a(0,e))})},function(e,t,r){var n=r(37).core,o=r(42);n.isIterable=o.is,n.getIterator=o.get},function(e,t,r){"use strict";function n(e){return isNaN(e=+e)?0:(e>0?y:h)(e)}function o(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}function i(e,t,r){return e[t]=r,e}function u(e){return b?function(t,r,n){return O.setDesc(t,r,o(e,n))}:i}function a(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function s(e){return"function"==typeof e}function c(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}var l="undefined"!=typeof self?self:Function("return this")(),f={},d=Object.defineProperty,p={}.hasOwnProperty,h=Math.ceil,y=Math.floor,v=Math.max,g=Math.min,b=!!function(){try{return 2==d({},"a",{get:function(){return 2}}).a}catch(e){}}(),m=u(1),O=e.exports=r(47)({g:l,core:f,html:l.document&&document.documentElement,isObject:a,isFunction:s,that:function(){return this},toInteger:n,toLength:function(e){return e>0?g(n(e),9007199254740991):0},toIndex:function(e,t){return e=n(e),0>e?v(e+t,0):g(e,t)},has:function(e,t){return p.call(e,t)},create:Object.create,getProto:Object.getPrototypeOf,DESC:b,desc:o,getDesc:Object.getOwnPropertyDescriptor,setDesc:d,setDescs:Object.defineProperties,getKeys:Object.keys,getNames:Object.getOwnPropertyNames,getSymbols:Object.getOwnPropertySymbols,assertDefined:c,ES5Object:Object,toObject:function(e){return O.ES5Object(c(e))},hide:m,def:u(0),set:l.Symbol?i:m,each:[].forEach});"undefined"!=typeof __e&&(__e=f),"undefined"!=typeof __g&&(__g=l)},function(e,t,r){var n=r(37),o=r(48),i=n.isObject,u=n.toObject;n.each.call("freeze,seal,preventExtensions,isFrozen,isSealed,isExtensible,getOwnPropertyDescriptor,getPrototypeOf,keys,getOwnPropertyNames".split(","),function(e,t){var a=(n.core.Object||{})[e]||Object[e],s=0,c={};c[e]=0==t?function(e){return i(e)?a(e):e}:1==t?function(e){return i(e)?a(e):e}:2==t?function(e){return i(e)?a(e):e}:3==t?function(e){return i(e)?a(e):!0}:4==t?function(e){return i(e)?a(e):!0}:5==t?function(e){return i(e)?a(e):!1}:6==t?function(e,t){return a(u(e),t)}:7==t?function(e){return a(Object(n.assertDefined(e)))}:8==t?function(e){return a(u(e))}:r(49).get;try{a("z")}catch(l){s=1}o(o.S+o.F*s,"Object",c)})},function(e){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString;e.exports=function(e,n,o){if("[object Function]"!==r.call(n))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var u=0;i>u;u++)n.call(o,e[u],u,e);else for(var a in e)t.call(e,a)&&n.call(o,e[a],a,e)}},function(e){"use strict";var t=Object.prototype.toString;e.exports=function(e){var r=t.call(e),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===t.call(e.callee)),n}},function(e,t,r){var n=r(37),o=r(50),i=r(45).safe("iter"),u=r(42),a=u.step,s=u.Iterators;r(46)(Array,"Array",function(e,t){n.set(this,i,{o:n.toObject(e),i:0,k:t})},function(){var e=this[i],t=e.o,r=e.k,n=e.i++;return!t||n>=t.length?(e.o=void 0,a(1)):"keys"==r?a(0,n):"values"==r?a(0,t[n]):a(0,[n,t[n]])},"values"),s.Arguments=s.Array,o("keys"),o("values"),o("entries")},function(e,t,r){"use strict";function n(e,t){o.hide(e,c,t),l in[]&&o.hide(e,l,t)}var o=r(37),i=r(51),u=i.classof,a=r(52),s=a.obj,c=r(43)("iterator"),l="@@iterator",f=r(53)("iterators"),d={};n(d,o.that),e.exports={BUGGY:"keys"in[]&&!("next"in[].keys()),Iterators:f,step:function(e,t){return{value:t,done:!!e}},is:function(e){var t=Object(e),r=o.g.Symbol;return(r&&r.iterator||l)in t||c in t||o.has(f,u(t))},get:function(e){var t,r=o.g.Symbol;return void 0!=e&&(t=e[r&&r.iterator||l]||e[c]||f[u(e)]),a(o.isFunction(t),e," is not iterable!"),s(t.call(e))},set:n,create:function(e,t,r,n){e.prototype=o.create(n||d,{next:o.desc(1,r)}),i.set(e,t+" Iterator")}}},function(e,t,r){var n=r(37).g,o=r(53)("wks");e.exports=function(e){return o[e]||(o[e]=n.Symbol&&n.Symbol[e]||r(45).safe("Symbol."+e))}},function(e,t,r){var n=r(37);e.exports=function(e){return function(t,r){var o,i,u=String(n.assertDefined(t)),a=n.toInteger(r),s=u.length;return 0>a||a>=s?e?"":void 0:(o=u.charCodeAt(a),55296>o||o>56319||a+1===s||(i=u.charCodeAt(a+1))<56320||i>57343?e?u.charAt(a):o:e?u.slice(a,a+2):(o-55296<<10)+(i-56320)+65536)}}},function(e,t,r){function n(e){return"Symbol(".concat(void 0===e?"":e,")_",(++o+Math.random()).toString(36))}var o=0;n.safe=r(37).g.Symbol||n,e.exports=n},function(e,t,r){var n=r(48),o=r(54),i=r(37),u=r(51),a=r(42),s=r(43)("iterator"),c="@@iterator",l="keys",f="values",d=a.Iterators;e.exports=function(e,t,r,p,h,y,v){function g(e){function t(t){return new r(t,e)}switch(e){case l:return function(){return t(this)};case f:return function(){return t(this)}}return function(){return t(this)}}a.create(r,t,p);var b,m,O=t+" Iterator",j=e.prototype,w=j[s]||j[c]||h&&j[h],x=w||g(h);if(w){var E=i.getProto(x.call(new e));u.set(E,O,!0),i.FW&&i.has(j,c)&&a.set(E,i.that)}if((i.FW||v)&&a.set(j,x),d[t]=x,d[O]=i.that,h)if(b={keys:y?x:g(l),values:h==f?x:g(f),entries:h!=f?x:g("entries")},v)for(m in b)m in j||o(j,m,b[m]);else n(n.P+n.F*a.BUGGY,t,b)}},function(e){e.exports=function(e){return e.FW=!1,e.path=e.core,e}},function(e,t,r){function n(e,t){return function(){return e.apply(t,arguments)}}function o(e,t,r){var i,c,l,f,d=e&o.G,p=e&o.P,h=d?u:e&o.S?u[t]:(u[t]||{}).prototype,y=d?a:a[t]||(a[t]={});d&&(r=t);for(i in r)c=!(e&o.F)&&h&&i in h,c&&i in y||(l=c?h[i]:r[i],d&&!s(h[i])?f=r[i]:e&o.B&&c?f=n(l,u):e&o.W&&h[i]==l?!function(e){f=function(t){return this instanceof e?new e(t):e(t)},f.prototype=e.prototype}(l):f=p&&s(l)?n(Function.call,l):l,y[i]=f,p&&((y.prototype||(y.prototype={}))[i]=l))}var i=r(37),u=i.g,a=i.core,s=i.isFunction;o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,e.exports=o},function(e,t,r){function n(e){try{return u(e)}catch(t){return a.slice()}}var o=r(37),i={}.toString,u=o.getNames,a="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.get=function(e){return a&&"[object Window]"==i.call(e)?n(e):u(o.toObject(e))}},function(e){e.exports=function(){}},function(e,t,r){function n(e){return u.call(e).slice(8,-1)}var o=r(37),i=r(43)("toStringTag"),u={}.toString;n.classof=function(e){var t,r;return void 0==e?void 0===e?"Undefined":"Null":"string"==typeof(r=(t=Object(e))[i])?r:n(t)},n.set=function(e,t,r){e&&!o.has(e=r?e:e.prototype,i)&&o.hide(e,i,t)},e.exports=n},function(e,t,r){function n(e,t,r){if(!e)throw TypeError(r?t+r:t)}var o=r(37);n.def=o.assertDefined,n.fn=function(e){if(!o.isFunction(e))throw TypeError(e+" is not a function!");return e},n.obj=function(e){if(!o.isObject(e))throw TypeError(e+" is not an object!");return e},n.inst=function(e,t,r){if(!(e instanceof t))throw TypeError(r+": use the 'new' operator!");return e},e.exports=n},function(e,t,r){var n=r(37),o="__core-js_shared__",i=n.g[o]||(n.g[o]={});e.exports=function(e){return i[e]||(i[e]={})}},function(e,t,r){e.exports=r(37).hide}])});
{
"name": "fakerest",
"version": "1.2.0",
"version": "1.2.1",
"repository": "https://github.com/marmelab/FakeRest",

@@ -5,0 +5,0 @@ "description": "Patch XMLHttpRequest to fake a REST server based on JSON data. ",

@@ -31,2 +31,3 @@ import objectAssign from 'object.assign';

this.log(request, response);
response.headers = new Headers(response.headers)

@@ -43,3 +44,3 @@ return response;

console.log(request.method, request.url);
console.log('headers', request.requestHeaders);
console.log('headers', request.headers);
console.log('body ', request.requestBody);

@@ -53,3 +54,3 @@ console.groupEnd();

} else {
console.log('FakeRest request ', request.method, request.url, 'headers', request.requestHeaders, 'body', request.requestBody);
console.log('FakeRest request ', request.method, request.url, 'headers', request.headers, 'body', request.requestBody);
console.log('FakeRest response', response.status, 'headers', response.headers, 'body', response.body);

@@ -56,0 +57,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc