PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / utils / camel-case-to-dash / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/utils/camel-case-to-dash/index.js

20 lines 536 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * camelCaseToDash('userId') => "user-id"
3 * camelCaseToDash('waitAMoment') => "wait-a-moment"
4 * camelCaseToDash('TurboPascal') => "turbo-pascal"
5 *
6 * https://gist.github.com/youssman/745578062609e8acac9f
7 *
8 * @param {string} str - camel-cased string.
9 * @return {string} - new dashed string.
10 */
11 export default function camelCaseToDash(str) {
12 if (typeof str !== 'string') {
13 return str;
14 }
15
16 str = str.replace(/[a-z]([A-Z])+/g, (m) => `${m[0]}-${m.substring(1)}`);
17
18 return str && str.toLowerCase ? str.toLowerCase() : str;
19 }
20