-
is safe , without eval
-
pure js , zero depends , support broswer and node.js
-
support async and sync
-
supports
- null ,
- undefined ,
- NaN ,
- Infinity ,
- Number ,
- String ,
- RegExp ,
- Date ,
- Error ,
- Array ,
- Buffer ,
- NUMBER64
- Object
-
Default max recu level is 5
console.time('process_sync');
var s1 = serialize( process );
console.timeEnd('process_sync');
//console.log( s1 );
console.time('process_async');
serialize(
process ,
function( err , data )
{
console.timeEnd('process_async');
if ( err )
{
console.log(err);
}
else
{
unserialize(
data ,
function(err2 , data2)
{
if ( err2 )
{
console.log( err2 );
}
else
{
//console.log( JSON.stringify( data2 , null , '\t') );
}
}
);
}
}
);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> test serialize.js </title>
<script src="serialize.js"></script>
<script>
console.log( serialize(window) );
</script>
</head>
</html>