kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
56 lines (52 loc) • 6.05 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.diffUpdateTriggers = diffUpdateTriggers;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
/* eslint-disable guard-for-in */
/**
*
* @param {Object} updateTriggers {getPosition: {column}, getData: {filteredIndex}}
* @param {Object} oldUpdateTriggers
* @returns {boolean|object} `false` if nothing changed, or `triggerChanged` as an object
*/
function diffUpdateTriggers(updateTriggers) {
var oldUpdateTriggers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var triggerChanged = {};
var reason = false;
for (var triggerName in updateTriggers) {
var newTriggers = updateTriggers[triggerName] || {};
var oldTriggers = oldUpdateTriggers[triggerName] || {};
var diffReason = compareUpdateTrigger(newTriggers, oldTriggers, triggerName);
if (diffReason) {
triggerChanged[triggerName] = true;
reason = triggerChanged;
}
}
return reason;
}
function compareUpdateTrigger(newTriggers, oldTriggers, triggerName) {
if ((0, _typeof2["default"])(oldTriggers) !== 'object') {
return oldTriggers === newTriggers ? null : "".concat(triggerName, " changed shallowly");
}
for (var key in oldTriggers) {
if (!(key in newTriggers)) {
return "".concat(triggerName, ".").concat(key, " deleted");
}
// shallow compare
if (oldTriggers[key] !== newTriggers[key]) {
return "".concat(triggerName, ".").concat(key, " changed shallowly");
}
}
for (var _key in newTriggers) {
if (!(_key in oldTriggers)) {
return "".concat(triggerName, ".").concat(_key, " added");
}
}
return null;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJkaWZmVXBkYXRlVHJpZ2dlcnMiLCJ1cGRhdGVUcmlnZ2VycyIsIm9sZFVwZGF0ZVRyaWdnZXJzIiwiYXJndW1lbnRzIiwibGVuZ3RoIiwidW5k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