Gathering detailed insights and metrics for seroval-plugins
Gathering detailed insights and metrics for seroval-plugins
Gathering detailed insights and metrics for seroval-plugins
Gathering detailed insights and metrics for seroval-plugins
npm install seroval-plugins
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
83.6
Quality
81.5
Maintenance
100
Vulnerability
100
License
TypeScript (95.61%)
HTML (3.95%)
JavaScript (0.43%)
Total Downloads
7,450,232
Last Day
10,279
Last Week
119,902
Last Month
689,906
Last Year
7,449,028
535 Stars
843 Commits
7 Forks
5 Watching
3 Branches
3 Contributors
Latest Version
1.1.1
Package Id
seroval-plugins@1.1.1
Unpacked Size
152.56 kB
Size
24.21 kB
File Count
51
NPM Version
lerna/8.1.6/node@v20.11.1+arm64 (darwin)
Node Version
20.11.1
Publised On
30 Jul 2024
Cumulative downloads
Total Downloads
Last day
-68%
10,279
Compared to previous day
Last week
-34.4%
119,902
Compared to previous week
Last month
1.8%
689,906
Compared to previous month
Last year
618,590%
7,449,028
Compared to previous year
1
7
Stringify JS values
1npm install --save seroval
1yarn add seroval
1pnpm add seroval
1import { serialize } from 'seroval'; 2 3const object = { 4 number: [Math.random(), -0, NaN, Infinity, -Infinity], 5 string: ['hello world', '<script>Hello World</script>'], 6 boolean: [true, false], 7 null: null, 8 undefined: undefined, 9 bigint: 9007199254740991n, 10 array: [,,,], // holes 11 regexp: /[a-z0-9]+/i, 12 date: new Date(), 13 map: new Map([['hello', 'world']]), 14 set: new Set(['hello', 'world']), 15}; 16 17// self cyclic references 18// recursive objects 19object.self = object; 20// recursive arrays 21object.array.push(object.array); 22// recursive maps 23object.map.set('self', object.map); 24// recursive sets 25object.set.add(object.set); 26 27// mutual cyclic references 28object.array.push(object.map); 29object.map.set('mutual', object.set); 30object.set.add(object.array); 31 32const result = serialize(object); 33console.log(result);
Output (as a string):
1((h,j,k,m,o)=>(o={number:[0.5337763749243287,-0,0/0,1/0,-1/0],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:9007199254740991n,array:h=[,,,,k=(j=[],new Map([["hello","world"],["mutual",m=new Set(["hello","world"])]]))],regexp:/[a-z0-9]+/i,date:new Date("2023-12-07T17:28:57.909Z"),map:k,set:m},h[3]=h,k.set("self",k),m.add(m).add(h),o.self=o,o))() 2 3// Formatted for readability 4((h, j, k, m, o) => ( 5 (o = { 6 number: [0.5337763749243287, -0, 0 / 0, 1 / 0, -1 / 0], 7 string: ["hello world", "\x3Cscript>Hello World\x3C/script>"], 8 boolean: [!0, !1], 9 null: null, 10 undefined: void 0, 11 bigint: 9007199254740991n, 12 array: (h = [ 13 , 14 , 15 , 16 , 17 (k = 18 ((j = []), 19 new Map([ 20 ["hello", "world"], 21 ["mutual", (m = new Set(["hello", "world"]))], 22 ]))), 23 ]), 24 regexp: /[a-z0-9]+/i, 25 date: new Date("2023-12-07T17:28:57.909Z"), 26 map: k, 27 set: m, 28 }), 29 (h[3] = h), 30 k.set("self", k), 31 m.add(m).add(h), 32 (o.self = o), 33 o 34))();
MIT © lxsmnsyc
No vulnerabilities found.
No security vulnerabilities found.