mirror of
https://github.com/flynx/serialize.js.git
synced 2026-08-25 17:26:42 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
1543469cdf
commit
2dd85e20df
@ -203,10 +203,7 @@ function(obj, indent, depth=0, functions){
|
|||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// XXX better error handling...
|
// XXX better error handling...
|
||||||
// XXX add function support...
|
|
||||||
// XXX try and make this single stage (see notes for : .recursive(..))
|
// XXX try and make this single stage (see notes for : .recursive(..))
|
||||||
// XXX BUG: deserialize('Set([1,2,3])') -> Set([3])
|
|
||||||
// XXX BUG: deserialize('Map([[1,2],[3,4]])')) -> err
|
|
||||||
var eJSON =
|
var eJSON =
|
||||||
module.eJSON = {
|
module.eJSON = {
|
||||||
chars: {
|
chars: {
|
||||||
@ -495,7 +492,6 @@ module.eJSON = {
|
|||||||
if(str[i] != ')'){
|
if(str[i] != ')'){
|
||||||
this.error('Expected ")", got "'+ str[i] +'".', str, i, line) }
|
this.error('Expected ")", got "'+ str[i] +'".', str, i, line) }
|
||||||
return [res, i+1, line] },
|
return [res, i+1, line] },
|
||||||
// XXX need to destinguish between key and value in path...
|
|
||||||
map: function(state, path, match, str, i, line){
|
map: function(state, path, match, str, i, line){
|
||||||
debug.lex('map', str, i, line)
|
debug.lex('map', str, i, line)
|
||||||
i += match.length
|
i += match.length
|
||||||
@ -508,7 +504,6 @@ module.eJSON = {
|
|||||||
var obj
|
var obj
|
||||||
;[[key, value], i, line] = this.value(
|
;[[key, value], i, line] = this.value(
|
||||||
state,
|
state,
|
||||||
// XXX need a way to index path or value...
|
|
||||||
[...path, index],
|
[...path, index],
|
||||||
str, i, line)
|
str, i, line)
|
||||||
res.set(key, value)
|
res.set(key, value)
|
||||||
@ -545,8 +540,7 @@ module.eJSON = {
|
|||||||
rec.push([path, obj])
|
rec.push([path, obj])
|
||||||
return [{}, i, line] }) },
|
return [{}, i, line] }) },
|
||||||
|
|
||||||
// XXX disable this by default...
|
// NOTE: this uses eval(..) so care must be taken when enabling this...
|
||||||
// XXX can we avoid eval here???
|
|
||||||
func: function(state, path, match, str, i, line){
|
func: function(state, path, match, str, i, line){
|
||||||
if(state.functions == null){
|
if(state.functions == null){
|
||||||
this.error('Deserializing functions disabled.', str, i, line) }
|
this.error('Deserializing functions disabled.', str, i, line) }
|
||||||
@ -577,7 +571,6 @@ module.eJSON = {
|
|||||||
return [res, i+2, line] },
|
return [res, i+2, line] },
|
||||||
|
|
||||||
value: function(state, path, str, i=0, line=0){
|
value: function(state, path, str, i=0, line=0){
|
||||||
//debug.lex('value', str, i, line)
|
|
||||||
|
|
||||||
;[i, line] = this.skipWhitespace(str, i, line)
|
;[i, line] = this.skipWhitespace(str, i, line)
|
||||||
|
|
||||||
@ -628,7 +621,7 @@ function(str, functions){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//---------------------------------------------------------------------
|
||||||
// utils...
|
// utils...
|
||||||
|
|
||||||
var deepCopy =
|
var deepCopy =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user