Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
flatulence
Advanced tools
Flatten objects and arrays so that each key is the full path to a primitive value. Paths are lodash-compatible. Inflate flattened objects and make them regular JS objects again.
Flatten objects and arrays into non-nested objects and arrays. A flattened object consists of key paths pointing to primitive values. Paths are lodash-compatible so they can be used with _.set() and _.get().
Unflatten flattened objects and make them regular, nested JS objects again.
const flatulence = require('flatulence')
// Create a flat object
const flattened = flatulence.flatten({
a: 1,
b: {
c: 1,
d: [1,2,3]
}
})
// {
// a: 1,
// 'b.c': 1,
// 'b.d[0]': 1,
// 'b.d[1]': 2,
// 'b.d[2]': 3
// }
// Optionally you can decide to keep empty arrays and objects
const flattened = fl.flatten.keepEmpty({
"name": "Mega Group 2",
"loginId": "admin_mega_merchant_2",
"description": "again, some description here",
"merchantUsers": [],
"map": {}
})
//
// {
// name: 'Mega Group 2',
// loginId: 'admin_mega_merchant_2',
// description: 'again, some description here',
// merchantUsers: [],
// map: {}
// }
// Create a flat object and provide a prefix to each key
var flattened2 = flatulence.flatten(
{ a: 1, b: { c: 1, d: [ 1, 2, 3 ] } },
'my.prefix.key'
)
//{
// 'my.prefix.key.a': 1,
// 'my.prefix.key.b.c': 1,
// 'my.prefix.key.b.d[0]': 1,
// 'my.prefix.key.b.d[1]': 2,
// 'my.prefix.key.b.d[2]': 3
//}
const regular = flatulence.unflatten(flattened)
// { a: 1, b: { c: 1, d: [ 1, 2, 3 ] } }
// Only unflatten a sub object
const b = flatulence.unflatten(flattened, 'b')
// { c: 1, d: [ 1, 2, 3 ] }
// Sub objects can even be arrays
const array = flatulence.unflatten(flattened, 'b.d')
// [ 1, 2, 3 ]
FAQs
Flatten objects and arrays so that each key is the full path to a primitive value. Paths are lodash-compatible. Inflate flattened objects and make them regular JS objects again.
The npm package flatulence receives a total of 88 weekly downloads. As such, flatulence popularity was classified as not popular.
We found that flatulence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.