Socket
Socket
Sign inDemoInstall

snakecase-keys

Package Overview
Dependencies
7
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    snakecase-keys

Convert an object's keys to snake case


Version published
Weekly downloads
527K
decreased by-0.18%
Maintainers
1
Install size
514 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 09 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc