Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@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"
notARealExpression(true)
outputs ["notARealExpression", true]
.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.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.