Code Monkey home page Code Monkey logo

camelize's Introduction

camelize

String transformation to camelCase.

  • Allowed 'word' separators are space, hyphen, dot, and underscore.
  • Strips anything else that isn't a-z/A-Z.
  • Ignores acronyms/initialisms.
  • Defaults to dromedaryCase, optional PascalCase (see Usage options).

Getting it

npm install --save tdous/camelize
# or
npm install --save-dev tdous/camelize

Usage

import { camelize } from 'camelize';

let output;

output = camelize('perform this task');
// output === 'performThisTask'

output = camelize('Perform thIS taSk');
// output === 'performThisTask'

output = camelize('dO.Perform-thIS_taSk please');
// output === 'doPerformThisTaskPlease'

output = camelize('dO.29Perfor\m\-th&IS_taSk ple93;3ase!');
// output === 'doPerformThisTaskPlease'

output = camelize('dO.P29Perfor\m\-th&IS_TASK ple93;3ase!');
// output === 'doPerformThisTASKPlease'

output = camelize('dO.""pE?r\'f:or@m~#\\\';}{|__tHIs`¬+)(*&)!"^)!^)!2 task8/?.,><#--plE&£$Ase---');
// output === 'doPerformThisTaskPlease'

output = camelize(
  'dO.""pE?r\'f:or@m~#\\\';}{|__tHIs`¬+)(*&)!"^)!^)!2 task8/?.,><#--plE&£$Ase---'
  { pascal: true }
);
// output === 'DoPerformThisTaskPlease'

output = camelize(
  'DO.""PE?R\'F:OR@M~#\\\';}{|__THIS`¬+)(*&)!"^)!^)!2 TASK8/?.,><#--PLE&£$ASE---',
  { divider: '_' }
);
// output === 'DO_PERFORM_THIS_TASK_PLEASE'

Options

PascalCase

output = camelize('do-perform_THIS task --please', { pascal: true });
// output === 'DoPerformTHISTaskPlease'

camelize's People

Contributors

tdous avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.