Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including capitalization with all npm packages installed. Try it out:

var capitalization = require("capitalization")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

capitalization v1.0.0

Contains capitalize <=> hyphenate, camelCase <=> underline functions.

Capitalization

Contains capitalize <=> hyphenate, camelCase <=> underline functions.

Example

const assert = require("assert");
var capitalization = require("capitalization");
var assert = require("assert");
var capitalize = capitalization.capitalize;
var hyphenate = capitalization.hyphenate;
var camelCase = capitalization.camelCase;
var underline = capitalization.underline;

assert.equal(capitalize("x-requested-with"), "X-Requested-With");
assert.equal(capitalize("x-requested-with", true), "XRequestedWith");
assert.equal(capitalize("test string"), "Test String");
assert.equal(hyphenate("XRequestedWith"), "X-Requested-With");
assert.equal(hyphenate("XRequestedWith", true), "x-requested-with");
assert.equal(camelCase("var_name"), "varName");
assert.equal(camelCase("var_name", true), "VarName");
assert.equal(underline("varName"), "var_name");
assert.equal(underline("varName", true), "var_Name");
assert.equal(underline("VarName", true), "Var_Name");

console.log("All tests passed!");
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free