123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 'use strict';
- exports.before = function before(str, re) {
- return str.replace(re, function (match) {
- var id = randomize();
- cache[id] = match;
- return '__ID' + id + '__';
- });
- };
- exports.after = function after(str) {
- return str.replace(/__ID(.{5})__/g, function (_, id) {
- return cache[id];
- });
- };
- function randomize() {
- return Math.random().toString().slice(2, 7);
- }
- var cache = {};
|