nv-stringify-without-circular-check-and-without-buffer-ref
v1.0.1
Published
nv-stringify-without-circular-check-and-without-buffer-ref ========================================================== - similiar to jsesc - simple AND more readable version of nv-buf-data-to-code - NOT support circular-reference, NOT support buf-referen
Downloads
3
Readme
nv-stringify-without-circular-check-and-without-buffer-ref
- similiar to jsesc
- simple AND more readable version of nv-buf-data-to-code
- NOT support circular-reference, NOT support buf-reference
install
- npm install nv-stringify-without-circular-check-and-without-buffer-ref
splitted
usage
const x = require("nv-stringify-without-circular-check-and-without-buffer-ref");
example
0
var ab = new ArrayBuffer(32);
var u8a = new Uint8Array(ab);
u8a.set([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,333,555])
var mp = new Map([
["ary",[1,2,3,{
"k0": [88,99,1010],
"k1": "sssss",
"k2": new Set([{a:111,b:222},null,undefined,true,false])
}]],
["nest",new Set([
Symbol("lcl-sym"),
Symbol.for("gsym"),
new Date(),
/[0-9]+/g,
new AggregateError(["other",{cause:[1,2,{},4,5]}])
])],
["int",1],
["double",1.1],
["abvw",{
u8a,
u8ca: new Uint8ClampedArray(ab),
u16a:new Uint16Array(ab),
u32a:new Uint32Array(ab),
u64a:new BigUint64Array(ab),
i8a:new Int8Array(ab),
i16a:new Int16Array(ab),
i32a:new Int32Array(ab),
i64a:new BigInt64Array(ab),
f32a: new Float32Array(ab),
f64a: new Float64Array(ab)
}]
]);
console.log(x(mp))
/*
new Map(
[
[
"ary",
[
1,
2,
3,
{
"k0":[
88,
99,
1010
],
"k1":"sssss",
"k2":new Set(
[
{
"a":111,
"b":222
},
null,
undefined,
true,
false
]
)
}
]
],
[
"nest",
new Set(
[
Symbol("lcl-sym"),
Symbol.for("gsym"),
(new Date(1715428306599)),
(new RegExp("[0-9]+","g")),
(()=>{
var ___agg_err = new AggregateError(
[
"other",
{
"cause":[
1,
2,
{},
4,
5
]
}
]
);
___agg_err.stack = "AggregateError\n at REPL76:12:5\n at ContextifyScript.runInThisContext (node:vm:136:12)\n at REPLServer.defaultEval (node:repl:598:22)\n at bound (node:domain:432:15)\n at REPLServer.runBound [as eval] (node:domain:443:12)\n at REPLServer.onLine (node:repl:927:10)\n at REPLServer.emit (node:events:531:35)\n at REPLServer.emit (node:domain:488:12)\n at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)\n at [_line] [as _line] (node:internal/readline/interface:887:18)";
return(___agg_err);
})()
]
)
],
[
"int",
1
],
[
"double",
1.1
],
[
"abvw",
{
"u8a":(new Uint8Array([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,77,43])),
"u8ca":(new Uint8ClampedArray([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,77,43])),
"u16a":(new Uint16Array([2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,11085])),
"u32a":(new Uint32Array([555092736,1296185132,184574808,925638934,1666731330,555092736,1296185132,726491992])),
"u64a":(new BigUint64Array([5567072752056535808n,3975588949618877272n,2384105149033893186n,3120259347742078764n])),
"i8a":(new Int8Array([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,77,43])),
"i16a":(new Int16Array([2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,11085])),
"i32a":(new Uint32Array([555092736,1296185132,184574808,925638934,1666731330,555092736,1296185132,726491992])),
"i64a":(new BigInt64Array([5567072752056535808n,3975588949618877272n,2384105149033893186n,3120259347742078764n])),
"f32a":(new Float32Array([5.083653521403895e-19,203649728,2.47266412189819e-32,0.000010259702321491204,3.9900637320106465e+21,5.083653521403895e-19,203649728,7.296849756366353e-13])),
"f64a":(new Float64Array([1.4986858208249942e+64,6.306794313078433e-43,2.69359539533677e-149,4.1987736298680986e-100]))
}
]
]
)
*/
/*
Map(5) {
'ary' => [ 1, 2, 3, { k0: [Array], k1: 'sssss', k2: [Set] } ],
'nest' => Set(5) {
Symbol(lcl-sym),
Symbol(gsym),
2024-05-11T11:51:46.599Z,
/[0-9]+/g,
AggregateError
at REPL76:12:5
at ContextifyScript.runInThisContext (node:vm:136:12)
at REPLServer.defaultEval (node:repl:598:22)
at bound (node:domain:432:15)
at REPLServer.runBound [as eval] (node:domain:443:12)
at REPLServer.onLine (node:repl:927:10)
at REPLServer.emit (node:events:531:35)
at REPLServer.emit (node:domain:488:12)
at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
at [_line] [as _line] (node:internal/readline/interface:887:18) {
[errors]: [Array]
}
},
'int' => 1,
'double' => 1.1,
'abvw' => {
u8a: Uint8Array(32) [
0, 11, 22, 33, 44, 55, 66, 77, 88,
99, 0, 11, 22, 33, 44, 55, 66, 77,
88, 99, 0, 11, 22, 33, 44, 55, 66,
77, 88, 99, 77, 43
],
u8ca: Uint8ClampedArray(32) [
0, 11, 22, 33, 44, 55, 66, 77, 88,
99, 0, 11, 22, 33, 44, 55, 66, 77,
88, 99, 0, 11, 22, 33, 44, 55, 66,
77, 88, 99, 77, 43
],
u16a: Uint16Array(16) [
2816, 8470, 14124,
19778, 25432, 2816,
8470, 14124, 19778,
25432, 2816, 8470,
14124, 19778, 25432,
11085
],
u32a: Uint32Array(8) [
555092736, 1296185132,
184574808, 925638934,
1666731330, 555092736,
1296185132, 726491992
],
u64a: BigUint64Array(4) [
5567072752056535808n,
3975588949618877272n,
2384105149033893186n,
3120259347742078764n
],
i8a: Int8Array(32) [
0, 11, 22, 33, 44, 55, 66, 77, 88,
99, 0, 11, 22, 33, 44, 55, 66, 77,
88, 99, 0, 11, 22, 33, 44, 55, 66,
77, 88, 99, 77, 43
],
i16a: Int16Array(16) [
2816, 8470, 14124,
19778, 25432, 2816,
8470, 14124, 19778,
25432, 2816, 8470,
14124, 19778, 25432,
11085
],
i32a: Uint32Array(8) [
555092736, 1296185132,
184574808, 925638934,
1666731330, 555092736,
1296185132, 726491992
],
i64a: BigInt64Array(4) [
5567072752056535808n,
3975588949618877272n,
2384105149033893186n,
3120259347742078764n
],
f32a: Float32Array(8) [
5.083653521403895e-19,
203649728,
2.47266412189819e-32,
0.000010259702321491204,
3.9900637320106465e+21,
5.083653521403895e-19,
203649728,
7.296849756366353e-13
],
f64a: Float64Array(4) [
1.4986858208249942e+64,
6.306794313078433e-43,
2.69359539533677e-149,
4.1987736298680986e-100
]
}
}
*/
1
var a = [1,2,3]
a.x ="xxxx"
a.y="yyyy"
a.d= {
"k0": [88,99,1010],
"k1": "sssss",
"k2": new Set([{a:111,b:222},null,undefined,true,false])
}
var ab = new ArrayBuffer(32);
var u8a = new Uint8Array(ab);
u8a.set([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,333,555])
var mp = new Map([
["nest",a],
["int",1],
["double",1.1],
["abvw",{
u8a,
u8ca: new Uint8ClampedArray(ab),
u16a:new Uint16Array(ab),
u32a:new Uint32Array(ab),
u64a:new BigUint64Array(ab),
i8a:new Int8Array(ab),
i16a:new Int16Array(ab),
i32a:new Int32Array(ab),
i64a:new BigInt64Array(ab),
f32a: new Float32Array(ab),
f64a: new Float64Array(ab)
}]
]);
mp.agg_errs = new AggregateError([
new Error("other",{cause:[1,2,3,4,5]})
]);
mp.gsym = Symbol.for("gsym-agg-errs");
console.log(x(mp))
/*
(()=>{
var ___mp = new Map(
[
[
"nest",
(()=>{
var ___a = [
1,
2,
3
];
___a["x"] = "xxxx";
___a["y"] = "yyyy";
___a["d"] = {
"k0":[
88,
99,
1010
],
"k1":"sssss",
"k2":new Set(
[
{
"a":111,
"b":222
},
null,
undefined,
true,
false
]
)
};
return(___a);
})()
],
[
"int",
1
],
[
"double",
1.1
],
[
"abvw",
{
"u8a":(new Uint8Array([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,77,43])),
"u8ca":(new Uint8ClampedArray([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,77,43])),
"u16a":(new Uint16Array([2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,11085])),
"u32a":(new Uint32Array([555092736,1296185132,184574808,925638934,1666731330,555092736,1296185132,726491992])),
"u64a":(new BigUint64Array([5567072752056535808n,3975588949618877272n,2384105149033893186n,3120259347742078764n])),
"i8a":(new Int8Array([0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,0,11,22,33,44,55,66,77,88,99,77,43])),
"i16a":(new Int16Array([2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,2816,8470,14124,19778,25432,11085])),
"i32a":(new Uint32Array([555092736,1296185132,184574808,925638934,1666731330,555092736,1296185132,726491992])),
"i64a":(new BigInt64Array([5567072752056535808n,3975588949618877272n,2384105149033893186n,3120259347742078764n])),
"f32a":(new Float32Array([5.083653521403895e-19,203649728,2.47266412189819e-32,0.000010259702321491204,3.9900637320106465e+21,5.083653521403895e-19,203649728,7.296849756366353e-13])),
"f64a":(new Float64Array([1.4986858208249942e+64,6.306794313078433e-43,2.69359539533677e-149,4.1987736298680986e-100]))
}
]
]
);
___mp["agg_errs"] = (()=>{
var ___agg_err = new AggregateError(
[
(()=>{
var ___other_err = new Error(
"other",
{
"cause":[
1,
2,
3,
4,
5
]
}
);
___other_err.stack = "Error: other\n at REPL38:2:2\n at ContextifyScript.runInThisContext (node:vm:136:12)\n at REPLServer.defaultEval (node:repl:598:22)\n at bound (node:domain:432:15)\n at REPLServer.runBound [as eval] (node:domain:443:12)\n at REPLServer.onLine (node:repl:927:10)\n at REPLServer.emit (node:events:531:35)\n at REPLServer.emit (node:domain:488:12)\n at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)\n at [_line] [as _line] (node:internal/readline/interface:887:18)";
return(___other_err);
})()
]
);
___agg_err.stack = "AggregateError\n at REPL38:1:15\n at ContextifyScript.runInThisContext (node:vm:136:12)\n at REPLServer.defaultEval (node:repl:598:22)\n at bound (node:domain:432:15)\n at REPLServer.runBound [as eval] (node:domain:443:12)\n at REPLServer.onLine (node:repl:927:10)\n at REPLServer.emit (node:events:531:35)\n at REPLServer.emit (node:domain:488:12)\n at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)\n at [_line] [as _line] (node:internal/readline/interface:887:18)";
return(___agg_err);
})();
___mp["gsym"] = Symbol.for("gsym-agg-errs");
return(___${tname});
})()
*/
METHODS
APIS
LICENSE
- ISC