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

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

Notifications You must be signed in to change notification settings

huynhsamha/js-pathcase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

js-pathcase

NPM version NPM downloads

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

Installation

$ npm install --save js-pathcase

or

$ yarn add js-pathcase

Usage

Node.JS

const toPathCase = require('js-pathcase');

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

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

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

Browser

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

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

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

API

toPathCase(str)

Returns a new string which is pathcase format of str.

Dependencies

No dependencies

Related