1.2.1 • Published 6 years ago

js-dotcase v1.2.1

Weekly downloads
156
License
ISC
Repository
github
Last release
6 years ago

js-dotcase

NPM version NPM downloads

JavaScript convert string to dot.case - Use for both Node.JS and Browser.

Installation

$ npm install --save js-dotcase

or

$ yarn add js-dotcase

Usage

Node.JS

const todDotcCase = require('js-dotcase');

console.log(toDotCase('string')); // => string
console.log(toDotCase('camelCase')); // => camel.case
console.log(toDotCase('param-case')); // => param.case
console.log(toDotCase('PascalCase')); // => pascal.case
console.log(toDotCase('UPPER_CASE')); // => upper.case
console.log(toDotCase('snake_case')); // => snake.case
console.log(toDotCase('sentence case')); // => sentence.case
console.log(toDotCase('Title Case')); // => title.case
console.log(toDotCase('dot.case')); // => // dot.case

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

console.log(toDotCase('Abc ___ 123 ___ xYz')); // => abc.123.x.yz
console.log(toDotCase('123__abc  ... ?// {#} def 12')); // => 123.abc.def.12
console.log(toDotCase('	tab space ??? ________')); // => tab.space
console.log(toDotCase('___?||123  abc|| 123..123')); // => 123.abc.123.123
console.log(toDotCase('!@#$%  {}|":;" ABC XyZ G123H')); // => abc.xy.z.g123h
console.log(toDotCase(' ^&* #DEFine x: 15 + ==')); // => define.x.15
console.log(toDotCase('123456789')); // => 123456789

Browser

1. NPM Package
<script src="./node_modules/js-dotcase/dist/js-dotcase.js"></script>
<!-- Or use minified -->
<script src="./node_modules/js-dotcase/dist/js-dotcase.min.js"></script>
2. Download from source
<script src="path/to/js-dotcase"></script>
Usage
<script>
	console.log(toDotCase('string')); // => string
	console.log(toDotCase('camelCase')); // => camel.case
	console.log(toDotCase('param-case')); // => param.case
	console.log(toDotCase('PascalCase')); // => pascal.case
	console.log(toDotCase('UPPER_CASE')); // => upper.case
	console.log(toDotCase('snake_case')); // => snake.case
	console.log(toDotCase('sentence case')); // => sentence.case
	console.log(toDotCase('Title Case')); // => title.case
	console.log(toDotCase('dot.case')); // => // dot.case

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

	console.log(toDotCase('Abc ___ 123 ___ xYz')); // => abc.123.x.yz
	console.log(toDotCase('123__abc  ... ?// {#} def 12')); // => 123.abc.def.12
	console.log(toDotCase('	tab space ??? ________')); // => tab.space
	console.log(toDotCase('___?||123  abc|| 123..123')); // => 123.abc.123.123
	console.log(toDotCase('!@#$%  {}|":;" ABC XyZ G123H')); // => abc.xy.z.g123h
	console.log(toDotCase(' ^&* #DEFine x: 15 + ==')); // => define.x.15
	console.log(toDotCase('123456789')); // => 123456789
</script>

API

toDotCase(str)

Returns a new string which is dotcase format of str.

Dependencies

No dependencies

Related