UNPKG

diff2html

Version:

Fast Diff to colorized HTML

41 lines 828 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeForRegExp = escapeForRegExp; exports.unifyPath = unifyPath; exports.hashCode = hashCode; const specials = [ '-', '[', ']', '/', '{', '}', '(', ')', '*', '+', '?', '.', '\\', '^', '$', '|', ]; const regex = RegExp('[' + specials.join('\\') + ']', 'g'); function escapeForRegExp(str) { return str.replace(regex, '\\$&'); } function unifyPath(path) { return path ? path.replace(/\\/g, '/') : path; } function hashCode(text) { let i, chr, len; let hash = 0; for (i = 0, len = text.length; i < len; i++) { chr = text.charCodeAt(i); hash = (hash << 5) - hash + chr; hash |= 0; } return hash; } //# sourceMappingURL=utils.js.map