Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiryukhin, Vadim committed Jul 30, 2016
1 parent eddba77 commit 299b4be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions jsonfn.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion jsonfn.min.js
Expand Up @@ -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);
")"):"_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);
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "json-fn",
"version": "1.1.0",
"version": "1.1.1",
"author": "Vadim Kiryukhin <vkiryukhin@gmail.com>",
"description": "javascript plugin to stringify, parse and clone javascript objects with Functions, RegExp and Date.",
"contributors": [
Expand Down

0 comments on commit 299b4be

Please sign in to comment.