Git Product home page Git Product logo

js-headercase's Introduction

js-headercase

NPM version NPM downloads

JavaScript convert string to Header Case - Use for both Node.JS and Browser.

Installation

$ npm install --save js-headercase

or

$ yarn add js-headercase

Usage

Node.JS

const toHeaderCase = require('js-headercase');

console.log(toHeaderCase('string')); // => String
console.log(toHeaderCase('camelCase')); // => Camel Case
console.log(toHeaderCase('param-case')); // => Param Case
console.log(toHeaderCase('PascalCase')); // => Pascal Case
console.log(toHeaderCase('UPPER_CASE')); // => Upper Case
console.log(toHeaderCase('snake_case')); // => Snake Case
console.log(toHeaderCase('sentence case')); // => Sentence Case
console.log(toHeaderCase('Title Case')); // => Title Case
console.log(toHeaderCase('dot.case')); // => // Dot Case

console.log(toHeaderCase('')); // => ''
console.log(toHeaderCase(null)); // => ''
console.log(toHeaderCase(undefined)); // => ''

console.log(toHeaderCase('Abc ___ 123 ___ xYz')); // => Abc 123 X Yz
console.log(toHeaderCase('123__abc  ... ?// {#} def 12')); // => 123 Abc Def 12
console.log(toHeaderCase('	tab space ??? ________')); // => Tab Space
console.log(toHeaderCase('___?||123  abc|| 123..123')); // => 123 Abc 123 123
console.log(toHeaderCase('!@#$%  {}|":;" ABC XyZ G123H')); // => Abc Xy z G123h
console.log(toHeaderCase(' ^&* #DEFine x: 15 + ==')); // => Define X 15
console.log(toHeaderCase('123456789')); // => 123456789

Browser

1. NPM Package
<script src="./node_modules/js-headercase/dist/js-headercase.js"></script>
<!-- Or use minified -->
<script src="./node_modules/js-headercase/dist/js-headercase.min.js"></script>
2. Download from source
<script src="path/to/js-headercase"></script>
Usage
<script>
	console.log(toHeaderCase('string')); // => String
	console.log(toHeaderCase('camelCase')); // => Camel Case
	console.log(toHeaderCase('param-case')); // => Param Case
	console.log(toHeaderCase('PascalCase')); // => Pascal Case
	console.log(toHeaderCase('UPPER_CASE')); // => Upper Case
	console.log(toHeaderCase('snake_case')); // => Snake Case
	console.log(toHeaderCase('sentence case')); // => Sentence Case
	console.log(toHeaderCase('Title Case')); // => Title Case
	console.log(toHeaderCase('dot.case')); // => // Dot Case

	console.log(toHeaderCase('')); // => ''
	console.log(toHeaderCase(null)); // => ''
	console.log(toHeaderCase(undefined)); // => ''

	console.log(toHeaderCase('Abc ___ 123 ___ xYz')); // => Abc 123 X Yz
	console.log(toHeaderCase('123__abc  ... ?// {#} def 12')); // => 123 Abc Def 12
	console.log(toHeaderCase('	tab space ??? ________')); // => Tab Space
	console.log(toHeaderCase('___?||123  abc|| 123..123')); // => 123 Abc 123 123
	console.log(toHeaderCase('!@#$%  {}|":;" ABC XyZ G123H')); // => Abc Xy z G123h
	console.log(toHeaderCase(' ^&* #DEFine x: 15 + ==')); // => Define X 15
	console.log(toHeaderCase('123456789')); // => 123456789
</script>

API

toHeaderCase(str)

Returns a new string which is headercase format of str.

Dependencies

No dependencies

Related

js-headercase's People

Contributors

huynhsamha avatar

Watchers

 avatar  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.