decamelize

  • Version 6.0.0
  • Published
  • 6.84 kB
  • No dependencies
  • MIT license

Install

npm i decamelize
yarn add decamelize
pnpm add decamelize

Overview

Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow

Index

Functions

function decamelize

decamelize: (string: string, options?: Options) => string;
  • Convert a camelized string into a lowercased one with a custom separator: unicornRainbowunicorn_rainbow.

    Parameter string

    The camelcase string to decamelize.

    Example 1

    import decamelize from 'decamelize';
    decamelize('unicornRainbow');
    //=> 'unicorn_rainbow'
    decamelize('unicornRainbow', {separator: '-'});
    //=> 'unicorn-rainbow'

Interfaces

interface Options

interface Options {}

    property preserveConsecutiveUppercase

    readonly preserveConsecutiveUppercase?: boolean;
    • Preserve sequences of uppercase characters.

      false

      Example 1

      ``` import decamelize from 'decamelize';

      decamelize('testGUILabel'); //=> 'test_gui_label'

      decamelize('testGUILabel', {preserveConsecutiveUppercase: true}); //=> 'test_GUI_label' ```

    property separator

    readonly separator?: string;
    • Character or string inserted to separate words in string.

      '_'

      Example 1

      ``` import decamelize from 'decamelize';

      decamelize('unicornRainbow'); //=> 'unicorn_rainbow'

      decamelize('unicornRainbow', {separator: '-'}); //=> 'unicorn-rainbow' ```

    Package Files (1)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (4)

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/decamelize.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/decamelize)
    • HTML
      <a href="https://www.jsdocs.io/package/decamelize"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>