diff --git a/README.md b/README.md index 04b9dbe..d8b489d 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,21 @@ Repository to store signatures of the Tibia files `7.10`, `7.30`, `7.40`, `7.50`, `7.55`, `7.60`, `7.70`, `7.80`, `7.90`, `7.92`, `8.00`, `8.10`, `8.11`, `8.20`, `8.30`, `8.40`, `8.41`, `8.42`, `8.50`, `8.52`, `8.53`, `8.54`, `8.55`, `8.60`, `8.61`, `8.62`, `8.70`, `8.71`, `8.72`, `9.00`, `9.10`, `9.20`, `9.40`, `9.44`, `9.46`, `9.50`, `9.52`, `9.53`, `9.54`, `9.60`, `9.61`, `9.63`, `9.70`, `9.80`, `9.81`, `9.82`, `9.83`, `9.85`, `9.86`, `10.10`, `10.20`, `10.21`, `10.30`, `10.31`, `10.32`, `10.34`, `10.35`, `10.36`, `10.37`, `10.38`, `10.39`, `10.40`, `10.41`, `10.50`, `10.51`, `10.52`, `10.53`, `10.54`, `10.55` ## API - + * getSignatureByVersion(version) + * version - required - Client Version without dots + * returns Array or Object + * getVersionBySprSignature(hexSign) + * hexSign - required - First 4 bytes from Spr file + * returns Integer + * getVersionByDatSignature(hexSign) + * hexSign - required - First 4 bytes reversed from Dat file + * returns Integer * isValidSprSignature(hexSign) - * hexSign - required - First 4 bytes from Spr file + * hexSign - required - First 4 bytes from Spr file + * return Boolean * isValidDatSignature(hexSign) * hexSign - required - First 4 bytes reversed from Dat file + * return Boolean ## References diff --git a/index.js b/index.js index db46a1b..9e5c2db 100644 --- a/index.js +++ b/index.js @@ -384,19 +384,19 @@ clients = { } }; -_findBy = function(type, value) { +_findBy = function(type, value, returnVersion) { value = value.toUpperCase(); for(var version in clients) { var client = clients[version]; if(Array.isArray(client)) { for(var rev in client) { if(client[rev][type] == value) { - return true; + return (returnVersion) ? version : true; } } } else { if(client[type] == value) { - return true; + return (returnVersion) ? version : true; } } } @@ -406,6 +406,18 @@ _findBy = function(type, value) { module.exports = { + getSignatureByVersion: function(version) { + return (version in clients) ? clients[version] : false; + }, + + getVersionBySprSignature: function(value) { + return _findBy('spr', value, true); + }, + + getVersionByDatSignature: function(value) { + return _findBy('dat', value, true); + }, + isValidSprSignature: function(value) { return _findBy('spr', value); }, diff --git a/package.json b/package.json index 87cab9e..b467054 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tibia-signatures", - "version": "0.0.2", + "version": "0.0.3", "description": "Repository to store signatures of the Tibia files", "main": "index.js", "repository": {