3 module.exports = factory;
5 /* Factory to de-escape a value, based on a list at `key`
7 function factory(ctx, key) {
10 /* De-escape a string using the expression at `key`
12 function unescape(value) {
14 var index = value.indexOf('\\');
15 var escape = ctx[key];
19 while (index !== -1) {
20 queue.push(value.slice(prev, index));
22 character = value.charAt(prev);
24 /* If the following character is not a valid escape,
26 if (!character || escape.indexOf(character) === -1) {
30 index = value.indexOf('\\', prev);
33 queue.push(value.slice(prev));
35 return queue.join('');