Skip to content
This repository was archived by the owner on Dec 28, 2022. It is now read-only.

Commit 93771ce

Browse files
committed
fix for readableVariableName
1 parent f6b2b98 commit 93771ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/js/helpers.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ Pulsar.registerFunction(
55
"readableVariableName",
66
function (token, tokenGroup, prefix) {
77
// Create array with all path segments and token name at the end
8-
let segments = [...tokenGroup.path, token.name];
8+
const segments = [...tokenGroup.path];
9+
if (!tokenGroup.isRoot) {
10+
segments.push(tokenGroup.name)
11+
}
12+
segments.push(token.name);
13+
914
if (prefix && prefix.length > 0) {
1015
segments.unshift(prefix);
1116
}
@@ -14,12 +19,12 @@ Pulsar.registerFunction(
1419
let sentence = segments.join(" ");
1520

1621
// Return camelcased string from all segments
17-
sentence = sentence
22+
sentence = sentence
1823
.toLowerCase()
1924
.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase());
2025

2126
if (/^\d/.test(sentence)) {
22-
sentence = "_" + sentence;
27+
sentence = '_' + sentence;
2328
}
2429
return sentence;
2530
}

0 commit comments

Comments
 (0)