Skip to content

Instantly share code, notes, and snippets.

@NarendraPunchh
Created May 3, 2019 07:39
Show Gist options
  • Save NarendraPunchh/be41afa8b3e160e4dfd4db80dd7f4d66 to your computer and use it in GitHub Desktop.
Save NarendraPunchh/be41afa8b3e160e4dfd4db80dd7f4d66 to your computer and use it in GitHub Desktop.
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