@cocopina/transform-keys

1.0.0 • Public • Published

transform-keys

Creates a deep clone of a JSON data structure with keys transformed by a provided function.

Table of Contents

Installation

Install the package:

npm i @cocopina/transform-keys

API

transformKeys(object, transform, [options])

Returns a new, transformed object.

import transformKeys from '@cocopina/transform-keys';

const transformFn = (value) => `_${value}`;
const object = {
    key: 1
};
const transformed = transformKeys(object, transformFn);

console.log(transformed); // {_key: 1}

object [Object]

The object which keys' you wish to transform.

transform [Function]

The transformation function you wish to use on the object's keys.

options [Object]

Additional options:

Option Type What It Does Default
deep Boolean Whether or not to transform the object's keys recursively true
recursionLevel Number How deep should the transformation go -

Readme

Keywords

none

Package Sidebar

Install

npm i @cocopina/transform-keys

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

23.9 kB

Total Files

15

Last publish

Collaborators

  • cocopina