index.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm.
  16. Default: The host environment’s current locale.
  17. @example
  18. ```
  19. import camelCase = require('camelcase');
  20. camelCase('lorem-ipsum', {locale: 'en-US'});
  21. //=> 'loremIpsum'
  22. camelCase('lorem-ipsum', {locale: 'tr-TR'});
  23. //=> 'loremİpsum'
  24. camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
  25. //=> 'loremIpsum'
  26. camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
  27. //=> 'loremİpsum'
  28. ```
  29. */
  30. readonly locale?: false | string | readonly string[];
  31. }
  32. }
  33. /**
  34. Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
  35. Correctly handles Unicode strings.
  36. @param input - String to convert to camel case.
  37. @example
  38. ```
  39. import camelCase = require('camelcase');
  40. camelCase('foo-bar');
  41. //=> 'fooBar'
  42. camelCase('foo_bar');
  43. //=> 'fooBar'
  44. camelCase('Foo-Bar');
  45. //=> 'fooBar'
  46. camelCase('розовый_пушистый_единорог');
  47. //=> 'розовыйПушистыйЕдинорог'
  48. camelCase('Foo-Bar', {pascalCase: true});
  49. //=> 'FooBar'
  50. camelCase('--foo.bar', {pascalCase: false});
  51. //=> 'fooBar'
  52. camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
  53. //=> 'fooBAR'
  54. camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
  55. //=> 'FooBAR'
  56. camelCase('foo bar');
  57. //=> 'fooBar'
  58. console.log(process.argv[3]);
  59. //=> '--foo-bar'
  60. camelCase(process.argv[3]);
  61. //=> 'fooBar'
  62. camelCase(['foo', 'bar']);
  63. //=> 'fooBar'
  64. camelCase(['__foo__', '--bar'], {pascalCase: true});
  65. //=> 'FooBar'
  66. camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
  67. //=> 'FooBAR'
  68. camelCase('lorem-ipsum', {locale: 'en-US'});
  69. //=> 'loremIpsum'
  70. ```
  71. */
  72. declare function camelcase(
  73. input: string | readonly string[],
  74. options?: camelcase.Options
  75. ): string;
  76. export = camelcase;