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.
@alizeait/unflatto
Advanced tools
A tiny (~210B) and fast flattened object expander, unflattener
A tiny (~210B) and fast flattened object expander, unflattener
Takes an already flattened object and returns a new nested object by expanding the keys.
It assumes the keys are seperated by a .
by default but this can be changed to anything with the seperator option.
$ npm install @alizeait/unflatto
import { unflatto } from "@alizeait/unflatto";
const unflattened = unflatto(
{
"key1.keyA": "valueI",
"key2.keyB": "valueII",
"key3.a.b.c": 2,
"key4": [],
"key5.a.0": "value1",
"key5.a.1": "value2",
"key5.a.2.key1.keyA": "valueI",
"key5.a.2.key1.keyB.0": 1,
"key5.a.2.key1.keyB.1": 2,
"key5.a.2.key1.keyB.2": 3,
"key5.a.2.key1.keyB.3": 4,
"key5.b": null,
"key5.c": undefined,
"key6": {}
}
/*
{
key1: {
keyA: "valueI",
},
key2: {
keyB: "valueII",
},
key3: { a: { b: { c: 2 } } },
key4: [],
key5: {
a: [
"value1",
"value2",
{
key1: {
keyA: "valueI",
keyB: [1, 2, 3, 4],
},
},
],
b: null,
c: undefined,
},
key6: {},
});
*/
const unflattoCustom = unflatto({
"key1-keyA": "valueI",
"key2-keyB": "valueII",
"key3-a-b-c": 2,
},"-");
/*
{
key1: {
keyA: "valueI",
},
key2: {
keyB: "valueII",
},
key3: { a: { b: { c: 2 } } },
}
*/
Benchmarks:
flat.unflatten x 63,827 ops/sec ±0.95% (89 runs sampled)
@alizeait/unflatto x 208,279 ops/sec ±0.84% (93 runs sampled)
obj-unflatten x 168,569 ops/sec ±0.68% (92 runs sampled)
Running on Node.js v12.13.0, 64-bit OS, Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz, 16.0 GB RAM
Validation:
flat.unflatten ✔
@alizeait/unflatto ✔
obj-unflatten ✘
Wrongly expands arrays
Returns: Object
| Array
Returns a new expanded object/array.
FAQs
A tiny (~210B) and fast flattened object expander, unflattener
We found that @alizeait/unflatto 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.