diff --git a/jsonfn.js b/jsonfn.js index 8097e5a..9889905 100644 --- a/jsonfn.js +++ b/jsonfn.js @@ -34,16 +34,15 @@ exports.stringify = function (obj) { return JSON.stringify(obj, function (key, value) { - var fnBody; if (value instanceof Function || typeof value == 'function') { + fnBody = value.toString(); if (fnBody.length < 8 || fnBody.substring(0, 8) !== 'function') { //this is ES6 Arrow Function return '_NuFrRa_' + fnBody; } - return fnBody; } if (value instanceof RegExp) { diff --git a/jsonfn.min.js b/jsonfn.min.js index 2cab9ee..f714551 100644 --- a/jsonfn.min.js +++ b/jsonfn.min.js @@ -4,4 +4,4 @@ * License: MIT */ (function(a){a.stringify=function(a){return JSON.stringify(a,function(a,b){var d;return b instanceof Function||"function"==typeof b?(d=b.toString(),8>d.length||"function"!==d.substring(0,8)?"_NuFrRa_"+d:d):b instanceof RegExp?"_PxEgEr_"+b:b})};a.parse=function(a,f){var b=f?/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/:!1;return JSON.parse(a,function(a,c){var e;if("string"!=typeof c||8>c.length)return c;e=c.substring(0,8);return b&&c.match(b)?new Date(c):"function"===e?eval("("+c+ -")"):"_PxEgEr_"===e||"_NuFrRa_"===e?eval(c.slice(8)):c})};a.clone=function(g,f){return a.parse(a.stringify(g),f)}})("undefined"===typeof exports?window.JSONfn={}:exports); \ No newline at end of file +")"):"_PxEgEr_"===e||"_NuFrRa_"===e?eval(c.slice(8)):c})};a.clone=function(g,f){return a.parse(a.stringify(g),f)}})("undefined"===typeof exports?window.JSONfn={}:exports); diff --git a/package.json b/package.json index bde5045..e022123 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "json-fn", - "version": "1.1.0", + "version": "1.1.1", "author": "Vadim Kiryukhin ", "description": "javascript plugin to stringify, parse and clone javascript objects with Functions, RegExp and Date.", "contributors": [