Skip to content

Commit

Permalink
Simplify how token strings are converted
Browse files Browse the repository at this point in the history
No longer need to-string when using concat. However, it is still needed if the token string consists of a single token.
  • Loading branch information
jfirebaugh committed Sep 13, 2018
1 parent 4256281 commit 0a5cacd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/style-spec/function/convert.js
Expand Up @@ -226,7 +226,7 @@ export function convertTokenString(s: string) {
const literal = s.slice(pos, re.lastIndex - match[0].length);
pos = re.lastIndex;
if (literal.length > 0) result.push(literal);
result.push(['to-string', ['get', match[1]]]);
result.push(['get', match[1]]);
}

if (result.length === 1) {
Expand All @@ -236,7 +236,7 @@ export function convertTokenString(s: string) {
if (pos < s.length) {
result.push(s.slice(pos));
} else if (result.length === 2) {
return result[1];
return ['to-string', result[1]];
}

return result;
Expand Down
@@ -1,8 +1,8 @@
{
"expression": {"type": "interval", "stops": [[0, "0 {a}"], [1, "1 {b}"]]},
"expression": {"type": "interval", "stops": [[0, "0 {a}"], [1, "{b}"]]},
"inputs": [
[{"zoom": 0}, {"properties": {"a": "a", "b": "b"}}],
[{"zoom": 1}, {"properties": {"a": "a", "b": "b"}}],
[{"zoom": 0}, {"properties": {"a": "a", "b": 2}}],
[{"zoom": 1}, {"properties": {"a": "a", "b": 2}}],
[{"zoom": 0}, {"properties": {}}]
],
"propertySpec": {
Expand All @@ -18,13 +18,13 @@
"isZoomConstant": false,
"type": "string"
},
"outputs": ["0 a", "1 b", "0 "],
"outputs": ["0 a", "2", "0 "],
"serialized": [
"step",
["zoom"],
["concat", "0 ", ["to-string", ["get", "a"]]],
["concat", "0 ", ["get", "a"]],
1,
["concat", "1 ", ["to-string", ["get", "b"]]]
["to-string", ["get", "b"]]
]
}
}

0 comments on commit 0a5cacd

Please sign in to comment.