An open API service indexing awesome lists of open source software.

https://github.com/lightwithoutlisonlyight/dottify


https://github.com/lightwithoutlisonlyight/dottify

dot dot-notation dot-notation-dict dottify dotty javascript nodejs typescript

Last synced: 10 months ago
JSON representation

Awesome Lists containing this project

README

          

# dottify - The easiest way to flat a object

npm npm bundle size


How to use it ?

```javascript

// Import it
const dottify = require('dottify')

// Example Object
let object = {

a : 1,
b : 'Hello',
c : true,
d : [0,1,2,false,'Dottify'],
e : {
a: {
b : {
c : 'This is an inner value',
d : () => console.log(0)
}
}
},
f : undefined,
g : null

}

// Flat & save it
// The second parameter is optional... the default separator is the dot.
let flatted = dottify(object,'.')

//Print the result
console.log(flatted)

/*

The Output

{
a: 1,
b: 'Hello',
c: true,
'd.0': 0,
'd.1': 1,
'd.2': 2,
'd.3': false,
'd.4': 'Dottify',
'e.a.b.c': 'This is an inner value',
'e.a.b.d': [Function: d],
f: undefined,
g: null
}

*/

```