first commit

This commit is contained in:
Vitaly Puzrin
2016-12-09 12:12:16 +03:00
commit 0897ce4316
12 changed files with 6417 additions and 0 deletions

20
index.js Normal file
View File

@@ -0,0 +1,20 @@
'use strict';
var data = require('./data.json');
function escapeRegexp(str) {
return str.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
}
var REPLACE_RE = RegExp(Object.keys(data).map(escapeRegexp).join('|'), 'g');
function replace_fn(match) {
return data[match];
}
function unhomoglyph(str) {
return str.replace(REPLACE_RE, replace_fn);
}
module.exports = unhomoglyph;