2018-10-23 23:45:42 +08:00
|
|
|
'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) {
|
|
|
|
if (value !== value) {
|
|
|
|
return 'NaN';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value === Infinity) {
|
|
|
|
return 'Infinity';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value === -Infinity) {
|
|
|
|
return '-Infinity';
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
};
|