Skip to content

sahariko/transform-keys

Repository files navigation

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 -

About

Deeply mutate an object's keys

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published