lossless-json
Advanced tools
Comparing version 2.0.4 to 2.0.5
# History | ||
## 2023-01-06, version 2.0.5 | ||
- Fix: error handling unicode characters containing a `9`. | ||
## 2022-12-19, version 2.0.4 | ||
@@ -4,0 +8,0 @@ |
@@ -257,3 +257,3 @@ import { parseLosslessNumber } from './numberParsers.js'; | ||
function isHex(code) { | ||
return code >= codeZero && code < codeNine || code >= codeUppercaseA && code <= codeUppercaseF || code >= codeLowercaseA && code <= codeLowercaseF; | ||
return code >= codeZero && code <= codeNine || code >= codeUppercaseA && code <= codeUppercaseF || code >= codeLowercaseA && code <= codeLowercaseF; | ||
} | ||
@@ -260,0 +260,0 @@ function isDigit(code) { |
@@ -1,1 +0,1 @@ | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).LosslessJSON={})}(this,(function(t){"use strict";function r(t){return n.test(t)}var n=/^-?[0-9]+$/;function e(t){return a.test(t)}var o,a=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function i(t,n){var e=parseFloat(t),o=String(e),a=u(t),i=u(o);if(a===i)return!0;if(!0===(null==n?void 0:n.approx)){if(!r(t)&&i.length>=14&&a.startsWith(i.substring(0,14)))return!0}return!1}function c(n){if(!i(n,{approx:!1})){if(r(n))return t.UnsafeNumberReason.truncate_integer;var e=parseFloat(n);return isFinite(e)?0===e?t.UnsafeNumberReason.underflow:t.UnsafeNumberReason.truncate_float:t.UnsafeNumberReason.overflow}}function u(t){return t.replace(f,"").replace(s,"").replace(d,"").replace(l,"")}t.UnsafeNumberReason=void 0,(o=t.UnsafeNumberReason||(t.UnsafeNumberReason={})).underflow="underflow",o.overflow="overflow",o.truncate_integer="truncate_integer",o.truncate_float="truncate_float";var f=/[eE][+-]?\d+$/,l=/^-?(0*)?/,s=/\./,d=/0+$/;function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}function p(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,v(e.key),e)}}function v(t){var r=function(t,r){if("object"!==y(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,r||"default");if("object"!==y(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===y(r)?r:String(r)}var h=function(){function n(t){if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,n),function(t,r,n){(r=v(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n}(this,"isLosslessNumber",!0),!e(t))throw new Error('Invalid number (value: "'+t+'")');this.value=t}var o,a,i;return o=n,(a=[{key:"valueOf",value:function(){var n=c(this.value);if(void 0===n||n===t.UnsafeNumberReason.truncate_float)return parseFloat(this.value);if(r(this.value))return BigInt(this.value);throw new Error("Cannot safely convert to number: "+"the value '".concat(this.value,"' would ").concat(n," and become ").concat(parseFloat(this.value)))}},{key:"toString",value:function(){return this.value}}])&&p(o.prototype,a),i&&p(o,i),Object.defineProperty(o,"prototype",{writable:!1}),n}();function b(t){return t&&"object"===y(t)&&!0===t.isLosslessNumber||!1}function m(t){return new h(t)}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function g(t,r){return S({"":t},"",t,r)}function S(t,r,n,e){return Array.isArray(n)?e.call(t,r,function(t,r){for(var n=0;n<t.length;n++)t[n]=S(t,n+"",t[n],r);return t}(n,e)):n&&"object"===w(n)&&!b(n)?e.call(t,r,function(t,r){return Object.keys(t).forEach((function(n){var e=S(t,n,t[n],r);void 0!==e?t[n]=e:delete t[n]})),t}(n,e)):e.call(t,r,n)}function A(t){return t===_||t===F||t===J||t===L}function C(t){return t>=B&&t<Q||t>=z&&t<=M||t>=G&&t<=V}function N(t){return t>=B&&t<=Q}function x(t){return t>=D&&t<=Q}function E(t){return t>=32&&t<=1114111}var O={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},j=92,I=123,R=125,k=91,U=93,_=32,F=10,J=9,L=13,P=34,T=43,$=45,B=48,D=49,Q=57,W=44,Z=46,q=58,z=65,G=97,H=69,K=101,M=70,V=102;function X(t){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(t)}var Y=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;t.LosslessNumber=h,t.config=function(t){throw new Error("config is deprecated, support for circularRefs is removed from the library. If you encounter circular references in your data structures, please rethink your datastructures: better prevent circular references in the first place.")},t.getUnsafeNumberReason=c,t.isInteger=r,t.isLosslessNumber=b,t.isNumber=e,t.isSafeNumber=i,t.parse=function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:m,e=0,o=c();return p(o),h(),r?g(o,r):o;function a(){if(t.charCodeAt(e)===I){e++,f();for(var r={},n=!0;e<t.length&&t.charCodeAt(e)!==R;){n?n=!1:(d(),f());var o=l();void 0===o&&S(),Object.prototype.hasOwnProperty.call(r,o)&&_(o),f(),y(),r[o]=c()}return t.charCodeAt(e)!==R&&F(),e++,r}}function i(){if(t.charCodeAt(e)===k){e++,f();for(var r=[],n=!0;e<t.length&&t.charCodeAt(e)!==U;){n?n=!1:d();var o=c();v(o),r.push(o)}return t.charCodeAt(e)!==U&&J(),e++,r}}function c(){var t,r,n,e,o,c;f();var d=null!==(t=null!==(r=null!==(n=null!==(e=null!==(o=null!==(c=l())&&void 0!==c?c:s())&&void 0!==o?o:a())&&void 0!==e?e:i())&&void 0!==n?n:u("true",!0))&&void 0!==r?r:u("false",!1))&&void 0!==t?t:u("null",null);return f(),d}function u(r,n){if(t.slice(e,e+r.length)===r)return e+=r.length,n}function f(){for(;A(t.charCodeAt(e));)e++}function l(){if(t.charCodeAt(e)===P){e++;for(var r="";e<t.length&&t.charCodeAt(e)!==P;){if(t.charCodeAt(e)===j){var n=t[e+1],o=O[n];void 0!==o?(r+=o,e++):"u"===n?C(t.charCodeAt(e+2))&&C(t.charCodeAt(e+3))&&C(t.charCodeAt(e+4))&&C(t.charCodeAt(e+5))?(r+=String.fromCharCode(parseInt(t.slice(e+2,e+6),16)),e+=5):Q(e):D(e)}else E(t.charCodeAt(e))?r+=t[e]:L(t[e]);e++}return w(),e++,r}}function s(){var r=e;if(t.charCodeAt(e)===$&&(e++,b(r)),t.charCodeAt(e)===B)e++;else if(x(t.charCodeAt(e)))for(e++;N(t.charCodeAt(e));)e++;if(t.charCodeAt(e)===Z)for(e++,b(r);N(t.charCodeAt(e));)e++;if(t.charCodeAt(e)===K||t.charCodeAt(e)===H)for(e++,t.charCodeAt(e)!==$&&t.charCodeAt(e)!==T||e++,b(r);N(t.charCodeAt(e));)e++;if(e>r)return n(t.slice(r,e))}function d(){if(t.charCodeAt(e)!==W)throw new SyntaxError("Comma ',' expected after value ".concat(M()));e++}function y(){if(t.charCodeAt(e)!==q)throw new SyntaxError("Colon ':' expected after property name ".concat(M()));e++}function p(t){if(void 0===t)throw new SyntaxError("JSON value expected ".concat(M()))}function v(t){if(void 0===t)throw new SyntaxError("Array item expected ".concat(M()))}function h(){if(e<t.length)throw new SyntaxError("Expected end of input ".concat(M()))}function b(r){if(!N(t.charCodeAt(e))){var n=t.slice(r,e);throw new SyntaxError("Invalid number '".concat(n,"', expecting a digit ").concat(M()))}}function w(){if(t.charCodeAt(e)!==P)throw new SyntaxError("End of string '\"' expected ".concat(M()))}function S(){throw new SyntaxError("Quoted object key expected ".concat(M()))}function _(t){throw new SyntaxError("Duplicate key '".concat(t,"' encountered at position ").concat(e-t.length-1))}function F(){throw new SyntaxError("Quoted object key or end of object '}' expected ".concat(M()))}function J(){throw new SyntaxError("Array item or end of array ']' expected ".concat(M()))}function L(t){throw new SyntaxError("Invalid character '".concat(t,"' ").concat(z()))}function D(r){var n=t.slice(r,r+2);throw new SyntaxError("Invalid escape character '".concat(n,"' ").concat(z()))}function Q(r){for(var n=r+2;/\w/.test(t[n]);)n++;var e=t.slice(r,n);throw new SyntaxError("Invalid unicode character '".concat(e,"' ").concat(z()))}function z(){return"at position ".concat(e)}function G(){return e<t.length?"but got '".concat(t[e],"'"):"but reached end of input"}function M(){return G()+" "+z()}},t.parseLosslessNumber=m,t.parseNumberAndBigInt=function(t){return r(t)?BigInt(t):parseFloat(t)},t.reviveDate=function(t,r){return"string"==typeof r&&Y.test(r)?new Date(r):r},t.stringify=function t(r,n,o,a){var i=function(t){if("number"==typeof t)return" ".repeat(t);if("string"==typeof t&&""!==t)return t;return}(o);return c("function"==typeof n?n.call({"":r},"",r):r,"");function c(r,u){if(Array.isArray(a)){var f=a.find((function(t){return t.test(r)}));if(f){var l=f.stringify(r);if("string"!=typeof l||!e(l))throw new Error("Invalid JSON number: output of a number stringifier must be a string containing a JSON number "+"(output: ".concat(l,")"));return l}}return"boolean"==typeof r||"number"==typeof r||"string"==typeof r||null===r||r instanceof Date||r instanceof Boolean||r instanceof Number||r instanceof String?JSON.stringify(r):r&&r.isLosslessNumber||"bigint"==typeof r?r.toString():Array.isArray(r)?function(t,r){for(var e=i?r+i:void 0,o=i?"[\n":"[",a=0;a<t.length;a++){var u="function"==typeof n?n.call(t,String(a),t[a]):t[a];i&&(o+=e),o+=void 0!==u&&"function"!=typeof u?c(u,e):"null",a<t.length-1&&(o+=i?",\n":",")}return o+=i?"\n"+r+"]":"]"}(r,u):r&&"object"===X(r)?function(r,e){if("function"==typeof r.toJSON)return t(r.toJSON(),n,o,void 0);var a=Array.isArray(n)?n.map(String):Object.keys(r),u=i?e+i:void 0,f=!0,l=i?"{\n":"{";return a.forEach((function(t){var e="function"==typeof n?n.call(r,t,r[t]):r[t];if(function(t,r){return void 0!==r&&"function"!=typeof r&&"symbol"!==X(r)}(0,e)){f?f=!1:l+=i?",\n":",";var o=JSON.stringify(t);l+=i?u+o+": ":o+":",l+=c(e,u)}})),l+=i?"\n"+e+"}":"}"}(r,u):void 0}},t.toLosslessNumber=function(t){if(u(t+"").length>15)throw new Error("Invalid number: contains more than 15 digits and is most likely truncated and unsafe by itself "+"(value: ".concat(t,")"));if(isNaN(t))throw new Error("Invalid number: NaN");if(!isFinite(t))throw new Error("Invalid number: "+t);return new h(String(t))},t.toSafeNumberOrThrow=function(r,n){var e=parseFloat(r),o=c(r);if(!0===(null==n?void 0:n.approx)?o&&o!==t.UnsafeNumberReason.truncate_float:o){var a=o.replace(/_\w+$/,"");throw new Error("Cannot safely convert to number: "+"the value '".concat(r,"' would ").concat(a," and become ").concat(e))}return e}}));//# sourceMappingURL=lossless-json.js.map | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).LosslessJSON={})}(this,(function(t){"use strict";function r(t){return n.test(t)}var n=/^-?[0-9]+$/;function e(t){return a.test(t)}var o,a=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function i(t,n){var e=parseFloat(t),o=String(e),a=u(t),i=u(o);if(a===i)return!0;if(!0===(null==n?void 0:n.approx)){if(!r(t)&&i.length>=14&&a.startsWith(i.substring(0,14)))return!0}return!1}function c(n){if(!i(n,{approx:!1})){if(r(n))return t.UnsafeNumberReason.truncate_integer;var e=parseFloat(n);return isFinite(e)?0===e?t.UnsafeNumberReason.underflow:t.UnsafeNumberReason.truncate_float:t.UnsafeNumberReason.overflow}}function u(t){return t.replace(f,"").replace(s,"").replace(d,"").replace(l,"")}t.UnsafeNumberReason=void 0,(o=t.UnsafeNumberReason||(t.UnsafeNumberReason={})).underflow="underflow",o.overflow="overflow",o.truncate_integer="truncate_integer",o.truncate_float="truncate_float";var f=/[eE][+-]?\d+$/,l=/^-?(0*)?/,s=/\./,d=/0+$/;function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}function p(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,v(e.key),e)}}function v(t){var r=function(t,r){if("object"!==y(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,r||"default");if("object"!==y(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===y(r)?r:String(r)}var h=function(){function n(t){if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,n),function(t,r,n){(r=v(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n}(this,"isLosslessNumber",!0),!e(t))throw new Error('Invalid number (value: "'+t+'")');this.value=t}var o,a,i;return o=n,(a=[{key:"valueOf",value:function(){var n=c(this.value);if(void 0===n||n===t.UnsafeNumberReason.truncate_float)return parseFloat(this.value);if(r(this.value))return BigInt(this.value);throw new Error("Cannot safely convert to number: "+"the value '".concat(this.value,"' would ").concat(n," and become ").concat(parseFloat(this.value)))}},{key:"toString",value:function(){return this.value}}])&&p(o.prototype,a),i&&p(o,i),Object.defineProperty(o,"prototype",{writable:!1}),n}();function b(t){return t&&"object"===y(t)&&!0===t.isLosslessNumber||!1}function m(t){return new h(t)}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function g(t,r){return S({"":t},"",t,r)}function S(t,r,n,e){return Array.isArray(n)?e.call(t,r,function(t,r){for(var n=0;n<t.length;n++)t[n]=S(t,n+"",t[n],r);return t}(n,e)):n&&"object"===w(n)&&!b(n)?e.call(t,r,function(t,r){return Object.keys(t).forEach((function(n){var e=S(t,n,t[n],r);void 0!==e?t[n]=e:delete t[n]})),t}(n,e)):e.call(t,r,n)}function A(t){return t===_||t===F||t===J||t===L}function C(t){return t>=B&&t<=Q||t>=z&&t<=M||t>=G&&t<=V}function N(t){return t>=B&&t<=Q}function x(t){return t>=D&&t<=Q}function E(t){return t>=32&&t<=1114111}var O={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},j=92,I=123,R=125,k=91,U=93,_=32,F=10,J=9,L=13,P=34,T=43,$=45,B=48,D=49,Q=57,W=44,Z=46,q=58,z=65,G=97,H=69,K=101,M=70,V=102;function X(t){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(t)}var Y=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;t.LosslessNumber=h,t.config=function(t){throw new Error("config is deprecated, support for circularRefs is removed from the library. If you encounter circular references in your data structures, please rethink your datastructures: better prevent circular references in the first place.")},t.getUnsafeNumberReason=c,t.isInteger=r,t.isLosslessNumber=b,t.isNumber=e,t.isSafeNumber=i,t.parse=function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:m,e=0,o=c();return p(o),h(),r?g(o,r):o;function a(){if(t.charCodeAt(e)===I){e++,f();for(var r={},n=!0;e<t.length&&t.charCodeAt(e)!==R;){n?n=!1:(d(),f());var o=l();void 0===o&&S(),Object.prototype.hasOwnProperty.call(r,o)&&_(o),f(),y(),r[o]=c()}return t.charCodeAt(e)!==R&&F(),e++,r}}function i(){if(t.charCodeAt(e)===k){e++,f();for(var r=[],n=!0;e<t.length&&t.charCodeAt(e)!==U;){n?n=!1:d();var o=c();v(o),r.push(o)}return t.charCodeAt(e)!==U&&J(),e++,r}}function c(){var t,r,n,e,o,c;f();var d=null!==(t=null!==(r=null!==(n=null!==(e=null!==(o=null!==(c=l())&&void 0!==c?c:s())&&void 0!==o?o:a())&&void 0!==e?e:i())&&void 0!==n?n:u("true",!0))&&void 0!==r?r:u("false",!1))&&void 0!==t?t:u("null",null);return f(),d}function u(r,n){if(t.slice(e,e+r.length)===r)return e+=r.length,n}function f(){for(;A(t.charCodeAt(e));)e++}function l(){if(t.charCodeAt(e)===P){e++;for(var r="";e<t.length&&t.charCodeAt(e)!==P;){if(t.charCodeAt(e)===j){var n=t[e+1],o=O[n];void 0!==o?(r+=o,e++):"u"===n?C(t.charCodeAt(e+2))&&C(t.charCodeAt(e+3))&&C(t.charCodeAt(e+4))&&C(t.charCodeAt(e+5))?(r+=String.fromCharCode(parseInt(t.slice(e+2,e+6),16)),e+=5):Q(e):D(e)}else E(t.charCodeAt(e))?r+=t[e]:L(t[e]);e++}return w(),e++,r}}function s(){var r=e;if(t.charCodeAt(e)===$&&(e++,b(r)),t.charCodeAt(e)===B)e++;else if(x(t.charCodeAt(e)))for(e++;N(t.charCodeAt(e));)e++;if(t.charCodeAt(e)===Z)for(e++,b(r);N(t.charCodeAt(e));)e++;if(t.charCodeAt(e)===K||t.charCodeAt(e)===H)for(e++,t.charCodeAt(e)!==$&&t.charCodeAt(e)!==T||e++,b(r);N(t.charCodeAt(e));)e++;if(e>r)return n(t.slice(r,e))}function d(){if(t.charCodeAt(e)!==W)throw new SyntaxError("Comma ',' expected after value ".concat(M()));e++}function y(){if(t.charCodeAt(e)!==q)throw new SyntaxError("Colon ':' expected after property name ".concat(M()));e++}function p(t){if(void 0===t)throw new SyntaxError("JSON value expected ".concat(M()))}function v(t){if(void 0===t)throw new SyntaxError("Array item expected ".concat(M()))}function h(){if(e<t.length)throw new SyntaxError("Expected end of input ".concat(M()))}function b(r){if(!N(t.charCodeAt(e))){var n=t.slice(r,e);throw new SyntaxError("Invalid number '".concat(n,"', expecting a digit ").concat(M()))}}function w(){if(t.charCodeAt(e)!==P)throw new SyntaxError("End of string '\"' expected ".concat(M()))}function S(){throw new SyntaxError("Quoted object key expected ".concat(M()))}function _(t){throw new SyntaxError("Duplicate key '".concat(t,"' encountered at position ").concat(e-t.length-1))}function F(){throw new SyntaxError("Quoted object key or end of object '}' expected ".concat(M()))}function J(){throw new SyntaxError("Array item or end of array ']' expected ".concat(M()))}function L(t){throw new SyntaxError("Invalid character '".concat(t,"' ").concat(z()))}function D(r){var n=t.slice(r,r+2);throw new SyntaxError("Invalid escape character '".concat(n,"' ").concat(z()))}function Q(r){for(var n=r+2;/\w/.test(t[n]);)n++;var e=t.slice(r,n);throw new SyntaxError("Invalid unicode character '".concat(e,"' ").concat(z()))}function z(){return"at position ".concat(e)}function G(){return e<t.length?"but got '".concat(t[e],"'"):"but reached end of input"}function M(){return G()+" "+z()}},t.parseLosslessNumber=m,t.parseNumberAndBigInt=function(t){return r(t)?BigInt(t):parseFloat(t)},t.reviveDate=function(t,r){return"string"==typeof r&&Y.test(r)?new Date(r):r},t.stringify=function t(r,n,o,a){var i=function(t){if("number"==typeof t)return" ".repeat(t);if("string"==typeof t&&""!==t)return t;return}(o);return c("function"==typeof n?n.call({"":r},"",r):r,"");function c(r,u){if(Array.isArray(a)){var f=a.find((function(t){return t.test(r)}));if(f){var l=f.stringify(r);if("string"!=typeof l||!e(l))throw new Error("Invalid JSON number: output of a number stringifier must be a string containing a JSON number "+"(output: ".concat(l,")"));return l}}return"boolean"==typeof r||"number"==typeof r||"string"==typeof r||null===r||r instanceof Date||r instanceof Boolean||r instanceof Number||r instanceof String?JSON.stringify(r):r&&r.isLosslessNumber||"bigint"==typeof r?r.toString():Array.isArray(r)?function(t,r){for(var e=i?r+i:void 0,o=i?"[\n":"[",a=0;a<t.length;a++){var u="function"==typeof n?n.call(t,String(a),t[a]):t[a];i&&(o+=e),o+=void 0!==u&&"function"!=typeof u?c(u,e):"null",a<t.length-1&&(o+=i?",\n":",")}return o+=i?"\n"+r+"]":"]"}(r,u):r&&"object"===X(r)?function(r,e){if("function"==typeof r.toJSON)return t(r.toJSON(),n,o,void 0);var a=Array.isArray(n)?n.map(String):Object.keys(r),u=i?e+i:void 0,f=!0,l=i?"{\n":"{";return a.forEach((function(t){var e="function"==typeof n?n.call(r,t,r[t]):r[t];if(function(t,r){return void 0!==r&&"function"!=typeof r&&"symbol"!==X(r)}(0,e)){f?f=!1:l+=i?",\n":",";var o=JSON.stringify(t);l+=i?u+o+": ":o+":",l+=c(e,u)}})),l+=i?"\n"+e+"}":"}"}(r,u):void 0}},t.toLosslessNumber=function(t){if(u(t+"").length>15)throw new Error("Invalid number: contains more than 15 digits and is most likely truncated and unsafe by itself "+"(value: ".concat(t,")"));if(isNaN(t))throw new Error("Invalid number: NaN");if(!isFinite(t))throw new Error("Invalid number: "+t);return new h(String(t))},t.toSafeNumberOrThrow=function(r,n){var e=parseFloat(r),o=c(r);if(!0===(null==n?void 0:n.approx)?o&&o!==t.UnsafeNumberReason.truncate_float:o){var a=o.replace(/_\w+$/,"");throw new Error("Cannot safely convert to number: "+"the value '".concat(r,"' would ").concat(a," and become ").concat(e))}return e}}));//# sourceMappingURL=lossless-json.js.map |
{ | ||
"name": "lossless-json", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Parse JSON without risk of losing numeric information", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
172904