Mapbox GL style functions are used to specify a property value that varies according to zoom level. This library implements the semantics of interpolated and piecewise-constant functions as specified by the Mapbox GL Style Specification.
Note that other Mapbox tools currently use v1, not v2.
Usage
var glfun = require('mapbox-gl-function');
var exponential = glfun({type: 'exponential', domain: [1, 5], range: [1, 10]});
exponential({ $zoom: 0 });
exponential({ $zoom: 1 });
exponential({ $zoom: 3 });
exponential({ $zoom: 5 });
exponential({ $zoom: 11 });
var interval = glfun({type: 'interval', domain: [1, 3, 4], range: ['a', 'b', 'c']});
interval({ $zoom: 0 });
interval({ $zoom: 1 });
interval({ $zoom: 2 });
interval({ $zoom: 3 });
interval({ $zoom: 4 });
var categorical = glfun({type: 'categorical', domain: ['A', 'B', 'C'], range: ['a', 'b', 'c']});
categorical({ $zoom: 'A' });
categorical({ $zoom: 'B' });
categorical({ $zoom: 'C' });