# pretty-camel

> Node module to prettify camel cased strings.

Latest version **0.0.8** (published 2012-11-10) · 0 weekly downloads

## Install

```sh
npm install pretty-camel
pnpm add pretty-camel
yarn add pretty-camel
bun add pretty-camel
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2012-11-10 |
| First published | 2012-06-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Blake VanLandingham |
| Maintainers | blakevanlan, adunkman |

## Links

- npm: https://www.npmjs.com/package/pretty-camel
- Repository: https://github.com/softek/pretty-camel
- npm.io page: https://npm.io/package/pretty-camel

## Recent versions

- 0.0.8 (latest) — 2012-11-10
- 0.0.7 — 2012-08-13
- 0.0.6 — 2012-07-26
- 0.0.5 — 2012-07-02
- 0.0.4 — 2012-06-20
- 0.0.3 — 2012-06-20
- 0.0.2 — 2012-06-19
- 0.0.1 — 2012-06-15

## README

# Pretty Camel
[![Build Status](https://secure.travis-ci.org/softek/pretty-camel.png?branch=master)](http://travis-ci.org/softek/pretty-camel)

Node module to format to and from camel case.

## toWords()

```javascript
var prettyCamel = require("pretty-camel");
prettyCamel(input, {
   "case": "title" (default) | "sentence" | "lower"
});
prettyCamel.toWords(input, {
   "case": "title" (default) | "sentence" | "lower"
});
```

`prettyCamel.toWords()` is aliased to `prettyCamel()` so it can be used either way.

Here are a few examples of prettification:
* procedureCode -> Procedure Code
* hospitalCPTCode -> Hospital CPT Code
* eatAHotdog -> Eat A Hotdog
* eatAHotdog -> eat a hotdog (lower case option)
* procCodeA938 -> Proc Code A938
* procA39BCode -> Proc A39B Code
* procA39BCode -. Proc A39B code (sentence case option)

### Rules
The following rules are applied to input strings:
* Words separated by uppercase letters, numbers, underscores, dashes, and periods
* Each word is separated by a space
* A sequence of capital letters and numbers is considered to be one word

### Options
Options are passed in an object as the second parameter. Currently the only option available is casing. 

#### Case Option
* "title"- (default) Uppercases the first letter of every word
* "sentence"- Uppercases the first letter of the first word and lowercases all other words
* "lower"- Lowercases all words except for abbreviation

## toCamelCase()

```javascript
var prettyCamel = require("pretty-camel");
prettyCamel.toCamelCase(input, {
   "case": "lower" (default) | "upper"
});
```

Here are a few examples:
* Procedure Code -> procedureCode
* Procedure-code -> procedureCode
* Procedure_code -> ProcedureCode (upper case option)

### Options
Options are passed in an object as the second parameter. Currently the only option available is casing. 

#### Case Option
* "lower"- (default) Lowercases the first letter of the first word
* "upper"- Uppercases the first letter of the first word

## Sample Usage

```javascript
var prettyCamel = require("pretty-camel");
var input = "hospitalCPTCode";
var output = prettyCamel(input);

console.log(output);
```
The outputs is ```Hospital CPT Code```

```javascript
var prettyCamel = require("pretty-camel");
var input = "hospitalCPTCode";
var options = {
   "case": "sentence" 
};
var output = prettyCamel.toWords(input, options);

console.log(output);
```
The outputs is ```Hospital CPT code```

```javascript
var prettyCamel = require("pretty-camel");
var input = "hospitalCPTCode";
var options = {
   "case": "lower" 
};
var output = prettyCamel(input, options);

console.log(output);
```
The outputs is ```hospital CPT code```

```javascript
var prettyCamel = require("pretty-camel");
var input = "hospital_CPT_Code";
var options = {
   "case": "upper" 
};
var output = prettyCamel.toUpperCase(input, options);

console.log(output);
```
The outputs is ```HospitalCPTCode```

## Install
``` bash
npm install pretty-camel
```

## Express Middleware
If you're using Express and want access to prettyCamel() in your views, add the following piece of middleware to your server:

```javascript
var prettyCamel = require("pretty-camel");
var express = require("express");
var app = express.createServer();

app.use(prettyCamel.middleware);
```

Version 0.0.7 was compatible with Express 2.x and 0.0.8 and above are compatible with Express 3.x.

---
_Source: https://npm.io/package/pretty-camel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
