Have ideas to improve npm?Join in the discussion! »

    decamelize
    TypeScript icon, indicating that this package has built-in type declarations

    5.0.0 • Public • Published

    decamelize

    Convert a camelized string into a lowercased one with a custom separator
    Example: unicornRainbowunicorn_rainbow

    Install

    $ npm install decamelize
    

    Usage

    const decamelize = require('decamelize');
    
    decamelize('unicornRainbow');
    //=> 'unicorn_rainbow'
    
    decamelize('unicornRainbow', {separator: '-'});
    //=> 'unicorn-rainbow'
    
    decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
    //=> 'test_GUI_label'
    
    decamelize('testGUILabel', {preserveConsecutiveUppercase: false});
    //=> 'test_gui_label'

    API

    decamelize(input, options?)

    input

    Type: string

    options

    Type: object

    separator

    Type: string
    Default: '_'

    Character or string inserted to separate words in string.

    cosnt decamelize = require('decamelize');
    
    decamelize('unicornRainbow');
    //=> 'unicorn_rainbow'
    
    decamelize('unicornRainbow', {separator: '-'});
    //=> 'unicorn-rainbow'
    preserveConsecutiveUppercase

    Type: boolean
    Default: false

    Preserve sequences of uppercase characters.

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

    Related

    See camelcase for the inverse.


    Get professional support for this package with a Tidelift subscription
    Tidelift helps make open source sustainable for maintainers while giving companies
    assurances about security, maintenance, and licensing for their dependencies.

    Install

    npm i decamelize

    DownloadsWeekly Downloads

    21,806,786

    Version

    5.0.0

    License

    MIT

    Unpacked Size

    6.78 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar