Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

recursive-change-key-case

jonathanwoahn15MIT1.0.1

Convert object keys to any other case, such as camelCase, snake_case, etc.

map, obj, object, key, keys, value, values, val, camelCase, snakecase, camelcase, snake_case, camel, case, snake, deep, resurse, recursive

readme

Description

Utility used to change the case of keys in an object to any other case. Performs a deep modification of the original object, changing the keys of all nested objects, arrays, and objects within arrays

Install

npm i change-key-case

Usage

Utilizes the Change Case library


const superHero = {
  hero_name: 'Captain America',
  real_name: 'Steve Rogers'
};

const newKeys = changeKeyCase(superHero, 'camelCase');

/**
 *  newKeys prints out to
 * {
 *    heroName: 'Captain America',
 *    realName: 'Steve Rogers'
 * }
 **/

API

changeKeyCase(object, caseType)

object

An object, array, or even string that you want to convert

caseType

String that represents the final output you want your object keys to be in. You can choose any of the values from the Change Case library

  • camelCase
  • camel
  • constant
  • dot
  • header
  • isLower
  • isUpper
  • lower
  • lcFirst
  • no
  • param
  • pascal
  • path
  • sentence
  • snake
  • swap
  • title
  • upper
  • ucFirst