Created
May 3, 2019 07:39
-
-
Save NarendraPunchh/be41afa8b3e160e4dfd4db80dd7f4d66 to your computer and use it in GitHub Desktop.
This file contains 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
const checkForceUpdate = (serverVersion, localVersion) => { | |
const strServerVersion = serverVersion.replace(/\./g, ''); | |
const strLocalVersion = localVersion.replace(/\./g, ''); | |
const power = | |
Math.max(strServerVersion.length, strLocalVersion.length) - | |
Math.min(strServerVersion.length, strLocalVersion.length); | |
let numServer = parseInt(strServerVersion); | |
let numLocal = parseInt(strLocalVersion); | |
if (strServerVersion.length < strLocalVersion.length) { | |
numServer = numServer * Math.pow(10, power); | |
} else { | |
numLocal = numLocal * Math.pow(10, power); | |
} | |
return numLocal < numServer; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment