Created
March 27, 2014 00:01
-
-
Save mckelvey/9796733 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by CoffeeScript 1.4.0 | |
(function() { | |
var PreProcessor; | |
PreProcessor = (function() { | |
/* | |
from: https://github.com/sockjs/sockjs-node/commit/e0e7113f0f8bd8e5fea25e1eb2a8b1fe1413da2c | |
from: https://github.com/sockjs/sockjs-client/blob/a571c94e051de7af489b4fc541194956e1d171fe/lib/utils.js | |
*/ | |
function PreProcessor() { | |
this.escapable = /[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e]/g; | |
this.lookup = this.unroll_lookup(); | |
} | |
PreProcessor.prototype.unroll_lookup = function() { | |
var c, i, unrolled; | |
unrolled = {}; | |
c = (function() { | |
var _i, _results; | |
_results = []; | |
for (i = _i = 0; _i < 65536; i = ++_i) { | |
_results.push(String.fromCharCode(i)); | |
} | |
return _results; | |
})(); | |
this.escapable.lastIndex = 0; | |
c.join('').replace(this.escapable, function(a) { | |
unrolled[a] = '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); | |
return ''; | |
}); | |
return unrolled; | |
}; | |
PreProcessor.prototype.prepare = function(data) { | |
var expanded, obj, quoted; | |
quoted = JSON.stringify(data); | |
obj = this; | |
expanded = quoted.replace(this.escapable, function(a) { | |
return obj.lookup[a]; | |
}); | |
return expanded; | |
}; | |
return PreProcessor; | |
})(); | |
module.exports = PreProcessor; | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment