
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
@mapbox/expression-jamsession
Advanced tools
Write Mapbox GL expressions in a more familiar, handwritable, spreadsheet-like, programming-like syntax.
Write Mapbox GL expressions in a more familiar, handwritable, spreadsheet-like, programming-like syntax. This library translates these handwritten formulas into valid spec-compliant Mapbox GL expressions that you can use in a Mapbox style.
get("population"), log2(get("population")).+ - * / %) and parentheses work like in high school math, e.g. ((3 + 4) * 2) / 7.
That is, the formula should contain 3 + 4 instead of +(3, 4).get("foo") != 4 instead of !=(get("foo"), 4).concat("egg", "s") not concat(egg, s).& operator concatenates strings, as in spreadsheet programs.// Input
2 + 2
// Output
["+", 2, 2]
// Input
max(3, log2(6))
// Output
["max", 3, ["log2", 6]]
// Input
((3 + get("num")) * 2) / 7
// Output
["/", ["*", ["+", 3, get("num")], 2], 7]
// Input
"name: " & get("name")
// Output
["concat", ["name ", ["get", "name"]]]
The module exports two functions so you can transform in both directions:
formulaToExpression transforms (string) formulas to (array) expressions.expressionToFormula transforms expressions to formulas.import jamsession from '@mapbox/expression-jamsession';
jamsession.formulaToExpression("3 + 4"); // ["+", 3, 4]
jamsession.expressionToFormula(["+", 3, 4]); // "3 + 4"
This library should work in IE11+. It uses a Set, so you might get it working in older browsers by adding a polyfill.
get(true) outputs ["get", true], which fails.literal expression.
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.FAQs
Write Mapbox GL expressions in a more familiar, handwritable, spreadsheet-like, programming-like syntax.
The npm package @mapbox/expression-jamsession receives a total of 1,010 weekly downloads. As such, @mapbox/expression-jamsession popularity was classified as popular.
We found that @mapbox/expression-jamsession demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.