MCPcopy Create free account
hub / github.com/idank/explainshell / bind

Function bind

explainshell/web/static/js/d3.v3.js:823–875  ·  view source on GitHub ↗
(group, groupData)

Source from the content-addressed store, hash-verified

821 return value;
822 }
823 function bind(group, groupData) {
824 var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData;
825 if (key) {
826 var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue;
827 for (i = -1; ++i < n; ) {
828 keyValue = key.call(node = group[i], node.__data__, i);
829 if (nodeByKeyValue.has(keyValue)) {
830 exitNodes[i] = node;
831 } else {
832 nodeByKeyValue.set(keyValue, node);
833 }
834 keyValues.push(keyValue);
835 }
836 for (i = -1; ++i < m; ) {
837 keyValue = key.call(groupData, nodeData = groupData[i], i);
838 if (node = nodeByKeyValue.get(keyValue)) {
839 updateNodes[i] = node;
840 node.__data__ = nodeData;
841 } else if (!dataByKeyValue.has(keyValue)) {
842 enterNodes[i] = d3_selection_dataNode(nodeData);
843 }
844 dataByKeyValue.set(keyValue, nodeData);
845 nodeByKeyValue.remove(keyValue);
846 }
847 for (i = -1; ++i < n; ) {
848 if (nodeByKeyValue.has(keyValues[i])) {
849 exitNodes[i] = group[i];
850 }
851 }
852 } else {
853 for (i = -1; ++i < n0; ) {
854 node = group[i];
855 nodeData = groupData[i];
856 if (node) {
857 node.__data__ = nodeData;
858 updateNodes[i] = node;
859 } else {
860 enterNodes[i] = d3_selection_dataNode(nodeData);
861 }
862 }
863 for (;i < m; ++i) {
864 enterNodes[i] = d3_selection_dataNode(groupData[i]);
865 }
866 for (;i < n; ++i) {
867 exitNodes[i] = group[i];
868 }
869 }
870 enterNodes.update = updateNodes;
871 enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;
872 enter.push(enterNodes);
873 update.push(updateNodes);
874 exit.push(exitNodes);
875 }
876 var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);
877 if (typeof value === "function") {
878 while (++i < n) {

Callers 1

d3.v3.jsFile · 0.85

Calls 2

d3_selection_dataNodeFunction · 0.85
callMethod · 0.45

Tested by

no test coverage detected