1. snakecase-keys
Convert an object's keys to snake case
snakecase-keys
Package: snakecase-keys
Created by: bendrucker
Last modified: Tue, 09 Apr 2024 21:58:39 GMT
Version: 8.0.0
License: MIT
Downloads: 2,146,746
Repository: https://github.com/bendrucker/snakecase-keys

Install

npm install snakecase-keys
yarn add snakecase-keys

snakecase-keys tests

Convert an object's keys to snake case

Install

$ npm install --save snakecase-keys

Usage

 var snakecaseKeys = require('snakecase-keys')

snakecaseKeys({fooBar: 'baz'})
//=> {foo_bar: 'baz'}

snakecaseKeys({'foo-bar': true, nested: {fooBaz: 'bar'}});
//=> {foo_bar: true, nested: {foo_baz: 'bar'}}

API

snakecaseKeys(obj, options) -> object

obj

Required
Type: object | array[object]

A plain object or array of plain objects to transform into snake case (keys only).

options

Optional
Type: object

deep

Type: boolean
Default: true

Enables snake-casing of keys in nested objects.

exclude

Type: array[string || regexp]
Default: []

An array of strings or regular expressions matching keys that will be excluded from snake-casing.

shouldRecurse(key, val) -> boolean

Optional
Type: function

A function that determines if val should be recursed.

Requires deep: true.

License

MIT © Ben Drucker

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin