ts-object-mapper
Version:
A TypeScript library to serialize and deserialize JSON objects
2 lines • 2.69 kB
JavaScript
var ObjectMapper=function(e){var r={};function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";r.__esModule=!0;var n=t(1),i=function(){function e(){}return e.getInstance=function(){return this.Instance||(this.Instance=new e),this.Instance},e.serialize=function(e,r){return void 0!==r?(Array,this.getInstance().serialize(e,r)):this.getInstance().serialize(e)},e.deserialize=function(e,r){return this.getInstance().deserialize(e,r)},e.deserializeArray=function(e,r){return this.getInstance().deserializeArray(e,r)},e.prototype.serialize=function(e,r){var t=this;return e instanceof Array?void 0!==r?e.map(function(e){return t.serializeObject(e,r)}):JSON.stringify(e.map(function(e){return t.serializeObject(e,Object)})):void 0!==r?this.serializeObject(e,r):JSON.stringify(this.serializeObject(e,Object))},e.prototype.deserialize=function(e,r){if("string"==typeof r){var t=void 0;try{t=JSON.parse(r)}catch(e){throw e instanceof SyntaxError?new n.ObjectMapperError("JSON syntax error: "+e.message,e):new n.ObjectMapperError("Unknown error",e)}return this.deserializeObject(e,t)}return this.deserializeObject(e,r)},e.prototype.deserializeArray=function(e,r){var t=this;if("string"==typeof r){var i=void 0;try{i=JSON.parse(r)}catch(e){throw e instanceof SyntaxError?new n.ObjectMapperError("JSON syntax error: "+e.message,e):new n.ObjectMapperError("Unknown error",e)}return i.map(function(r){return t.deserializeObject(e,r)})}return r.map(function(r){return t.deserializeObject(e,r)})},e.prototype.serializeObject=function(e,r){return new r},e.prototype.deserializeObject=function(e,r){return new e},e}();r.ObjectMapper=i},function(e,r,t){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])},function(e,r){function t(){this.constructor=e}n(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)});r.__esModule=!0;var o=function(e){function r(r,t){var n=e.call(this,r)||this;return n.name=n.constructor.name,n.message=r||"Unexpected error",Error.captureStackTrace(n,n.constructor),n.cause=t,n}return i(r,e),r}(Error);r.ObjectMapperError=o}]).ObjectMapper;
//# sourceMappingURL=ts-object-mapper.browser.min.js.map