(a, b)
| 3675 | } |
| 3676 | |
| 3677 | function interpolateString(a, b) { |
| 3678 | var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b |
| 3679 | am, // current match in a |
| 3680 | bm, // current match in b |
| 3681 | bs, // string preceding current number in b, if any |
| 3682 | i = -1, // index in s |
| 3683 | s = [], // string constants and placeholders |
| 3684 | q = []; // number interpolators |
| 3685 | |
| 3686 | // Coerce inputs to strings. |
| 3687 | a = a + "", b = b + ""; |
| 3688 | |
| 3689 | // Interpolate pairs of numbers in a & b. |
| 3690 | while ((am = reA.exec(a)) |
| 3691 | && (bm = reB.exec(b))) { |
| 3692 | if ((bs = bm.index) > bi) { // a string precedes the next number in b |
| 3693 | bs = b.slice(bi, bs); |
| 3694 | if (s[i]) s[i] += bs; // coalesce with previous string |
| 3695 | else s[++i] = bs; |
| 3696 | } |
| 3697 | if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match |
| 3698 | if (s[i]) s[i] += bm; // coalesce with previous string |
| 3699 | else s[++i] = bm; |
| 3700 | } else { // interpolate non-matching numbers |
| 3701 | s[++i] = null; |
| 3702 | q.push({i: i, x: interpolateNumber(am, bm)}); |
| 3703 | } |
| 3704 | bi = reB.lastIndex; |
| 3705 | } |
| 3706 | |
| 3707 | // Add remains of b. |
| 3708 | if (bi < b.length) { |
| 3709 | bs = b.slice(bi); |
| 3710 | if (s[i]) s[i] += bs; // coalesce with previous string |
| 3711 | else s[++i] = bs; |
| 3712 | } |
| 3713 | |
| 3714 | // Special optimization for only a single match. |
| 3715 | // Otherwise, interpolate each of the numbers and rejoin the string. |
| 3716 | return s.length < 2 ? (q[0] |
| 3717 | ? one(q[0].x) |
| 3718 | : zero(b)) |
| 3719 | : (b = q.length, function(t) { |
| 3720 | for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); |
| 3721 | return s.join(""); |
| 3722 | }); |
| 3723 | } |
| 3724 | |
| 3725 | function interpolate$2(a, b) { |
| 3726 | var t = typeof b, c; |
nothing calls this directly
no test coverage detected