2 * preserve <https://github.com/jonschlinkert/preserve>
4 * Copyright (c) 2014-2015, Jon Schlinkert.
5 * Licensed under the MIT license.
11 * Replace tokens in `str` with a temporary, heuristic placeholder.
14 * tokens.before('{a\\,b}');
18 * @param {String} `str`
19 * @return {String} String with placeholders.
23 exports.before = function before(str, re) {
24 return str.replace(re, function (match) {
27 return '__ID' + id + '__';
32 * Replace placeholders in `str` with original tokens.
35 * tokens.after('{__ID1__}');
39 * @param {String} `str` String with placeholders
40 * @return {String} `str` String with original tokens.
44 exports.after = function after(str) {
45 return str.replace(/__ID(.{5})__/g, function (_, id) {
50 function randomize() {
51 return Math.random().toString().slice(2, 7);