# flat-the-object

> Convert the Object into flatten object

Latest version **1.0.2** (published 2022-09-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install flat-the-object
pnpm add flat-the-object
yarn add flat-the-object
bun add flat-the-object
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-09-08 |
| First published | 2022-09-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | archanparmar |
| Maintainers | archanparmar |
| Keywords | flat, flattenobject, convert, convertobject |

## Links

- npm: https://www.npmjs.com/package/flat-the-object
- Repository: https://github.com/Archan26/flat-the-object
- Homepage: https://github.com/Archan26/flat-the-object#readme
- Issues: https://github.com/Archan26/flat-the-object/issues
- npm.io page: https://npm.io/package/flat-the-object

## Recent versions

- 1.0.2 (latest) — 2022-09-08
- 1.0.1 — 2022-09-06
- 1.0.0 — 2022-09-06

## README

## Flat the object 
#### The purpose of the package is to convert the nested object into faltten object


### Installation
```js
$ npm install flat-the-object
```

### Example
This is the practical example of how to use 
```js
const getFlattenObject = require('flat-the-object')

const user = {
    name: "Your Name",
    address: {
        personal: {
            city: "NY",
            state: "WX",
            coordinates: {
                x: 35.12,
                y: -21.49,
            },
        },
    },
    contact: {
        phone: {
            home: "xxx",
            office: "yyy",
        },
        email: {
            home: "xxx",
            office: "yyy"
        },
    },
};

//convert the object by passing the object in the function
//there are 2 parameters 
//1. the actual object
//2. give the name and object key will start with that name

console.log(getFlattenObject(user, "data"));

// result will be like this:
// {
//   data_name: 'Your Name',
//   data_address_personal_city: 'NY',
//   data_address_personal_state: 'WX',
//   data_address_personal_coordinates_x: 35.12,
//   data_address_personal_coordinates_y: -21.49,
//   data_contact_phone_home: 'xxx',
//   data_contact_phone_office: 'yyy',
//   data_contact_email_home: 'xxx',
//   data_contact_email_office: 'yyy'
// }
```

---
_Source: https://npm.io/package/flat-the-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
