@mapbox/expression-jamsession
Advanced tools
Comparing version 0.3.2 to 0.4.0
# Changelog | ||
## 0.4.0 | ||
- **[BREAKING]** Reject unquoted literal strings as passed in as formulas to `formulaToExpression`. | ||
## 0.3.2 | ||
@@ -4,0 +8,0 @@ |
@@ -7,7 +7,9 @@ 'use strict'; | ||
function handleSyntaxErrors(error, input) { | ||
function handleSyntaxErrors(error) { | ||
var input = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var newError = new Error('Syntax error'); | ||
newError.type = 'SyntaxError'; | ||
newError.index = error.index; | ||
newError.description = error.description; | ||
newError.description = error.description || error.message; | ||
@@ -41,3 +43,3 @@ if (/expression/.test(newError.description)) { | ||
default: | ||
throw new Error('Invalid syntax'); | ||
throw handleSyntaxErrors(new Error('Invalid syntax')); | ||
} | ||
@@ -47,2 +49,6 @@ } | ||
function astToExpression(input) { | ||
if (input.type === 'Identifier') { | ||
throw handleSyntaxErrors(new Error('Unexpected identifier')); | ||
} | ||
if (input.value !== undefined) return input.value; | ||
@@ -49,0 +55,0 @@ if (input.name !== undefined) return input.name; |
{ | ||
"name": "@mapbox/expression-jamsession", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "Write Mapbox GL expressions in a more familiar, handwritable, spreadsheet-like, programming-like syntax.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -16,2 +16,3 @@ # @mapbox/expression-jamsession | ||
So `get("foo") != 4` instead of `!=(get("foo"), 4)`. | ||
- Strings must always be wrapped in quotation marks, e.g. `concat("egg", "s")` not `concat(egg, s)`. | ||
- `&` operator concatenates strings, as in spreadsheet programs. | ||
@@ -70,3 +71,3 @@ | ||
- You cannot use JSON object literal arguments to [the `literal` expression](https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-types-literal). | ||
Even though this is allowed in the spec, objects are not supported by jsep and the use case for this type of expression is enough of an edge case that it doesn't seem worth serious work. | ||
This is allowed in the spec; but objects are not supported by jsep and the use case for this type of expression is kind of an edge case — so it's probably not worth trying to adjust the parser to support this edge case. | ||
If you disagree, please consider filing an issue and/or PR. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11619
150
72