Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.
/ js-dotcase Public archive

πŸ›‘ [deprecated] πŸ›‘ JavaScript Dotcase for both node.js and browser

Notifications You must be signed in to change notification settings

huynhsamha/js-dotcase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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