web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.5 KiB

  1. # camelcase [![Build Status](https://travis-ci.com/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.com/sindresorhus/camelcase)
  2. > Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
  3. Correctly handles Unicode strings.
  4. ## Install
  5. ```
  6. $ npm install camelcase
  7. ```
  8. *If you need to support Firefox, stay on version 5 as version 6 uses regex features not available in Firefox.*
  9. ## Usage
  10. ```js
  11. const camelCase = require('camelcase');
  12. camelCase('foo-bar');
  13. //=> 'fooBar'
  14. camelCase('foo_bar');
  15. //=> 'fooBar'
  16. camelCase('Foo-Bar');
  17. //=> 'fooBar'
  18. camelCase('розовый_пушистый_единороги');
  19. //=> 'розовыйПушистыйЕдинороги'
  20. camelCase('Foo-Bar', {pascalCase: true});
  21. //=> 'FooBar'
  22. camelCase('--foo.bar', {pascalCase: false});
  23. //=> 'fooBar'
  24. camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
  25. //=> 'fooBAR'
  26. camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
  27. //=> 'FooBAR'
  28. camelCase('foo bar');
  29. //=> 'fooBar'
  30. console.log(process.argv[3]);
  31. //=> '--foo-bar'
  32. camelCase(process.argv[3]);
  33. //=> 'fooBar'
  34. camelCase(['foo', 'bar']);
  35. //=> 'fooBar'
  36. camelCase(['__foo__', '--bar'], {pascalCase: true});
  37. //=> 'FooBar'
  38. camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
  39. //=> 'FooBAR'
  40. camelCase('lorem-ipsum', {locale: 'en-US'});
  41. //=> 'loremIpsum'
  42. ```
  43. ## API
  44. ### camelCase(input, options?)
  45. #### input
  46. Type: `string | string[]`
  47. String to convert to camel case.
  48. #### options
  49. Type: `object`
  50. ##### pascalCase
  51. Type: `boolean`\
  52. Default: `false`
  53. Uppercase the first character: `foo-bar``FooBar`
  54. ##### preserveConsecutiveUppercase
  55. Type: `boolean`\
  56. Default: `false`
  57. Preserve the consecutive uppercase characters: `foo-BAR``FooBAR`.
  58. ##### locale
  59. Type: `string | string[]`\
  60. Default: The host environment’s current locale.
  61. 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.
  62. ```js
  63. const camelCase = require('camelcase');
  64. camelCase('lorem-ipsum', {locale: 'en-US'});
  65. //=> 'loremIpsum'
  66. camelCase('lorem-ipsum', {locale: 'tr-TR'});
  67. //=> 'loremİpsum'
  68. camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
  69. //=> 'loremIpsum'
  70. camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
  71. //=> 'loremİpsum'
  72. ```
  73. ## camelcase for enterprise
  74. Available as part of the Tidelift Subscription.
  75. The maintainers of camelcase 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?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
  76. ## Related
  77. - [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
  78. - [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
  79. - [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
  80. - [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
  81. - [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case