diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2017-05-09 14:46:02 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-05-23 19:39:43 +0200 |
commit | c0d858f8bb8ba5212548da2fba6a7bc02db0462b (patch) | |
tree | 99f043ec5aec3f5150a2aed0f62597234b158140 /deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js | |
parent | 994617370e8e66f3ea9488fec32fd912e7902396 (diff) | |
download | android-node-v8-c0d858f8bb8ba5212548da2fba6a7bc02db0462b.tar.gz android-node-v8-c0d858f8bb8ba5212548da2fba6a7bc02db0462b.tar.bz2 android-node-v8-c0d858f8bb8ba5212548da2fba6a7bc02db0462b.zip |
deps: upgrade npm beta to 5.0.0-beta.56
PR-URL: https://github.com/nodejs/node/pull/12936
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js')
-rw-r--r-- | deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js b/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js index e3d2a45620..c8492a2286 100644 --- a/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js +++ b/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/camelcase/index.js @@ -6,15 +6,15 @@ function preserveCamelCase(str) { let isLastLastCharUpper = false; for (let i = 0; i < str.length; i++) { - const c = str.charAt(i); + const c = str[i]; - if (isLastCharLower && (/[a-zA-Z]/).test(c) && c.toUpperCase() === c) { + if (isLastCharLower && /[a-zA-Z]/.test(c) && c.toUpperCase() === c) { str = str.substr(0, i) + '-' + str.substr(i); isLastCharLower = false; isLastLastCharUpper = isLastCharUpper; isLastCharUpper = true; i++; - } else if (isLastCharUpper && isLastLastCharUpper && (/[a-zA-Z]/).test(c) && c.toLowerCase() === c) { + } else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(c) && c.toLowerCase() === c) { str = str.substr(0, i - 1) + '-' + str.substr(i - 1); isLastLastCharUpper = isLastCharUpper; isLastCharUpper = false; @@ -29,8 +29,15 @@ function preserveCamelCase(str) { return str; } -module.exports = function () { - let str = [].map.call(arguments, x => x.trim()).filter(x => x.length).join('-'); +module.exports = function (str) { + if (arguments.length > 1) { + str = Array.from(arguments) + .map(x => x.trim()) + .filter(x => x.length) + .join('-'); + } else { + str = str.trim(); + } if (str.length === 0) { return ''; @@ -40,7 +47,15 @@ module.exports = function () { return str.toLowerCase(); } - str = preserveCamelCase(str); + if (/^[a-z0-9]+$/.test(str)) { + return str; + } + + const hasUpperCase = str !== str.toLowerCase(); + + if (hasUpperCase) { + str = preserveCamelCase(str); + } return str .replace(/^[_.\- ]+/, '') |