snakecase-keys
Advanced tools
Comparing version 6.0.0 to 7.0.0
@@ -50,10 +50,10 @@ import { SnakeCase } from "type-fest"; | ||
export type SnakeCaseKeys< | ||
T extends ObjectUnion | readonly any[], | ||
T extends ObjectUnion | ReadonlyArray<Record<string, unknown>>, | ||
Deep extends boolean = true, | ||
Exclude extends readonly unknown[] = EmptyTuple, | ||
Path extends string = "" | ||
> = T extends readonly any[] | ||
> = T extends ReadonlyArray<Record<string, unknown>> | ||
? // Handle arrays or tuples. | ||
{ | ||
[P in keyof T]: T[P] extends Record<string, unknown> | readonly any[] | ||
[P in keyof T]: T[P] extends Record<string, unknown> | ReadonlyArray<Record<string, unknown>> | ||
? SnakeCaseKeys<T[P], Deep, Exclude> | ||
@@ -68,3 +68,3 @@ : T[P]; | ||
: SnakeCase<P>]: [Deep] extends [true] | ||
? T[P] extends ObjectUnion | readonly any[] | ||
? T[P] extends ObjectUnion | ReadonlyArray<Record<string, unknown>> | ||
? SnakeCaseKeys<T[P], Deep, Exclude, AppendPath<Path, P & string>> | ||
@@ -111,3 +111,3 @@ : T[P] | ||
declare function snakecaseKeys< | ||
T extends Record<string, unknown> | readonly any[], | ||
T extends Record<string, unknown> | ReadonlyArray<Record<string, unknown>>, | ||
Options extends snakecaseKeys.Options | ||
@@ -114,0 +114,0 @@ >( |
@@ -7,2 +7,5 @@ 'use strict' | ||
module.exports = function (obj, options) { | ||
if (Array.isArray(obj) && obj.some(item => item.constructor !== Object)) { throw new Error('obj must be array of plain objects') } | ||
if (obj.constructor !== Object) throw new Error('obj must be an plain object') | ||
options = Object.assign({ deep: true, exclude: [], parsingOptions: {} }, options) | ||
@@ -9,0 +12,0 @@ |
{ | ||
"name": "snakecase-keys", | ||
"main": "index.js", | ||
"version": "6.0.0", | ||
"version": "7.0.0", | ||
"description": "Convert an object's keys to snake case", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -32,5 +32,5 @@ # snakecase-keys [![tests](https://github.com/bendrucker/snakecase-keys/workflows/tests/badge.svg)](https://github.com/bendrucker/snakecase-keys/actions?query=workflow%3Atests) | ||
*Required* | ||
Type: `object` | ||
Type: `object | array[object]` | ||
An object to transform into snake case (keys only). | ||
A plain object or array of plain objects to transform into snake case (keys only). | ||
@@ -37,0 +37,0 @@ ##### options |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7609
135