maxime-deleniti-soluta

![npm version](https://img.shields.io/npm/v/@firanorg/maxime-deleniti-soluta.svg?style=flat) ![Code Size](https://img.shields.io/github/languages/code-size/emranffl/@firanorg/maxime-deleniti-soluta) ![GitHub license](https://img.shields.io/github/license/

MIT License

Downloads
2.2K
Stars
0
Committers
1

@firanorg/maxime-deleniti-soluta

Table of Contents

Getting Started

deepObjectKeyAlternator is a versatile utility function that allows you to recursively parse an object or array of objects, applying a key mapping to rename object keys. It's particularly handy when you need to transform the structure of nested objects while preserving the original data.

Installation

You can install @firanorg/maxime-deleniti-soluta using npm:

npm install @firanorg/maxime-deleniti-soluta

or yarn:

yarn add @firanorg/maxime-deleniti-soluta

or pnpm:

pnpm add @firanorg/maxime-deleniti-soluta

Features

  • Recursively parses nested objects.
  • Customizable key mapping with intellisense support.
  • Supports arrays (without intellisense support).
  • Preserves the structure of arrays.

Usage

Here's how you can use deepObjectKeyAlternator in your projects:

ECMAScript Modules (ESM) Import

import { deepObjectKeyAlternator } from "@firanorg/maxime-deleniti-soluta"

CommonJS (CJS) Import

const { deepObjectKeyAlternator } = require("@firanorg/maxime-deleniti-soluta")

Examples

For Objects (with intellisense support)

import { deepObjectKeyAlternator } from "@firanorg/maxime-deleniti-soluta"
// or const { deepObjectKeyAlternator } = require("@firanorg/maxime-deleniti-soluta")

// Define your input object
const inputObject = {
  id: 95,
  name: "Your Input Data",
  // ... Your input data ...
}

// Use deepObjectKeyAlternator to parse the object
const parsedObject = deepObjectKeyAlternator(inputObject, {
  id: "customId",
  name: "customName",
  // ... Your key mapping ...
})

console.log(parsedObject)
// {
//   customId: 95,
//   customName: 'Your Input Data',
//   // ... Your input data ...
// }

For Arrays (without intellisense support)

import { deepObjectKeyAlternator } from "@firanorg/maxime-deleniti-soluta"
// or const { deepObjectKeyAlternator } = require("@firanorg/maxime-deleniti-soluta");

// Define an array of objects
const inputArray = [
  {
    id: 1,
    name: "Item 1",
  },
  {
    id: 2,
    name: "Item 2",
  },
  // ... More items ...
]

// Use deepObjectKeyAlternator to parse the array of objects
const parsedArray = inputArray.map((item) => {
  return deepObjectKeyAlternator(item, {
    id: "customId",
    name: "customName",
    // ... Your key mapping ...
  })
})

console.log(parsedArray)
// [
//   {
//     customId: 1,
//     customName: 'Item 1',
//     // ... Your input data ...
//   },
//   {
//     customId: 2,
//     customName: 'Item 2',
//     // ... Your input data ...
//   },
//   // ... More items ...
// ]

License

This package is licensed under the MIT License - see the LICENSE file for details.

Package Rankings
Top 36.49% on Npmjs.org
Badges
Extracted from project README
Commitizen friendly npm downloads
Related Projects