@types/camelize
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Installation

npm install --save @types/camelize

Summary

This package contains type definitions for camelize (https://github.com/ljharb/camelize).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/camelize.

type CamelSeparator = "-" | "_" | ".";

/**
 * Converts a string to camel case.
 */
type CamelCase<S extends string> = S extends `${infer FirstWord}${CamelSeparator}${infer SecondChar}${infer Remaining}`
    ? `${Lowercase<FirstWord>}${Uppercase<SecondChar>}${CamelCase<Remaining>}`
    : Lowercase<S>;

type Camelize<T> = T extends Date ? T
    : T extends RegExp ? T
    : T extends Array<infer I> ? Array<Camelize<I>>
    : T extends object ? {
            [K in keyof T as CamelCase<string & K>]: Camelize<T[K]>;
        }
    : T;

declare function camelize<T>(obj: T): T extends string ? CamelCase<T> : Camelize<T>;

export = camelize;

Additional Details

  • Last updated: Sat, 27 Jul 2024 07:07:31 GMT
  • Dependencies: none

Credits

These definitions were written by Tristan F..

Readme

Keywords

none

Package Sidebar

Install

npm i @types/camelize

Weekly Downloads

15,786

Version

1.0.1

License

MIT

Unpacked Size

3.81 kB

Total Files

5

Last publish

Collaborators

  • types