turbo-carto
Advanced tools
Comparing version 0.21.1 to 0.21.2
# Changelog | ||
## Version 0.21.2 | ||
Released 2019-06-12 | ||
- Fix crash when ramp fed with undefined argument #85 | ||
## Version 0.21.1 | ||
@@ -4,0 +8,0 @@ Released 2019-01-21 |
{ | ||
"name": "turbo-carto", | ||
"version": "0.21.1", | ||
"version": "0.21.2", | ||
"description": "CartoCSS preprocessor", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -191,4 +191,18 @@ 'use strict'; | ||
var method = (args[1] || 'quantiles').toLowerCase(); | ||
var numBuckets = values.getLength(); | ||
return getRamp(datasource, column, numBuckets, method).then(compatibilityCreateRampFn(values)); | ||
if (values.is(LazyFiltersResult)) { | ||
var mapping = args[2]; | ||
var strategy = strategyFromMapping(mapping); | ||
return values.getLength(column, strategy) | ||
.then(function (numBuckets) { | ||
return getRamp(datasource, column, numBuckets, method); | ||
}) | ||
.then(compatibilityCreateRampFn(values)); | ||
} else { | ||
var numBuckets = values.getLength(); | ||
return getRamp(datasource, column, numBuckets, method) | ||
.then(compatibilityCreateRampFn(values)); | ||
} | ||
} | ||
@@ -195,0 +209,0 @@ |
@@ -19,1 +19,5 @@ 'use strict'; | ||
}; | ||
LazyFiltersResult.prototype.getLength = function (column, strategy) { | ||
return this.get(column, strategy); | ||
}; |
@@ -219,2 +219,29 @@ 'use strict'; | ||
}); | ||
it('should return an error if it receives an evil ramp (instead of unhandled exception)', function (done) { | ||
// NOTE the missing first param (the column) in the ramp | ||
var cartocss = [ | ||
'#layercat{', | ||
' marker-width: ramp(, cartocolor(Safe), category(3));', | ||
'}' | ||
].join('\n'); | ||
var headtailsDatasource = new DummyDatasource(function () { | ||
return { | ||
ramp: [ | ||
'United States of America', | ||
'Russia', | ||
'China' | ||
], | ||
strategy: 'exact', | ||
stats: { min_val: undefined, max_val: undefined, avg_val: undefined } }; | ||
}); | ||
turbocarto(cartocss, headtailsDatasource, function (err /*, result, metadata */) { | ||
if (err) { | ||
// We're expecting this error | ||
assert.strictEqual(err.name, 'TurboCartoError'); | ||
assert.strictEqual(err.message, 'Failed to process "marker-width" property: column.replace is not a function'); | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
122930
93
2894
1