camelcase-keys
Advanced tools
Comparing version 8.0.2 to 9.0.0
@@ -1,2 +0,2 @@ | ||
import {CamelCase, PascalCase} from 'type-fest'; | ||
import type {CamelCase, PascalCase} from 'type-fest'; | ||
@@ -6,2 +6,4 @@ // eslint-disable-next-line @typescript-eslint/ban-types | ||
type ObjectOptional = Record<string, unknown> | undefined; | ||
/** | ||
@@ -40,3 +42,3 @@ Return a default type if input type is nil. | ||
export type CamelCaseKeys< | ||
T extends Record<string, any> | readonly any[], | ||
T extends ObjectOptional | readonly any[], | ||
Deep extends boolean = false, | ||
@@ -50,16 +52,13 @@ IsPascalCase extends boolean = false, | ||
? { | ||
[P in keyof T]: T[P] extends Record<string, any> | readonly any[] | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
? {} extends CamelCaseKeys<T[P]> | ||
? T[P] | ||
: CamelCaseKeys< | ||
T[P], | ||
Deep, | ||
IsPascalCase, | ||
Exclude, | ||
StopPaths | ||
> | ||
[P in keyof T]: T[P] extends Record<string, unknown> | readonly any[] | ||
? CamelCaseKeys< | ||
T[P], | ||
Deep, | ||
IsPascalCase, | ||
Exclude, | ||
StopPaths | ||
> | ||
: T[P]; | ||
} | ||
: T extends Record<string, any> | ||
: T extends Record<string, unknown> | ||
// Handle objects. | ||
@@ -75,6 +74,4 @@ ? { | ||
? T[P] | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
: {} extends CamelCaseKeys<T[P]> | ||
? T[P] | ||
: [Deep] extends [true] | ||
: [Deep] extends [true] | ||
? T[P] extends ObjectOptional | readonly any[] | ||
? CamelCaseKeys< | ||
@@ -88,3 +85,4 @@ T[P], | ||
> | ||
: T[P]; | ||
: T[P] | ||
: T[P]; | ||
} | ||
@@ -187,3 +185,3 @@ // Return anything else as-is. | ||
``` | ||
import {parseArgs} from 'node:utils'; | ||
import {parseArgs} from 'node:util'; | ||
import camelcaseKeys from 'camelcase-keys'; | ||
@@ -199,3 +197,3 @@ | ||
export default function camelcaseKeys< | ||
T extends Record<string, any> | readonly any[], | ||
T extends Record<string, unknown> | readonly any[], | ||
OptionsType extends Options = Options, | ||
@@ -202,0 +200,0 @@ >( |
19
index.js
@@ -25,3 +25,3 @@ import mapObject from 'map-obj'; | ||
const camelCaseConvert = (input, options) => { | ||
const transform = (input, options = {}) => { | ||
if (!isObject(input)) { | ||
@@ -31,10 +31,9 @@ return input; | ||
options = { | ||
deep: false, | ||
pascalCase: false, | ||
...options, | ||
}; | ||
const { | ||
exclude, | ||
pascalCase = false, | ||
stopPaths, | ||
deep = false, | ||
} = options; | ||
const {exclude, pascalCase, stopPaths, deep} = options; | ||
const stopPathsSet = new Set(stopPaths); | ||
@@ -75,6 +74,6 @@ | ||
if (Array.isArray(input)) { | ||
return Object.keys(input).map(key => camelCaseConvert(input[key], options)); | ||
return Object.keys(input).map(key => transform(input[key], options)); | ||
} | ||
return camelCaseConvert(input, options); | ||
return transform(input, options); | ||
} |
{ | ||
"name": "camelcase-keys", | ||
"version": "8.0.2", | ||
"version": "9.0.0", | ||
"description": "Convert object keys to camel case", | ||
@@ -14,6 +14,8 @@ "license": "MIT", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"types": "./index.d.ts", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"engines": { | ||
"node": ">=14.16" | ||
"node": ">=16" | ||
}, | ||
@@ -30,3 +32,2 @@ "scripts": { | ||
"map", | ||
"obj", | ||
"object", | ||
@@ -37,3 +38,2 @@ "key", | ||
"values", | ||
"val", | ||
"iterate", | ||
@@ -59,12 +59,12 @@ "camelcase", | ||
"dependencies": { | ||
"camelcase": "^7.0.0", | ||
"map-obj": "^4.3.0", | ||
"camelcase": "^8.0.0", | ||
"map-obj": "5.0.0", | ||
"quick-lru": "^6.1.1", | ||
"type-fest": "^2.13.0" | ||
"type-fest": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^4.3.0", | ||
"ava": "^5.3.1", | ||
"matcha": "^0.7.0", | ||
"tsd": "^0.23.0", | ||
"xo": "^0.49.0" | ||
"tsd": "^0.28.1", | ||
"xo": "^0.56.0" | ||
}, | ||
@@ -71,0 +71,0 @@ "xo": { |
@@ -36,3 +36,3 @@ # camelcase-keys | ||
```js | ||
import {parseArgs} from 'node:utils'; | ||
import {parseArgs} from 'node:util'; | ||
import camelcaseKeys from 'camelcase-keys'; | ||
@@ -117,12 +117,6 @@ | ||
## camelcase-keys for enterprise | ||
Available as part of the Tidelift Subscription. | ||
The maintainers of camelcase-keys and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase-keys?utm_source=npm-camelcase-keys&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) | ||
## Related | ||
- [decamelize-keys](https://github.com/sindresorhus/decamelize-keys) - The inverse of this package | ||
- [snakecase-keys](https://github.com/bendrucker/snakecase-keys) | ||
- [kebabcase-keys](https://github.com/mattiloh/kebabcase-keys) | ||
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
11006
230
121
+ Addedcamelcase@8.0.0(transitive)
+ Addedmap-obj@5.0.0(transitive)
+ Addedtype-fest@4.27.0(transitive)
- Removedcamelcase@7.0.1(transitive)
- Removedmap-obj@4.3.0(transitive)
- Removedtype-fest@2.19.0(transitive)
Updatedcamelcase@^8.0.0
Updatedmap-obj@5.0.0
Updatedtype-fest@^4.2.0