index.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. declare namespace camelcase {
  2. interface Options {
  3. /**
  4. Uppercase the first character: `foo-bar` → `FooBar`.
  5. @default false
  6. */
  7. readonly pascalCase?: boolean;
  8. /**
  9. Preserve the consecutive uppercase characters: `foo-BAR` → `FooBAR`.
  10. @default false
  11. */
  12. readonly preserveConsecutiveUppercase?: boolean;
  13. /**
  14. The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
  15. Default: The host environment’s current locale.
  16. @example
  17. ```
  18. import camelCase = require('camelcase');
  19. camelCase('lorem-ipsum', {locale: 'en-US'});
  20. //=> 'loremIpsum'
  21. camelCase('lorem-ipsum', {locale: 'tr-TR'});
  22. //=> 'loremİpsum'
  23. camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
  24. //=> 'loremIpsum'
  25. camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
  26. //=> 'loremİpsum'
  27. ```
  28. */
  29. readonly locale?: string | readonly string[];
  30. }
  31. }
  32. /**
  33. Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
  34. Correctly handles Unicode strings.
  35. @param input - String to convert to camel case.
  36. @example
  37. ```
  38. import camelCase = require('camelcase');
  39. camelCase('foo-bar');
  40. //=> 'fooBar'
  41. camelCase('foo_bar');
  42. //=> 'fooBar'
  43. camelCase('Foo-Bar');
  44. //=> 'fooBar'
  45. camelCase('розовый_пушистый_единороги');
  46. //=> 'розовыйПушистыйЕдинороги'
  47. camelCase('Foo-Bar', {pascalCase: true});
  48. //=> 'FooBar'
  49. camelCase('--foo.bar', {pascalCase: false});
  50. //=> 'fooBar'
  51. camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
  52. //=> 'fooBAR'
  53. camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
  54. //=> 'FooBAR'
  55. camelCase('foo bar');
  56. //=> 'fooBar'
  57. console.log(process.argv[3]);
  58. //=> '--foo-bar'
  59. camelCase(process.argv[3]);
  60. //=> 'fooBar'
  61. camelCase(['foo', 'bar']);
  62. //=> 'fooBar'
  63. camelCase(['__foo__', '--bar'], {pascalCase: true});
  64. //=> 'FooBar'
  65. camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
  66. //=> 'FooBAR'
  67. camelCase('lorem-ipsum', {locale: 'en-US'});
  68. //=> 'loremIpsum'
  69. ```
  70. */
  71. declare function camelcase(
  72. input: string | readonly string[],
  73. options?: camelcase.Options
  74. ): string;
  75. export = camelcase;