Gathering detailed insights and metrics for flatley
Gathering detailed insights and metrics for flatley
Gathering detailed insights and metrics for flatley
Gathering detailed insights and metrics for flatley
signalk-scheduler-sherri-flatley
<h1 align="center">Welcome to Jass World 👋 </h1>
jojs-carole-flatley
<h1 align="center">Welcome to Jass World 👋 </h1>
cron-carol-flatley
<h1 align="center">Welcome to Jass World 👋 </h1>
stitch-eric-flatley
<h1 align="center">Welcome to Jass World 👋 </h1>
npm install flatley
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
BSD-3-Clause License
10 Stars
90 Commits
2 Watchers
2 Branches
1 Contributors
Updated on Jun 25, 2025
Latest Version
5.2.0
Package Id
flatley@5.2.0
Unpacked Size
24.87 kB
Size
6.14 kB
File Count
6
NPM Version
5.6.0
Node Version
9.5.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Take a nested Javascript object and flatten it, or unflatten an object with delimited keys.
Based on 'flat' by Hugh Kennedy (http://hughskennedy.com)
1$ npm install flatley
Flattens the object - it'll return an object one level deep, regardless of how nested the original object was:
1var flatten = require('flatley') 2 3flatten({ 4 key1: { 5 keyA: 'valueI' 6 }, 7 key2: { 8 keyB: 'valueII' 9 }, 10 key3: { a: { b: { c: 2 } } } 11}) 12 13// { 14// 'key1.keyA': 'valueI', 15// 'key2.keyB': 'valueII', 16// 'key3.a.b.c': 2 17// }
Flattening is reversible too, you can call flatten.unflatten()
on an object:
1var unflatten = require('flatley').unflatten 2 3unflatten({ 4 'three.levels.deep': 42, 5 'three.levels': { 6 nested: true 7 } 8}) 9 10// { 11// three: { 12// levels: { 13// deep: 42, 14// nested: true 15// } 16// } 17// }
Use a custom delimiter for (un)flattening your objects, instead of .
.
When enabled, both flat
and unflatten
will preserve arrays and their
contents. This is disabled by default.
1var flatten = require('flatley') 2 3flatten({ 4 this: [ 5 { contains: 'arrays' }, 6 { preserving: { 7 them: 'for you' 8 }} 9 ] 10}, { 11 safe: true 12}) 13 14// { 15// 'this': [ 16// { contains: 'arrays' }, 17// { preserving: { 18// them: 'for you' 19// }} 20// ] 21// }
When enabled, arrays will not be created automatically when calling unflatten, like so:
1unflatten({ 2 'hello.you.0': 'ipsum', 3 'hello.you.1': 'lorem', 4 'hello.other.world': 'foo' 5}, { object: true }) 6 7// hello: { 8// you: { 9// 0: 'ipsum', 10// 1: 'lorem', 11// }, 12// other: { world: 'foo' } 13// }
When enabled, existing keys in the unflattened object may be overwritten if they cannot hold a newly encountered nested value:
1unflatten({ 2 'TRAVIS': 'true', 3 'TRAVIS_DIR': '/home/travis/build/kvz/environmental' 4}, { overwrite: true }) 5 6// TRAVIS: { 7// DIR: '/home/travis/build/kvz/environmental' 8// }
Without overwrite
set to true
, the TRAVIS
key would already have been set to a string, thus could not accept the nested DIR
element.
This only makes sense on ordered arrays, and since we're overwriting data, should be used with care.
Maximum number of nested objects to flatten.
1var flatten = require('flatley') 2 3flatten({ 4 key1: { 5 keyA: 'valueI' 6 }, 7 key2: { 8 keyB: 'valueII' 9 }, 10 key3: { a: { b: { c: 2 } } } 11}, { maxDepth: 2 }) 12 13// { 14// 'key1.keyA': 'valueI', 15// 'key2.keyB': 'valueII', 16// 'key3.a': { b: { c: 2 } } 17// }
Optionally run a test/set of tests on your incoming key/value(s) and transform the resulting value if it matches.
This is particularly useful in the case of transforming https://www.npmjs.com/package/mongoose ObjectIds
1var ObjectId = mongoose.Types.ObjectId 2 3var coercion = [{ 4 test: function (key, value) { return key === '_id' && ObjectId.isValid(value) } 5 transform: function (value) { return value.valueOf() } 6}] 7var options = { coercion: coercion } 8 9flatten({ 10 group1: { 11 prop1: ObjectId('aaabbbcccdddeee') 12 } 13}, options) 14 15// { 16// 'group1.prop1': 'aaabbbcccdddeee' 17// }
Optionally run a test/set of tests on your incoming key/value(s) and don't transform this key's children if it matches.
1 2const someObject = { 3 prop1: 'abc', 4 prop2: 'def' 5} 6 7var filters = [{ 8 test: function (key, value) { return value.prop1 === 'abc' } 9}] 10var options = { filters: filters } 11 12flatten({ 13 group1: { 14 someObject: someObject 15 } 16}, options) 17 18// { 19// 'group1.someObject': { 20// 'prop1': 'abc', 21// 'prop2': 'def' 22// } 23// }
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More