-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
13 lines (12 loc) · 613 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
'use strict';
module.exports = input => {
if (input.includes('_') && /^([A-Z][A-Z0-9_]+)+$/.test(input)) return 'uppersnake';
if (input.includes('_') && /^([a-z][a-z0-9_]+)+$/.test(input)) return 'snakecase';
if (/^[a-z0-9_]+$/.test(input)) return 'lowercase';
if (/^[A-Z][A-Z0-9_]*$/.test(input)) return 'uppercase';
if (/^([A-Z][a-z0-9_]*[A-Z]*){2,}$/.test(input)) return 'pascalcase';
if (/^([a-z][a-z0-9_]*[A-Z][a-z0-9_]*)+$/.test(input)) return 'camelcase';
if (/^[A-Z][a-z]*$/.test(input)) return 'titlecase';
if (/^[A-Z][a-z0-9_]*$/.test(input)) return 'mixedcase';
return 'unknown';
};