Windshaft-cartodb/lib/utils/json-replacer.js

22 lines
531 B
JavaScript
Raw Normal View History

'use strict';
2018-04-03 19:21:41 +08:00
module.exports = function jsonReplacerFactory () {
// Fix: https://github.com/CartoDB/Windshaft-cartodb/issues/705
// See: http://expressjs.com/en/4x/api.html#app.set
return function jsonReplacer (key, value) {
2019-11-06 20:56:59 +08:00
if (value !== value) { // eslint-disable-line no-self-compare
2018-04-03 19:21:41 +08:00
return 'NaN';
}
if (value === Infinity) {
return 'Infinity';
}
if (value === -Infinity) {
return '-Infinity';
}
return value;
};
};