mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
22 lines
474 B
JavaScript
22 lines
474 B
JavaScript
|
'use strict';
|
||
|
|
||
|
/* eslint-disable no-var, prefer-template */
|
||
|
var uppercasePattern = /[A-Z]/g;
|
||
|
var msPattern = /^ms-/;
|
||
|
var cache = {};
|
||
|
|
||
|
function toHyphenLower(match) {
|
||
|
return '-' + match.toLowerCase()
|
||
|
}
|
||
|
|
||
|
function hyphenateStyleName(name) {
|
||
|
if (cache.hasOwnProperty(name)) {
|
||
|
return cache[name]
|
||
|
}
|
||
|
|
||
|
var hName = name.replace(uppercasePattern, toHyphenLower);
|
||
|
return (cache[name] = msPattern.test(hName) ? '-' + hName : hName)
|
||
|
}
|
||
|
|
||
|
module.exports = hyphenateStyleName;
|