![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
flattie
Advanced tools
Readme
A tiny (187B) and fast utility to flatten an object with customizable glue
This module recursively squashes an Object/Array. The output is a flat object – AKA, it has a single level of depth.
By default, the .
character is used to glue/join layers' keys together. This is customizable.
Finally, any keys with nullish values (null
and undefined
) are not included in the return object.
$ npm install --save flattie
import { flattie } from 'flattie';
flattie({
a: 'hi',
b: {
a: null,
b: ['foo', '', null, 'bar'],
d: 'hello',
e: {
a: 'yo',
b: undefined,
c: 'sup',
d: 0,
f: [
{ foo: 123, bar: 123 },
{ foo: 465, bar: 456 },
]
}
},
c: 'world'
});
// {
// 'a': 'hi',
// 'b.b.0': 'foo',
// 'b.b.1': '',
// 'b.b.3': 'bar',
// 'b.d': 'hello',
// 'b.e.a': 'yo',
// 'b.e.c': 'sup',
// 'b.e.d': 0,
// 'b.e.f.0.foo': 123,
// 'b.e.f.0.bar': 123,
// 'b.e.f.1.foo': 465,
// 'b.e.f.1.bar': 456,
// 'c': 'world'
// }
Note:
null
andundefined
values are purged.
Returns: Object
Returns a new object with a single level of depth.
Important: An object is always returned despite
input
type.
Type: Object|Array
The object to flatten.
Type: String
Default: .
A string used to join parent key names to nested child key names.
const foo = { bar: 123 };
flattie({ foo }); //=> { 'foo.bar': 123 }
flattie({ foo }, '???'); //=> { 'foo???bar': 123 }
Running on Node.js v10.13.0
Load Time:
flat 1.004ms
flatten-object 1.223ms
flat-obj 0.971ms
flattie 0.239ms
Validation:
✔ flat
✔ flatten-object
✔ flat-obj
✔ flattie
Benchmark:
flat x 183,670 ops/sec ±1.30% (86 runs sampled)
flatten-object x 209,886 ops/sec ±0.32% (93 runs sampled)
flat-obj x 383,326 ops/sec ±1.65% (89 runs sampled)
flattie x 901,407 ops/sec ±0.72% (90 runs sampled)
MIT © Luke Edwards
FAQs
A tiny (203B) and fast utility to flatten an object with customizable glue
The npm package flattie receives a total of 209,117 weekly downloads. As such, flattie popularity was classified as popular.
We found that flattie demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.