🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@maptalks/function-type

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maptalks/function-type - npm Package Compare versions

Comparing version
1.1.1
to
1.2.0
+38
-13
index.js

@@ -7,4 +7,4 @@ /*eslint-disable no-var, prefer-const*/

fun = function () { return parameters; };
// fun.isFeatureConstant = true;
// fun.isZoomConstant = true;
fun.isFeatureConstant = true;
fun.isZoomConstant = true;

@@ -51,19 +51,22 @@ } else {

fun = function (zoom, feature) {
return evaluateExponentialFunction({ stops: featureFunctionStops, base: parameters.base }, zoom)(zoom, feature);
const value = evaluateExponentialFunction({ stops: featureFunctionStops, base: parameters.base }, zoom)(zoom, feature);
return typeof value === 'function' ? value(zoom, feature) : value;
};
// fun.isFeatureConstant = false;
// fun.isZoomConstant = false;
fun.isFeatureConstant = false;
fun.isZoomConstant = false;
} else if (zoomDependent) {
fun = function (zoom) {
return innerFun(parameters, zoom);
const value = innerFun(parameters, zoom);
return typeof value === 'function' ? value(zoom) : value;
};
// fun.isFeatureConstant = true;
// fun.isZoomConstant = false;
fun.isFeatureConstant = true;
fun.isZoomConstant = false;
} else {
fun = function (zoom, feature) {
return innerFun(parameters, feature ? feature[parameters.property] : null);
const value = innerFun(parameters, feature ? feature[parameters.property] : null);
return typeof value === 'function' ? value(zoom, feature) : value;
};
// fun.isFeatureConstant = false;
// fun.isZoomConstant = true;
fun.isFeatureConstant = false;
fun.isZoomConstant = true;
}

@@ -192,3 +195,3 @@ }

export function interpolated(parameters) {
return createFunction(parameters, 'exponential');
return createFunction1(parameters, 'exponential');
}

@@ -198,3 +201,3 @@

export function piecewiseConstant(parameters) {
return createFunction(parameters, 'interval');
return createFunction1(parameters, 'interval');
}

@@ -284,1 +287,23 @@

/*eslint-enable no-var, prefer-const*/
function createFunction1(parameters, defaultType) {
if (!isFunctionDefinition(parameters)) {
return function () { return parameters; };
}
parameters = JSON.parse(JSON.stringify(parameters));
let isZoomConstant = true;
let isFeatureConstant = true;
const stops = parameters.stops;
for (let i = 0; i < stops.length; i++) {
if (isFunctionDefinition(stops[i][1])) {
const fn = createFunction(stops[i][1], defaultType);
isZoomConstant = isZoomConstant && fn.isZoomConstant;
isFeatureConstant = isFeatureConstant && fn.isFeatureConstant;
stops[i] = [stops[i][0], fn];
}
}
const fn = createFunction(parameters, defaultType);
fn.isZoomConstant = isZoomConstant && fn.isZoomConstant;
fn.isFeatureConstant = isFeatureConstant && fn.isFeatureConstant;
return fn;
}
{
"name": "@maptalks/function-type",
"version": "1.1.1",
"version": "1.2.0",
"main": "./index.js",

@@ -5,0 +5,0 @@ "module": "./index.js",