1.0.0 • Published 6 years ago

@cocopina/transform-keys v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

transform-keys npm.io

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:

OptionTypeWhat It DoesDefault
deepBooleanWhether or not to transform the object's keys recursivelytrue
recursionLevelNumberHow deep should the transformation go-