Gathering detailed insights and metrics for @saoviettest/repudiandae-commodi-rerum-quasi
Gathering detailed insights and metrics for @saoviettest/repudiandae-commodi-rerum-quasi
npm install @saoviettest/repudiandae-commodi-rerum-quasi
Typescript
Module System
Node Version
NPM Version
67.8
Supply Chain
94.7
Quality
75.9
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-50%
1
Compared to previous week
Last month
400%
5
Compared to previous month
Last year
0%
96
Compared to previous year
Safely flatten a nested JavaScript object.
1$ npm i @saoviettest/repudiandae-commodi-rerum-quasi
Flattens an object to one level deep. Optionally takes a custom delimiter
, otherwise uses .
by default. Circular references within the object will be replaced with [Circular]
.
1const { flatten } = require('@saoviettest/repudiandae-commodi-rerum-quasi') 2 3const original = { 4 a: { 5 b: { 6 c: [{ 7 val: 'one' 8 }, { 9 val: 'two' 10 }], 11 d: 'three' 12 }, 13 e: 'four', 14 } 15} 16original.a.b.f = original.a.b 17original.a.b.c.push(original.a) 18 19const flat = flatten(original) 20/* 21{ 22 'a.b.c.0.val': 'one', 23 'a.b.c.1.val': 'two', 24 'a.b.c.2': '[Circular]', 25 'a.b.d': 'three', 26 'a.e': 'four', 27 'a.b.f': '[Circular]' 28} 29*/ 30 31const underscoreFlat = flatten(original, '_') 32/* 33{ 34 'a_b_c_0_val': 'one', 35 'a_b_c_1_val': 'two', 36 'a_b_c_2': '[Circular]', 37 'a_b_d': 'three', 38 'a_e': 'four', 39 'a_b_f': '[Circular]' 40} 41*/
Unflattens an object back to its original nested form. Optionally takes a custom delimiter
, otherwise uses .
by default. Circular references denoted by [Circular]
are treated as Strings.
1const { unflatten } = require('@saoviettest/repudiandae-commodi-rerum-quasi') 2 3const original = { 4 'a.b.c.0.val': 'one', 5 'a.b.c.1.val': 'two', 6 'a.b.c.2': '[Circular]', 7 'a.b.d': 'three', 8 'a.e': 'four', 9 'a.b.f': '[Circular]' 10} 11 12 13const unflat = unflatten(original) 14 15/*{ 16 a:{ 17 b:{ 18 c:[ 19 { 20 val:'one' 21 }, 22 { 23 val:'two' 24 }, 25 '[Circular]' 26 ], 27 d:'three', 28 f:'[Circular]' 29 }, 30 e:'four' 31 } 32}*/
No vulnerabilities found.
No security vulnerabilities found.