From 157d36e2a6d5fef085774b2f7923213725830693 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 4 Oct 2024 11:34:24 +0300 Subject: [PATCH] notes and tweaks... Signed-off-by: Alex A. Naanou --- serialize.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/serialize.js b/serialize.js index aa8c92c..f109501 100644 --- a/serialize.js +++ b/serialize.js @@ -2,6 +2,13 @@ * * XXX the structure of this will change!! * +* XXX merge serialize(..) and stringify(..) -> pre-parse theinput string +* in deserialize(..) to replace undefined, NaN and with +* appropriate placeholders... +* There should be two formats: +* - pretty +* - fast -- w/o pre-processing... +* **********************************************************************/ ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) (function(require){ var module={} // make module AMD/node compatible... @@ -22,9 +29,11 @@ var EMPTY = '<< EMPTY >>' var UNDEFINED = '<< UNDEFINED >>' var NAN = '<< NAN >>' +// XXX unify the output format... +// XXX handle formatting -- pass to JSON.stringify(..)... var serialize = module.serialize = -function(value, raw=false){ +function(value, raw=true){ var replacer = function(k, v){ // undefined... if(v === undefined){ @@ -51,6 +60,13 @@ function(value, raw=false){ .replace(new RegExp('"'+ NAN +'"', 'g'), 'NaN') } +var stringify = +module.stringify = +function(value){ + return serialize(value, false) } + + +// XXX this should pre-parse te string -- need to handle strings correctly... var deserialize = module.deserialize = function(str){