5.4.4 • Published 8 months ago

change-case v5.4.4

Weekly downloads
2,127,274
License
MIT
Repository
github
Last release
8 months ago

Change Case

Transform a string between camelCase, PascalCase, Capital Case, snake_case, kebab-case, CONSTANT_CASE and others.

Installation

npm install change-case --save

Usage

import * as changeCase from "change-case";

changeCase.camelCase("TEST_VALUE"); //=> "testValue"

Included case functions:

MethodResult
camelCasetwoWords
capitalCaseTwo Words
constantCaseTWO_WORDS
dotCasetwo.words
kebabCasetwo-words
noCasetwo words
pascalCaseTwoWords
pascalSnakeCaseTwo_Words
pathCasetwo/words
sentenceCaseTwo words
snakeCasetwo_words
trainCaseTwo-Words

All methods accept an options object as the second argument:

  • delimiter?: string The character to use between words. Default depends on method, e.g. _ in snake case.
  • locale?: string[] | string | false Lower/upper according to specified locale, defaults to host environment. Set to false to disable.
  • split?: (value: string) => string[] A function to define how the input is split into words. Defaults to split.
  • prefixCharacters?: string Retain at the beginning of the string. Defaults to "". Example: use "_" to keep the underscores in __typename.
  • suffixCharacters?: string Retain at the end of the string. Defaults to "". Example: use "_" to keep the underscore in type_.

By default, pascalCase and snakeCase separate ambiguous characters with _. For example, V1.2 would become V1_2 instead of V12. If you prefer them merged you can set mergeAmbiguousCharacters to true.

Split

Change case exports a split utility which can be used to build other case functions. It accepts a string and returns each "word" as an array. For example:

split("fooBar")
  .map((x) => x.toLowerCase())
  .join("_"); //=> "foo_bar"

Change Case Keys

import * as changeKeys from "change-case/keys";

changeKeys.camelCase({ TEST_KEY: true }); //=> { testKey: true }

Change case keys wraps around the core methods to transform object keys to any case.

API

  • input: any Any JavaScript value.
  • depth: number Specify the depth to transfer for case transformation. Defaults to 1.
  • options: object Same as base case library.

TypeScript and ESM

This package is a pure ESM package and ships with TypeScript definitions. It cannot be require'd or used with CommonJS module resolution in TypeScript.

License

MIT

saucelabs@hwhang0917/nestgen@uimi/cli@idemax/react-creator-helper@ilscc/mrm-presetcdp-app@corabank/ibanking@gmjs/lib-util@gmjs/mongo-util@gritwork/swagger-generate-apicaweb-cli@atomist/sdm@atomist/sdm-core@jadex/webx-gulpcreate-pwa-revanthnative-stream-wa-automate@iharob/graphql-mesh-clitypeorm-model-generator-relations-republish@coderich/dataloader@itemsjs/configdiez-style-dictionarycoco-flight-domesticfieldfirst-againsendo-pwa-loaderbrandify-core-libbig-pink-import-testgenerator-bipbop-tdd@reatc/responsivesoap4me-transmissionlayout-compsdoostrapperreact-fondlesos-repotypeorm-model-generator-relationstypeorm-model-generator-relations-npmdesite-clinodejstestalexloujnt-spaceadonis5-kueunqork-diez-targetstc-cli-plus@jakeblaxon-graphql-mesh/transform-naming-convention@teslagov/clarakm-jsgraphene-forkgraphql-mongodb-adapter@testing4638/styleguidetxp-graphql-to-postmantxptest-graphql-to-postman@acanto/workflow-laravel-frontendgenerator-octant-plugin@iharob/graphql-mesh-transform-naming-convention@cfchase/interactive-landscape@smileit/react-smile@beatak-org/vaceline-trunk@xcentium/jss-angular-kit@dupy/mainsg-import-pluginvex-desktopcentral-design-system@hulkstack/rushmanlwc-builder-ui-ninoish-test@mayahq/wabornflypress-metagroups@scrift/rush-tools@svgr-iconkit/fontawesome5-solidn8n-nodes-base-ziworete-two-editortwintwoo-editorlencebamboo-react-clipwc-code-generator@aotemanlei/cli@techmmunity/compassgenerator-surpriseapp-session-service8base@ts-elmish/eslint-pluginnebula-test-fragmentdainty-shareddainty-vsdainty-vscodegenerator-fe-stackjadoochoerodon-hap-front-bootcrtc@jacobwgillespie/apollo-codegenstyled-components-theme-helpers@gulppress/setup@flip-b/serverdevel-clig-dev-clitemplate-sixmon-vue@wearerequired/wordpress-plugin-boilerplatedesign-tokens-jda-cdkdomeniere-cli@stories-js/stories-clidaswag-cliredux-namervuerd-plugin-erd
5.4.4

8 months ago

5.4.3

10 months ago

5.4.2

11 months ago

5.4.1

11 months ago

5.4.0

11 months ago

5.3.0

1 year ago

5.1.2

1 year ago

5.2.0

1 year ago

5.1.1

1 year ago

5.0.2

1 year ago

5.1.0

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

4.1.2

4 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.1.0

6 years ago

3.0.2

7 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.3.1

9 years ago

2.3.0

10 years ago

2.2.0

10 years ago

2.1.6

10 years ago

2.1.5

10 years ago

2.1.4

10 years ago

2.1.3

10 years ago

2.1.2

10 years ago

2.1.1

11 years ago

2.1.0

11 years ago

2.0.1

11 years ago

2.0.0

11 years ago

1.0.6

11 years ago

1.0.5

11 years ago

1.0.4

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago