Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@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.0.5.0
13.21.0
and removes block list predicated on object support.literal
expression, which now supports any literal value (arrays, objects, strings, etc), in accordance with the style spec.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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.