mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Define Base.hyphenate, to hyphenate camelized strings.
This commit is contained in:
parent
d6cf11efce
commit
fa29686202
1 changed files with 8 additions and 0 deletions
|
@ -128,6 +128,14 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
});
|
||||
},
|
||||
|
||||
hyphenate: function(str) {
|
||||
return str.replace(/[a-z][A-Z0-9]|[0-9][a-zA-Z]|[A-Z]{2}[a-z]/g,
|
||||
function(match) {
|
||||
return match.charAt(0) + '-' + match.substring(1);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function for rendering numbers to strings at a precision of
|
||||
* up to 5 fractional digits.
|
||||
|
|
Loading…
Reference in a new issue