UNPKG

jscpd

Version:

Copy/paste detector for programming code, support JavaScript, CoffeeScript, PHP, Ruby, Python, Less, Go, Java, Yaml, C#, C++, C languages

52 lines (38 loc) 1.55 kB
// Generated by CoffeeScript 1.10.0 (function() { var TokenizerBase, crypto, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; crypto = require('crypto'); TokenizerBase = (function() { function TokenizerBase() { this.skipComments = false; this.tokenTypes = []; } TokenizerBase.prototype.tokenize = function(code) {}; TokenizerBase.prototype.getType = function() {}; TokenizerBase.prototype.generateMap = function() {}; TokenizerBase.prototype.isEmptyToken = function(value) { return value.replace(/^\s+|\s+$/g, '').length === 0; }; TokenizerBase.prototype.validToken = function(type) { var ref; return (((ref = this.type) === 'coffeescript' || ref === 'python' || ref === 'ruby') || type !== 'empty') && (!this.skipComments || type !== 'comment'); }; TokenizerBase.prototype.getTokenTypeId = function(name) { var result; result = 0; if (indexOf.call(this.tokenTypes, name) >= 0) { result = this.tokenTypes.indexOf(name); } else { result = this.tokenTypes.length; this.tokenTypes.push(name); } return result; }; TokenizerBase.prototype.createMap = function(type, value) { return String.fromCharCode(this.getTokenTypeId(type)) + crypto.createHash('md5').update(value.toString()).digest('hex'); }; return TokenizerBase; })(); module.exports = TokenizerBase; }).call(this);