Last change
on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
323 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | module.exports = function (str, sep) {
|
---|
3 | if (typeof str !== 'string') {
|
---|
4 | throw new TypeError('Expected a string');
|
---|
5 | }
|
---|
6 |
|
---|
7 | sep = typeof sep === 'undefined' ? '_' : sep;
|
---|
8 |
|
---|
9 | return str
|
---|
10 | .replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
|
---|
11 | .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
|
---|
12 | .toLowerCase();
|
---|
13 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.