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

1.0.0 • 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.

index.d.ts

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> = {
    [K in keyof T as CamelCase<string & K>]: T[K] extends {} ? Camelize<T[K]> : T[K];
};

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

export = camelize;

Additional Details

  • Last updated: Tue, 05 Dec 2023 21:35:54 GMT
  • Dependencies: none

Credits

These definitions were written by Tristan F..

Readme

Keywords

none

Package Sidebar

Install

npm i @types/camelize

Weekly Downloads

4,067

Version

1.0.0

License

MIT

Unpacked Size

3.72 kB

Total Files

5

Last publish

Collaborators

  • types