scratch – Diff between revs 75 and 125

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 75 Rev 125
1 // Generated by CoffeeScript 1.10.0 1 // Generated by CoffeeScript 1.12.4
2 var Escaper, Pattern; 2 var Escaper, Pattern;
3   3  
4 Pattern = require('./Pattern'); 4 Pattern = require('./Pattern');
5   5  
6 Escaper = (function() { 6 Escaper = (function() {
7 var ch; 7 var ch;
8   8  
9 function Escaper() {} 9 function Escaper() {}
10   10  
11 Escaper.LIST_ESCAPEES = ['\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", (ch = String.fromCharCode)(0x0085), ch(0x00A0), ch(0x2028), ch(0x2029)]; 11 Escaper.LIST_ESCAPEES = ['\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", (ch = String.fromCharCode)(0x0085), ch(0x00A0), ch(0x2028), ch(0x2029)];
12   12  
13 Escaper.LIST_ESCAPED = ['\\\\', '\\"', '\\"', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", "\\N", "\\_", "\\L", "\\P"]; 13 Escaper.LIST_ESCAPED = ['\\\\', '\\"', '\\"', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", "\\N", "\\_", "\\L", "\\P"];
14   14  
15 Escaper.MAPPING_ESCAPEES_TO_ESCAPED = (function() { 15 Escaper.MAPPING_ESCAPEES_TO_ESCAPED = (function() {
16 var i, j, mapping, ref; 16 var i, j, mapping, ref;
17 mapping = {}; 17 mapping = {};
18 for (i = j = 0, ref = Escaper.LIST_ESCAPEES.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { 18 for (i = j = 0, ref = Escaper.LIST_ESCAPEES.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
19 mapping[Escaper.LIST_ESCAPEES[i]] = Escaper.LIST_ESCAPED[i]; 19 mapping[Escaper.LIST_ESCAPEES[i]] = Escaper.LIST_ESCAPED[i];
20 } 20 }
21 return mapping; 21 return mapping;
22 })(); 22 })();
23   23  
24 Escaper.PATTERN_CHARACTERS_TO_ESCAPE = new Pattern('[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9'); 24 Escaper.PATTERN_CHARACTERS_TO_ESCAPE = new Pattern('[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9');
25   25  
26 Escaper.PATTERN_MAPPING_ESCAPEES = new Pattern(Escaper.LIST_ESCAPEES.join('|').split('\\').join('\\\\')); 26 Escaper.PATTERN_MAPPING_ESCAPEES = new Pattern(Escaper.LIST_ESCAPEES.join('|').split('\\').join('\\\\'));
27   27  
28 Escaper.PATTERN_SINGLE_QUOTING = new Pattern('[\\s\'":{}[\\],&*#?]|^[-?|<>=!%@`]'); 28 Escaper.PATTERN_SINGLE_QUOTING = new Pattern('[\\s\'":{}[\\],&*#?]|^[-?|<>=!%@`]');
29   29  
30 Escaper.requiresDoubleQuoting = function(value) { 30 Escaper.requiresDoubleQuoting = function(value) {
31 return this.PATTERN_CHARACTERS_TO_ESCAPE.test(value); 31 return this.PATTERN_CHARACTERS_TO_ESCAPE.test(value);
32 }; 32 };
33   33  
34 Escaper.escapeWithDoubleQuotes = function(value) { 34 Escaper.escapeWithDoubleQuotes = function(value) {
35 var result; 35 var result;
36 result = this.PATTERN_MAPPING_ESCAPEES.replace(value, (function(_this) { 36 result = this.PATTERN_MAPPING_ESCAPEES.replace(value, (function(_this) {
37 return function(str) { 37 return function(str) {
38 return _this.MAPPING_ESCAPEES_TO_ESCAPED[str]; 38 return _this.MAPPING_ESCAPEES_TO_ESCAPED[str];
39 }; 39 };
40 })(this)); 40 })(this));
41 return '"' + result + '"'; 41 return '"' + result + '"';
42 }; 42 };
43   43  
44 Escaper.requiresSingleQuoting = function(value) { 44 Escaper.requiresSingleQuoting = function(value) {
45 return this.PATTERN_SINGLE_QUOTING.test(value); 45 return this.PATTERN_SINGLE_QUOTING.test(value);
46 }; 46 };
47   47  
48 Escaper.escapeWithSingleQuotes = function(value) { 48 Escaper.escapeWithSingleQuotes = function(value) {
49 return "'" + value.replace(/'/g, "''") + "'"; 49 return "'" + value.replace(/'/g, "''") + "'";
50 }; 50 };
51   51  
52 return Escaper; 52 return Escaper;
53   53  
54 })(); 54 })();
55   55  
56 module.exports = Escaper; 56 module.exports = Escaper;
57   57