1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = _default;
|
7 |
|
8 | var _number = _interopRequireDefault(require("./number.js"));
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11 |
|
12 | var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
|
13 | reB = new RegExp(reA.source, "g");
|
14 |
|
15 | function zero(b) {
|
16 | return function () {
|
17 | return b;
|
18 | };
|
19 | }
|
20 |
|
21 | function one(b) {
|
22 | return function (t) {
|
23 | return b(t) + "";
|
24 | };
|
25 | }
|
26 |
|
27 | function _default(a, b) {
|
28 | var bi = reA.lastIndex = reB.lastIndex = 0,
|
29 |
|
30 | am,
|
31 |
|
32 | bm,
|
33 |
|
34 | bs,
|
35 |
|
36 | i = -1,
|
37 |
|
38 | s = [],
|
39 |
|
40 | q = [];
|
41 |
|
42 |
|
43 | a = a + "", b = b + "";
|
44 |
|
45 | while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
|
46 | if ((bs = bm.index) > bi) {
|
47 |
|
48 | bs = b.slice(bi, bs);
|
49 | if (s[i]) s[i] += bs;
|
50 | else s[++i] = bs;
|
51 | }
|
52 |
|
53 | if ((am = am[0]) === (bm = bm[0])) {
|
54 |
|
55 | if (s[i]) s[i] += bm;
|
56 | else s[++i] = bm;
|
57 | } else {
|
58 |
|
59 | s[++i] = null;
|
60 | q.push({
|
61 | i: i,
|
62 | x: (0, _number.default)(am, bm)
|
63 | });
|
64 | }
|
65 |
|
66 | bi = reB.lastIndex;
|
67 | }
|
68 |
|
69 |
|
70 | if (bi < b.length) {
|
71 | bs = b.slice(bi);
|
72 | if (s[i]) s[i] += bs;
|
73 | else s[++i] = bs;
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 | return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) {
|
79 | for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
|
80 |
|
81 | return s.join("");
|
82 | });
|
83 | } |
\ | No newline at end of file |