MCPcopy Index your code
hub / github.com/idank/explainshell / d3_interpolateString

Function d3_interpolateString

explainshell/web/static/js/d3.v3.js:4765–4826  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

4763 }
4764 d3.interpolateString = d3_interpolateString;
4765 function d3_interpolateString(a, b) {
4766 var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o;
4767 d3_interpolate_number.lastIndex = 0;
4768 for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
4769 if (m.index) s.push(b.substring(s0, s1 = m.index));
4770 q.push({
4771 i: s.length,
4772 x: m[0]
4773 });
4774 s.push(null);
4775 s0 = d3_interpolate_number.lastIndex;
4776 }
4777 if (s0 < b.length) s.push(b.substring(s0));
4778 for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) {
4779 o = q[i];
4780 if (o.x == m[0]) {
4781 if (o.i) {
4782 if (s[o.i + 1] == null) {
4783 s[o.i - 1] += o.x;
4784 s.splice(o.i, 1);
4785 for (j = i + 1; j < n; ++j) q[j].i--;
4786 } else {
4787 s[o.i - 1] += o.x + s[o.i + 1];
4788 s.splice(o.i, 2);
4789 for (j = i + 1; j < n; ++j) q[j].i -= 2;
4790 }
4791 } else {
4792 if (s[o.i + 1] == null) {
4793 s[o.i] = o.x;
4794 } else {
4795 s[o.i] = o.x + s[o.i + 1];
4796 s.splice(o.i + 1, 1);
4797 for (j = i + 1; j < n; ++j) q[j].i--;
4798 }
4799 }
4800 q.splice(i, 1);
4801 n--;
4802 i--;
4803 } else {
4804 o.x = d3_interpolateNumber(parseFloat(m[0]), parseFloat(o.x));
4805 }
4806 }
4807 while (i < n) {
4808 o = q.pop();
4809 if (s[o.i + 1] == null) {
4810 s[o.i] = o.x;
4811 } else {
4812 s[o.i] = o.x + s[o.i + 1];
4813 s.splice(o.i + 1, 1);
4814 }
4815 n--;
4816 }
4817 if (s.length === 1) {
4818 return s[0] == null ? q[0].x : function() {
4819 return b;
4820 };
4821 }
4822 return function(t) {

Callers 1

d3.v3.jsFile · 0.85

Calls 2

d3_interpolateNumberFunction · 0.85
execMethod · 0.45

Tested by

no test coverage detected