mirror of
https://github.com/flynx/serialize.js.git
synced 2026-07-14 04:50:57 +00:00
more cleanup and notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ed993e7391
commit
6c7f043d18
@ -128,7 +128,9 @@ function(obj, path=[], seen=new Map(), space, indent=0){
|
|||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
// XXX better error handling...
|
||||||
// XXX add function support...
|
// XXX add function support...
|
||||||
|
// XXX try and make this single stage (see notes for : .recursive(..))
|
||||||
var eJSON =
|
var eJSON =
|
||||||
module.eJSON = {
|
module.eJSON = {
|
||||||
chars: {
|
chars: {
|
||||||
@ -217,13 +219,19 @@ module.eJSON = {
|
|||||||
&& str[j] <= '9'))){
|
&& str[j] <= '9'))){
|
||||||
j++ }
|
j++ }
|
||||||
return [ str.slice(i, j)*1, j, line ] },
|
return [ str.slice(i, j)*1, j, line ] },
|
||||||
// XXX count \\n
|
// XXX TEST count \\n
|
||||||
string: function(state, path, match, str, i, line){
|
string: function(state, path, match, str, i, line){
|
||||||
var j = i+1
|
var j = i+1
|
||||||
while(j < str.length
|
while(j < str.length
|
||||||
&& str[j] != match){
|
&& str[j] != match){
|
||||||
|
// newlines...
|
||||||
if(str[j] == '\n'){
|
if(str[j] == '\n'){
|
||||||
line++ }
|
line++ }
|
||||||
|
// escaped newlines...
|
||||||
|
if(str[j] == '\\'
|
||||||
|
&& j+1 < str.length
|
||||||
|
&& str[j+1] == 'n'){
|
||||||
|
line++ }
|
||||||
// skip escaped quotes...
|
// skip escaped quotes...
|
||||||
if(str[j] == '\\'
|
if(str[j] == '\\'
|
||||||
&& j+1 < str.length
|
&& j+1 < str.length
|
||||||
@ -243,8 +251,6 @@ module.eJSON = {
|
|||||||
j++ }
|
j++ }
|
||||||
return [ str.slice(i, j), j, line ] },
|
return [ str.slice(i, j), j, line ] },
|
||||||
|
|
||||||
// XXX method or func???
|
|
||||||
// XXX interface???
|
|
||||||
//
|
//
|
||||||
// handler(res, index, str, i, line)
|
// handler(res, index, str, i, line)
|
||||||
// -> [res, i, line]
|
// -> [res, i, line]
|
||||||
@ -375,6 +381,7 @@ module.eJSON = {
|
|||||||
// XXX another strategy would be to have an path-object map and
|
// XXX another strategy would be to have an path-object map and
|
||||||
// directly reference that -- this would eliminate the need for
|
// directly reference that -- this would eliminate the need for
|
||||||
// stage two... (XXX TEST)
|
// stage two... (XXX TEST)
|
||||||
|
// ...need to use serialized paths as keys...
|
||||||
recursive: function(state, path, match, str, i, line){
|
recursive: function(state, path, match, str, i, line){
|
||||||
return this.sequence(
|
return this.sequence(
|
||||||
state, path, str, i+match.length, line,
|
state, path, str, i+match.length, line,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user